mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
50 lines
1.3 KiB
GDScript
50 lines
1.3 KiB
GDScript
class_name PlayerShipController
|
|
extends ShipController
|
|
|
|
# Drives a Ship from the local player's input actions (see project.godot
|
|
# [input] and FLIGHT_MANUAL.md).
|
|
|
|
|
|
func get_action() -> ShipAction:
|
|
var action := ShipAction.new()
|
|
|
|
# Forward/Backward thrust (main engines)
|
|
if Input.is_action_pressed("move_forward"):
|
|
action.thrust.z += 1.0
|
|
if Input.is_action_pressed("move_back"):
|
|
action.thrust.z -= 1.0
|
|
|
|
# Strafe thrusters (left/right)
|
|
if Input.is_action_pressed("move_left"):
|
|
action.thrust.x -= 1.0
|
|
if Input.is_action_pressed("move_right"):
|
|
action.thrust.x += 1.0
|
|
|
|
# Vertical thrusters (up/down)
|
|
if Input.is_action_pressed("move_up"):
|
|
action.thrust.y += 1.0
|
|
if Input.is_action_pressed("move_down"):
|
|
action.thrust.y -= 1.0
|
|
|
|
# Yaw (turn left/right around Y axis)
|
|
if Input.is_action_pressed("turn_left"):
|
|
action.rotation.y += 1.0
|
|
if Input.is_action_pressed("turn_right"):
|
|
action.rotation.y -= 1.0
|
|
|
|
# Pitch (nose up/down around X axis)
|
|
if Input.is_action_pressed("pitch_up"):
|
|
action.rotation.x -= 1.0
|
|
if Input.is_action_pressed("pitch_down"):
|
|
action.rotation.x += 1.0
|
|
|
|
# Roll (bank left/right around Z axis)
|
|
if Input.is_action_pressed("roll_left"):
|
|
action.rotation.z += 1.0
|
|
if Input.is_action_pressed("roll_right"):
|
|
action.rotation.z -= 1.0
|
|
|
|
action.turbo = Input.is_action_pressed("turbo")
|
|
|
|
return action
|