Skip to content

NivadDen/gui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŸก PacMan Java Game A simple 2D Pac-Man clone built using Java Swing. This project includes basic mechanics such as:

Pac-Man movement

Ghosts with randomized AI

Wall collisions

Food collection

Life system and score tracking

Basic teleport logic (optional to implement further)

๐ŸŽฎ Features Custom tile map rendering with characters representing walls, food, Pac-Man, and ghosts

Smooth keyboard-controlled movement

Basic game loop with timer-based animation (20 FPS)

Ghosts move with randomized directions and can collide with walls

Collision detection for:

Walls

Food pellets

Ghosts (Pac-Man loses a life)

Automatic level reset when all food is eaten

Game over logic with restart on key press

๐Ÿงฉ Game Controls โ†‘ โ†“ โ† โ†’ โ€” Move Pac-Man in the desired direction

On Game Over, pressing any arrow key will restart the game

๐Ÿ—บ๏ธ Tile Map Key Each character in the tileMap string array represents a tile:

Symbol Meaning X Wall (space) Food pellet P Pac-Man starting point b Blue ghost o Orange ghost p Pink ghost r Red ghost O Teleport zone (visual only currently)

๐Ÿ“ File Structure bash Copy code . โ”œโ”€โ”€ App.java # Main entry point for launching the game โ”œโ”€โ”€ PacMan.java # Main game logic, rendering, and event handling โ”œโ”€โ”€ wall.png # Image for wall tiles โ”œโ”€โ”€ blueGhost.png # Ghost sprites โ”œโ”€โ”€ orangeGhost.png โ”œโ”€โ”€ pinkGhost.png โ”œโ”€โ”€ redGhost.png โ”œโ”€โ”€ pacmanUp.png # Pac-Man sprites (for direction changes) โ”œโ”€โ”€ pacmanDown.png โ”œโ”€โ”€ pacmanLeft.png โ”œโ”€โ”€ pacmanRight.png โš ๏ธ Make sure the image files are located in the correct directory (./) relative to your compiled classes or resource path.

๐Ÿ› ๏ธ Technologies Used Java 8+

Java Swing (JFrame, JPanel, Timer, KeyListener)

Object-Oriented Programming (OOP) concepts

Basic game loop and rendering logic

๐Ÿš€ How to Run Compile the project: javac App.java PacMan.java

Run the game: java App

You can also run it from an IDE like IntelliJ IDEA or Eclipse. Just make sure resources (images) are correctly referenced in the classpath.

๐Ÿง  Future Improvements Add teleport logic for Pac-Man and ghosts when exiting map edges

Smarter ghost pathfinding (e.g., A* or BFS)

Add sound effects

Create a start menu and end screen

Save high scores

๐Ÿ“ท Screenshots:

pacgame

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages