diff options
author | Astatin <[email protected]> | 2025-04-29 11:40:31 +0200 |
---|---|---|
committer | Astatin <[email protected]> | 2025-04-29 11:40:31 +0200 |
commit | 7faf16e4453f935ee1159d32ddc2a6501ea91bbb (patch) | |
tree | 5719a1f712ec896e41b3e4773322ffb083d132d0 /enemiesattacks | |
parent | fb689cdc68b8d1da3d988da43671bd0ddb063e88 (diff) |
Give a turn for the enemies to turn around when bunny is behind them
Diffstat (limited to 'enemiesattacks')
-rw-r--r-- | enemiesattacks/basic.gbasm | 16 | ||||
-rw-r--r-- | enemiesattacks/freeze.gbasm | 16 | ||||
-rw-r--r-- | enemiesattacks/laser.gbasm | 16 |
3 files changed, 48 insertions, 0 deletions
diff --git a/enemiesattacks/basic.gbasm b/enemiesattacks/basic.gbasm index c617b7a..63bf3e4 100644 --- a/enemiesattacks/basic.gbasm +++ b/enemiesattacks/basic.gbasm @@ -1,5 +1,21 @@ Basic_Enemy_Attack: ; Direction to face in E. Result in BC (XY), Direction in D LD A, E + DEC A + DEC D + XOR D + INC D + CP $00 + JR Z, =.attack + BIT 1, A + JR NZ, =.attack + + LD A, E + OR $00 + LD D, A + RET + + .attack: + LD A, E OR $10 LD D, A diff --git a/enemiesattacks/freeze.gbasm b/enemiesattacks/freeze.gbasm index eb27a48..35dadf3 100644 --- a/enemiesattacks/freeze.gbasm +++ b/enemiesattacks/freeze.gbasm @@ -1,5 +1,21 @@ Freeze_Enemy_Attack: ; Direction to face in E. Result in BC (XY), Direction in D LD A, E + DEC A + DEC D + XOR D + INC D + CP $00 + JR Z, =.attack + BIT 1, A + JR NZ, =.attack + + LD A, E + OR $00 + LD D, A + RET + + .attack: + LD A, E OR $10 LD D, A diff --git a/enemiesattacks/laser.gbasm b/enemiesattacks/laser.gbasm index caf6db2..c26e4e3 100644 --- a/enemiesattacks/laser.gbasm +++ b/enemiesattacks/laser.gbasm @@ -1,4 +1,20 @@ Laser_sight_check: ; BC = XY of the enemy. D is unchanged. Direction to face in E (or 0 if not) + LD A, E + DEC A + DEC D + XOR D + INC D + CP $00 + JR Z, =.attack + BIT 1, A + JR NZ, =.attack + + LD A, E + OR $00 + LD D, A + RET + + .attack: LD E, $00 ; straight line + distance <= 4 |