From: Lukas Krickl Date: Fri, 1 Nov 2024 06:14:11 +0000 (+0100) Subject: wip: point rectangle collision X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=a2bd7454f6a2260aa3532f2d6eeb688e8b81bd8d;p=gbrg%2F.git wip: point rectangle collision --- 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: