A classic Pacman game implementation in Java using Swing GUI framework, featuring a complete game engine with map editor and custom level support.
- Classic Pacman Gameplay: Navigate through mazes, collect dots, avoid ghosts, and eat power pellets
- Multiple Ghost Types:
- Red Ghost (Chaser) - Aggressively pursues Pacman
- Pink Ghost (Traveler) - Strategic movement patterns
- Cyan Ghost (Patrol) - Patrols specific areas
- Power-Up System: Collect power pellets to make ghosts vulnerable and eat them for bonus points
- Sound Effects: Authentic Pacman sound effects including siren, eating sounds, and game over music
- Map Editor: Built-in level editor to create custom maps
- Dynamic Map Generation: Automatic wall segment generation based on map layout
- Teleportation Tunnels: Special passages for quick traversal
- Score System: Track your progress with a scoring system
- Java Development Kit (JDK) 8 or higher
- Any Java IDE (IntelliJ IDEA, Eclipse, VS Code) or command line tools
-
Clone the repository:
git clone <repository-url> cd Pacman
-
Compile and run:
javac -cp src src/Main.java java -cp src Main
-
Or run directly from your IDE:
- Open the project in your preferred Java IDE
- Run the
Main.javafile
- Arrow Keys: Move Pacman (Up, Down, Left, Right)
- R Key: Restart game when game over
- Start Game: Choose "Start Game" from the main menu to play the default level
- Customize Game: Select "Customize Game" to create your own levels using the map editor
- Collect Dots: Navigate through the maze and collect all yellow dots
- Avoid Ghosts: Don't let the ghosts catch you!
- Power Pellets: Collect large dots to make ghosts vulnerable and eat them for bonus points
- Win Condition: Collect all dots to complete the level
The built-in map editor allows you to create custom levels using simple text-based syntax:
X: Wall (impassable)Y: Semi-wall (passable by ghosts only)_: Empty space with food dot=: Empty space without foodP: Pacman starting position1: Red Ghost (Chaser)2: Pink Ghost (Traveler)3: Cyan Ghost (Patrol)F: Fruit (bonus food)O: Power pelletB: Ghost base (where ghosts respawn)
XXXXXXXXXXXXXXXXXXXXXXXXXXX
X___O________X________O___X
X_XXXX_XXXXX_X_XXXXX_XXXX_X
XP________________________X
X______XX_________XX______X
XXXXXX_XX_XXX_XXX_XX_XXXXXX
=====X_XX_XXXOXXX_XX_X=====
=====X2XX_________XX_X=====
=====X_XX__XXYXX_3XX_X=====
XXXXXX_XX__X===X__XX_XXXXXX
X=====_____X=B=X_____====1X
XXXXXXXXXXXXXXXXXXXXXXXXXXX
src/
├── Main.java # Entry point
├── StartWindow.java # Main menu interface
├── PacWindow.java # Game window and map loading
├── PacBoard.java # Game board and rendering
├── Pacman.java # Player character logic
├── Ghost.java # Abstract ghost class
├── RedGhost.java # Red ghost implementation
├── PinkGhost.java # Pink ghost implementation
├── CyanGhost.java # Cyan ghost implementation
├── MapEditor.java # Level editor interface
├── MapData.java # Map data structure
├── Food.java # Food dot objects
├── PowerUpFood.java # Power pellet objects
├── TeleportTunnel.java # Teleportation system
├── SoundPlayer.java # Audio management
├── ImageHelper.java # Image processing utilities
├── BFSFinder.java # Pathfinding algorithm
└── FansyButton.java # Custom button component
resources/
├── images/ # Game sprites and textures
│ ├── pac/ # Pacman animation frames
│ ├── ghost/ # Ghost sprites by color
│ ├── food/ # Food and power pellet sprites
│ └── map segments/ # Wall segment textures
├── sounds/ # Audio files
├── fonts/ # Custom fonts
└── maps/ # Level files
- Swing GUI: Modern Java desktop application
- Animation System: Smooth sprite-based animations
- Collision Detection: Precise collision handling
- Pathfinding: BFS algorithm for ghost AI
- Resource Management: Efficient image and sound loading
- Event-Driven Architecture: Clean separation of game logic and rendering
The game includes authentic Pacman sound effects:
- Background siren during gameplay
- Eating sounds for dots and ghosts
- Power pellet activation sound
- Game over and victory music
- Custom sound effects for different game events
- PacBoard: Main game engine handling rendering, collision detection, and game state
- Pacman: Player character with movement, animation, and input handling
- Ghost: Abstract base class for AI-driven ghost behavior
- MapEditor: Visual map creation tool with real-time preview
- SoundPlayer: Audio management with support for looping and one-shot sounds
The game is designed to be easily extensible:
- Add new ghost types by extending the
Ghostclass - Create custom map layouts using the map editor
- Modify game mechanics by adjusting constants in the source code
- Add new power-up types by extending the food system
This project is open source. See the LICENSE file for details.
Armin Kazemi - Original developer of AKP Pacman v1.0
Enjoy playing this classic arcade game recreated in Java! 🎮
