DocumentatiiNotite/Ziua2:Miscari caracter 2

23 lines
629 B
Plaintext
Raw Permalink Normal View History

2024-07-05 12:51:30 +03:00
Cum procesam datele oferite de la tastatura // continuare joc zi anterioara
extends Sprite2D
var speed = 400
var angular_speed = PI
func _process(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.ZERO
if Input.is_action_pressed("ui_up"):
velocity = Vector2.UP.rotated(rotation) * speed
if Input.is_action_pressed("ui_down"):
velocity = Vector2.DOWN.rotated(rotation) * speed
position += velocity * delta