From: Lukas Krickl Date: Sun, 28 Sep 2025 04:18:36 +0000 (+0200) Subject: projectile: Added stub for player performing an attack action X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=92115985ce843840f5e1c8bdeccc26119dd4a508;p=gbrg%2F.git projectile: Added stub for player performing an attack action --- diff --git a/src/actor.s b/src/actor.s index 2f2a5ec..3e5f894 100644 --- a/src/actor.s +++ b/src/actor.s @@ -95,6 +95,9 @@ actor_update_draw_table: dw act_nop dw player_update_and_draw dw act_guard_update_and_draw + dw act_nop + dw act_nop + dw act_projectile_pistol_update_and_draw ; called when an actor is spawned ; via a map object @@ -102,11 +105,17 @@ actor_init_table: dw act_nop dw act_nop dw act_guard_init + dw act_nop + dw act_nop + dw act_nop actor_collision_res_table: dw act_nop dw player_col_res dw act_guard_col_res + dw act_nop + dw act_nop + dw act_projectile_pistol_col_res ; inits an actors ; inputs: diff --git a/src/defs.s b/src/defs.s index f262314..b39e0dc 100644 --- a/src/defs.s +++ b/src/defs.s @@ -60,6 +60,7 @@ .de ACT_T_GUARD, 1 .de ACT_T_DOG, 1 .de ACT_T_HAZMAT, 1 +.de ACT_T_PISTOL_BULLET, 1 ; actor struct ; act_def diff --git a/src/enemy.s b/src/enemy.s index 3469546..ddea0f8 100644 --- a/src/enemy.s +++ b/src/enemy.s @@ -54,7 +54,7 @@ act_guard_update_and_draw: ; collision resolution between guard and another actor ; inputs: - ; de: even origin actor + ; de: event origin actor ; bc: guard act_guard_col_res: ld hl, act_hp diff --git a/src/main.s b/src/main.s index e1ff764..ca2b769 100644 --- a/src/main.s +++ b/src/main.s @@ -67,6 +67,7 @@ main: #include "game.s" #include "actor.s" #include "rectangle.s" +#include "projectile.s" #include "tiles.inc" #include "text.s" diff --git a/src/player.s b/src/player.s index d0102a3..28c672b 100644 --- a/src/player.s +++ b/src/player.s @@ -68,6 +68,12 @@ player_update: call player_try_move @not_right: + ld b, BTNA + input_just + jr z, @not_a REL + call player_shoot +@not_a: + @direction_done: ; write collider for this frame ld a, [player+act_pos_y] @@ -254,6 +260,14 @@ player_draw: ; shoots the player's current weapon player_shoot: + ; TODO: check player curr weapon + + call actor_try_add + ld a, h + or a, l + ret z + + call act_spawn_projectile_pistol_player ret ; combination of update and draw call diff --git a/src/projectile.s b/src/projectile.s new file mode 100644 index 0000000..4a01712 --- /dev/null +++ b/src/projectile.s @@ -0,0 +1,51 @@ + +#define PISTOL_SPRITE 0x82 + + ; spawns a pistol projectile for player + ; inputs: + ; hl: actor ptr +act_spawn_projectile_pistol_player: + ld a, ACT_T_PISTOL_BULLET + ld [hl+], a ; write type + + ld de, act_pos_y + add hl, de + ; hl = new pos y + + + ret + + ; updates a simple pistol projectile + ; inputs: + ; de: actor ptr +act_projectile_pistol_update: + ret + + ; draws a pistol projectile + ; inputs: + ; de: actor +act_projectile_pistol_draw: + push de + ld a, 1 + call oamalloc + pop de + + ld b, PISTOL_SPRITE + ld c, 0 + ld a, 0 + jp actor_draw + + ; updates and draws projectile + ; for pistosl +act_projectile_pistol_update_and_draw: + push de + call act_projectile_pistol_update + pop de + jp act_projectile_pistol_draw + + ; collision resolution for pistol projectile + ; inputs: + ; de: event origin actor + ; bc: projectile +act_projectile_pistol_col_res: + ret diff --git a/tiles/bank8800.inc b/tiles/bank8800.inc index e2f301c..68c1a2e 100644 --- a/tiles/bank8800.inc +++ b/tiles/bank8800.inc @@ -17,9 +17,9 @@ .chr 00000000 ; tile 1 .chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 00010000 +.chr 00323000 +.chr 00030000 .chr 00000000 .chr 00000000 .chr 00000000