actor: Added optional y and x offset to collision checker
authorLukas Krickl <lukas@krickl.dev>
Wed, 3 Dec 2025 12:32:11 +0000 (13:32 +0100)
committerLukas Krickl <lukas@krickl.dev>
Wed, 3 Dec 2025 12:32:11 +0000 (13:32 +0100)
src/actor.s
src/levels.s

index 823071835df171bdea848225f8c5fdb22dad31ba..a78d2499a88ce2da3aa0d6beb92de12b57b72456 100644 (file)
@@ -87,9 +87,18 @@ act_test_tile_collision:
        ; checks collision
        ; inputs:
        ;               $1: point to check
-       ;               $2: label to jump to (jr)
+       ;               $2: y offset
+       ;               $3: x offset
+       ;               $4: label to jump to (jr)
 #macro _act_tile_col_check
        _act_col_load_pt $1
+       ld a, b
+       add a, $2
+       ld b, a
+
+       ld a, c
+       add a, $3
+       ld c, a
        div16 b
        div16 c
 
@@ -98,7 +107,7 @@ act_test_tile_collision:
        add hl, de
        ld a, [hl]
        and a, TF_WALL
-       jr nz, $2 REL
+       jr nz, $4 REL
 #endmacro
        
        ; test direction routines:
@@ -107,10 +116,10 @@ _act_test_tile_left_collision:
        push de
 
        ; top left point
-       _act_tile_col_check col_point_tl, @collision
+       _act_tile_col_check col_point_tl, (-1 & 0xFF), 0, @collision
 
        ; bottom left point
-       _act_tile_col_check col_point_bl, @collision
+       _act_tile_col_check col_point_bl, (-1 & 0xFF), 0, @collision
 
        pop de
        ret
@@ -123,10 +132,10 @@ _act_test_tile_right_collision:
        push de
 
        ; top right point
-       _act_tile_col_check col_point_tr, @collision
+       _act_tile_col_check col_point_tr, (-1 & 0xFF), 0, @collision
 
        ; bottom right point
-       _act_tile_col_check col_point_br, @collision
+       _act_tile_col_check col_point_br, (-1 & 0xFF), 0, @collision
 
        pop de
        ret
@@ -139,10 +148,10 @@ _act_test_tile_up_collision:
        push de
        
        ; top left point
-       _act_tile_col_check col_point_tl, @collision
+       _act_tile_col_check col_point_tl, 0, (-1 & 0xFF), @collision
 
        ; top right point
-       _act_tile_col_check col_point_tr, @collision
+       _act_tile_col_check col_point_tr, 0, (-1 & 0xFF), @collision
 
        pop de
        ret
@@ -155,10 +164,10 @@ _act_test_tile_down_collision:
        push de
 
        ; bottom left point
-       _act_tile_col_check col_point_bl, @collision
+       _act_tile_col_check col_point_bl, 0, (-1 & 0xFF), @collision
 
        ; bottom rihgt point
-       _act_tile_col_check col_point_br, @collision
+       _act_tile_col_check col_point_br, 0, (-1 & 0xFF), @collision
 
        pop de
        ret
index 78fc062fd605f1d500a9d15008611b02ddc38021..8d83e55bc1eb98f1384896373ac1d5e9cebdf288 100644 (file)
@@ -17,7 +17,7 @@ l1:
        .db TWL, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
        .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
        .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
-       .db TGS, TGS, TGS, TGS, TWL, TGS, TGS, TGS, TGS, TGS
+       .db TGS, TGS, TGS, TWL, TWL, TWL, TGS, TGS, TGS, TGS
        .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
        .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS
        .db TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TGS, TWL