SlimePlatformer/UI/main_menu.gd
tachyonwolf e7ae22b8cd Add Maze mode with one-way tubes and a soft-lock check
- Main menu "Maze" button opens a setup panel (width, height in screens;
  complexity 1-5) and generates a maze of rock chambers joined by tubes,
  with Start and End pads and a win panel.
- New one-way tube kind: orange tiles that only let the slime in at their
  entrance, with motes drifting into it (OneWayTube, TubeVacuum). The
  auto-tube trace moved to PixelStream.trace_tube so the player and the
  maze validator share it.
- Generation: chamber graph (spanning tree rooted at End, one-way tubes
  only towards End on the route, extra tubes), carved with AStarGrid2D.
  MazeValidator re-derives the chamber graph from the tiles and checks
  that End is reachable from every chamber reachable from Start.
- tests/maze_check.gd: headless batch check (360 mazes) plus a known
  soft-lock the validator must reject. See docs/MAZE.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 15:45:46 -06:00

46 lines
1.4 KiB
GDScript
Executable file

extends Control
# Quick placeholder title screen. Start goes straight to the test level for now.
const FIRST_LEVEL = "res://Levels/test_level.tscn"
@onready var mainPanel = $CenterContainer
@onready var startButton = $CenterContainer/VBoxContainer/StartButton
@onready var mazeButton = $CenterContainer/VBoxContainer/MazeButton
@onready var optionsButton = $CenterContainer/VBoxContainer/OptionsButton
@onready var optionsMenu = $OptionsMenu
@onready var mazeSetupMenu = $MazeSetupMenu
func _ready() -> void:
# Keyboard focus on Start so arrow keys + Enter work right away.
startButton.grab_focus()
func _unhandled_input(event: InputEvent) -> void:
# Escape backs out of the options or maze screen.
if event.is_action_pressed("pause") and optionsMenu.visible:
optionsMenu.close()
get_viewport().set_input_as_handled()
elif event.is_action_pressed("pause") and mazeSetupMenu.visible:
mazeSetupMenu.close()
get_viewport().set_input_as_handled()
func _on_start_button_pressed() -> void:
Transition.change_scene(FIRST_LEVEL)
func _on_maze_button_pressed() -> void:
mainPanel.hide()
mazeSetupMenu.open()
func _on_maze_setup_menu_closed() -> void:
mainPanel.show()
mazeButton.grab_focus()
func _on_options_button_pressed() -> void:
mainPanel.hide()
optionsMenu.open()
func _on_options_menu_closed() -> void:
mainPanel.show()
optionsButton.grab_focus()
func _on_quit_button_pressed() -> void:
get_tree().quit()