From a2bd7454f6a2260aa3532f2d6eeb688e8b81bd8d Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 1 Nov 2024 07:14:11 +0100 Subject: [PATCH] wip: point rectangle collision --- src/collision.s | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/collision.s b/src/collision.s index 33162b7..6c4ff8c 100644 --- a/src/collision.s +++ b/src/collision.s @@ -188,19 +188,40 @@ collision_tile: ; a = 0 -> no collision ; a = 1 -> collision collision_pt_rec: +@top_left: ; check top left ; -> y pos ld a, [hl+] add a, b ; a = rec y + y offset - cp a, d ; tl < py? + cp a, d ; tl > py? jr nc, @no_collision REL ; -> x pos ld a, [hl+] add a, c ; a = rec x + x offset - cp a, d ; t1 < px? + cp a, e ; t1 > px? jr nc, @no_collision REL +@top_right: + ; check top right + ; y pos + ld a, [hl+] + add a, b ; a = rec y + y offset + cp a, d ; tr > py? + jr nc, @no_collision REL + + ; x pos + ld a, [hl+] + add a, c ; a = rec x + x offset + cp a, e ; tr < px + jr c, @no_collision REL + + ; TODO check bottom left + @bottom_left: + + ; TODO check bottom right +@bottom_right: + @collision: ld a, 1 @no_collision: -- 2.30.2