From 703100ed74e7655c266644dafb23e64ba79e5346 Mon Sep 17 00:00:00 2001 From: Xander Swan Date: Fri, 5 Dec 2025 22:34:37 -0500 Subject: variable jump height --- src/player.odin | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/player.odin b/src/player.odin index f204126..854ef53 100644 --- a/src/player.odin +++ b/src/player.odin @@ -8,6 +8,13 @@ import sapp "shared:sokol/app" import "draw" import "phys" +PLAYER_SPEED :: 100 +PLAYER_ACCEL :: 10 +PLAYER_JUMP_FORCE :: 350 +JUMP_BUFFERING :: 0.07 +CYOTE_TIME :: 0.05 +JUMP_RELEASE_CUT :: -100 + Player :: struct { body_handle: phys.Body_Handle, anim: draw.Animation, @@ -17,13 +24,6 @@ Player :: struct { cyote_time: f32, } -PLAYER_SPEED :: 100 -PLAYER_ACCEL :: 10 -PLAYER_JUMP_FORCE :: 350 - -JUMP_BUFFERING :: 0.07 -CYOTE_TIME :: 0.05 - init_player :: proc(p: ^Player) { anim_ok := draw.init_anim_data(&p.anim, "res/robot2.json") if !anim_ok { @@ -87,6 +87,12 @@ update_player :: proc(p: ^Player, dt: f32) { body.vel.y = -PLAYER_JUMP_FORCE } + if .DOWN not_in body.collisions \ + && !is_keybind_down(state.input, state.input.jump) \ + && body.vel.y < JUMP_RELEASE_CUT { + body.vel.y = JUMP_RELEASE_CUT + } + body.vel.x = math.lerp( body.vel.x, input * PLAYER_SPEED, -- cgit v1.3-2-g0d8e