2023-11-23 23:02:18 +00:00
|
|
|
extends Node
|
|
|
|
|
2023-11-25 13:27:41 +00:00
|
|
|
func input_event_to_8way_direction(p_event: InputEvent) -> Vector2:
|
2023-11-23 23:02:18 +00:00
|
|
|
var result := Vector2.ZERO
|
|
|
|
if p_event.is_action_pressed("move_down"):
|
|
|
|
result.y += 1
|
|
|
|
if p_event.is_action_pressed("move_right"):
|
|
|
|
result.x += 1
|
|
|
|
if p_event.is_action_pressed("move_up"):
|
|
|
|
result.y -= 1
|
|
|
|
if p_event.is_action_pressed("move_left"):
|
|
|
|
result.x -= 1
|
|
|
|
return result
|
2023-11-25 13:27:41 +00:00
|
|
|
|
|
|
|
func input_event_to_4way_direction(p_event: InputEvent) -> Vector2:
|
|
|
|
if p_event.is_action_pressed("move_down") and not p_event.is_action_pressed("move_up"):
|
|
|
|
return Vector2.DOWN
|
|
|
|
elif p_event.is_action_pressed("move_up") and not p_event.is_action_pressed("move_down"):
|
|
|
|
return Vector2.UP
|
|
|
|
elif p_event.is_action_pressed("move_left") and not p_event.is_action_pressed("move_right"):
|
|
|
|
return Vector2.LEFT
|
|
|
|
elif p_event.is_action_pressed("move_right") and not p_event.is_action_pressed("move_left"):
|
|
|
|
return Vector2.RIGHT
|
|
|
|
else:
|
|
|
|
return Vector2.ZERO
|