Arrange fleet abilities around fire stick

This commit is contained in:
Loïc Wisniewski 2026-09-03 23:00:52 +02:00
commit 9864e59efc
8 changed files with 156 additions and 7 deletions

View file

@ -0,0 +1,90 @@
extends SceneTree
# The three aimed abilities share one responsive quarter-circle layout around
# the fire stick in both playable scenes. This exercises the real space HUD;
# PlanetSurface carries the same layout node and is checked structurally.
var main: Node
var fleet: Node
var stage: int = 0
var elapsed: float = 0.0
func _initialize() -> void:
var state: Node = root.get_node("GameState")
state.reset_new_game()
state.intro_active = false
state.vessel_levels["unlock_laser"] = 1
state.vessel_levels["unlock_gas_bomber"] = 1
state.vessel_levels["unlock_distorder"] = 1
state.fleet_inventory.total_capacity = -1
state.deposit_fleet_resource(GameState.RESOURCE_ENERGY, 500)
state.deposit_fleet_resource(GameState.RESOURCE_GAS, 500)
main = load("res://world/Main.tscn").instantiate()
root.add_child(main)
current_scene = main
fleet = main.get_node("Fleet")
func _process(delta: float) -> bool:
elapsed += delta
if stage == 0 and elapsed >= 0.2:
main.get_node("EnemySpawner").set_process(false)
main.get_node("AsteroidField").set_process(false)
fleet.spawn_ships(3, Vector2.ZERO, PackedStringArray([
GameState.VESSEL_DISTORDER,
GameState.VESSEL_GAS_BOMBER,
GameState.VESSEL_LASER,
]))
_refresh_layout()
var layout: Node = main.get_node("AbilityButtonLayout")
var center: Vector2 = _fire_center()
var previous_angle: float = -INF
for path in ["UI/DashButton", "UI/GasBombButton", "UI/LaserButton"]:
var button: Control = main.get_node(path)
if not button.visible:
return _fail("%s is hidden in a fleet that provides every ability" % path)
var offset: Vector2 = button.global_position + button.size * 0.5 - center
if absf(offset.length() - layout.arc_radius) > 1.0 \
or offset.x > 0.1 or offset.y > 0.1:
return _fail("%s is not on the fire stick's upper-left quarter circle" % path)
var angle: float = offset.angle()
if angle < 0.0:
angle += TAU
if previous_angle != -INF and angle <= previous_angle:
return _fail("ability buttons do not follow the quarter-circle order")
previous_angle = angle
fleet.spawn_ships(1, Vector2.ZERO, PackedStringArray([GameState.VESSEL_LASER]))
_refresh_layout()
var laser: Control = main.get_node("UI/LaserButton")
var single_offset: Vector2 = laser.global_position + laser.size * 0.5 - _fire_center()
if absf(single_offset.x) > 1.0 or single_offset.y >= 0.0:
return _fail("a single ability does not sit directly above the fire stick")
var surface: Node = load("res://surface/PlanetSurface.tscn").instantiate()
if surface.get_node_or_null("AbilityButtonLayout") == null:
return _fail("planet surface is missing the shared ability layout")
surface.free()
print("abilities fan through the fire stick's upper-left quarter circle")
print("TEST_ABILITY_BUTTON_LAYOUT: PASS")
quit(0)
return true
return false
func _refresh_layout() -> void:
main.get_node("DashController")._process(0.0)
main.get_node("GasBombController")._process(0.0)
main.get_node("LaserController")._process(0.0)
main.get_node("AbilityButtonLayout")._process(0.0)
func _fire_center() -> Vector2:
var stick: Control = main.get_node("UI/FireStick")
return stick.global_position + stick.size * 0.5
func _fail(message: String) -> bool:
print("TEST_ABILITY_BUTTON_LAYOUT: FAIL (%s)" % message)
quit(1)
return true

View file

@ -97,6 +97,8 @@ func _process(delta: float) -> bool:
first_shooter = skill._next_ready_laser_ship()
if first_shooter == null:
return _fail_now("no laser ship is ready right after spawning")
if absf(first_shooter.get_component("laser").beam_range - 2900.0) > 0.1:
return _fail_now("laser ship beam range was not doubled to 2900")
var press := InputEventScreenTouch.new()
press.index = 7
@ -131,7 +133,7 @@ func _process(delta: float) -> bool:
off_line_enemy.speed = 0.0
beyond_range_enemy = load("res://enemies/Enemy.tscn").instantiate()
beyond_range_enemy.position = first_shooter.global_position + Vector2(2000.0, 0.0)
beyond_range_enemy.position = first_shooter.global_position + Vector2(3400.0, 0.0)
main.add_child(beyond_range_enemy)
beyond_range_enemy.speed = 0.0