From: Lukas Krickl Date: Fri, 5 Dec 2025 04:26:20 +0000 (+0100) Subject: actor: fixed collision getting stuck when bumping into walls X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=14eb0070bb23e161914545140ed1b94f144c9c00;p=gbrg%2F.git actor: fixed collision getting stuck when bumping into walls --- diff --git a/src/actor.s b/src/actor.s index a78d249..263d78e 100644 --- a/src/actor.s +++ b/src/actor.s @@ -1,4 +1,24 @@ + ; applies gravity to an actor + ; sets act_direction to DOWN + ; inputs: + ; de: actor +act_apply_gravity: + ld a, [col_direction] + and a, DIRUP + ret nz + + ld a, [col_direction] + or a, DIRDOWN + ld [col_direction], a + + ld hl, act_pos_y + add hl, de + ld a, [hl] + inc a + ld [hl], a + ret + ; stores current position in col_prev_pos ; inputs: ; de: actor @@ -116,7 +136,7 @@ _act_test_tile_left_collision: push de ; top left point - _act_tile_col_check col_point_tl, (-1 & 0xFF), 0, @collision + _act_tile_col_check col_point_tl, (1 & 0xFF), 0, @collision ; bottom left point _act_tile_col_check col_point_bl, (-1 & 0xFF), 0, @collision @@ -132,7 +152,7 @@ _act_test_tile_right_collision: push de ; top right point - _act_tile_col_check col_point_tr, (-1 & 0xFF), 0, @collision + _act_tile_col_check col_point_tr, (1 & 0xFF), 0, @collision ; bottom right point _act_tile_col_check col_point_br, (-1 & 0xFF), 0, @collision @@ -148,7 +168,7 @@ _act_test_tile_up_collision: push de ; top left point - _act_tile_col_check col_point_tl, 0, (-1 & 0xFF), @collision + _act_tile_col_check col_point_tl, 0, (1 & 0xFF), @collision ; top right point _act_tile_col_check col_point_tr, 0, (-1 & 0xFF), @collision @@ -164,7 +184,7 @@ _act_test_tile_down_collision: push de ; bottom left point - _act_tile_col_check col_point_bl, 0, (-1 & 0xFF), @collision + _act_tile_col_check col_point_bl, 0, (1 & 0xFF), @collision ; bottom rihgt point _act_tile_col_check col_point_br, 0, (-1 & 0xFF), @collision diff --git a/src/player.s b/src/player.s index 6846e37..8757001 100644 --- a/src/player.s +++ b/src/player.s @@ -64,6 +64,10 @@ player_update: push de call player_handle_move + pop de + push de + call act_apply_gravity + pop de call act_test_tile_collision