From: Lukas Krickl Date: Wed, 10 Dec 2025 04:45:07 +0000 (+0100) Subject: actor: Added more collision points X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=1291121c91d7c5d015fe49ae4622e418dbc8b7b3;p=gbrg%2F.git actor: Added more collision points This allows tile collision to sample more points for better collision detection. --- diff --git a/src/actor.s b/src/actor.s index 802fde1..a4d4b6c 100644 --- a/src/actor.s +++ b/src/actor.s @@ -156,6 +156,9 @@ _act_test_tile_left_collision: ; bottom left point _act_tile_col_check col_point_bl, (-1 & 0xFF), 0, @collision + ; center left point + _act_tile_col_check col_point_lc, (-1 & 0xFF), 0, @collision + pop de xor a, a ret @@ -174,6 +177,9 @@ _act_test_tile_right_collision: ; bottom right point _act_tile_col_check col_point_br, (-1 & 0xFF), 0, @collision + ; center right point + _act_tile_col_check col_point_rc, (-1 & 0xFF), 0, @collision + pop de xor a, a ret @@ -192,6 +198,9 @@ _act_test_tile_up_collision: ; top right point _act_tile_col_check col_point_tr, 0, (-1 & 0xFF), @collision + ; top center point + _act_tile_col_check col_point_tc, 0, (-1 & 0xFF), @collision + pop de xor a, a ret @@ -210,6 +219,9 @@ _act_test_tile_down_collision: ; bottom rihgt point _act_tile_col_check col_point_br, 0, (-1 & 0xFF), @collision + ; bottom center point + _act_tile_col_check col_point_bc, 0, (-1 & 0xFF), @collision + pop de xor a, a ret diff --git a/src/debug.s b/src/debug.s index 6539673..f3fecb2 100644 --- a/src/debug.s +++ b/src/debug.s @@ -39,7 +39,7 @@ ; using the debug sprite ; if enabled debug_draw_collision: - ld a, 5 + ld a, 9 call oamalloc ; draw each point @@ -49,4 +49,9 @@ debug_draw_collision: debug_draw_point col_point_br debug_draw_point col_point_ct + debug_draw_point col_point_tc + debug_draw_point col_point_bc + debug_draw_point col_point_lc + debug_draw_point col_point_rc + ret diff --git a/src/player.s b/src/player.s index 42c0d15..493c84a 100644 --- a/src/player.s +++ b/src/player.s @@ -54,7 +54,7 @@ player_col_write_points: add a, 14 ld [col_point_br], a ld a, c - add a, 14 + add a, 12 ld [col_point_br+1], a ; center point @@ -62,9 +62,41 @@ player_col_write_points: add a, 8 ld [col_point_ct], a ld a, c - add a, 4 + add a, 7 ld [col_point_ct+1], a + ; top center point + ld a, b + add a, 2 + ld [col_point_tc], a + ld a, c + add a, 7 + ld [col_point_tc+1], a + + ; bottom center point + ld a, b + add a, 14 + ld [col_point_bc], a + ld a, c + add a, 7 + ld [col_point_bc+1], a + + ; left center point + ld a, b + add a, 8 + ld [col_point_lc], a + ld a, c + add a, 2 + ld [col_point_lc+1], a + + ; right center point + ld a, b + add a, 8 + ld [col_point_rc], a + ld a, c + add a, 12 + ld [col_point_rc+1], a + ret ; updates the special player actor diff --git a/src/wram.s b/src/wram.s index ededf33..860e24d 100644 --- a/src/wram.s +++ b/src/wram.s @@ -97,13 +97,32 @@ tiles_end: .adv 0 ; collision related data ; y/x positions + + ; corner points + ; used for actor -> actor center collision + ; should form a rectangle + ; also used for tile collision + ; + ; top left, top right + ; bottom left, bottom right col_point_tl: .adv 2 col_point_tr: .adv 2 col_point_bl: .adv 2 col_point_br: .adv 2 + + ; mid points + ; top, bottom, left, right center + ; used for tile collision +col_point_tc: .adv 2 +col_point_bc: .adv 2 +col_point_lc: .adv 2 +col_point_rc: .adv 2 + ; center point of the actor ; this is used to check for actor -> actor collision col_point_ct: .adv 2 + + ; direction the movement is happening ; in. this is required so that the collision code ; can handle pushbacks in case of wall collision