spaceship/tests/_crafter_preview.gd
Loïc Wisniewski b641fa5891 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

41 lines
1.4 KiB
GDScript

extends Node2D
# Preview scene for eyeballing building art - NOT run by run_tests.sh
# (underscore prefix). Lays out the mothership and command centre alongside
# several phases of the ship crafter's assembly cycle, with the crafter's
# _process disabled and anim_time pinned, so a single softpipe render shows
# the whole animation at once (the renderer is far too slow here to time a
# live frame).
#
# bash tests/screenshot.sh res://tests/_crafter_preview.tscn /tmp/out.png 20
# Each cell is either a building type (drawn once) or a crafter phase.
const CELLS: Array = [
{"type": "mothership"},
{"type": "command_center"},
{"type": "mothership"},
{"phase": 0.10},
{"phase": 0.35},
{"phase": 0.60},
{"phase": 0.88},
]
func _ready() -> void:
RenderingServer.set_default_clear_color(Color(0.02, 0.03, 0.06))
var building_scene: PackedScene = load("res://Building.tscn")
for i in range(CELLS.size()):
var cell: Dictionary = CELLS[i]
var b: Node2D = building_scene.instantiate()
b.building_type = cell.get("type", GameState.BUILDING_SHIP_CRAFTER)
b.position = Vector2(-240.0 + float(i % 3) * 240.0, -105.0 + float(i / 3) * 215.0)
add_child(b)
if cell.has("phase"):
b.set_process(false)
b.anim_time = float(cell.phase) * b.CYCLE
b.apply_animation()
var cam: Camera2D = Camera2D.new()
cam.zoom = Vector2(1.65, 1.65)
add_child(cam)
cam.make_current()