spaceship/Hauler.gd
Loïc Wisniewski 85814ce88c Initial commit: SpaceshipTest, a top-down space RTS in Godot 4.7.1
A fleet of neon-outlined ships explores a procedurally generated, seeded
infinite world: tap/joystick steering, pinch zoom, formation pivoting,
planet landings, an ore economy with extractors and haulers, and player
built structures (mothership, ship crafter, command centre).

All art is hand-drawn with draw_* calls rather than textures, and the
backgrounds are camera-relative shaders so they stay precise at large
world coordinates.

Includes a 35-test headless suite (tests/run_tests.sh) plus screenshot
tooling that renders real frames through Xvfb and Mesa softpipe, since
--headless has no GPU.

Excluded from version control: .godot/ (import cache, and it holds
export credentials), builds/, android/build/ and packaged APKs - all
regenerable, and ~325 MB combined.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 18:41:58 +02:00

39 lines
1.2 KiB
GDScript

extends Node2D
# Purely visual: an automated ore hauler running an extractor's route. It
# carries no state of its own - GameState owns the simulation and this node
# is created, positioned and freed to match it. See HaulerField.
const HULL_COLOR: Color = Color(0.55, 0.85, 0.4)
var laden: bool = false
func _ready() -> void:
add_to_group("haulers")
z_index = -1
queue_redraw()
func set_laden(value: bool) -> void:
if laden == value:
return
laden = value
queue_redraw()
func _draw() -> void:
# Blunt freighter silhouette - deliberately unlike the player's sharp
# triangles, so it is obvious at a glance this is not a fleet vessel.
var hull: PackedVector2Array = PackedVector2Array([
Vector2(0, -20), Vector2(11, -6), Vector2(11, 16), Vector2(-11, 16), Vector2(-11, -6),
])
NeonDraw.draw_glowing_polygon(self, hull, HULL_COLOR, 1.0)
if laden:
# Ore in the hold on the outbound leg, so a glance tells you which
# way it is going.
var cargo: PackedVector2Array = PackedVector2Array()
for i in range(6):
var a: float = (float(i) / 6.0) * TAU - PI / 2.0
cargo.append(Vector2(cos(a), sin(a)) * 6.0 + Vector2(0, 4))
NeonDraw.draw_glowing_polygon(self, cargo, Color(0.0, 0.62, 0.7), 1.0)