#@tool
#@icon
#class_name
extends CharacterBody2D
## Top-down player controller

## Signals
## Enums
## Constants
## @export variables
@export var walking_speed: int = 100
@export var running_speed: int = 150
@export var turning_speed: float = 0.1
## Regular variables
var thrust: float = 0.0
var rudder: float = 0.0
var yaw: float = 0.0
var heading: Vector2 = Vector2.UP
var is_running: bool = false
## @onready variables

## Overridden built-in virtual methods
#func _init() -> void:
#func _enter_tree() -> void:
#func _ready() -> void:
#func _process(_delta: float) -> void:
	
func _physics_process(_delta: float) -> void:
	thrust = Input.get_axis("backward", "forward")
	rudder = Input.get_axis("turn_left", "turn_right")
	yaw = rudder * turning_speed
	
	heading = heading.rotated(yaw)
	rotate(yaw)
	
	is_running = Input.is_action_pressed("run") and thrust > 0.0
	if is_running:
		velocity = thrust * heading * running_speed
	else:
		velocity = thrust * heading * walking_speed

		
	move_and_slide()
## Remaining virtual methods
## Overridden custom methods
## Remaining methods
## Subclasses
