Boosting Ship Speed

This commit is contained in:
Torsten 2024-03-01 13:34:29 +01:00
parent 6a0d25a16a
commit 55f6772d03
3 changed files with 19 additions and 0 deletions

View file

@ -0,0 +1,19 @@
```python
func _process(delta: float) -> void:
var direction := Vector2(0, 0)
direction.x = Input.get_axis("move_left", "move_right")
direction.y = Input.get_axis("move_up", "move_down")
if direction.length() > 1.0:
direction = direction.normalized()
if Input.is_action_just_pressed("boost"):
max_speed = boost_speed
get_node("Timer").start()
velocity = direction * max_speed
position += velocity * delta
if direction.length() > 0.0:
rotation = velocity.angle()
```