This commit is contained in:
bee
2026-07-07 10:01:56 +02:00
parent 2e28afebce
commit e946b43db7
13 changed files with 140 additions and 63 deletions
+3 -3
View File
@@ -25,6 +25,9 @@ func _physics_process(delta: float) -> void:
throttle = move_toward(throttle, desired_throttle, throttle_response * delta)
if submerged_ratio <= 0.0:
return # airborne: no thrust, no rudder, no keel
# boat's forward direction, flattened onto the water plane
var forward := -global_basis.z
forward.y = 0.0
@@ -40,9 +43,6 @@ func _physics_process(delta: float) -> void:
var rudder_bite := clampf(forward_speed / 3.0, -1.0, 1.0)
apply_torque(Vector3.UP * steer_input * rudder_strength * rudder_bite * mass * submerged_ratio)
if submerged_ratio <= 0.0:
return # airborne: no thrust, no rudder, no keelffffff
# --- keel: kill sideways sliding ---
var right := global_basis.x
right.y = 0.0
-1
View File
@@ -57,7 +57,6 @@ func _physics_process(_delta: float) -> void:
var factor := clampf(depth / full_force_depth, 0.0, 1.0)
submerged_ratio += factor / _probe_offsets.size()
var force := Vector3.UP * _gravity * mass * buoyancy * factor / _probe_offsets.size()
apply_force(force, pos - global_position)
var r := pos - global_position
# velocity of this specific point on the hull (body motion + rotation)
var point_velocity := linear_velocity + angular_velocity.cross(r)
+6
View File
@@ -0,0 +1,6 @@
# scripts/game.gd — autoloaded as "Game"
extends Node
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("restart"):
get_tree().reload_current_scene()
+1
View File
@@ -0,0 +1 @@
uid://dtkqmj8h5mg8y
+27
View File
@@ -0,0 +1,27 @@
class_name Hud
extends CanvasLayer
## The HUD's only inputs. Everything inside hud.tscn gets its references
## from here -- nothing inside the scene reaches out on its own.
@export var boat: Boat:
set(value):
boat = value
if is_node_ready():
_distribute()
@export var world: WorldManager:
set(value):
world = value
if is_node_ready():
_distribute()
@onready var _stats_label: Label = %StatsLabel
func _ready() -> void:
_distribute()
func _distribute() -> void:
_stats_label.boat = boat
_stats_label.world = world
+1
View File
@@ -0,0 +1 @@
uid://b3gsctxaxjaj1
+3 -3
View File
@@ -5,7 +5,7 @@ extends Label
func _process(_delta: float) -> void:
if boat == null:
if boat == null or world == null:
text = "no boat"
return
@@ -22,6 +22,6 @@ Position: (%.0f, %.0f)
boat.throttle * 100.0,
speed,
boat.submerged_ratio * 100.0,
boat.global_position.x,
boat.global_position.z,
pos.x,
pos.z,
]
+4
View File
@@ -22,6 +22,8 @@ func true_position(node: Node3D) -> Vector3:
func _physics_process(_delta: float) -> void:
if focus == null:
return
_maybe_shift_origin()
_recenter_followers()
@@ -34,6 +36,7 @@ func _maybe_shift_origin() -> void:
origin_offset += shift
for node in get_tree().get_nodes_in_group("shift_with_origin"):
node.global_position -= shift
node.reset_physics_interpolation()
ocean.shift_origin(shift)
@@ -45,3 +48,4 @@ func _recenter_followers() -> void:
if new_x != node.global_position.x or new_z != node.global_position.z:
node.global_position.x = new_x
node.global_position.z = new_z
node.reset_physics_interpolation()