2023-06-11 23:38:54 +02:00
|
|
|
class_name PlayerIdleState
|
|
|
|
extends PlayerState
|
|
|
|
|
2023-06-18 20:30:25 +02:00
|
|
|
var collide_with_ball = false
|
|
|
|
|
2023-06-11 23:38:54 +02:00
|
|
|
func enter(_msg := {}):
|
|
|
|
player.velocity = Vector2.ZERO
|
|
|
|
player.animation_player.play("idle")
|
|
|
|
|
|
|
|
func update(_delta):
|
2023-06-18 20:30:25 +02:00
|
|
|
if collide_with_ball && Input.is_action_pressed("hit"):
|
|
|
|
collide_with_ball = false
|
|
|
|
state_machine.transition_to("Throw")
|
|
|
|
|
2023-06-11 23:38:54 +02:00
|
|
|
if get_input_direction() != Vector2.ZERO:
|
|
|
|
state_machine.transition_to("Walk")
|
|
|
|
|
|
|
|
func get_input_direction():
|
|
|
|
return Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
2023-06-18 20:30:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
func _on_player_collide_with_ball():
|
|
|
|
collide_with_ball = true
|