Double Jump
This commit is contained in:
parent
abb03863b9
commit
7f8aabadcf
2 changed files with 21 additions and 12 deletions
|
@ -17,7 +17,8 @@ export (int) var bullet_speed = 250
|
|||
var invincible = false setget set_invincible
|
||||
var motion = Vector2.ZERO
|
||||
var snap_vector = Vector2.ZERO
|
||||
var just_jumped= false
|
||||
var just_jumped = false
|
||||
var double_jump = true
|
||||
|
||||
onready var sprite = $Sprite
|
||||
onready var animation = $Animation
|
||||
|
@ -78,16 +79,23 @@ func update_snap_vector():
|
|||
if is_on_floor():
|
||||
snap_vector = Vector2.DOWN
|
||||
|
||||
func jump(force):
|
||||
Utils.instance_scene_on_main(JumpEffect, global_position)
|
||||
motion.y = -force
|
||||
snap_vector = Vector2.ZERO
|
||||
|
||||
func jump_check():
|
||||
if is_on_floor() or coyoteJumpTimer.time_left > 0:
|
||||
if Input.is_action_just_pressed("ui_select"):
|
||||
Utils.instance_scene_on_main(JumpEffect, global_position)
|
||||
motion.y = -jump_force
|
||||
snap_vector = Vector2.ZERO
|
||||
jump(jump_force)
|
||||
just_jumped = true
|
||||
else:
|
||||
if Input.is_action_just_released("ui_select") and motion.y < -jump_force/2:
|
||||
motion.y = motion.y/2
|
||||
|
||||
if Input.is_action_just_pressed("ui_select") and double_jump:
|
||||
jump(jump_force * .75)
|
||||
double_jump = false
|
||||
|
||||
func apply_gravity(delta):
|
||||
if not is_on_floor():
|
||||
|
@ -121,6 +129,7 @@ func move():
|
|||
motion.x = last_motion.x
|
||||
#create_dust_effect()
|
||||
Utils.instance_scene_on_main(JumpEffect, global_position)
|
||||
double_jump = true
|
||||
|
||||
|
||||
# Just left ground
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue