diff options
Diffstat (limited to 'src/player.odin')
| -rw-r--r-- | src/player.odin | 20 |
1 files 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, |
