Files
boatgame/scripts/stats_label.gd
T
2026-07-07 08:17:45 +02:00

28 lines
582 B
GDScript

extends Label
@export var boat: Boat # drag the Crate into this slot in the inspector
@export var world: WorldManager
func _process(_delta: float) -> void:
if boat == null:
text = "no boat"
return
var forward := -boat.global_basis.z
forward.y = 0.0
var speed := boat.linear_velocity.dot(forward.normalized())
var pos := world.true_position(boat)
text = "Throttle: %+.0f %%
Speed: %.1f m/s
Submerged: %.0f %%
Position: (%.0f, %.0f)
" % [
boat.throttle * 100.0,
speed,
boat.submerged_ratio * 100.0,
boat.global_position.x,
boat.global_position.z,
]