aboutsummaryrefslogtreecommitdiff
path: root/entity/actions.gbasm
diff options
context:
space:
mode:
authorAstatin <[email protected]>2024-10-08 18:04:22 +0900
committerAstatin <astatin@redacted>2024-10-08 18:04:22 +0900
commitd355a883e53574c474d322b39872ae51a40cedc5 (patch)
tree8de5825730ed3f1cf6bd5692c811c3e68bbae902 /entity/actions.gbasm
parent9bdce0aa0daf5bf25f21e2bc6863312f01f55376 (diff)
Fox following bunny (WIP)
Diffstat (limited to 'entity/actions.gbasm')
-rw-r--r--entity/actions.gbasm55
1 files changed, 49 insertions, 6 deletions
diff --git a/entity/actions.gbasm b/entity/actions.gbasm
index 5064c79..e8905cc 100644
--- a/entity/actions.gbasm
+++ b/entity/actions.gbasm
@@ -96,15 +96,57 @@ Fox_AI:
LD A, $mem_moving_animation_step
CP $00
JR NZ, =Fox_AI.Start_action_or_movement.end
- CALL =RNG_Step
- AND $03
- INC A
+
+ ; Choose direction
+
+ LD A, B
+ ADD $80
+ LD E, A
+ LD A, $mem_bunny_x
+ ADD $80
+ CP E
+ JR Z =Fox_AI.Vertical
+ JR NC =Fox_AI.Go_Left
+
+ Fox_AI.Go_Right:
+ LD A, $enum_direction_left
+ JR =Fox_AI.Direction_check_end
+ Fox_AI.Go_Left:
+ LD A, $enum_direction_right
+ JR Z =Fox_AI.Direction_check_end
+
+ Fox_AI.Vertical:
+ LD A, C
+ ADD $80
LD E, A
- CALL =RNG_Step
- AND $08
- OR E
+ LD A, $mem_bunny_y
+ ADD $80
+ CP E
+ PUSH AF
+ PUSH HL
+ LD HL, $9800
+ LD A, $00
+ RL A
+ CALL =Print_8bit
+ POP HL
+ POP AF
+
+ JR Z =Fox_AI.Start_action_or_movement.end
+ JR C =Fox_AI.Go_Up
+ Fox_AI.Go_Down:
+ LD A, $enum_direction_down
+ JR =Fox_AI.Direction_check_end
+ Fox_AI.Go_Up:
+ LD A, $enum_direction_up
+
+ Fox_AI.Direction_check_end:
+
+ OR $08
LD D, A
+ ; Check collision
+
+ Check_Collision:
PUSH BC
CALL =Get_Position_After_Move
LD A, C
@@ -115,6 +157,7 @@ Fox_AI:
JR Z, =Fox_AI.Start_action_or_movement.not_collision
RES 3, D
Fox_AI.Start_action_or_movement.not_collision:
+
Fox_AI.Start_action_or_movement.end:
Fox_AI.End_movement: