diff options
author | Astatin <[email protected]> | 2024-10-29 17:06:53 +0900 |
---|---|---|
committer | Astatin <[email protected]> | 2024-10-29 17:06:53 +0900 |
commit | 0a2fe23ecc1f24043aad7ff7de9f56f2091acbe9 (patch) | |
tree | 4a1b049b9180ce1d58e4e4f6246672d2b9b45fae /entity | |
parent | 96df60d319238dc7df53fe948e8a2593f1857be7 (diff) |
Bunny can be attacked and deadge
Diffstat (limited to 'entity')
-rw-r--r-- | entity/actions.gbasm | 55 | ||||
-rw-r--r-- | entity/bunny.gbasm | 10 | ||||
-rw-r--r-- | entity/display.gbasm | 22 | ||||
-rw-r--r-- | entity/init.gbasm | 4 |
4 files changed, 87 insertions, 4 deletions
diff --git a/entity/actions.gbasm b/entity/actions.gbasm index c87f13a..28f1cca 100644 --- a/entity/actions.gbasm +++ b/entity/actions.gbasm @@ -97,6 +97,61 @@ Fox_AI: CP $00 JP NZ, =Fox_AI.Start_action_or_movement.end + ; Is bunny right next to fox + Fox_AI.Check_next_to_vertical: + + LD A, $mem_bunny_x + CP B + JR NZ, =Fox_AI.Check_next_to_horizontal + + ; up + LD E, $14 + LD A, $mem_bunny_y + SUB $01 + CP C + JR Z, =Fox_AI.Start_Attack + + ; down + LD E, $13 + ADD $02 + CP C + JR Z, =Fox_AI.Start_Attack + + JR =Fox_AI.Check_next_to.end + + Fox_AI.Check_next_to_horizontal: + + LD A, $mem_bunny_y + CP C + JR NZ, =Fox_AI.Check_next_to.end + + ; left + LD E, $12 + LD A, $mem_bunny_x + SUB $01 + CP B + JR Z, =Fox_AI.Start_Attack + + ; right + LD E, $11 + ADD $02 + CP B + JR Z, =Fox_AI.Start_Attack + + JR NZ, =Fox_AI.Check_next_to.end + + Fox_AI.Start_Attack: + LD D, E + + LD A, $mem_bunny_health + DEC A + DAA + LD $mem_bunny_health, A + + JP =Fox_AI.Check_Collision + + Fox_AI.Check_next_to.end: + ; Is Bunny close enough to follow LD A, $mem_bunny_x SUB B diff --git a/entity/bunny.gbasm b/entity/bunny.gbasm index abffd43..8601d79 100644 --- a/entity/bunny.gbasm +++ b/entity/bunny.gbasm @@ -1,4 +1,14 @@ Move_Bunny: + LD A, $mem_bunny_health + CP $00 + JR NZ, =Move_Bunny.not_dead + + LD A, $20 + LD $mem_bunny_direction, A + RET + + Move_Bunny.not_dead: + Start_action_or_movement: LD A, $mem_map_loading_flags BIT 3, A diff --git a/entity/display.gbasm b/entity/display.gbasm index a33a6cc..8a0daf1 100644 --- a/entity/display.gbasm +++ b/entity/display.gbasm @@ -211,28 +211,33 @@ Display_Entity: JP =Display_Entity.Down_Direction_sprite Display_Entity.Left_Direction_sprite: - LD D, $00 + CALL =Flags_From_Animation + LD D, A JP =Display_Entity.Write_OBJ Display_Entity.Right_Direction_sprite: LD A, $02 ADD E LD E, A - LD D, $20 + CALL =Flags_From_Animation + OR $20 + LD D, A JP =Display_Entity.Write_OBJ Display_Entity.Up_Direction_sprite: LD A, $04 ADD E LD E, A - LD D, $00 + CALL =Flags_From_Animation + LD D, A JP =Display_Entity.Write_OBJ Display_Entity.Down_Direction_sprite: LD A, $08 ADD E LD E, A - LD D, $00 + CALL =Flags_From_Animation + LD D, A JP =Display_Entity.Write_OBJ Display_Entity.Write_OBJ: @@ -276,3 +281,12 @@ Display_Entity: ADD $10 LD L, A RET + +Flags_From_Animation: + LD A, D + AND $f0 + CP $20 + LD A, $00 + RET NZ + LD A, $40 + RET diff --git a/entity/init.gbasm b/entity/init.gbasm index dba0a91..188a4b9 100644 --- a/entity/init.gbasm +++ b/entity/init.gbasm @@ -38,6 +38,10 @@ Initialize_Entities: LD (HL+), A LD A, C LD (HL+), A + + LD A, $20 + LD (HL), A + LD A, L ADD $0a LD L, A |