- 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>
37 lines
1.4 KiB
GDScript
37 lines
1.4 KiB
GDScript
extends Node2D
|
|
|
|
# A generated maze (see docs/MAZE.md). Builds the maze from MazeSettings when
|
|
# it loads, puts the player on Start, and shows the win panel at End.
|
|
|
|
const MENU_SCENE = "res://UI/main_menu.tscn"
|
|
|
|
@onready var layer: TileMapLayer = $TileMapLayer
|
|
@onready var player: CharacterBody2D = $Player
|
|
@onready var vacuum: TubeVacuum = $TubeVacuum
|
|
@onready var startMarker: MazeMarker = $StartMarker
|
|
@onready var endMarker: MazeMarker = $EndMarker
|
|
@onready var pauseMenu: CanvasLayer = $PauseMenu
|
|
@onready var winMenu: MazeWinMenu = $WinMenu
|
|
|
|
|
|
func _ready() -> void:
|
|
var firstSeed := MazeSettings.mazeSeed if MazeSettings.mazeSeed != 0 else randi()
|
|
MazeSettings.mazeSeed = 0 # The next maze gets a new one.
|
|
var builder := MazeBuilder.new(layer, Vector2i(MazeSettings.width, MazeSettings.height),
|
|
MazeSettings.complexity, firstSeed)
|
|
if not builder.isValid:
|
|
push_error("Couldn't make a maze: %s" % ", ".join(builder.problems))
|
|
Transition.change_scene(MENU_SCENE)
|
|
return
|
|
|
|
startMarker.position = layer.map_to_local(builder.carver.startCell)
|
|
endMarker.position = layer.map_to_local(builder.carver.endCell)
|
|
player.global_position = startMarker.global_position
|
|
player.reset_physics_interpolation()
|
|
vacuum.refresh()
|
|
endMarker.reached.connect(_on_end_reached)
|
|
|
|
|
|
func _on_end_reached() -> void:
|
|
pauseMenu.process_mode = Node.PROCESS_MODE_DISABLED # So Escape can't unpause under the win panel.
|
|
winMenu.open()
|