Loading...
Loading...
Expert blueprint for puzzle games including undo systems (Command pattern for state reversal), grid-based logic (Sokoban-style mechanics), non-verbal tutorials (teach through level design), win condition checking, state management, and visual feedback (instant confirmation of valid moves). Use for logic puzzles, physics puzzles, or match-3 games. Trigger keywords: puzzle_game, undo_system, command_pattern, grid_logic, non_verbal_tutorial, state_management.
npx skill4agent add thedivergentai/gd-agentic-skills godot-genre-puzzleMANDATORY: Read the appropriate script before implementing the corresponding pattern.
| Phase | Skills | Purpose |
|---|---|---|
| 1. Interaction | | Clicking, dragging, grid movement |
| 2. Logic | | Undo/Redo, tracking level state |
| 3. Feedback | | Visual confirmation of valid moves |
| 4. Progression | | Unlocking levels, tracking stars/score |
| 5. Polish | | Non-intrusive HUD |
# command.gd
class_name Command extends RefCounted
func execute() -> void: pass
func undo() -> void: pass
# level_manager.gd
var history: Array[Command] = []
var history_index: int = -1
func commit_command(cmd: Command) -> void:
# Clear redo history if diverging
if history_index < history.size() - 1:
history = history.slice(0, history_index + 1)
cmd.execute()
history.append(cmd)
history_index += 1
func undo() -> void:
if history_index >= 0:
history[history_index].undo()
history_index -= 1# grid_manager.gd
var grid_size: Vector2i = Vector2i(16, 16)
var objects: Dictionary = {} # Vector2i -> Node
func move_object(obj: Node, direction: Vector2i) -> bool:
var start_pos = grid_pos(obj.position)
var target_pos = start_pos + direction
if is_wall(target_pos):
return false
if objects.has(target_pos):
# Handle pushing logic here
return false
# Execute move
objects.erase(start_pos)
objects[target_pos] = obj
tween_movement(obj, target_pos)
return truefunc check_win_condition() -> void:
for target in targets:
if not is_satisfied(target):
return
level_complete.emit()
save_progress()create_tween().tresstate_changed