|
@@ -30,13 +30,21 @@ func _process(delta: float) -> void:
|
|
|
|
|
|
|
|
|
func _new_direction() -> Vector2:
|
|
|
- var new_dir := Vector2(Input.get_joy_axis(0, JOY_AXIS_LEFT_X), 0.0)
|
|
|
- if absf(new_dir.x) < STICK_DEADZONE:
|
|
|
- new_dir.x = 0.0
|
|
|
-
|
|
|
- new_dir.x += Input.get_axis("move_left", "move_right")
|
|
|
+ var new_dir := Vector2.ZERO
|
|
|
+ new_dir += _direction_from_axis()
|
|
|
+ new_dir += _direction_from_keys()
|
|
|
|
|
|
if new_dir == Vector2.ZERO:
|
|
|
return Vector2.ZERO
|
|
|
|
|
|
return new_dir.normalized()
|
|
|
+
|
|
|
+
|
|
|
+func _direction_from_axis() -> Vector2:
|
|
|
+ var axis_dir := Vector2(Input.get_joy_axis(0, JOY_AXIS_LEFT_X), 0.0)
|
|
|
+ if absf(axis_dir.x) < STICK_DEADZONE:
|
|
|
+ axis_dir.x = 0.0
|
|
|
+ return axis_dir
|
|
|
+
|
|
|
+func _direction_from_keys() -> Vector2:
|
|
|
+ return Vector2(Input.get_axis("move_left", "move_right"), 0)
|