maze-generator-assets-lib/player.gd
megamichi 7bb83a1340 init
2025-02-28 17:13:53 +01:00

28 lines
656 B
GDScript

extends CharacterBody2D
const SPEED = 100
var direction: Vector2
var button_toggled: bool
var inp :Vector3
func _physics_process(delta: float) -> void:
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()
func _on_generator_done() -> void:
$Camera2D.enabled = true
func _on_button_toggled(toggled_on: bool) -> void:
button_toggled = toggled_on