How to play Pac-Man
| Keys | Action |
|---|---|
| ↑ ↓ ← → | Move |
| W A S D | Move |
| P | Pause |
| R | Restart |
| M | Mute |
On phones and tablets, use the on-screen tactile D-pad under the viewport.
About Pac-Man
Pac-Man is a maze chase. You steer around a 28 by 31 tile maze to eat all 240 dots and 4 power pellets while four ghosts hunt you. Touching a ghost costs one of your three lives. A power pellet frightens the ghosts for a few seconds: they turn around, slow down and wander, and you can eat them.
Each ghost has its own chase rule. Blinky heads straight for Pac-Man. Pinky aims four tiles ahead of him, with the arcade quirk that facing up also shifts her target four tiles left. Inky doubles the line from Blinky to a point two tiles ahead of Pac-Man, so he cuts you off. Clyde chases from more than eight tiles away and retreats when closer. Between chases the ghosts scatter to their home corners, twice for 7 seconds and twice for 5, before they chase for good.
Scoring, levels and tips
- Dots score 10 and power pellets 50. Ghosts eaten on one power pellet score 200, 400, 800, then 1,600.
- Fruit appears below the ghost house after 70 and 170 dots, for 9 seconds, worth 100 times the level.
- A cleared level pays 800, plus 200 per level number, plus 250 per remaining life.
- Frightened time starts at 8 seconds and drops 0.6 seconds per level, to a minimum of 2. Everyone speeds up each level, and Blinky gets faster as the last 50 pellets go.
- Your high score is saved in the browser.
- Tip: ghosts slow to about half speed in the side tunnels. Pac-Man doesn't.
- Tip: let the ghosts come close before taking a power pellet. All four on one pellet is worth 3,000.
How it's built
The game is written from scratch in TypeScript on an HTML canvas, with no game framework, and updates 120 times per second on a fixed timestep. The maze is a text map drawn once into an offscreen canvas. Pac-Man and the ghosts move from tile centre to tile centre: a turn pressed early is queued until it fits, and reversing is instant. At each centre a ghost takes the open tile nearest its target, never reversing unless its mode changes and breaking ties in the original up, left, down, right order. Sound is synthesized with the Web Audio API.
This is an unofficial tribute written from scratch for the browser. It is not affiliated with or endorsed by the owners of the original game.