A classic Pac-Man game implementation for the terminal using Python's curses library. No external dependencies required!
- Classic Gameplay: Traditional Pac-Man mechanics in your terminal
- Ghost AI: Intelligent ghost behavior with vulnerability states
- Power-Ups: Power pellets that make ghosts vulnerable
- Lives System: Start with 3 lives
- Score Tracking: Earn points by eating dots and ghosts
- Color Graphics: Full-color terminal rendering
- Username Input: Personalized game experience
- Python 3.x (standard library only)
- Terminal with curses support (Linux/macOS/Windows with proper terminal)
No installation required! Just clone and run.
# Make executable
chmod +x pacman.py
# Run the game
./pacman.py
# or
python3 pacman.py- Arrow Keys: Move Pac-Man (↑ ↓ ← →)
- Q: Quit game
- Objective: Eat all dots and power pellets while avoiding ghosts
- Scoring:
- Regular dot: Points earned
- Power pellet: Makes ghosts vulnerable
- Vulnerable ghost: Bonus points
- Lives: Start with 3 lives, lose one when caught by a ghost
- Win Condition: Collect all dots and pellets
- Lose Condition: Run out of lives
- Pac-Man (●): Yellow player character
- Ghosts: Enemy AI with different behaviors
- Normal state: Chase Pac-Man
- Vulnerable state: Run away from Pac-Man
- Eaten state: Return to spawn
- Dots (·): Regular collectibles
- Power Pellets (○): Grant temporary invincibility
- Pathfinding: 70% chance to move toward Pac-Man
- States: Normal → Vulnerable → Eaten → Normal
- Vulnerability Timer: Limited time when ghosts are edible
- Respawn: Ghosts return to center after being eaten
- Grid Size: 10x10
- Walls: Impassable barriers
- Valid Moves: Only through empty spaces and collectibles
The game is contained in a single file (pacman.py) with these classes:
- Entity - Base class for game objects (position, movement)
- Pacman - Player with lives, score, power-up state
- Ghost - Enemy AI with vulnerability mechanics
- Maze - Grid management, collision detection
- Game - Main controller, game loop, rendering
- Yellow: Pac-Man
- Red/Blue/Green/Purple: Ghosts
- White: Dots and walls
- Cyan: Power pellets
For developers working with this code, see CLAUDE.md for detailed architecture documentation.
Works best with:
- Linux terminals (gnome-terminal, konsole, xterm)
- macOS Terminal
- Windows Terminal (with proper curses support)
Game doesn't start:
- Ensure your terminal supports curses
- Check Python version (3.x required)
Display issues:
- Resize terminal to at least 80x24
- Ensure terminal supports color
Controls not working:
- Make sure terminal window is focused
- Try running with
python3instead ofpython
Contributions welcome! Possible improvements:
- Additional ghost AI behaviors
- Level progression
- High score persistence
- Sound effects (terminal beep)
- Larger mazes
- Difficulty settings
See LICENSE file for details.
Classic Pac-Man game reimagined for the terminal. Built with Python curses library.