obsidian/MyObsidianVault/Knowledgebase/Godot/2D/Tutorial M4 - to space and beyond/03. Increasing speed.md
2024-12-22 14:02:54 +01:00

486 B

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()