aboutsummaryrefslogtreecommitdiff
path: root/enemiesattacks.gbasm
diff options
context:
space:
mode:
authorAstatin <[email protected]>2025-01-16 18:13:21 +0900
committerAstatin <[email protected]>2025-01-16 18:13:21 +0900
commit02038990a93c0b4cf58269b5456327ea64b998b7 (patch)
tree8f23c7270bc705d17d9d380d3a927f12f20ca1fa /enemiesattacks.gbasm
parentdc5a9431bf4438000dcd028aa6b9c17c9ca492d8 (diff)
Move basic enemy attack & walker AI to enemiesattacks
Diffstat (limited to 'enemiesattacks.gbasm')
-rw-r--r--enemiesattacks.gbasm47
1 files changed, 47 insertions, 0 deletions
diff --git a/enemiesattacks.gbasm b/enemiesattacks.gbasm
new file mode 100644
index 0000000..ce8f5f0
--- /dev/null
+++ b/enemiesattacks.gbasm
@@ -0,0 +1,47 @@
+Check_player_next_to: ; BC = XY of the enemy. D is unchanged. Direction to face in E (or 0 if not)
+ .vertical:
+ LD A, $mem_bunny_x
+ CP B
+ JR NZ, =.horizontal
+
+ ; up
+ LD A, $mem_bunny_y
+ SUB $01
+ CP C
+ LD E, $enum_direction_down
+ RET Z
+
+ ; down
+ ADD $02
+ CP C
+ LD E, $enum_direction_up
+ RET Z
+
+ LD E, $00
+ RET
+
+ .horizontal:
+
+ LD A, $mem_bunny_y
+ CP C
+ LD E, $00
+ RET NZ
+
+ ; left
+ LD A, $mem_bunny_x
+ SUB $01
+ CP B
+ LD E, $enum_direction_right
+ RET Z
+
+ ; right
+ ADD $02
+ CP B
+ LD E, $enum_direction_left
+ RET Z
+
+ LD E, $00
+ RET
+
+.INCLUDE "enemiesattacks/walk.gbasm"
+.INCLUDE "enemiesattacks/basic.gbasm"