Randoloot/scripts/game/flight_hud.gd

62 lines
1.9 KiB
GDScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends CanvasLayer
@onready var debug_toggle: Button = $HUDRoot/DebugToggle
@onready var debug_info: Label = $HUDRoot/DebugInfo
@onready var player: CharacterBody2D = get_parent().get_node("PlayerShip")
@onready var inventory_button: Button = $HUDRoot/ShipEquipmentPanel/Contents/InventoryButton
@onready var inventory_panel: Control = $HUDRoot/ShipInventoryPanel
var _debug_expanded := true
func _ready() -> void:
debug_toggle.pressed.connect(_toggle_debug)
inventory_button.pressed.connect(_toggle_inventory)
_update_debug_toggle()
func _process(_delta: float) -> void:
if not _debug_expanded:
return
var ship_position := player.global_position
var ship_velocity := player.velocity
var angular_speed := float(player.get("angular_velocity"))
debug_info.text = """STEROWANIE
W: ciąg S: hamulec / wsteczny
Q / E: strafe A / D: obrót
LPM / PPM: broń 1 / broń 2
STATEK
KADŁUB: %d / %d
TARCZE: %d / %d
ENERGIA: %d / %d
ENERGIA REGEN: %.1f /s
TARCZE REGEN: %.1f /s
RUCH
PRĘDKOŚĆ: %.1f px/s
WEKTOR X: %.1f px/s
WEKTOR Y: %.1f px/s
POZYCJA X: %.1f
POZYCJA Y: %.1f
KIERUNEK: %.1f°
OBRÓT: %.2f rad/s""" % [
roundi(float(player.get("hull"))), roundi(float(player.get("max_hull"))),
roundi(float(player.get("shields"))), roundi(float(player.get("max_shields"))),
roundi(float(player.get("energy"))), roundi(float(player.get("max_energy"))),
float(player.get("energy_regeneration")),
float(player.get("shield_regeneration")),
ship_velocity.length(), ship_velocity.x, ship_velocity.y,
ship_position.x, ship_position.y, rad_to_deg(player.rotation), angular_speed,
]
func _toggle_debug() -> void:
_debug_expanded = not _debug_expanded
debug_info.visible = _debug_expanded
_update_debug_toggle()
func _update_debug_toggle() -> void:
debug_toggle.text = "DEBUG [−]" if _debug_expanded else "DEBUG [+]"
func _toggle_inventory() -> void:
inventory_panel.visible = not inventory_panel.visible