34 lines
898 B
GDScript
34 lines
898 B
GDScript
extends State
|
|
class_name PlayerJump
|
|
|
|
func get_state_name():
|
|
return str(self).split(":")[0]
|
|
|
|
func enter():
|
|
player.ap.play("jump")
|
|
player.velocity.y = -player.jump_force
|
|
player.jumps_done += 1
|
|
player.v_mult = player.jump_mult
|
|
|
|
func exit():
|
|
player.v_mult = 1
|
|
|
|
func update(delta):
|
|
|
|
player.jumpbuffer(delta)
|
|
|
|
if player.transitionledgegrab():
|
|
Transitioned.emit(self, "PlayerLedgeGrab")
|
|
elif player.transitiondash():
|
|
Transitioned.emit(self, "PlayerDash")
|
|
elif player.transitionfall():
|
|
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
|