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_crafter_animation.gd
|
|
|
|
|
# The ship crafter is drawn as a factory with a hull being assembled on the
|
|
|
|
|
# line. Verifies:
|
|
|
|
|
# 1. a crafter spawned the normal way (BuildingField, from GameState)
|
|
|
|
|
# actually animates - the animation is what tells the player what the
|
|
|
|
|
# building does. The mothership animates too (reactor core, orbiting
|
|
|
|
|
# satellites)
|
|
|
|
|
# 2. the command centre stays static, because per-frame redraws of art
|
|
|
|
|
# that never changes were a measurable framerate cost earlier on
|
|
|
|
|
# 3. the hull assembles progressively over the cycle rather than popping
|
|
|
|
|
# in whole, and every piece is on before the assembly phase ends
|
2026-08-23 21:58:59 +02:00
|
|
|
# 4. the cycle loops without anim_time growing without bound, WHILE THERE
|
|
|
|
|
# IS SOMETHING ON THE LINE - #117 stops the clock on an idle crafter,
|
|
|
|
|
# because a factory whose cranes swing over an empty cradle reads as
|
|
|
|
|
# working on nothing
|
|
|
|
|
# 5. and an idle crafter really is still
|
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
|
|
|
|
|
|
|
|
var scene: Node
|
|
|
|
|
var game_state: Node
|
|
|
|
|
var field: Node
|
|
|
|
|
var stage: int = 0
|
|
|
|
|
var elapsed: float = 0.0
|
|
|
|
|
var crafter: Node2D
|
|
|
|
|
var time_at_start: float = 0.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _initialize() -> void:
|
|
|
|
|
game_state = root.get_node("GameState")
|
|
|
|
|
game_state.rocks = 200
|
|
|
|
|
game_state.buildings.clear()
|
|
|
|
|
game_state.extractors.clear()
|
|
|
|
|
|
#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)
|
|
|
|
|
field = scene.get_node("BuildingField")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _find(type: String) -> Node2D:
|
|
|
|
|
for b in field.spawned:
|
|
|
|
|
if is_instance_valid(b) and b.building_type == type:
|
|
|
|
|
return b
|
|
|
|
|
return null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _process(delta: float) -> bool:
|
|
|
|
|
elapsed += delta
|
|
|
|
|
match stage:
|
|
|
|
|
0:
|
|
|
|
|
scene.get_node("AsteroidField").set_process(false)
|
|
|
|
|
scene.get_node("EnemySpawner").set_process(false)
|
|
|
|
|
field.place(GameState.BUILDING_SHIP_CRAFTER, Vector2(500.0, 0.0))
|
|
|
|
|
field.place(GameState.BUILDING_MOTHERSHIP, Vector2(-500.0, 0.0))
|
|
|
|
|
field.place(GameState.BUILDING_COMMAND_CENTER, Vector2(0.0, 500.0))
|
|
|
|
|
elapsed = 0.0
|
|
|
|
|
stage = 1
|
|
|
|
|
return false
|
|
|
|
|
1:
|
|
|
|
|
# Spawning is deferred, so give the tree a frame to attach them.
|
|
|
|
|
if elapsed < 0.2:
|
|
|
|
|
return false
|
2026-08-14 21:44:28 +02:00
|
|
|
var crafter_building: Node2D = _find(GameState.BUILDING_SHIP_CRAFTER)
|
|
|
|
|
if crafter_building == null:
|
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
|
|
|
print("TEST_CRAFTER_ANIMATION: FAIL (crafter never spawned)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
2026-08-14 21:44:28 +02:00
|
|
|
crafter = crafter_building.visual
|
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
|
|
|
|
|
|
|
|
var animated: bool = crafter.is_processing()
|
2026-08-14 21:44:28 +02:00
|
|
|
var mothership_building: Node2D = _find(GameState.BUILDING_MOTHERSHIP)
|
|
|
|
|
var mothership: Node2D = mothership_building.visual if mothership_building != null else null
|
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
|
|
|
var mothership_animates: bool = mothership != null and mothership.is_processing()
|
2026-08-14 21:44:28 +02:00
|
|
|
var command_building: Node2D = _find(GameState.BUILDING_COMMAND_CENTER)
|
|
|
|
|
var command: Node2D = command_building.visual if command_building != null else null
|
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
|
|
|
var command_static: bool = command != null and not command.is_processing()
|
|
|
|
|
print("crafter animates=%s mothership animates=%s command centre static=%s" % [
|
|
|
|
|
animated, mothership_animates, command_static
|
|
|
|
|
])
|
|
|
|
|
if not (animated and mothership_animates and command_static):
|
|
|
|
|
print("TEST_CRAFTER_ANIMATION: FAIL (wrong buildings are animating)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
# --- the hull assembles piece by piece ------------------------
|
|
|
|
|
var total: int = crafter.SHIP_PARTS.size()
|
|
|
|
|
var counts: Array = []
|
|
|
|
|
for p in [0.0, 0.1, 0.35, 0.55, 0.9, 1.0]:
|
|
|
|
|
counts.append(crafter.attached_part_count(p))
|
|
|
|
|
var progressive: bool = counts[0] == 0 and counts[-1] == total
|
|
|
|
|
for i in range(1, counts.size()):
|
|
|
|
|
if counts[i] < counts[i - 1]:
|
|
|
|
|
progressive = false
|
|
|
|
|
# Nothing may still be missing when the welding phase ends, or
|
|
|
|
|
# the hull would launch half-built.
|
|
|
|
|
var complete_before_launch: bool = crafter.attached_part_count(1.0) == total
|
|
|
|
|
print("parts attached across the phase: %s (of %d) progressive=%s" % [
|
|
|
|
|
counts, total, progressive
|
|
|
|
|
])
|
|
|
|
|
if not (progressive and complete_before_launch and counts[1] < total):
|
|
|
|
|
print("TEST_CRAFTER_ANIMATION: FAIL (hull does not build up gradually)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
|
2026-08-23 21:58:59 +02:00
|
|
|
# --- #117: idle means idle --------------------------------
|
|
|
|
|
if crafter.is_working():
|
|
|
|
|
print("TEST_CRAFTER_ANIMATION: FAIL (a crafter with an empty queue calls itself working)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
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
|
|
|
time_at_start = crafter.anim_time
|
|
|
|
|
elapsed = 0.0
|
|
|
|
|
stage = 2
|
|
|
|
|
return false
|
|
|
|
|
2:
|
2026-08-23 21:58:59 +02:00
|
|
|
if elapsed < 0.4:
|
|
|
|
|
return false
|
|
|
|
|
if crafter.anim_time != time_at_start:
|
|
|
|
|
print("TEST_CRAFTER_ANIMATION: FAIL (an idle crafter kept animating)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
print("idle crafter held its clock at %.3f" % crafter.anim_time)
|
|
|
|
|
# Put something on the line, and it should run again.
|
|
|
|
|
game_state.queue_order(int(_find(GameState.BUILDING_SHIP_CRAFTER).building_id),
|
|
|
|
|
GameState.VESSEL_INTERCEPTOR)
|
|
|
|
|
if not crafter.is_working():
|
|
|
|
|
print("TEST_CRAFTER_ANIMATION: FAIL (an order was queued and the crafter is still idle)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
time_at_start = crafter.anim_time
|
|
|
|
|
elapsed = 0.0
|
|
|
|
|
stage = 3
|
|
|
|
|
return false
|
|
|
|
|
3:
|
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
|
|
|
if elapsed < 0.4:
|
|
|
|
|
return false
|
|
|
|
|
var advanced: bool = crafter.anim_time != time_at_start
|
|
|
|
|
var bounded: bool = crafter.anim_time >= 0.0 and crafter.anim_time < crafter.CYCLE
|
|
|
|
|
print("anim_time %.3f -> %.3f (cycle %.2f) advanced=%s bounded=%s" % [
|
|
|
|
|
time_at_start, crafter.anim_time, crafter.CYCLE, advanced, bounded
|
|
|
|
|
])
|
|
|
|
|
if advanced and bounded:
|
|
|
|
|
print("TEST_CRAFTER_ANIMATION: PASS")
|
|
|
|
|
quit(0)
|
|
|
|
|
else:
|
|
|
|
|
print("TEST_CRAFTER_ANIMATION: FAIL (animation clock stalled or ran away)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
return false
|