actor: Added more collision points
authorLukas Krickl <lukas@krickl.dev>
Wed, 10 Dec 2025 04:45:07 +0000 (05:45 +0100)
committerLukas Krickl <lukas@krickl.dev>
Wed, 10 Dec 2025 04:45:07 +0000 (05:45 +0100)
This allows tile collision to sample more points for better collision detection.

src/actor.s
src/debug.s
src/player.s
src/wram.s

index 802fde1198a6f961e4047575ce1c17e2a976be1d..a4d4b6ce5bdb0e08520d737b51a21aa309dd63fb 100644 (file)
@@ -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
index 6539673fb40a461fab6b1d8869cc270872129902..f3fecb267624ab52384afc2c35b55b7d64dac43d 100644 (file)
@@ -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
index 42c0d155902a4c40cd663e1f6dbc8bce444adb4d..493c84a2fd342b16c4cb53cc540304c95d01b073 100644 (file)
@@ -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
index ededf33d02f71270d0ae1df29a0b154e5809bd3c..860e24de3f7436667ec9e208ed63626f4a8a0d64 100644 (file)
@@ -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