From: Lukas Krickl Date: Wed, 3 Dec 2025 12:32:11 +0000 (+0100) Subject: actor: Added optional y and x offset to collision checker X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=126b045f96807da3f8a1f09ac251108f9f940c24;p=gbrg%2F.git actor: Added optional y and x offset to collision checker --- diff --git a/src/actor.s b/src/actor.s index 8230718..a78d249 100644 --- a/src/actor.s +++ b/src/actor.s @@ -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 diff --git a/src/levels.s b/src/levels.s index 78fc062..8d83e55 100644 --- a/src/levels.s +++ b/src/levels.s @@ -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