Back to Pac-Man TypeScript

README

๐ŸŽฎ PAC-MAN TypeScript

A faithful recreation of the classic 1980 Namco arcade game, built with TypeScript, WebGL, and Test-Driven Development.

๐Ÿ“ธ Screenshots

Pac-Man Gameplay

More Screenshots

Screenshot 2

Screenshot 3

โœจ Features

  • Authentic Gameplay: Original 28ร—31 maze, ghost AI, and game mechanics
  • WebGL Rendering: GPU-accelerated graphics with batched rendering
  • All 4 Ghost Personalities:
- ๐Ÿ”ด Blinky - Direct chase (the aggressor) - ๐Ÿฉท Pinky - Ambush 4 tiles ahead (the interceptor) - ๐Ÿฉต Inky - Erratic targeting (the wildcard) - ๐ŸŸ  Clyde - Shy behavior (the scaredy-cat)
  • 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

KeyAction
Arrow Keys / WASDMove Pac-Man
Space / EnterStart Game
P / EscapePause

๐Ÿ—๏ธ 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:coverage

190 tests covering:

  • Vector math operations
  • Maze data and navigation
  • Pac-Man movement and animation
  • Ghost AI behaviors
  • Collision detection
  • Rendering system

๐Ÿ“– Documentation

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.md

This guide explains the TDD workflow, code patterns, and feature backlog.

๐ŸŽฏ Game Mechanics

Ghost Modes

Ghosts cycle through behavioral modes:

  • Scatter (7s) - Each ghost heads to their corner
  • Chase (20s) - Ghosts use their targeting AI
  • Repeat 4 times, then permanent Chase
  • Power Pellets

    • Ghosts turn blue and become edible
    • Points multiply: 200 โ†’ 400 โ†’ 800 โ†’ 1600
    • Duration decreases each level

    Scoring

    ItemPoints
    Pellet10
    Power Pellet50
    Ghost (1st)200
    Ghost (2nd)400
    Ghost (3rd)800
    Ghost (4th)1600
    Extra life awarded at 10,000 points.

    ๐Ÿ› ๏ธ 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 ๐Ÿ•น๏ธ

    ยฉ 2026 Jonathan Leahy ยท v0.8.1-31-g196fa14