From fd480287c3af245da25524be5f1a07c6c84b2058 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Mon, 29 Sep 2025 16:58:59 +0200 Subject: [PATCH] player: Shooting is now on a timer --- src/defs.s | 2 +- src/player.s | 18 ++++++++++++++++-- src/wram.s | 3 ++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/defs.s b/src/defs.s index b0b0399..350fc6c 100644 --- a/src/defs.s +++ b/src/defs.s @@ -13,7 +13,7 @@ #define NULL 0 -#define ACTS_PLAYER_PROJECTILES 3 +#define ACTS_PLAYER_PROJECTILES 6 #define ACTS_ENEMY 6 #define ACTS_ENEMY_PROJECTILES 6 #define ACTS_MAX (ACTS_PLAYER_PROJECTILES + ACTS_ENEMY + ACTS_ENEMY_PROJECTILES) diff --git a/src/player.s b/src/player.s index 98f2e17..5e751d3 100644 --- a/src/player.s +++ b/src/player.s @@ -69,7 +69,7 @@ player_update: @not_right: ld b, BTNA - input_just + input_held jr z, @not_a REL call player_shoot @not_a: @@ -259,9 +259,15 @@ player_draw: ld a, 8 call actor_draw ret - + + +#define PLAYER_SHOOT_DELAY 15 ; shoots the player's current weapon player_shoot: + ld a, [player_shoot_delay] + cp a, 0 + jp nz, @tick + ; TODO: check player curr weapon call actor_try_add_player_projectile @@ -270,6 +276,14 @@ player_shoot: ret z call act_spawn_projectile_pistol_player + + ld a, PLAYER_SHOOT_DELAY + ld [player_shoot_delay], a + + ret +@tick: + dec a + ld [player_shoot_delay], a ret ; combination of update and draw call diff --git a/src/wram.s b/src/wram.s index d04901e..f5f6ffe 100644 --- a/src/wram.s +++ b/src/wram.s @@ -62,7 +62,8 @@ srand: .adv 2 ; if player y < next_scroll ; advance if possible player_next_scroll_y: .adv 1 - + +player_shoot_delay: .adv 1 ; y/x sub pixel movement for player player_sub_pixel_y: .adv 1 -- 2.30.2