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_asteroid_spawning.gd
|
|
|
|
|
# Verifies AsteroidField spawns moving asteroids once the fleet enters an
|
|
|
|
|
# ASTEROID_FIELD biome chunk, and despawns them again once the fleet moves
|
|
|
|
|
# far enough away - guards against unbounded node accumulation over a long
|
|
|
|
|
# play session while still populating newly-entered regions on the fly.
|
|
|
|
|
|
|
|
|
|
var main_scene: Node
|
|
|
|
|
var fleet: Node
|
|
|
|
|
var asteroid_field: Node
|
|
|
|
|
var asteroid_chunk: Vector2i
|
|
|
|
|
var spawned_asteroids: Array = []
|
|
|
|
|
var elapsed: float = 0.0
|
|
|
|
|
var stage: int = 0
|
|
|
|
|
var ok: bool = true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
if WorldGen.biome_at_chunk(chunk) == WorldGen.Biome.ASTEROID_FIELD:
|
|
|
|
|
asteroid_chunk = chunk
|
|
|
|
|
found = true
|
|
|
|
|
break
|
|
|
|
|
if found:
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
if not found:
|
|
|
|
|
print("FAIL: could not find any ASTEROID_FIELD chunk to test with")
|
|
|
|
|
quit(1)
|
|
|
|
|
return
|
|
|
|
|
|
#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
|
|
|
var packed: PackedScene = load("res://world/Main.tscn")
|
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
|
|
|
main_scene = packed.instantiate()
|
|
|
|
|
root.add_child(main_scene)
|
|
|
|
|
fleet = main_scene.get_node("Fleet")
|
|
|
|
|
asteroid_field = main_scene.get_node("AsteroidField")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _process(delta: float) -> bool:
|
|
|
|
|
elapsed += delta
|
|
|
|
|
match stage:
|
|
|
|
|
0:
|
|
|
|
|
# Wait one tick so Fleet._ready() has run and fleet.ships is
|
|
|
|
|
# populated before we try to teleport them - reposition
|
|
|
|
|
# attempted synchronously in _initialize() would silently
|
|
|
|
|
# no-op on an empty ships array.
|
|
|
|
|
var target_pos: Vector2 = WorldGen.chunk_origin(asteroid_chunk) + Vector2.ONE * WorldGen.CHUNK_SIZE * 0.5
|
|
|
|
|
for ship in fleet.ships:
|
|
|
|
|
ship.position = target_pos
|
|
|
|
|
fleet.move_to(target_pos)
|
|
|
|
|
elapsed = 0.0
|
|
|
|
|
stage = 1
|
|
|
|
|
return false
|
|
|
|
|
1:
|
|
|
|
|
if elapsed < asteroid_field.check_interval + 0.1:
|
|
|
|
|
return false
|
|
|
|
|
_check_spawned()
|
|
|
|
|
elapsed = 0.0
|
|
|
|
|
stage = 2
|
|
|
|
|
return false
|
|
|
|
|
2:
|
|
|
|
|
var far_pos: Vector2 = WorldGen.chunk_origin(asteroid_chunk) + Vector2(50000, 50000)
|
|
|
|
|
for ship in fleet.ships:
|
|
|
|
|
ship.position = far_pos
|
|
|
|
|
fleet.move_to(far_pos)
|
|
|
|
|
elapsed = 0.0
|
|
|
|
|
stage = 3
|
|
|
|
|
return false
|
|
|
|
|
3:
|
|
|
|
|
if elapsed < asteroid_field.check_interval + 0.1:
|
|
|
|
|
return false
|
|
|
|
|
_check_despawned()
|
|
|
|
|
return true
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _check_spawned() -> void:
|
|
|
|
|
var has_chunk: bool = asteroid_field.populated_chunks.has(asteroid_chunk)
|
|
|
|
|
if not has_chunk:
|
|
|
|
|
ok = false
|
|
|
|
|
print("FAIL: asteroid_chunk %s not populated after check_interval" % asteroid_chunk)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
spawned_asteroids = asteroid_field.populated_chunks[asteroid_chunk]
|
|
|
|
|
var count_ok: bool = spawned_asteroids.size() == asteroid_field.asteroids_per_chunk
|
|
|
|
|
var moving_ok: bool = true
|
|
|
|
|
for asteroid in spawned_asteroids:
|
|
|
|
|
if asteroid.velocity.length() <= 0.1:
|
|
|
|
|
moving_ok = false
|
|
|
|
|
|
|
|
|
|
ok = ok and count_ok and moving_ok
|
|
|
|
|
print("spawned_count=%d expected=%d moving_ok=%s" % [spawned_asteroids.size(), asteroid_field.asteroids_per_chunk, moving_ok])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _check_despawned() -> void:
|
|
|
|
|
var chunk_removed: bool = not asteroid_field.populated_chunks.has(asteroid_chunk)
|
|
|
|
|
var all_freed: bool = true
|
|
|
|
|
for asteroid in spawned_asteroids:
|
|
|
|
|
if is_instance_valid(asteroid):
|
|
|
|
|
all_freed = false
|
|
|
|
|
|
|
|
|
|
ok = ok and chunk_removed and all_freed
|
|
|
|
|
print("chunk_removed=%s all_freed=%s" % [chunk_removed, all_freed])
|
|
|
|
|
|
|
|
|
|
if ok:
|
|
|
|
|
print("TEST_ASTEROID_SPAWNING: PASS")
|
|
|
|
|
quit(0)
|
|
|
|
|
else:
|
|
|
|
|
print("TEST_ASTEROID_SPAWNING: FAIL")
|
|
|
|
|
quit(1)
|