From fb3f09ad7691765a7f578309a80c4a0cf4012236 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Fri, 6 Mar 2026 21:27:20 +0100 Subject: Check for enemy death after its movement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some enemies might die right after moving (e.g. asteroids exploding into the ground). In these cases, there's no point on checking for player collision. Moreover, this also avoids the corner case of having two explosions on a single death. Signed-off-by: Miquel Sabaté Solà --- .nasm/segments.txt | 2 +- src/enemies.s | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.nasm/segments.txt b/.nasm/segments.txt index 96d2f66..5907869 100644 --- a/.nasm/segments.txt +++ b/.nasm/segments.txt @@ -1,4 +1,4 @@ - HEADER: 16/16 (100%) -- ROM0: 6555/32762 (20.01%) +- ROM0: 6561/32762 (20.03%) - ROMV: 6/6 (100%) - ROM2: 8192/8192 (100%) diff --git a/src/enemies.s b/src/enemies.s index 64e4b23..000b50d 100644 --- a/src/enemies.s +++ b/src/enemies.s @@ -386,6 +386,15 @@ ;; Restore the value from the 'x' register. ldx Enemies::zp_pool_index + ;; The enemy might have been burst to dust due to ground + ;; collision. Let's check it here and skip player collision if that's + ;; the case. This is not just an optimization detail, but otherwise we + ;; might get two explosions on the corner case of an enemy exploding due + ;; to background collision and colliding with the player at the same. + lda Enemies::zp_enemies_pool_base, x + cmp #$FF + beq @increase_index_next + ;; Save the current tile coordinates for this enemy. lda Enemies::zp_enemies_pool_base + 1, x lsr -- cgit v1.2.3