From fc1fc0b784a6a3b3da888ee66679155d825bf383 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 26 Mar 2024 10:35:08 +0100 Subject: [PATCH] Finishing scripting_player_input section --- scripting_first_script/Sprite2D.gd | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripting_first_script/Sprite2D.gd b/scripting_first_script/Sprite2D.gd index 6ff92a6..dde6e6e 100644 --- a/scripting_first_script/Sprite2D.gd +++ b/scripting_first_script/Sprite2D.gd @@ -4,8 +4,15 @@ var speed = 400 var angular_speed = PI func _process(delta): - 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 + rotation += angular_speed * direction * delta - var velocity = Vector2.UP.rotated(rotation) * speed + var velocity = Vector2.ZERO + if Input.is_action_pressed('ui_up'): + velocity = Vector2.UP.rotated(rotation) * speed position += velocity * delta