player: splut up/down and left/right direction into separate frames
authorLukas Krickl <lukas@krickl.dev>
Wed, 24 Sep 2025 13:02:42 +0000 (15:02 +0200)
committerLukas Krickl <lukas@krickl.dev>
Wed, 24 Sep 2025 13:02:42 +0000 (15:02 +0200)
src/actor.s
src/player.s
src/wram.s

index d78b2f4ff7b23a1219bd74f98ffb275dc9b13bd7..7a3a776e6474dfcf715c3cd641492010ab3cf6be 100644 (file)
@@ -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
index b7966c371283e7c68d84e23828880cc06a3f7c8f..62024d26ace3198c0abcb159f5906e0efb939ca3 100644 (file)
@@ -1,4 +1,4 @@
-#define PLAYER_SPEED 0x8
+#define PLAYER_SPEED 0xE
 
        ; 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
index e52a323085b649cecf5c9ec5c6ac3ef7a38944f4..3e9c7bc80d886658137776692ed67653460a85a1 100644 (file)
@@ -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