projectile: Added stub for player performing an attack action
authorLukas Krickl <lukas@krickl.dev>
Sun, 28 Sep 2025 04:18:36 +0000 (06:18 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 28 Sep 2025 04:18:36 +0000 (06:18 +0200)
src/actor.s
src/defs.s
src/enemy.s
src/main.s
src/player.s
src/projectile.s [new file with mode: 0644]
tiles/bank8800.inc

index 2f2a5ec27fd870b83ee202f246cd79dd88427c01..3e5f8949b10b1dee503dfd1f049b707ac8c32e47 100644 (file)
@@ -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:
index f26231466999f49a919d80c1cbced8bc894cf803..b39e0dc673833b323e0c699b6c533251422c46c9 100644 (file)
@@ -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
index 3469546aae8faa9419229b5d3ba744c12ebae117..ddea0f87db43ffae3cc31e2c8fba3c81db863db4 100644 (file)
@@ -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
index e1ff764c52cd0d67df88cfac2ed4faeab7ac910f..ca2b769198cae20a467ac7172f36fdcb98579590 100644 (file)
@@ -67,6 +67,7 @@ main:
 #include "game.s"
 #include "actor.s"
 #include "rectangle.s"
+#include "projectile.s"
 
 #include "tiles.inc"
 #include "text.s"
index d0102a31f91d49ae1ecbc47aa707e53a2e90f505..28c672b2c68e991b6b24be196ba1e08f9a47134c 100644 (file)
@@ -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 (file)
index 0000000..4a01712
--- /dev/null
@@ -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
index e2f301c98bdc7a34af790f9ce372cbea018bad7b..68c1a2eac3bd389d33e802e98698952dec6d7fa4 100644 (file)
@@ -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