47 lines
1.3 KiB
GDScript
47 lines
1.3 KiB
GDScript
extends Node
|
|
|
|
export var flipped_sprite: bool = true
|
|
onready var idle_timeout = $IdleTimeout
|
|
|
|
var desired_movement_vector: Vector2
|
|
|
|
var flip_flop = false
|
|
var wandering = false
|
|
var current_state_name: String = ""
|
|
|
|
# Return the desired direction of movement for the character
|
|
# in the range [-1, 1], where positive values indicate a desire
|
|
# to move to the right and negative values to the left.
|
|
func get_movement_direction() -> float:
|
|
#return Input.get_axis('move_left', 'move_right')
|
|
if current_state_name == "idle" and idle_timeout.time_left == 0:
|
|
if flip_flop:
|
|
flip_flop = false
|
|
desired_movement_vector.x = 1.0
|
|
idle_timeout.start()
|
|
else:
|
|
flip_flop = true
|
|
desired_movement_vector.x = -1.0
|
|
idle_timeout.start()
|
|
if current_state_name == "move" and idle_timeout.time_left == 0:
|
|
idle_timeout.start()
|
|
desired_movement_vector.x = 0.0
|
|
return 0.0
|
|
|
|
# Return a boolean indicating if the character wants to jump
|
|
func wants_jump() -> bool:
|
|
return false
|
|
# if Input.is_action_just_pressed("jump_" + str(player_number)):
|
|
# desired_movement_vector.y = 1
|
|
# return true
|
|
# else:
|
|
# return false
|
|
|
|
# Return a boolean indicating if the character wants to jump
|
|
func wants_shoot() -> bool:
|
|
# if Input.is_action_just_pressed("shoot_" + str(player_number)):
|
|
# return true
|
|
# else:
|
|
# return false
|
|
return false
|