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 Node2D
|
|
|
|
|
|
2026-08-14 16:05:32 +02:00
|
|
|
const SURFACE_PROFILES = preload("res://PlanetSurfaceProfiles.gd")
|
2026-08-14 16:13:24 +02:00
|
|
|
const PLANET_DEFINITIONS = preload("res://PlanetDefinitions.gd")
|
2026-08-15 14:41:37 +02:00
|
|
|
const PLANET_SETUPS = preload("res://PlanetSetups.gd")
|
|
|
|
|
const SETUP_HOST_SCENE: PackedScene = preload("res://PlanetSetupHost.tscn")
|
2026-08-14 16:05:32 +02:00
|
|
|
|
2026-08-14 23:15:12 +02:00
|
|
|
# Bootstraps the surviving fleet, including each vessel type, on this scene's
|
|
|
|
|
# own startup (from GameState, since this is a fresh scene tree - nothing here
|
|
|
|
|
# carries over automatically) and handles the always-available exit prompt that
|
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
|
|
|
# fades back out to Main.tscn, restoring the fleet at wherever it left
|
|
|
|
|
# space from.
|
|
|
|
|
|
|
|
|
|
@export var fade_duration: float = 0.4
|
|
|
|
|
|
|
|
|
|
@onready var fleet: Node2D = get_node("../Fleet")
|
|
|
|
|
@onready var camera: Camera2D = get_node("../Camera2D")
|
|
|
|
|
@onready var planet_name_label: Label = get_node("../UI/PlanetNameLabel")
|
|
|
|
|
@onready var exit_button: IconButton = get_node("../UI/ExitButton")
|
|
|
|
|
@onready var fade_rect: ColorRect = get_node("../FadeOverlay/FadeRect")
|
2026-08-14 16:05:32 +02:00
|
|
|
@onready var background: ColorRect = get_node("../BackgroundLayer/LunarBackground")
|
|
|
|
|
@onready var feature_host: Node2D = get_node("../SurfaceFeatures")
|
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 transitioning: bool = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
2026-08-14 16:13:24 +02:00
|
|
|
var planet_definition: Resource = PLANET_DEFINITIONS.get_definition(GameState.planet_definition_id)
|
|
|
|
|
_compose_surface(SURFACE_PROFILES.get_profile(planet_definition.surface_profile_id))
|
2026-08-14 23:15:12 +02:00
|
|
|
fleet.spawn_ships(GameState.surviving_ship_count, Vector2.ZERO,
|
|
|
|
|
GameState.surviving_vessel_types)
|
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
|
|
|
camera.position = Vector2.ZERO
|
|
|
|
|
camera.zoom = Vector2(GameState.return_camera_zoom, GameState.return_camera_zoom)
|
|
|
|
|
planet_name_label.text = GameState.planet_name
|
|
|
|
|
exit_button.pressed.connect(_on_exit_pressed)
|
|
|
|
|
|
|
|
|
|
fade_rect.color.a = 1.0
|
|
|
|
|
var tween: Tween = create_tween()
|
|
|
|
|
tween.tween_property(fade_rect, "color:a", 0.0, fade_duration)
|
|
|
|
|
|
|
|
|
|
|
2026-08-14 16:05:32 +02:00
|
|
|
func _compose_surface(profile: Resource) -> void:
|
|
|
|
|
var atmosphere: ShaderMaterial = background.material
|
Give the gas planet surface its own background shader (#51)
lunar_surface.gdshader recoloured was the whole gas surface backdrop,
so a landed gas giant read as regolith - the crater field never went
away, just changed colour. New gas_surface.gdshader replaces it for
gas profiles only: a nearest-row-wins horizontal band field (same
single-scalar discipline as lunar's nearest-crater field), with
drifting per-row turbulence so the bands ripple instead of reading as
ruled lines. Keeps the exact same uniform interface as lunar
(camera_cell/camera_frac/camera_zoom/viewport_size/cell_size/
base_color/crater_color/highlight_color), so LunarBackground.gd needs
no changes at all.
PlanetSurfaceProfile gains background_shader (default null = keep the
scene's existing lunar shader); PlanetSurfaceController._compose_surface()
swaps the background material's shader in only when a profile names one.
GasSurfaceProfile.tres points at the new shader and retunes its palette
to a deep-atmosphere/shadowed-band/lit-crest read; RockySurfaceProfile.tres
is untouched, so the rocky surface renders exactly as before.
Precision: every hash input is either an exact integer cell/row index or
a bounded [0,1) local fraction, same split as lunar_surface.gdshader and
Starfield.gd use for the same reason (world coordinates reach the tens of
thousands, where mobile float precision collapses). TIME-based lateral
drift is folded into the lattice coordinate via the same floor/remainder
trick rather than ever being added to a large cell index directly - see
combine_lattice()'s header note.
Tests: new tests/test_surface_profiles.gd (rocky resolves no
background_shader and keeps the lunar shader; gas resolves and applies
its own, different from lunar's). Full suite: 78/78 passed. Screenshot
of the gas surface confirms drifting bands with no craters, rendered
well inside the softpipe performance budget (20 frames in ~2m40s,
against lunar's "minutes per frame" baseline the ticket warns about).
Repo notes for the next agent, confirmed empirically this session:
- Never reference a plain (non-autoload) class_name class by its bare
global name from a -s entry-point test script - `load()` it by path
into a local var instead, same as PlanetSurfaceController.gd and
PlanetSetups.gd already do for exactly this reason. Doing it the
unsafe way here didn't fail to compile - it corrupted something in
the resource-loading state badly enough that an UNRELATED scene's
Rock.tscn lost its script attachment and RockField's rock-spawning
loop exhausted the physics server's entire RID pool. If a test's
crash trace implicates code you never touched, check every bare
global class_name reference in the test first.
- Running a `tests/screenshot.sh` render (Mesa softpipe, genuinely
minutes for a crater-shader scene) at the same time as a
`run_tests.sh` full-suite run starves both for CPU on this device -
kill one before waiting on the other rather than running them
concurrently.
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-16 09:05:31 +02:00
|
|
|
if profile.background_shader != null:
|
|
|
|
|
atmosphere.shader = profile.background_shader
|
2026-08-14 16:05:32 +02:00
|
|
|
atmosphere.set_shader_parameter("base_color", profile.base_color)
|
|
|
|
|
atmosphere.set_shader_parameter("crater_color", profile.crater_color)
|
|
|
|
|
atmosphere.set_shader_parameter("highlight_color", profile.highlight_color)
|
2026-08-15 21:22:10 +02:00
|
|
|
for caption_path in ["../UI/BankCaption", "../UI/FleetCaption", "../UI/CaptureLabel"]:
|
2026-08-14 16:05:32 +02:00
|
|
|
var caption: Label = get_node(caption_path)
|
|
|
|
|
caption.add_theme_color_override("font_color", profile.caption_color)
|
|
|
|
|
caption.add_theme_color_override("font_outline_color", profile.caption_outline_color)
|
2026-08-15 14:41:37 +02:00
|
|
|
if profile.features_scene != null:
|
|
|
|
|
var features: Node = profile.features_scene.instantiate()
|
|
|
|
|
feature_host.add_child(features)
|
|
|
|
|
|
|
|
|
|
var setup: Resource = PLANET_SETUPS.setup_for_planet(GameState.planet_id, profile.profile_id)
|
|
|
|
|
if setup != null:
|
|
|
|
|
# Untyped on purpose: a static PlanetSetupHost annotation here would
|
|
|
|
|
# need the global class_name cache to already know about it, which
|
|
|
|
|
# is only true after an editor/import pass has run (see #31/#35's
|
|
|
|
|
# load-order notes) - a plain Node reference plus duck-typed
|
|
|
|
|
# apply_setup() sidesteps that entirely, same as BuildingDefinitions
|
|
|
|
|
# and VesselDefinitions already do for their own resource types.
|
|
|
|
|
var setup_host: Node = SETUP_HOST_SCENE.instantiate()
|
|
|
|
|
feature_host.add_child(setup_host)
|
|
|
|
|
setup_host.apply_setup(setup)
|
2026-08-14 16:05:32 +02:00
|
|
|
|
|
|
|
|
|
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
|
|
|
func _on_exit_pressed() -> void:
|
|
|
|
|
if transitioning:
|
|
|
|
|
return
|
|
|
|
|
transitioning = true
|
|
|
|
|
|
|
|
|
|
GameState.surviving_ship_count = fleet.ships.size()
|
2026-08-14 23:15:12 +02:00
|
|
|
GameState.surviving_vessel_types = fleet.vessel_types()
|
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 tween: Tween = create_tween()
|
|
|
|
|
tween.tween_property(fade_rect, "color:a", 1.0, fade_duration)
|
|
|
|
|
tween.tween_callback(_return_to_space)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _return_to_space() -> void:
|
|
|
|
|
get_tree().change_scene_to_file("res://Main.tscn")
|