From 6240748512a0cd97c0536a2f07ffc1b26baa6409 Mon Sep 17 00:00:00 2001 From: Laegnur Date: Wed, 11 Sep 2024 18:40:57 +0200 Subject: [PATCH] Step by step - Listening to player input --- scripts/icon.gd | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/icon.gd b/scripts/icon.gd index 4695b05..91de13e 100644 --- a/scripts/icon.gd +++ b/scripts/icon.gd @@ -4,8 +4,16 @@ var speed = 400 var angular_speed = PI func _process(delta: float) -> void: - rotation += angular_speed * delta - - var velocity = Vector2.UP.rotated(rotation) * speed + var direction = 0 + if Input.is_action_pressed("ui_left"): + direction = -1 + if Input.is_action_pressed("ui_right"): + direction = 1 + + 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