README
๐ฎ PAC-MAN TypeScript
A faithful recreation of the classic 1980 Namco arcade game, built with TypeScript, WebGL, and Test-Driven Development.
๐ธ Screenshots

More Screenshots


โจ Features
- Authentic Gameplay: Original 28ร31 maze, ghost AI, and game mechanics
- WebGL Rendering: GPU-accelerated graphics with batched rendering
- All 4 Ghost Personalities:
- Synthesized Sound: Web Audio API for authentic retro audio
- Responsive Controls: Cornering and input buffering
- High Score Persistence: Saved to localStorage
๐ Quick Start
bash
# Install dependencies
npm install
# Start development server with hot reload
npm run dev
# Run tests
npm test
# Build for production
npm run build
๐ฎ Controls
| Key | Action |
|---|---|
| Arrow Keys / WASD | Move Pac-Man |
| Space / Enter | Start Game |
| P / Escape | Pause |
๐๏ธ Architecture
shell
src/
โโโ main.ts # Entry point
โโโ Game.ts # Main game controller
โโโ constants.ts # Game constants
โโโ types.ts # TypeScript interfaces
โโโ entities/
โ โโโ Entity.ts # Base entity class
โ โโโ PacMan.ts # Player character
โ โโโ Ghost.ts # Base ghost AI
โ โโโ Blinky.ts # Red ghost
โ โโโ Pinky.ts # Pink ghost
โ โโโ Inky.ts # Cyan ghost
โ โโโ Clyde.ts # Orange ghost
โโโ systems/
โ โโโ WebGLRenderer.ts # GPU rendering
โ โโโ Input.ts # Keyboard/touch
โ โโโ Collision.ts # Hit detection
โ โโโ Sound.ts # Audio synthesis
โโโ utils/
โโโ MazeData.ts # Maze layout
โโโ Vector.ts # 2D math
๐งช Test-Driven Development
This project was built using TDD. Every feature has corresponding tests:
bash
# Run tests once
npm test -- --run
# Run tests in watch mode
npm test
# Run with coverage
npm run test:coverage190 tests covering:
- Vector math operations
- Maze data and navigation
- Pac-Man movement and animation
- Ghost AI behaviors
- Collision detection
- Rendering system
๐ Documentation
docs/SPECIFICATION.md- Technical specificationdocs/LESSONS_LEARNED.md- Development insightsdocs/AI_DEVELOPMENT_GUIDE.md- AI/Claude instructions for adding featuresdocs/diary/- Build diary with decision rationale
For AI Assistants
If you're using Claude or another AI to add features to this project, point it to:
shell
docs/AI_DEVELOPMENT_GUIDE.mdThis guide explains the TDD workflow, code patterns, and feature backlog.
๐ฏ Game Mechanics
Ghost Modes
Ghosts cycle through behavioral modes:
Power Pellets
- Ghosts turn blue and become edible
- Points multiply: 200 โ 400 โ 800 โ 1600
- Duration decreases each level
Scoring
| Item | Points |
|---|---|
| Pellet | 10 |
| Power Pellet | 50 |
| Ghost (1st) | 200 |
| Ghost (2nd) | 400 |
| Ghost (3rd) | 800 |
| Ghost (4th) | 1600 |
๐ ๏ธ Tech Stack
- Language: TypeScript 5.3
- Build Tool: Vite 5.0
- Testing: Vitest
- Rendering: WebGL with custom shaders
- Audio: Web Audio API (synthesized)
๐ License
MIT
๐ Credits
- Original Pac-Man ยฉ 1980 Namco
- This is a fan recreation for educational purposes
Built with TDD, documented with care, powered by WebGL ๐น๏ธ