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>
94 lines
2.7 KiB
GDScript
94 lines
2.7 KiB
GDScript
extends SceneTree
|
|
|
|
# Headless gameplay test: run with
|
|
# godot --headless -s res://tests/test_pinch_zoom.gd
|
|
# Injects synthetic two-finger touch/drag events (via Input.parse_input_event)
|
|
# to exercise the real GameController input-handling code path: spreading two
|
|
# fingers apart should zoom the camera IN (lower Camera2D.zoom value) and must
|
|
# not be misread as a single-finger fleet move order.
|
|
|
|
var main_scene: Node
|
|
var fleet: Node
|
|
var camera: Camera2D
|
|
var elapsed: float = 0.0
|
|
var stage: int = 0
|
|
var initial_zoom: float
|
|
var fleet_target_before: Vector2
|
|
var baseline_captured: bool = false
|
|
|
|
|
|
func _initialize() -> void:
|
|
var packed: PackedScene = load("res://Main.tscn")
|
|
main_scene = packed.instantiate()
|
|
root.add_child(main_scene)
|
|
camera = main_scene.get_node("Camera2D")
|
|
fleet = main_scene.get_node("Fleet")
|
|
|
|
|
|
func _physics_process(delta: float) -> bool:
|
|
if not baseline_captured:
|
|
# Fleet._ready() runs on the first physics tick in `-s` script mode,
|
|
# not synchronously inside _initialize(), so capture baselines here.
|
|
initial_zoom = camera.zoom.x
|
|
fleet_target_before = fleet.fleet_target
|
|
baseline_captured = true
|
|
return false
|
|
|
|
elapsed += delta
|
|
match stage:
|
|
0:
|
|
_touch(0, true, Vector2(300, 600))
|
|
_touch(1, true, Vector2(340, 600))
|
|
stage = 1
|
|
1:
|
|
if elapsed > 0.1:
|
|
# Spread fingers apart: should zoom IN (Camera2D.zoom is a
|
|
# magnification, so zooming in means zoom.x increases), and
|
|
# must not move the fleet.
|
|
_drag(0, Vector2(100, 600))
|
|
_drag(1, Vector2(540, 600))
|
|
stage = 2
|
|
2:
|
|
if elapsed > 0.4:
|
|
_touch(0, false, Vector2(100, 600))
|
|
_touch(1, false, Vector2(540, 600))
|
|
stage = 3
|
|
3:
|
|
if elapsed > 0.7:
|
|
_finish()
|
|
return true
|
|
return false
|
|
|
|
|
|
func _touch(index: int, pressed: bool, pos: Vector2) -> void:
|
|
var ev: InputEventScreenTouch = InputEventScreenTouch.new()
|
|
ev.index = index
|
|
ev.pressed = pressed
|
|
ev.position = pos
|
|
Input.parse_input_event(ev)
|
|
|
|
|
|
func _drag(index: int, pos: Vector2) -> void:
|
|
var ev: InputEventScreenDrag = InputEventScreenDrag.new()
|
|
ev.index = index
|
|
ev.position = pos
|
|
Input.parse_input_event(ev)
|
|
|
|
|
|
func _finish() -> void:
|
|
var zoomed_in: bool = camera.zoom.x > initial_zoom + 0.01
|
|
var fleet_untouched: bool = fleet.fleet_target == fleet_target_before
|
|
|
|
print("initial_zoom=%.3f final_zoom=%.3f" % [initial_zoom, camera.zoom.x])
|
|
print("fleet_target_before=%s fleet_target_after=%s" % [fleet_target_before, fleet.fleet_target])
|
|
|
|
if zoomed_in and fleet_untouched:
|
|
print("TEST_PINCH_ZOOM: PASS")
|
|
quit(0)
|
|
else:
|
|
if not zoomed_in:
|
|
print("FAIL: camera did not zoom in on pinch-out gesture")
|
|
if not fleet_untouched:
|
|
print("FAIL: pinch gesture incorrectly triggered a fleet move order")
|
|
print("TEST_PINCH_ZOOM: FAIL")
|
|
quit(1)
|