Step by step - Listening to player input

This commit is contained in:
Laegnur 2024-09-11 18:40:57 +02:00
parent 8235939bf3
commit 6240748512
Signed by: laegnur
GPG key ID: F8FE83A0B2D932A3

View file

@ -4,8 +4,16 @@ var speed = 400
var angular_speed = PI
func _process(delta: float) -> void:
rotation += angular_speed * delta
var direction = 0
if Input.is_action_pressed("ui_left"):
direction = -1
if Input.is_action_pressed("ui_right"):
direction = 1
var velocity = Vector2.UP.rotated(rotation) * speed
rotation += angular_speed * direction * delta
var velocity = Vector2.ZERO
if Input.is_action_pressed("ui_up"):
velocity = Vector2.UP.rotated(rotation) * speed
position += velocity * delta