2025-02-28 17:13:53 +01:00
|
|
|
extends CharacterBody2D
|
|
|
|
|
|
|
|
|
|
|
|
const SPEED = 100
|
|
|
|
var direction: Vector2
|
|
|
|
var button_toggled: bool
|
|
|
|
var inp :Vector3
|
|
|
|
func _physics_process(delta: float) -> void:
|
2025-02-28 23:05:41 +01:00
|
|
|
if button_toggled:
|
|
|
|
inp = Input.get_accelerometer()
|
|
|
|
direction = Vector2(inp.x,-inp.y)
|
|
|
|
else:
|
|
|
|
if $"../CanvasLayer/stick/Joystick".posVector:
|
|
|
|
direction = $"../CanvasLayer/stick/Joystick".posVector
|
|
|
|
else:
|
|
|
|
direction = Input.get_vector("ui_left", "ui_right","ui_up","ui_down")
|
|
|
|
|
|
|
|
velocity = direction*SPEED
|
|
|
|
|
|
|
|
move_and_slide()
|
2025-02-28 17:13:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
func _on_generator_done() -> void:
|
2025-02-28 23:05:41 +01:00
|
|
|
$Camera2D.enabled = true
|
2025-02-28 17:13:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
func _on_button_toggled(toggled_on: bool) -> void:
|
2025-02-28 23:05:41 +01:00
|
|
|
button_toggled = toggled_on
|