62 lines
2.1 KiB
GDScript
62 lines
2.1 KiB
GDScript
extends SceneTree
|
|
var failures := 0
|
|
func _initialize() -> void:
|
|
call_deferred("run")
|
|
func check(ok: bool, label: String) -> void:
|
|
if not ok:
|
|
failures += 1
|
|
push_error(label)
|
|
func run() -> void:
|
|
var launcher = load("res://games/launcher/ArcadeLauncher.tscn").instantiate()
|
|
root.add_child(launcher)
|
|
await process_frame
|
|
if is_instance_valid(launcher.setup):
|
|
launcher.setup.close()
|
|
await process_frame
|
|
check(launcher.list.item_count == 8, "Seven games and control setup listed")
|
|
launcher._select(-1)
|
|
check(launcher.selected == 7, "Menu wraps to setup")
|
|
for i in range(7):
|
|
launcher._select(i)
|
|
launcher.launch()
|
|
check(launcher.game is ArcadeGame, "Game loads: %s" % i)
|
|
check(not launcher.menu.visible, "Menu hides")
|
|
check(launcher.game.start_game(), "Game starts: %s" % i)
|
|
await process_frame
|
|
launcher.return_to_menu()
|
|
await process_frame
|
|
check(launcher.game == null and launcher.menu.visible, "Game unloads: %s" % i)
|
|
# Rebind a battery to a different key, then verify the former key no longer fires.
|
|
InputMap.action_erase_events("arcade_action_2")
|
|
var key := InputEventKey.new()
|
|
key.physical_keycode = KEY_F9
|
|
InputMap.action_add_event("arcade_action_2", key)
|
|
launcher._select(3)
|
|
launcher.launch()
|
|
var missile = launcher.game
|
|
missile.start_game()
|
|
missile.phase = "play"
|
|
var old := InputEventKey.new()
|
|
old.physical_keycode = KEY_S
|
|
old.pressed = true
|
|
missile._unhandled_input(old)
|
|
check(missile.ammo[1] == 10, "Old hard-coded key does not fire")
|
|
key.pressed = true
|
|
missile._unhandled_input(key)
|
|
check(missile.ammo[1] == 9, "Remapped key fires middle battery")
|
|
launcher.return_to_menu()
|
|
await process_frame
|
|
launcher._select(6)
|
|
launcher.launch()
|
|
Input.action_press("robotron_fire_up")
|
|
Input.action_press("robotron_fire_right")
|
|
var direction: Vector2 = launcher.game.control_vector("fire_")
|
|
check(direction.x > 0.6 and direction.y < -0.6, "Two fire buttons produce diagonal")
|
|
Input.action_release("robotron_fire_up")
|
|
Input.action_release("robotron_fire_right")
|
|
launcher.return_to_menu()
|
|
launcher.queue_free()
|
|
await process_frame
|
|
print("Launcher/input checks: %d failures" % failures)
|
|
quit(1 if failures else 0)
|