diff --git a/Miscari caracter b/Miscari caracter index 70a11cc..7dff84d 100644 --- a/Miscari caracter +++ b/Miscari caracter @@ -13,28 +13,3 @@ As we already saw, the var keyword defines a new variable. If you put it at the We define a local variable named velocity, a 2D vector representing both a direction and a speed. To make the node move forward, we start from the Vector2 class’s constant Vector2.UP, a vector pointing up, and rotate it by calling the Vector2 method rotated(). This expression, Vector2.UP.rotated(rotation), is a vector pointing forward relative to our icon. Multiplied by our speed property, it gives us a velocity we can use to move the node forward. We add velocity * delta to the node’s position to move it. The position itself is of type Vector2, a built-in type in Godot representing a 2D vector. - - -Ziua 2: -Cum procesam datele oferite de la tastatura // continuare joc zi anterioara: -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 -