unit: the player unit can now move in multiple directions on the same
authorLukas Krickl <lukas@krickl.dev>
Sun, 22 Jun 2025 05:47:19 +0000 (07:47 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 22 Jun 2025 05:47:19 +0000 (07:47 +0200)
frame

src/unit.s

index 4b2420e24e7a674de7ff715c1e41b5ca325bbc1d..c9618efd4aef6befca64ddefa8ae5a22060c7e16 100644 (file)
@@ -145,39 +145,51 @@ unit_generic_draw:
   ;   hl: action table 
   ;    a: remaining moves
 unit_handle_inputs:
+  ; push next state to the stack for now
+  ld bc, NULL
+  push bc
+
   input_held BTNUP
   jr z, @notup REL
 
     call unit_try_move_up
+
+    pop bc
     ld bc, st_unit_delay_to_active
-    ret
+    push bc
 @notup:
 
   input_held BTNDOWN
   jr z, @notdown REL
     
     call unit_try_move_down
+    
+    pop bc
     ld bc, st_unit_delay_to_active
-    ret
+    push bc
 @notdown:
 
   input_held BTNLEFT
   jr z, @notleft REL
 
     call unit_try_move_left
+
+    pop bc
     ld bc, st_unit_delay_to_active
-    ret
+    push bc
 @notleft:
 
   input_held BTNRIGHT
   jr z, @notright REL
 
     call unit_try_move_right
+
+    pop bc
     ld bc, st_unit_delay_to_active
-    ret
+    push bc
 @notright:
-
-  ldnull bc
+  
+  pop bc
   ret
 
   ; performs a generic collision test