From ecc572003b836d1e62f6e9a1fc91650a61fdce6a Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Wed, 24 Sep 2025 15:02:42 +0200 Subject: [PATCH] player: splut up/down and left/right direction into separate frames --- src/actor.s | 6 ++---- src/player.s | 13 ++++++++++++- src/wram.s | 7 +++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/actor.s b/src/actor.s index d78b2f4..7a3a776 100644 --- a/src/actor.s +++ b/src/actor.s @@ -135,10 +135,8 @@ actor_load_test: actor_spawn_test_guard 2, 20, 50 actor_spawn_test_guard 3, 20, 60 actor_spawn_test_guard 4, 20, 70 - actor_spawn_test_guard 5, 40, 80 - actor_spawn_test_guard 6, 40, 90 - actor_spawn_test_guard 7, 50, 90 - actor_spawn_test_guard 8, 60, 90 + actor_spawn_test_guard 5, 20, 80 + actor_spawn_test_guard 6, 30, 80 ret ; despawns an actor diff --git a/src/player.s b/src/player.s index b7966c3..62024d2 100644 --- a/src/player.s +++ b/src/player.s @@ -1,4 +1,4 @@ -#define PLAYER_SPEED 0x80 +#define PLAYER_SPEED 0xE0 ; sets up the player actor player_init: @@ -14,6 +14,13 @@ player_init: ; updates the special player actor player_update: + ld a, [player_direction_proc] + xor a, 1 + ld [player_direction_proc], a + + cp a, 1 + jp z, @left_right + ld b, BTNUP input_held jr z, @not_up REL @@ -37,6 +44,9 @@ player_update: call player_try_move @not_down: + jp @direction_done + +@left_right: ld b, BTNLEFT input_held @@ -57,6 +67,7 @@ player_update: call player_try_move @not_right: +@direction_done: ; write collider for this frame ld a, [player+act_pos_y] ld b, a diff --git a/src/wram.s b/src/wram.s index e52a323..3e9c7bc 100644 --- a/src/wram.s +++ b/src/wram.s @@ -63,6 +63,13 @@ srand: .adv 2 ; advance if possible player_next_scroll_y: .adv 1 +; either 0 or 1 +; if 0 up/down are handeled this frame +; if 1 left/right are handeled +; this is done because the player tends to be +; colliding with most objects on screen and each direction +; performs the checks +player_direction_proc: .adv 1 ; y/x sub pixel movement for player player_sub_pixel_y: .adv 1 player_sub_pixel_x: .adv 1 -- 2.30.2