← cd ~
~/42-firenze/pac-man
42 firenze · milestone 4 · python · pygame
Pac-Man
A remake of Namco's 1980 arcade game in Python. Every level is a non-perfect maze generated by an A-Maze-ing package, loaded by name from the config. Four ghosts with their own targeting, arcade-accurate rules from the Pac-Man Dossier, 10 levels, a persistent top-10 and a Double mode with a maze twice as big and 8 ghosts. Below is the same code, running in your browser.
The game's own Python, unchanged, compiled to WebAssembly with pygbag. Click the game first, then play with the keyboard. Desktop only.
how it works
- Mazes: the loader imports the A-Maze-ing package named in the config and reads the factory's signature to pass the arguments it understands (
width,height,seed,perfect=False…). Switching package needs no code change. - Ghosts: each one picks a different target tile, as in the arcade: Blinky chases, Pinky aims ahead of you, Inky uses Blinky's position, Clyde backs off when close. Scatter and chase alternate in per-level waves, and Cruise Elroy speeds Blinky up near the end.
- Rules: bonus fruit at 70 and 170 dots, an extra life at 10,000, a level timer, and food that grows back after 30 s.
- Robust by design: every config value is validated and clamped, and highscores are saved atomically, so no error ever shows a traceback.
- Shipped: a native macOS app built with PyInstaller and packaged for itch.io.