# pi-pac-man

Play a terminal-native Pac-Man game inside [Pi](https://github.com/earendil-works/pi).

`pi-pac-man` adds a persistent TUI overlay opened with `/pac-man`. You move Pac-Man through multi-level ASCII mazes while four local ghosts chase, scatter, and flee deterministically.

## Features

- Centered terminal overlay, built with Pi TUI
- Three larger levels
- Four named ghosts: Blinky, Pinky, Inky, and Clyde
- Pellets, power pellets, frightened ghosts, lives, scoring, and level clears
- Arrow-key and WASD input
- Session persistence across Pi reloads/resumes
- Validated saved state, wall collision checks, and deterministic rules
- TypeScript source, no build step required
- Manual npm publish workflow included

## Install

```bash
pi install npm:pi-pac-man
```

Or add it to `~/.pi/agent/settings.json`:

```json
{
  "packages": ["npm:pi-pac-man"]
}
```

## Usage

Start or resume a game:

```text
/pac-man
```

Start a fresh game:

```text
/pac-man new
```

## Controls

| Key | Action |
| --- | --- |
| Arrow keys | Move Pac-Man |
| `W` `A` `S` `D` | Move Pac-Man |
| `n` | New game |
| `q` | Close overlay |

The overlay is TUI-only. It will not open in Pi print, JSON, or RPC modes.

## Symbols

| Symbol | Meaning |
| --- | --- |
| Green `P` | Pac-Man |
| Red `B` `K` `I` `C` | Dangerous ghosts |
| Blue `g` | Frightened ghost |
| `.` | Pellet |
| `o` | Power pellet |
| `#` | Wall |

## Development

```bash
npm install
npm test
npm run check
```

Try the extension locally:

```bash
pi -e ./extensions/index.ts
```

Then run:

```text
/pac-man
```

## Package Notes

Pi loads TypeScript extensions directly, so this package publishes the source `.ts` files. Pi core packages are declared as peer dependencies to avoid bundling duplicate Pi runtime packages.

## License

MIT
