no message
This commit is contained in:
26
sidescroller/scripts/playerdoublejump.gd
Normal file
26
sidescroller/scripts/playerdoublejump.gd
Normal file
@ -0,0 +1,26 @@
|
||||
extends State
|
||||
class_name PlayerDoubleJump
|
||||
|
||||
func get_state_name():
|
||||
return str(self).split(":")[0]
|
||||
|
||||
func enter():
|
||||
player.ap.play("double jump")
|
||||
player.velocity.y = -player.jump_force
|
||||
player.air_jumps_done += 1
|
||||
|
||||
func exit():
|
||||
pass
|
||||
|
||||
func update(delta):
|
||||
if player.velocity.y > 0 and !player.is_on_floor():
|
||||
Transitioned.emit(self, "PlayerFall")
|
||||
elif !player.is_on_floor() and Input.is_action_just_pressed("jump") and (player.air_jumps_done < player.max_air_jumps):
|
||||
Transitioned.emit(self, "PlayerDoubleJump")
|
||||
elif player.is_on_floor() && player.velocity.x != 0:
|
||||
Transitioned.emit(self, "PlayerRun")
|
||||
elif player.is_on_floor():
|
||||
Transitioned.emit(self, "PlayerIdle")
|
||||
|
||||
func physics_update(delta):
|
||||
pass
|
||||
Reference in New Issue
Block a user