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>
This commit is contained in:
Loïc Wisniewski 2026-08-10 18:41:58 +02:00
commit 85814ce88c
192 changed files with 9602 additions and 0 deletions

View file

@ -0,0 +1,77 @@
extends SceneTree
# Headless gameplay test: run with
# godot --headless -s res://tests/test_fleet_formation.gd
# Verifies that issuing a fleet move order makes every ship converge on its
# formation slot (offset preserved) around the ordered point AND actually
# stops there - a regression guard for the arrival-overshoot bug where ships
# oscillated back and forth around the target forever instead of settling.
const CHECKPOINT_TIME: float = 4.0
const TEST_DURATION: float = 7.0
const ARRIVE_TOLERANCE: float = 2.0
const STABLE_TOLERANCE: float = 1.0
const VELOCITY_TOLERANCE: float = 1.0
var main_scene: Node
var fleet: Node
var target: Vector2 = Vector2(600.0, 300.0)
var elapsed: float = 0.0
var started: bool = false
var checkpoint_taken: bool = false
var checkpoint_positions: Array = []
func _initialize() -> void:
var packed: PackedScene = load("res://Main.tscn")
main_scene = packed.instantiate()
root.add_child(main_scene)
fleet = main_scene.get_node("Fleet")
func _physics_process(delta: float) -> bool:
if not started:
# Wait one physics tick so Fleet/Ship _ready() has run and
# formation_offsets are computed before we issue the order.
fleet.move_to(target)
started = true
return false
elapsed += delta
if not checkpoint_taken and elapsed >= CHECKPOINT_TIME:
checkpoint_taken = true
for ship in fleet.ships:
checkpoint_positions.append(ship.position)
if elapsed >= TEST_DURATION:
_finish()
return true
return false
func _finish() -> void:
var all_ok: bool = true
for i in range(fleet.ships.size()):
var ship: Node = fleet.ships[i]
var expected: Vector2 = target + fleet.formation_offsets[i]
var dist: float = ship.position.distance_to(expected)
var drift_since_checkpoint: float = ship.position.distance_to(checkpoint_positions[i])
var speed: float = ship.velocity.length()
var arrived: bool = dist <= ARRIVE_TOLERANCE
var stable: bool = drift_since_checkpoint <= STABLE_TOLERANCE
var stopped: bool = speed <= VELOCITY_TOLERANCE
var ok: bool = arrived and stable and stopped
all_ok = all_ok and ok
print("Ship %d expected=%s actual=%s dist=%.3f drift_since_t%.0fs=%.3f speed=%.3f %s" % [
i, expected, ship.position, dist, CHECKPOINT_TIME, drift_since_checkpoint, speed, "OK" if ok else "FAIL"
])
if all_ok:
print("TEST_FLEET_FORMATION: PASS (ships arrived and settled, no oscillation)")
quit(0)
else:
print("TEST_FLEET_FORMATION: FAIL")
quit(1)