Skip to content

Commit

Permalink
Merge pull request #34 from SanicTeam/bdero/variable-jump
Browse files Browse the repository at this point in the history
Implement variable jump time.
  • Loading branch information
bdero authored Jun 14, 2016
2 parents 06e91d9 + f40a205 commit 5f81cc7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Binary file modified scenes/levels/test_level0.scn
Binary file not shown.
Binary file modified scenes/player.scn
Binary file not shown.
10 changes: 7 additions & 3 deletions scripts/player/character.gd
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
extends KinematicBody

const MAX_SPEED = 10
const GRAVITY = Vector3(0, -9.8*2, 0)
const GRAVITY = Vector3(0, -9.8*3.5, 0)
const MAX_SLOPE_ANGLE = deg2rad(45)
const JUMP_SPEED = 10
const JUMP_SPEED = 12
const Y_VEC = Vector3(0, -1, 0)

const ACCEL_SPEED = 40
Expand All @@ -13,6 +13,7 @@ const AIR_THRESHOLD = 5

var air_timer
var air_timeout = true
var jump_timer

var camera
var model
Expand All @@ -29,6 +30,7 @@ func _ready():
model = get_node("model")
animations = model.get_node("AnimationPlayer")
air_timer = get_parent().get_node("air_timer")
jump_timer = get_node("../jump_timer")
set_fixed_process(true)

func _fixed_process(delta):
Expand Down Expand Up @@ -59,11 +61,13 @@ func _fixed_process(delta):
# If we're on the ground and want to jump, set the velocity accordingly
if jump:
if on_ground and !jump_held:
velocity.y = JUMP_SPEED
jump_held = true
on_ground = false
air_timeout = true
get_node("sounds").play("jump")
jump_timer.start()
if jump_held and jump_timer.get_time_left() > 0:
velocity.y = JUMP_SPEED
else:
jump_held = false

Expand Down

0 comments on commit 5f81cc7

Please sign in to comment.