mirror of
https://github.com/tiennm99/sokoban.git
synced 2026-05-23 06:25:25 +00:00
2ee7ac886a
Expand the level data from the first 100 Microban layouts to the complete
set, up through the two oversized finale mazes ("Take the long way home"
and "The Dungeon"). Responsive tile sizing already handles the large
grids — no rendering changes needed.
Update credit language in README, PDR, changelog, roadmap, codebase
summary, menu subtitle, and the data file header to reflect the full
set. Credit for David W. Skinner's layouts remains prominent; ownership
of the engine, UI, parser, and progression code stays explicit.
Verified all 155 layouts parse cleanly, have a player, matching box/goal
counts, and none start already solved.
2.4 KiB
2.4 KiB
Codebase Summary
Layout
src/
├── main.js # Entry: boots Phaser on #game-container
└── game/
├── main.js # Phaser Game config + scene registration
├── data/
│ └── microban-levels.js # 155 XSB level strings (full Microban set)
├── core/
│ ├── level-parser.js # XSB text → {walls, targets, boxes, player, floors}
│ ├── board-model.js # Pure game state + move/undo/win logic
│ ├── progress-store.js # localStorage persistence (completed + best moves)
│ └── theme.js # Nord color palette, fonts, tile-size helper
├── ui/
│ ├── button-factory.js # Reusable rounded button with hover/press
│ └── board-renderer.js # Draws the board + animates moves
└── scenes/
├── menu-scene.js # Title, play, progress counter, keybinds
├── level-scene.js # Paginated 5×4 level grid (5 pages × 20)
└── game-scene.js # Gameplay: input, HUD, win overlay
public/
├── style.css # Page background + container shadow
├── favicon.png
└── assets/ # bg.png, logo.png (reserved for future use)
Data flow
main.jscreates the Phaser Game with Menu / Level / Game scenes.level-scenewritesregistry.currentLevelon click, startsGameScene.game-scenereads the level index, callsparseLevel()on the XSB string, builds aBoardModel, hands it toBoardRenderer.- Input →
BoardModel.tryMove()→BoardRenderer.animateMove()→ win check →progressStore.recordCompletion().
Key design choices
- XSB at runtime: levels are stored as the standard Sokoban text format; the parser flood-fills interior floor tiles so the renderer only paints inside the puzzle shape.
- Pure
BoardModel: move/undo/win logic has zero Phaser dependencies — trivial to unit-test later. - No Arcade physics: the original version wired colliders but moved sprites by tween; the physics system did nothing. Removed.
- One button factory: every scene goes through
createButton()so hover/press feels identical everywhere.
File size budget
Every file under 200 LOC per development rules. Data file (microban-levels.js) exceeds that because it's pure data, not logic.