- 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>
53 lines
1.6 KiB
GDScript
53 lines
1.6 KiB
GDScript
extends Control
|
|
|
|
# The Maze button's panel: pick the maze's size (in screens) and complexity,
|
|
# then Generate. Laid out like the options screen. What each setting does is
|
|
# in MazeSettings and docs/MAZE.md.
|
|
|
|
signal closed
|
|
|
|
const MAZE_SCENE = "res://Levels/Maze/maze_level.tscn"
|
|
|
|
@onready var widthBox: SpinBox = $CenterContainer/PanelContainer/VBoxContainer/SettingList/WidthBox
|
|
@onready var heightBox: SpinBox = $CenterContainer/PanelContainer/VBoxContainer/SettingList/HeightBox
|
|
@onready var complexityBox: SpinBox = $CenterContainer/PanelContainer/VBoxContainer/SettingList/ComplexityBox
|
|
@onready var generateButton: Button = $CenterContainer/PanelContainer/VBoxContainer/Buttons/GenerateButton
|
|
|
|
|
|
func _ready() -> void:
|
|
hide()
|
|
_set_range(widthBox, MazeSettings.MIN_WIDTH, MazeSettings.MAX_WIDTH)
|
|
_set_range(heightBox, MazeSettings.MIN_HEIGHT, MazeSettings.MAX_HEIGHT)
|
|
_set_range(complexityBox, MazeSettings.MIN_COMPLEXITY, MazeSettings.MAX_COMPLEXITY)
|
|
|
|
|
|
func open() -> void:
|
|
widthBox.value = MazeSettings.width
|
|
heightBox.value = MazeSettings.height
|
|
complexityBox.value = MazeSettings.complexity
|
|
show()
|
|
generateButton.grab_focus()
|
|
|
|
|
|
func close() -> void:
|
|
hide()
|
|
closed.emit()
|
|
|
|
|
|
static func _set_range(box: SpinBox, lowest: int, highest: int) -> void:
|
|
box.min_value = lowest
|
|
box.max_value = highest
|
|
box.step = 1
|
|
box.rounded = true
|
|
|
|
|
|
func _on_generate_button_pressed() -> void:
|
|
MazeSettings.width = int(widthBox.value)
|
|
MazeSettings.height = int(heightBox.value)
|
|
MazeSettings.complexity = int(complexityBox.value)
|
|
MazeSettings.mazeSeed = 0
|
|
Transition.change_scene(MAZE_SCENE)
|
|
|
|
|
|
func _on_back_button_pressed() -> void:
|
|
close()
|