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_star_coverage.gd
|
|
|
|
|
# Verifies the shader-based starfield's uniforms actually track the camera:
|
|
|
|
|
# after moving/zooming the camera, camera_pos/camera_zoom fed to the
|
|
|
|
|
# starfield shader should match, at every zoom level (this replaces the old
|
|
|
|
|
# tile-symmetry check now that stars are a single procedural fragment
|
|
|
|
|
# shader pass with no CPU-side tiling to go asymmetric in the first place).
|
|
|
|
|
|
|
|
|
|
const TOLERANCE: float = 0.5
|
|
|
|
|
|
|
|
|
|
var main_scene: Node
|
|
|
|
|
var camera: Camera2D
|
|
|
|
|
var starfield: ColorRect
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _initialize() -> void:
|
#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)
|
|
|
|
|
camera = main_scene.get_node("Camera2D")
|
|
|
|
|
starfield = main_scene.get_node("BackgroundLayer/Starfield")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _process(_delta: float) -> bool:
|
|
|
|
|
var all_ok: bool = true
|
|
|
|
|
|
|
|
|
|
for zoom_level in [1.0, 3.0, 6.0]:
|
|
|
|
|
camera.zoom = Vector2(zoom_level, zoom_level)
|
|
|
|
|
camera.global_position = Vector2(zoom_level * 100.0, -zoom_level * 50.0)
|
|
|
|
|
|
|
|
|
|
# Let the Starfield's own _process (which reads the camera and pushes
|
|
|
|
|
# shader uniforms) run for this frame before checking.
|
|
|
|
|
starfield._process(0.016)
|
|
|
|
|
|
|
|
|
|
# The camera position is handed to the shader pre-split into a cell
|
|
|
|
|
# index plus a fraction within that cell (so the shader never handles
|
|
|
|
|
# a large absolute world coordinate - see Starfield.gd). Verify the
|
|
|
|
|
# two parts reconstruct the real camera position exactly, and that
|
|
|
|
|
# the fraction really is a fraction: if it ever left [0,1) the split
|
|
|
|
|
# would be wrong and the shader would sample the wrong cell.
|
|
|
|
|
var cell: Vector2 = starfield.material.get_shader_parameter("camera_cell")
|
|
|
|
|
var frac: Vector2 = starfield.material.get_shader_parameter("camera_frac")
|
|
|
|
|
var cell_size: float = starfield.material.get_shader_parameter("cell_size")
|
|
|
|
|
var uniform_zoom: float = starfield.material.get_shader_parameter("camera_zoom")
|
|
|
|
|
|
|
|
|
|
var reconstructed: Vector2 = (cell + frac) * cell_size
|
|
|
|
|
var pos_ok: bool = reconstructed.distance_to(camera.global_position) <= TOLERANCE
|
|
|
|
|
var frac_ok: bool = frac.x >= 0.0 and frac.x < 1.0 and frac.y >= 0.0 and frac.y < 1.0
|
|
|
|
|
var zoom_ok: bool = abs(uniform_zoom - (1.0 / camera.zoom.x)) <= 0.01
|
|
|
|
|
var ok: bool = pos_ok and frac_ok and zoom_ok
|
|
|
|
|
all_ok = all_ok and ok
|
|
|
|
|
|
|
|
|
|
print("zoom=%.1f camera_pos=%s reconstructed=%s frac=%s zoom=%.2f/%.2f %s" % [
|
|
|
|
|
zoom_level, camera.global_position, reconstructed, frac,
|
|
|
|
|
camera.zoom.x, uniform_zoom, "OK" if ok else "FAIL"
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
if all_ok:
|
|
|
|
|
print("TEST_STAR_COVERAGE: PASS")
|
|
|
|
|
quit(0)
|
|
|
|
|
else:
|
|
|
|
|
print("TEST_STAR_COVERAGE: FAIL")
|
|
|
|
|
quit(1)
|
|
|
|
|
return true
|