player: Added player max jump
authorLukas Krickl <lukas@krickl.dev>
Mon, 8 Dec 2025 10:41:57 +0000 (11:41 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 8 Dec 2025 10:41:57 +0000 (11:41 +0100)
src/player.s

index 645418f7607b95d7fbb00ae72b4b0fd514e1e2f9..3dea74f111dc01083156fb8059ec77c6f503bb8e 100644 (file)
@@ -1,6 +1,7 @@
 #define PLAYER_CURSOR_L 0x88
 #define PLAYER_CURSOR_R 0x8A
 
+#define PLAYER_JUMP_MAX 32
 
        ; sets up the player actor
 player_init:
@@ -78,14 +79,22 @@ player_update:
 
        pop de
        call act_test_tile_collision
+       
+       ; check if jump timer is > max
+       ld a, [player_jump_timer]
+       cp a, PLAYER_JUMP_MAX
+       jr nc, @stop_jump REL
 
+       ; check if collided with ceiling
        ld a, [col_tile_collided_with]
        and a, DIRUP
        jr z, @not_up_collision REL
+@stop_jump:            
                ld a, 1
                ld [player_jump_peak], a
 @not_up_collision:
-
+       
+       ; check if touching floor
        ld a, [col_tile_collided_with]
        and a, DIRDOWN
        jr z, @not_down_collision REL
@@ -96,6 +105,7 @@ player_update:
 
                xor a, a
                ld [player_jump_peak], a
+               ld [player_jump_timer], a
 @not_down_collision:
        ret
        
@@ -127,6 +137,10 @@ player_handle_move:
                cp a, 0
                jr nz, @not_up REL
 
+               ld a, [player_jump_timer]
+               inc a
+               ld [player_jump_timer], a
+
                ld a, [player+act_pos_y]
                cp a, 0 ; min value
                jr z, @not_up REL