enemy: Added test collision resolution for bullets
authorLukas Krickl <lukas@krickl.dev>
Mon, 29 Sep 2025 11:08:35 +0000 (13:08 +0200)
committerLukas Krickl <lukas@krickl.dev>
Mon, 29 Sep 2025 11:08:35 +0000 (13:08 +0200)
src/enemy.s

index ddea0f87db43ffae3cc31e2c8fba3c81db863db4..e337f961e6453a25746a63811df19b3e17ba5e99 100644 (file)
@@ -15,12 +15,23 @@ act_guard_update:
        ld b, a
        ld a, [hl+]
        ld c, a
+
+       ; check if dead
+       ld hl, act_hp
+       add hl, de
+       ld a, [hl]
+       cp a, 0
+       jp z, @despawn
        
        ; write collision shape
        ld hl, act_rect
        add hl, de
        ld a, RF_ENEMY
        call actor_write_default_collider
+
+       ret
+@despawn:
+       call actor_despawn
        ret
        
        ; draws the guard enemy
@@ -57,10 +68,15 @@ act_guard_update_and_draw:
        ;               de: event origin actor
        ;               bc: guard
 act_guard_col_res:
+       ld a, [de]
+       cp a, ACT_T_PISTOL_BULLET
+       jr z, @pistol_bullet REL
+
+       ret
+@pistol_bullet:
        ld hl, act_hp
-       add hl, de
+       add hl, bc 
 
-       ; test take damage
        ld a, [hl]
        dec a
        ld [hl], a