How masonicgit/pacman works
Project type and purpose
• This is a single-page, front-end–only HTML5/JavaScript game (no persistent back-end).
• Purpose: faithfully recreate Pac-Man (and variants), including procedural map generation, accuracy modes, practice/learn modes, and sound.
File structure
Top-level areas:
• build.sh, package.json, .eslintrc.json, next.config.js
– Build environment: Node/npm (linting, packaging), simple bash script to concatenate source.
• src/
– Core game engine (Actor.js, Ghost.js, Map.js, game.js, renderers.js, input.js, sound.js, main.js, etc.).
• sprites/, sounds/, font/
– Static asset directories (sprite atlases, audio files, fonts).
• fruit/, mapgen/, randturn/, promo/
– Research & experimental tools: fruit-path analysis, procedural maze generators, random-turn statistics, promotional/demo pages.
• index.html / debug.html / pacman.js
– Entry points:
• debug.html loads individual src/*.js for development
• index.html loads bundled pacman.js for production
• doc/, issues/, BACKLOG
– Documentation, design notes, reverse-engineering artifacts
README for insights
• Confirms the static front-end nature: “all javascript source files are located in the ‘src/’ directory,” “build.sh concatenates into pacman.js,” “index.html uses pacman.js.”
• Describes game modes (Learn, Practice, Cookie-Man procedural maps), controls, confirmed platforms.
• Details design goals: accuracy to original arcade physics, ghost AI, timing.
Main components and relationships
a. Build & Deployment (offline toolchain)
• Node/npm environment (package.json)
• build.sh script
• Outputs pacman.js
• Static asset bundling
b. Static File Server (could be GitHub Pages, any HTTP server)
• Serves index.html, pacman.js, sprites/, sounds/, font/
c. Client (Browser)
• HTML5 Canvas + DOM (index.html)
• pacman.js game logic
• Canvas renderer (renderers.js)
• Input module (keyboard, touch)
• Audio module (sound.js)
• Asset loader (sprites, sounds, fonts)
• Game loop / state manager (main.js, executive.js, states.js)
• Generator (mapgen.js for Cookie-Man mode; experimental code in mapgen/ dir)
• UI overlays (menus, HUD, cutscenes)
d. External Resources
• Reverse-engineering docs (doc/disasm/)—used offline, not at runtime
• Experimental tools (fruit/, randturn/)—offline utilities
Architectural patterns & design principles
• Modular JavaScript: each concern in its own module (Actor, Ghost, Map, Renderer, Input, Sound).
• Single Event Loop: canonical game loop handles input → update → render.
• Asset Separation: clear directories for sprites, sounds, fonts.
• Build vs. Runtime separation: debug vs. production bundles.