SlimePlatformer/Levels/Maze/maze_marker.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

58 lines
1.8 KiB
GDScript

class_name MazeMarker
extends Area2D
# A maze's Start or End: a glowing pad on the floor with a label over it.
# Stand it on the middle of an air tile whose floor is below. The End one
# sends `reached` when the player touches it.
signal reached
const PAD_SIZE = Vector2(28, 4)
const PAD_DROP = 12.0 # How far below our position the pad's top is (16 is the floor).
const GLOW_HEIGHT = 20.0
const PULSE_SPEED = 3.0 # Radians per second.
const LABEL_RISE = 18.0 # How far above our position the label sits.
const LABEL_FONT_SIZE = 8
const TOUCH_SIZE = Vector2(20, 20)
@export var label := "START"
@export var color := Color(0.3, 1.0, 0.45)
@export var isGoal := false
var _time := 0.0
func _ready() -> void:
z_index = 1 # In front of the tiles.
monitoring = isGoal
var shape := RectangleShape2D.new()
shape.size = TOUCH_SIZE
var collision := CollisionShape2D.new()
collision.shape = shape
add_child(collision)
body_entered.connect(_on_body_entered)
func _process(delta: float) -> void:
_time += delta
queue_redraw()
func _draw() -> void:
var pulse := 0.5 + 0.5 * sin(_time * PULSE_SPEED)
# A glow rising off the pad, fading upwards.
var glowSteps := int(GLOW_HEIGHT)
for step in glowSteps:
var glow := color
glow.a = (1.0 - float(step) / glowSteps) * (0.15 + 0.15 * pulse)
draw_rect(Rect2(-PAD_SIZE.x / 2.0, PAD_DROP - step - 1, PAD_SIZE.x, 1), glow)
draw_rect(Rect2(Vector2(-PAD_SIZE.x / 2.0, PAD_DROP), PAD_SIZE), color.lightened(0.3 * pulse))
var font := ThemeDB.fallback_font
var textWidth := font.get_string_size(label, HORIZONTAL_ALIGNMENT_LEFT, -1, LABEL_FONT_SIZE).x
draw_string(font, Vector2(-textWidth / 2.0, -LABEL_RISE), label, HORIZONTAL_ALIGNMENT_LEFT, -1,
LABEL_FONT_SIZE, color.lightened(0.2 * pulse))
func _on_body_entered(body: Node2D) -> void:
if isGoal and body is CharacterBody2D:
reached.emit()