Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A classic Pacman game implementation in Java using Swing GUI framework, featuring a complete game engine with map editor and custom level support.

License

Notifications You must be signed in to change notification settings

starsentry/pacman_game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pacman Game

A classic Pacman game implementation in Java using Swing GUI framework, featuring a complete game engine with map editor and custom level support.

Alt text

🎮 Features

  • 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

🚀 Getting Started

Prerequisites

  • Java Development Kit (JDK) 8 or higher
  • Any Java IDE (IntelliJ IDEA, Eclipse, VS Code) or command line tools

Running the Game

  1. Clone the repository:

    git clone <repository-url>
    cd Pacman
  2. Compile and run:

    javac -cp src src/Main.java
    java -cp src Main
  3. Or run directly from your IDE:

    • Open the project in your preferred Java IDE
    • Run the Main.java file

🎯 How to Play

Controls

  • Arrow Keys: Move Pacman (Up, Down, Left, Right)
  • R Key: Restart game when game over

Gameplay

  1. Start Game: Choose "Start Game" from the main menu to play the default level
  2. Customize Game: Select "Customize Game" to create your own levels using the map editor
  3. Collect Dots: Navigate through the maze and collect all yellow dots
  4. Avoid Ghosts: Don't let the ghosts catch you!
  5. Power Pellets: Collect large dots to make ghosts vulnerable and eat them for bonus points
  6. Win Condition: Collect all dots to complete the level

🗺️ Map Editor

The built-in map editor allows you to create custom levels using simple text-based syntax:

Map Symbols

  • X: Wall (impassable)
  • Y: Semi-wall (passable by ghosts only)
  • _: Empty space with food dot
  • =: Empty space without food
  • P: Pacman starting position
  • 1: Red Ghost (Chaser)
  • 2: Pink Ghost (Traveler)
  • 3: Cyan Ghost (Patrol)
  • F: Fruit (bonus food)
  • O: Power pellet
  • B: Ghost base (where ghosts respawn)

Example Map

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

🏗️ Project Structure

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

🎨 Technical Features

  • 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

🎵 Audio

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

🛠️ Development

Key Classes Overview

  • 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

Customization

The game is designed to be easily extensible:

  • Add new ghost types by extending the Ghost class
  • 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

📝 License

This project is open source. See the LICENSE file for details.

👨‍💻 Developer

Armin Kazemi - Original developer of AKP Pacman v1.0


Enjoy playing this classic arcade game recreated in Java! 🎮

About

A classic Pacman game implementation in Java using Swing GUI framework, featuring a complete game engine with map editor and custom level support.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages