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_extractor_building.gd
|
|
|
|
|
# Extractors are built from SPACE, over a planet - not from the planet's
|
|
|
|
|
# surface. Verifies:
|
|
|
|
|
# 1. the option is greyed out when no planet is in reach, but still
|
|
|
|
|
# pressable, and explains itself instead of silently failing
|
|
|
|
|
# 2. it lights up once the fleet is over a planet
|
|
|
|
|
# 3. its info popup names the planet and offers a confirm, and confirming
|
|
|
|
|
# charges the cost and registers the extractor against that planet
|
|
|
|
|
# 4. a second one on the same planet is refused, with no confirm offered
|
|
|
|
|
|
|
|
|
|
var main_scene: Node
|
|
|
|
|
var fleet: Node
|
|
|
|
|
var game_state: Node
|
|
|
|
|
var controller: Node
|
|
|
|
|
var button: IconButton
|
|
|
|
|
var popup: Control
|
|
|
|
|
var target_chunk: Vector2i
|
|
|
|
|
var stage: int = 0
|
|
|
|
|
var elapsed: float = 0.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _initialize() -> void:
|
|
|
|
|
var found: bool = false
|
|
|
|
|
for x in range(-15, 15):
|
|
|
|
|
for y in range(-15, 15):
|
|
|
|
|
var chunk: Vector2i = Vector2i(x, y)
|
2026-08-17 19:48:55 +02:00
|
|
|
# #75: this test is about the planet-proximity/duplicate rules,
|
|
|
|
|
# not resource type - skip a research_lab specifically, since it
|
|
|
|
|
# yields nothing and is correctly refused (see
|
|
|
|
|
# test_research_lab_extractor_gate.gd for that behaviour).
|
|
|
|
|
if WorldGen.has_planet_at_chunk(chunk) \
|
|
|
|
|
and WorldGen.planet_data_at_chunk(chunk).definition_id != "research_lab":
|
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
|
|
|
target_chunk = chunk
|
|
|
|
|
found = true
|
|
|
|
|
break
|
|
|
|
|
if found:
|
|
|
|
|
break
|
|
|
|
|
if not found:
|
|
|
|
|
print("FAIL: no planet chunk to test with")
|
|
|
|
|
quit(1)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
game_state = root.get_node("GameState")
|
|
|
|
|
game_state.rocks = 200
|
|
|
|
|
game_state.buildings.clear()
|
|
|
|
|
game_state.extractors.clear()
|
2026-08-15 14:41:19 +02:00
|
|
|
game_state.planet_capture.clear()
|
|
|
|
|
# This test is about the planet-proximity/duplicate rules, not conquest
|
|
|
|
|
# (see test_planet_conquest_gate), so pre-conquer the target planet.
|
|
|
|
|
var target_planet_id: String = "chunk:%d:%d" % [target_chunk.x, target_chunk.y]
|
2026-09-05 13:31:25 +02:00
|
|
|
game_state.register_planet_garrison(target_planet_id, 1)
|
|
|
|
|
game_state.mark_garrison_enemy_destroyed(target_planet_id)
|
Skill tree, node-based building animation, bigger UI, and a 19x faster test suite
Gameplay and UI
- Research tree at the mothership gates which structures can be built and
grants permanent fleet-capacity upgrades (GameState.SKILL_TREE,
SkillTreeView). Node depth is derived from prerequisites, so the layout
cannot drift out of step with the dependencies.
- Building info popup before committing to a build, with per-building cost
and description.
- Ship crafter redrawn as a space factory with an assembly animation;
mothership redrawn as a radial flagship; command centre as a plotting hub.
- Keyboard and mouse support (WASD, Q/E pivot, wheel zoom) for the web build.
- UI and font scaled up for phone use, via a custom Theme resource -
gui/theme/default_font_size does not reach the default theme.
- Asteroids no longer spawn on top of the fleet's start position.
- Fleet formation origin derived from the layout's own offsets rather than
the centroid, fixing the lurch when a lopsided formation started moving.
- Fleet.stop() brakes from the ship's TRUE motion (velocity +
fleet_velocity). Ship zeroes its velocity when seated in its slot even
while the anchor drags that slot forward, so braking from velocity alone
stopped the fleet dead instead of coasting - and whether it did depended
on the frame rate.
Animation architecture (issue #10)
- Buildings, projectiles and explosion VFX no longer animate by redrawing.
Static geometry is rasterised once in _draw(); moving parts are NeonPiece
children animated through node properties, which reuse the cached
geometry. Every NeonDraw call expands into four antialiased polylines, so
redrawing to move something re-tessellated all of it.
Test suite (issue #8): 1075s -> ~55s
- Runs from a copy on Termux's own filesystem. The project lives on
Android's FUSE bridge, read through proot, where load("res://Main.tscn")
alone cost 8.5s per test against ~2s natively - and nearly every test
loads it.
- Runs 6 tests at a time, in a single proot-distro login, with output
buffered per test and printed only on failure.
- --fixed-fps 60 pins delta instead of measuring the wall clock, so a test's
result no longer depends on how busy the machine is. Without it,
parallelism made two tests fail on 2 of 3 runs.
- A test passes only if it both exits 0 and prints ": PASS".
- 38 tests, green on three consecutive runs.
Bundles Carrois Gothic SC (Apache 2.0) with its licence text.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-11 15:00:41 +02:00
|
|
|
# Extractors are gated behind research (see test_skill_tree). This test
|
|
|
|
|
# is about the planet-proximity rule, so grant the research up front.
|
|
|
|
|
game_state.reset_progression()
|
|
|
|
|
for node in GameState.SKILL_TREE:
|
|
|
|
|
game_state.unlocked.append(node.id)
|
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
|
|
|
|
#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
|
|
|
main_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(main_scene)
|
|
|
|
|
fleet = main_scene.get_node("Fleet")
|
|
|
|
|
controller = main_scene.get_node("BuildController")
|
|
|
|
|
button = main_scene.get_node("UI/BuildMenu/ExtractorButton")
|
|
|
|
|
popup = main_scene.get_node("UI/BuildMenu/InfoPopup")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _process(delta: float) -> bool:
|
|
|
|
|
elapsed += delta
|
|
|
|
|
match stage:
|
|
|
|
|
0:
|
|
|
|
|
main_scene.get_node("AsteroidField").set_process(false)
|
|
|
|
|
main_scene.get_node("EnemySpawner").set_process(false)
|
|
|
|
|
|
|
|
|
|
# Far from any planet: greyed, and pressing it explains why.
|
|
|
|
|
controller._on_build_pressed()
|
|
|
|
|
if button.enabled:
|
|
|
|
|
print("TEST_EXTRACTOR_BUILDING: FAIL (enabled with no planet in reach)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
2026-08-14 21:44:28 +02:00
|
|
|
controller._show_building_info(GameState.BUILDING_EXTRACTOR)
|
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 explained: bool = popup.visible and "planet" in popup.get_node("Panel/MessageLabel").text.to_lower()
|
|
|
|
|
var offered: bool = popup.get_node("Panel/BuildButton").visible
|
|
|
|
|
print("no planet: greyed=%s popup_shown=%s confirm_offered=%s" % [
|
|
|
|
|
not button.enabled, explained, offered
|
|
|
|
|
])
|
|
|
|
|
if not explained or offered:
|
|
|
|
|
print("TEST_EXTRACTOR_BUILDING: FAIL (greyed press did not explain itself, or offered a build)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
if not game_state.extractors.is_empty():
|
|
|
|
|
print("TEST_EXTRACTOR_BUILDING: FAIL (built one without a planet)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
popup.visible = false
|
|
|
|
|
|
|
|
|
|
# Fly over the planet.
|
|
|
|
|
var near: Vector2 = WorldGen.chunk_origin(target_chunk) + Vector2.ONE * WorldGen.CHUNK_SIZE * 0.5
|
|
|
|
|
for ship in fleet.ships:
|
|
|
|
|
ship.position = near
|
|
|
|
|
fleet.move_to(near)
|
|
|
|
|
elapsed = 0.0
|
|
|
|
|
stage = 1
|
|
|
|
|
return false
|
|
|
|
|
1:
|
|
|
|
|
var planet_field: Node = main_scene.get_node("PlanetField")
|
|
|
|
|
if elapsed < planet_field.check_interval + 0.2:
|
|
|
|
|
return false
|
|
|
|
|
if not planet_field.populated_chunks.has(target_chunk):
|
|
|
|
|
print("TEST_EXTRACTOR_BUILDING: FAIL (planet never spawned)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
var planet: Node2D = planet_field.populated_chunks[target_chunk][0]
|
|
|
|
|
for ship in fleet.ships:
|
|
|
|
|
ship.position = planet.position
|
|
|
|
|
fleet.move_to(planet.position)
|
|
|
|
|
elapsed = 0.0
|
|
|
|
|
stage = 2
|
|
|
|
|
return false
|
|
|
|
|
2:
|
|
|
|
|
if elapsed < 0.3:
|
|
|
|
|
return false
|
|
|
|
|
controller._on_build_pressed()
|
|
|
|
|
if not button.enabled:
|
|
|
|
|
print("TEST_EXTRACTOR_BUILDING: FAIL (still greyed while over a planet)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
var rocks_before: int = game_state.rocks
|
2026-08-14 21:44:28 +02:00
|
|
|
controller._show_building_info(GameState.BUILDING_EXTRACTOR)
|
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 planet_field2: Node = main_scene.get_node("PlanetField")
|
|
|
|
|
var planet2: Node2D = planet_field2.populated_chunks[target_chunk][0]
|
|
|
|
|
|
|
|
|
|
# The popup must name the planet it is about to mine, and nothing
|
|
|
|
|
# may be spent until it is confirmed.
|
|
|
|
|
var names_planet: bool = planet2.planet_name in popup.get_node("Panel/MessageLabel").text
|
|
|
|
|
var spent_early: bool = game_state.rocks != rocks_before
|
|
|
|
|
print("popup: names_planet=%s confirm_offered=%s spent_before_confirm=%s" % [
|
|
|
|
|
names_planet, popup.get_node("Panel/BuildButton").visible, spent_early
|
|
|
|
|
])
|
|
|
|
|
if not names_planet or spent_early or not popup.get_node("Panel/BuildButton").visible:
|
|
|
|
|
print("TEST_EXTRACTOR_BUILDING: FAIL (popup did not offer an informed build)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
controller._confirm_build()
|
|
|
|
|
|
2026-08-14 22:16:40 +02:00
|
|
|
var built: bool = game_state.has_extractor_at(planet2.planet_id)
|
#138: structures and doctrines cost more than rocks, and more the deeper they are
Both halves of the ticket, in the shape vessels have used since gas bombers
and laser ships: a definition carries an ore figure and, when it wants more
than ore, a dictionary that IS the price. `building_costs()` and
`skill_costs()` answer it the way `product_costs()` already did, so there is
one question with one answer whatever is being bought, and every payment
path now goes through `spend_resources` rather than `spend`.
Seven of ten structures and thirteen of seventeen doctrines now want gas,
energy or dark matter alongside their rocks, and the totals climb with tree
depth - structures 16/31/58/62/96 by depth, doctrines 15/30/73/96/143/258/530.
The constraint that shaped the table is REACHABILITY, and it is the reason
some prices stayed ore-only. Energy exists only where a gas burner stands,
and a gas burner needs Power Systems - so nothing at or before that depth
may be priced in energy, or it is a wall with no way through. Dark matter is
rarer still and appears once, on the deepest node in the game. The extractor
stays rocks-only despite its depth allowing gas, because the quest chain
reaches it before it has sent the player for any.
test_progressive_costs checks those as properties rather than transcribing
the numbers, so rebalancing a price costs nothing while breaking the shape
fails: nothing unreachable at its own depth, prices rising with depth, the
ore field agreeing with the dictionary (repairs quote the field alone, since
a repair drone carries ore and nothing else), and the quest chain never
asking for a structure it has not funded.
Two things cleaned up on the way:
- The per-building cost constants in GameState are gone. Nothing but tests
used them, and they were a second copy of a number the definitions already
hold - exactly what would drift once a price gained a resource.
- research_for_building() returns a display NAME, and the id-keyed half of
the tree wants an id. That mix-up is silent - skill_depth() of a name finds
no node and answers 0, so a deep structure reads as an ungated one, which
is how the first draft of the test let an unreachable price through.
research_node_for_building() is the id, and the name is expressed from it.
PriceTag no longer rebuilds its labels when re-told the same price; it
refreshes the held figures instead. The craft menu re-states prices every
frame and the build menu now does too, so that was a dozen Labels being torn
down and rebuilt sixty times a second.
2026-08-28 15:30:30 +02:00
|
|
|
var charged: bool = game_state.rocks == rocks_before - int(game_state.building_costs(GameState.BUILDING_EXTRACTOR)[GameState.RESOURCE_ORE])
|
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("over planet '%s': enabled=%s built=%s rocks %d->%d charged=%s" % [
|
|
|
|
|
planet2.planet_name, button.enabled, built, rocks_before, game_state.rocks, charged
|
|
|
|
|
])
|
|
|
|
|
if not (built and charged):
|
|
|
|
|
print("TEST_EXTRACTOR_BUILDING: FAIL (did not build/charge over a planet)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
# A second one on the same planet must be refused, not charged.
|
|
|
|
|
var rocks_now: int = game_state.rocks
|
|
|
|
|
controller._on_build_pressed()
|
2026-08-14 21:44:28 +02:00
|
|
|
controller._show_building_info(GameState.BUILDING_EXTRACTOR)
|
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 re_offered: bool = popup.get_node("Panel/BuildButton").visible
|
|
|
|
|
controller._confirm_build() # must do nothing even if pressed
|
|
|
|
|
var still_one: bool = game_state.extractors.size() == 1 and not re_offered
|
|
|
|
|
var not_charged: bool = game_state.rocks == rocks_now
|
|
|
|
|
print("second attempt: extractors=%d rocks=%d confirm_offered=%s refused=%s" % [
|
|
|
|
|
game_state.extractors.size(), game_state.rocks, re_offered, still_one and not_charged
|
|
|
|
|
])
|
|
|
|
|
if still_one and not_charged:
|
|
|
|
|
print("TEST_EXTRACTOR_BUILDING: PASS")
|
|
|
|
|
quit(0)
|
|
|
|
|
else:
|
|
|
|
|
print("TEST_EXTRACTOR_BUILDING: FAIL (allowed a duplicate extractor)")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|
|
|
|
|
return false
|