From: Lukas Krickl Date: Wed, 17 Dec 2025 13:52:21 +0000 (+0100) Subject: actor: act_move_frward and back now perform collision checks internally X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=ea85f153b18bd82d0d77c6d8d75dc419a6e9445e;p=gbrg%2F.git actor: act_move_frward and back now perform collision checks internally --- diff --git a/src/actor.s b/src/actor.s index 41c94b4..cb382a7 100644 --- a/src/actor.s +++ b/src/actor.s @@ -244,10 +244,21 @@ act_apply_pos: ; moves the actor forward - ; does not perform collision checks + ; performs collision checks ; inputs: ; de: actor act_move_forward: + push de + ld hl, act_dir_forward + call act_can_move + pop de + ret z ; bail on collision + + push de + call act_clear_tact + pop de + push de + ld hl, act_dir add hl, de ; hl = act_dir ld a, [hl] @@ -261,13 +272,30 @@ act_move_forward: call act_apply_vec + ; TODO: check if player collides with actor + ; at new location + + pop de + call act_set_tact + ret ; moves the actor back - ; does not perform collision checks + ; performs collision checks ; inputs: ; de: actor act_move_back: + push de + ld hl, act_dir_back + call act_can_move + pop de + ret z ; bail on collision + + push de + call act_clear_tact + pop de + push de + ld hl, act_dir add hl, de ; hl = act_dir ld a, [hl] @@ -286,6 +314,9 @@ act_move_back: ld b, [hl] ; b = direction call act_apply_vec + + pop de + call act_set_tact ret diff --git a/src/player.s b/src/player.s index 5ed0077..22fdf82 100644 --- a/src/player.s +++ b/src/player.s @@ -76,42 +76,22 @@ player_handle_move: ld b, DIRUP input_just jr z, @not_up REL - ld hl, act_dir_forward - ld de, player - call act_can_move - ld de, player - call nz, player_move_forward + call player_move_forward @not_up: ld b, DIRDOWN input_just jr z, @not_down REL - ld hl, act_dir_back - ld de, player - call act_can_move - ld de, player call nz, player_move_back @not_down: ret player_move_forward: - ld de, player - call act_clear_tact - ld de, player call act_move_forward - - ld de, player - call act_set_tact jp map_full_draw player_move_back: - ld de, player - call act_clear_tact - ld de, player call act_move_back - - ld de, player - call act_set_tact jp map_full_draw