From: Lukas Krickl Date: Sun, 13 Jul 2025 05:32:37 +0000 (+0200) Subject: unit: fixed movement delya being too long X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=64b4decf4d1f075fc2cd122bf5169049348e67d4;p=gbrg%2F.git unit: fixed movement delya being too long This was caused by the delay timer only being set *after* collision check. This caused the delay to be the last unit's delay which may be slower or faster than expected. --- diff --git a/BUGS.md b/BUGS.md index 9843a44..97fed4b 100644 --- a/BUGS.md +++ b/BUGS.md @@ -1,10 +1,2 @@ # Known Bugs -## Objects are out of bounds - -Sometimes objects are flickering at tile 0/0. - -## When hitting an actor the delay timer is too long - -When the player runs into an actor the movement delay triggeered -is way longer than expected. diff --git a/src/unit.s b/src/unit.s index 10b75d9..3836ed7 100644 --- a/src/unit.s +++ b/src/unit.s @@ -478,6 +478,12 @@ unit_set_delay_to_active_speed: ; actor initiative based on tile flags ; actor position unit_try_move_up: + ; enable subtile up + ld a, 0b10100000 + push de + call unit_set_delay_to_active_speed + pop de + ; y - 1 unit_test_collision dec b, CF_COLLISION @@ -494,13 +500,16 @@ unit_try_move_up: dec a ld [hl], a - ; enable subtile up - ld a, 0b10100000 - call unit_set_delay_to_active_speed ret unit_try_move_down: + ; enable subtile down + push de + ld a, 0b01100000 + call unit_set_delay_to_active_speed + pop de + ; y + 1 unit_test_collision inc b, CF_COLLISION @@ -513,14 +522,16 @@ unit_try_move_down: inc a ld [hl], a - - ; enable subtile down - ld a, 0b01100000 - call unit_set_delay_to_active_speed ret unit_try_move_left: + ; enable subtile left + push de + ld a, 0b00110000 + call unit_set_delay_to_active_speed + pop de + ; x - 1 unit_test_collision dec c, CF_COLLISION @@ -533,15 +544,16 @@ unit_try_move_left: dec a ld [hl], a - - ; enable subtile left - ld a, 0b00110000 - call unit_set_delay_to_active_speed ret unit_try_move_right: - + ; enable subtile right + push de + ld a, 0b00101000 + call unit_set_delay_to_active_speed + pop de + ; x + 1 unit_test_collision inc c, CF_COLLISION @@ -555,10 +567,6 @@ unit_try_move_right: inc a ld [hl], a - ; enable subtile right - ld a, 0b00101000 - call unit_set_delay_to_active_speed - ret