aboutsummaryrefslogtreecommitdiff
path: root/src/player.odin
diff options
context:
space:
mode:
authorXander Swan <[hidden email]>2026-01-02 22:16:57 -0500
committerXander Swan <[hidden email]>2026-01-02 22:16:57 -0500
commit7113c3bedbe48341507444bd28f1e832101eb2a0 (patch)
tree0aff76013890708ce28b0784ba4477d468a6d698 /src/player.odin
parentdb7bdc1a6752a1fccf140a1a86fd3106d7403df5 (diff)
Double jump
Diffstat (limited to 'src/player.odin')
-rw-r--r--src/player.odin23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/player.odin b/src/player.odin
index 5c001da..149e1ce 100644
--- a/src/player.odin
+++ b/src/player.odin
@@ -12,8 +12,9 @@ import "tiled"
PLAYER_SPEED :: 100
PLAYER_ACCEL :: 10
PLAYER_JUMP_FORCE :: 350
+PLAYER_DOUBLE_JUMP_FORCE :: 250
PLAYER_JUMP_BUFFERING :: 0.07
-PLAYER_COYOTE_TIME :: 0.05
+PLAYER_COYOTE_TIME :: 0.06
PLAYER_JUMP_RELEASE_CUT :: -100
PLAYER_DASH_SPEED :: 500
@@ -38,7 +39,10 @@ player: struct {
dash_timer: f32,
state: Player_State,
+
outside_room: bool,
+
+ has_double_jumped: bool,
}
init_player :: proc() {
@@ -109,12 +113,21 @@ default_state :: proc(dt: f32) {
if .DOWN in body.collisions {
player.coyote_time = PLAYER_COYOTE_TIME
+ player.has_double_jumped = false
}
- if player.jump_buffer > 0 && player.coyote_time > 0 {
- player.jump_buffer = 0
- player.coyote_time = 0
- body.vel.y = -PLAYER_JUMP_FORCE
+ if player.jump_buffer > 0 {
+ if player.coyote_time > 0 {
+ body.vel.y = -PLAYER_JUMP_FORCE
+
+ player.jump_buffer = 0
+ player.coyote_time = 0
+ } else if !player.has_double_jumped {
+ body.vel.y = -PLAYER_DOUBLE_JUMP_FORCE
+ player.has_double_jumped = true
+
+ player.jump_buffer = 0
+ }
}
if .DOWN not_in body.collisions \