From: Lukas Krickl Date: Mon, 29 Sep 2025 11:08:35 +0000 (+0200) Subject: enemy: Added test collision resolution for bullets X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=1a90a0cfdc444527bd81e59ed7b07d627d624f2f;p=gbrg%2F.git enemy: Added test collision resolution for bullets --- diff --git a/src/enemy.s b/src/enemy.s index ddea0f8..e337f96 100644 --- a/src/enemy.s +++ b/src/enemy.s @@ -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