Browser recreation of the 1980 Namco arcade classic. Single HTML file, no dependencies, no build step.
Play: https://pacman.petrochenko.info
Faithful to the original arcade:
- Original 28x31 maze with 240 dots, 4 power pellets, side tunnels
- 4 unique ghost AIs -- Blinky (chase), Pinky (ambush), Inky (unpredictable), Clyde (shy)
- Scatter/Chase mode cycling with arcade-accurate timers per level
- Elroy mode -- Blinky speeds up when few dots remain
- Frightened mode with per-level durations, flash warning, ghost chain scoring (200/400/800/1600)
- Level 19+ disables frightened mode (power pellets award points only)
- Fruit bonuses -- cherry through key, spawn at 70/170 dots
- Ghost house with dot-counter release, 3-phase vertical exit, backup timer
- Speed scaling -- Pac-Man, ghosts, tunnel, frightened speeds all vary by level
- Extra life at 10,000 points
- Eating slowdown -- 1 frame for dots, 3 frames for pellets
- Intermission cutscenes after levels 2, 5, and 9
- Level 256 kill screen -- right half corrupts (just like the original)
| Input | Desktop | Mobile |
|---|---|---|
| Move | Arrow keys / WASD | D-pad buttons |
| Move | -- | Swipe on maze |
| Start | Click INSERT COIN / any key | Tap INSERT COIN |
+--------------------------+
| SCORE HIGH SCORE |
| 2840 PAC-MAN 5120 |
| |
| . . . . . . . . . . . |
| . +---+ . +---+ . +-+ |
| o | | . | | . | | |
| . +---+ . +---+ . +-+ |
| . . . . . . . . . . . |
| +-+ +-+ |
| +---+ | | @ | | +---+ |
| +-+ +-+ |
| [ GHOST HOUSE ] |
| . . . . . . . . . . . |
| o . . . C < . . . . o |
| . . . . . . . . . . . |
+--------------------------+
| LV 3 x x |
+--------------------------+
- Rendering: Canvas 2D API
- Audio: Web Audio API synthesizer (waka, siren, death, intro melody)
- Hosting: Cloudflare Pages
- Size: Single
index.html(~2000 lines), zero dependencies
Adapts to any screen:
| Device | D-pad Size | Notes |
|---|---|---|
| iPhone SE / small | 52px | Compact layout |
| iPhone 14 / medium | 62px | Standard |
| iPhone Pro Max / large | 74px | Comfortable |
| Desktop | Hidden | Keyboard hint shown |
npx wrangler pages deploy . --project-name pacman --branch main --commit-dirty=trueOpen /test.html in a browser:
- 72 unit tests -- state init, movement, scoring, ghost AI, release thresholds, speeds, frighten mode, mode switching, fruit, level progression, intermissions, kill screen
- Simulation fuzzer -- 10,000 frames of random gameplay checking 10 invariants per frame (bounds, stuck states, memory leaks, timer underflows)
Everything lives in index.html. Sections:
- CSS -- responsive layout, D-pad, overlay
- HTML -- canvas, score header, lives row, D-pad, start/gameover overlay
- Constants -- maze template, ghost colors, speed tables, frighten durations, Elroy thresholds
- Game state -- score, lives, level, mode timers, fruit
- Maze -- init, wall checks, kill screen corruption
- Pac-Man -- creation, movement with grid snapping, eating slowdown
- Ghosts -- AI targeting, scatter/chase/frighten, house bounce, 3-phase exit, Elroy
- Mode switching -- scatter/chase timer with arcade durations per level tier
- Speed helpers -- per-level tables for Pac-Man, ghosts, tunnel, frightened, eaten
- Fruit -- 8 types, spawn at dot thresholds, timer
- Drawing -- maze, Pac-Man, ghosts, fruit, eyes, score popups
- Overlay -- HTML-based start/gameover screens with real button
- Input -- keyboard, D-pad touch/pointer, canvas swipe
- Game logic -- collision, death, level complete, flash animation
- Intermissions -- 3 cutscene acts with sprite animation
- Audio -- Web Audio synth: waka, power pellet, eat ghost, death, intro, siren
- Init -- canvas setup, high score from localStorage, resize
For educational purposes. PAC-MAN is a trademark of Bandai Namco Entertainment Inc.