From a20b308cfe92a8bb47c6896e7fdb24b15c2efd59 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Fri, 12 May 2023 23:36:49 +0100 Subject: Add player bullets Also a changes in the entity system: - don't preserve the BG (always erase black) - skip unused entities - fix in the reserved size (and entity is 8 bytes) - allocate new entities --- game/player.asm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'game/player.asm') diff --git a/game/player.asm b/game/player.asm index 0e44411..ef63839 100644 --- a/game/player.asm +++ b/game/player.asm @@ -2,6 +2,9 @@ ; player update code ; +cool_down: + .db 0 + player_update: ld x, [sp + 2] ld a, [sp + 3] @@ -52,6 +55,8 @@ player_update: ; base frame ld y, 0 + push b + ; both left and right and b, 48 cmp b, 48 @@ -69,4 +74,27 @@ player_update: player_store_frame: ld [a : x], y + + pop b + + ; fire + bit b, 0 + bnz + ret + + ld x, cool_down + ld y, [a : x] + cmp y, 0 + bz + jmp player_fire + dec y + ld [a : x], y + ret + +player_fire: + add y, 10 + ld [a : x], y + + call bullet_player_new ret -- cgit v1.2.3