2024-03-01 13:34:29 +01:00
|
|
|
```python
|
2024-02-27 16:32:53 +01:00
|
|
|
func _process(delta: float) -> void:
|
2024-03-01 13:34:29 +01:00
|
|
|
var direction := Vector2(0, 0)
|
2024-02-27 16:32:53 +01:00
|
|
|
direction.x = Input.get_axis("move_left", "move_right")
|
|
|
|
|
direction.y = Input.get_axis("move_up", "move_down")
|
2024-03-01 13:34:29 +01:00
|
|
|
|
2024-02-27 16:32:53 +01:00
|
|
|
if direction.length() > 1.0:
|
|
|
|
|
direction = direction.normalized()
|
2024-03-01 13:34:29 +01:00
|
|
|
|
|
|
|
|
if Input.is_action_just_pressed("boost"):
|
|
|
|
|
max_speed = boost_speed
|
|
|
|
|
get_node("Timer").start()
|
|
|
|
|
|
2024-02-27 16:32:53 +01:00
|
|
|
velocity = direction * max_speed
|
|
|
|
|
position += velocity * delta
|
2024-03-01 13:34:29 +01:00
|
|
|
|
2024-02-27 16:32:53 +01:00
|
|
|
if direction.length() > 0.0:
|
|
|
|
|
rotation = velocity.angle()
|
|
|
|
|
```
|