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
|
|
|
extends SceneTree
|
|
|
|
|
|
|
|
|
|
# Headless gameplay test: run with
|
|
|
|
|
# godot --headless -s res://tests/test_lopsided_formation_movement.gd
|
|
|
|
|
# Regression test for the fleet lurching the wrong way on the first frames
|
|
|
|
|
# of a move after the formation was edited at a command centre.
|
|
|
|
|
#
|
|
|
|
|
# Ships sit at anchor + offset, so the fleet CENTROID is anchor + the
|
|
|
|
|
# AVERAGE offset. Seeding the steering anchor from the centroid therefore
|
|
|
|
|
# displaced every slot by that average the moment the stick was pushed. The
|
|
|
|
|
# default wedge is balanced (average ~zero), so this was invisible; drag
|
|
|
|
|
# every slot into one corner and the average becomes large, and the fleet
|
|
|
|
|
# jerks towards that corner before the anchor catches up.
|
|
|
|
|
#
|
|
|
|
|
# Verifies, with every slot dragged to the top-right:
|
|
|
|
|
# 1. starting a move does NOT displace the ships' targets sideways
|
|
|
|
|
# 2. the fleet actually travels bottom-left from the outset - no frame in
|
|
|
|
|
# which the centroid moves the wrong way
|
|
|
|
|
# 3. releasing the stick leaves the formation origin where the ships are,
|
|
|
|
|
# so re-applying the layout does not teleport them
|
|
|
|
|
|
|
|
|
|
var scene: Node
|
|
|
|
|
var fleet: Node
|
|
|
|
|
var game_state: Node
|
|
|
|
|
var stage: int = 0
|
|
|
|
|
var elapsed: float = 0.0
|
|
|
|
|
var samples: Array = []
|
|
|
|
|
var start_centroid: Vector2 = Vector2.ZERO
|
|
|
|
|
var worst_backwards: float = 0.0
|
|
|
|
|
|
|
|
|
|
const HEADING: Vector2 = Vector2(-0.7071, 0.7071) # bottom-left
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _initialize() -> void:
|
|
|
|
|
game_state = root.get_node("GameState")
|
|
|
|
|
game_state.reset_formation()
|
|
|
|
|
# Every slot dragged into the top-right corner, as the command centre
|
|
|
|
|
# allows. The layout keeps its shape; only its centre is offset.
|
|
|
|
|
for i in range(game_state.formation.size()):
|
|
|
|
|
game_state.formation[i] += Vector2(90.0, -70.0)
|
|
|
|
|
|
#84: move 215 root files into a folder hierarchy
Everything lived in one flat directory, so a diff gave no clue what area it
touched and finding the file you wanted meant knowing its exact name. Twelve
folders now, grouped by what a thing IS rather than what type it is - a
vessel's definition, its component scenes and its upgrade resources sit
together, because that is the set you read when you change one of them.
buildings core controllers enemies logistics planets
resources shaders surface ui vessels vfx world
332 files moved and every res:// reference rewritten - 306 files touched,
including the autoload and main-scene paths in project.godot. Nothing renamed:
this is purely where files sit, so the diff is a pile of pure moves and no
behaviour is buried in it. ui_theme.tres, icon.svg and web_shell.html stay at
the root, where Godot and the export preset expect them.
Verified three ways, because a suite alone would not have caught all of it:
the full 117 pass, the web export builds clean, and the game renders.
The export is why that matters. The FIRST export after the move failed with
"Attempt to open script 'res://GameState.gd'" - the old path - while
project.godot on disk plainly said res://core/GameState.gd. That is this
project's documented Android FUSE mtime trap: Godot served a cached copy of a
file whose content had changed. A `touch` fixed it. Nothing in the test suite
would have found that, because the suite runs from a copy on a native
filesystem - the one place the bug cannot happen.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 19:44:14 +02:00
|
|
|
scene = load("res://world/Main.tscn").instantiate()
|
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
|
|
|
root.add_child(scene)
|
|
|
|
|
fleet = scene.get_node("Fleet")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _process(delta: float) -> bool:
|
|
|
|
|
elapsed += delta
|
|
|
|
|
match stage:
|
|
|
|
|
0:
|
|
|
|
|
scene.get_node("AsteroidField").set_process(false)
|
|
|
|
|
scene.get_node("EnemySpawner").set_process(false)
|
|
|
|
|
fleet.apply_formation()
|
|
|
|
|
elapsed = 0.0
|
|
|
|
|
stage = 1
|
|
|
|
|
return false
|
|
|
|
|
1:
|
|
|
|
|
# Let the ships settle into the lopsided layout first.
|
|
|
|
|
if elapsed < 1.0:
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
start_centroid = fleet.get_centroid()
|
|
|
|
|
var origin_before: Vector2 = fleet.get_formation_origin()
|
|
|
|
|
fleet.move_in_direction(HEADING)
|
|
|
|
|
|
|
|
|
|
# Direct assertion of the bug: the anchor steering starts from
|
|
|
|
|
# must be the point the ships are already arranged around. Taking
|
|
|
|
|
# the centroid instead puts it a whole average-offset away, which
|
|
|
|
|
# is what yanked the fleet sideways.
|
|
|
|
|
var drift: float = fleet.anchor.distance_to(origin_before)
|
|
|
|
|
print("anchor is %.2f units from the formation origin (centroid is %.2f away)" % [
|
|
|
|
|
drift, fleet.get_centroid().distance_to(origin_before)
|
|
|
|
|
])
|
|
|
|
|
if drift > 1.0:
|
|
|
|
|
print("TEST_LOPSIDED_FORMATION_MOVEMENT: FAIL (steering anchored off the formation)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
elapsed = 0.0
|
|
|
|
|
stage = 2
|
|
|
|
|
return false
|
|
|
|
|
2:
|
|
|
|
|
# Watch the centroid every frame: it must make progress along the
|
|
|
|
|
# heading from the very first one, never against it.
|
|
|
|
|
var travelled: float = (fleet.get_centroid() - start_centroid).dot(HEADING)
|
|
|
|
|
worst_backwards = minf(worst_backwards, travelled)
|
|
|
|
|
samples.append(travelled)
|
|
|
|
|
if elapsed < 0.6:
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
print("progress along heading: first=%.2f last=%.2f worst=%.2f" % [
|
|
|
|
|
samples[0], samples[-1], worst_backwards
|
|
|
|
|
])
|
|
|
|
|
if worst_backwards < -2.0:
|
|
|
|
|
print("TEST_LOPSIDED_FORMATION_MOVEMENT: FAIL (fleet moved backwards before setting off)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
if samples[-1] < 50.0:
|
|
|
|
|
print("TEST_LOPSIDED_FORMATION_MOVEMENT: FAIL (fleet did not travel along the heading)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
# --- releasing the stick --------------------------------------
|
|
|
|
|
fleet.stop()
|
|
|
|
|
var origin: Vector2 = fleet.fleet_target
|
|
|
|
|
var expected: Vector2 = fleet.get_formation_origin()
|
|
|
|
|
var settled_ok: bool = origin.distance_to(expected) < 0.01
|
|
|
|
|
print("after stop: fleet_target=%s formation origin=%s ok=%s" % [
|
|
|
|
|
origin, expected, settled_ok
|
|
|
|
|
])
|
|
|
|
|
if settled_ok:
|
|
|
|
|
print("TEST_LOPSIDED_FORMATION_MOVEMENT: PASS")
|
|
|
|
|
quit(0)
|
|
|
|
|
else:
|
|
|
|
|
print("TEST_LOPSIDED_FORMATION_MOVEMENT: FAIL (stop left the anchor off the formation)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
return false
|