Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pacman Clone

A browser-based clone of the classic Pacman game built with HTML, CSS, and JavaScript. The game features a playable Pacman character, ghost enemies with AI behavior, a complete map, scoring, and lives.

Table of Contents

Features

  • Responsive canvas-based rendering
  • Playable Pacman character that moves smoothly on a grid
  • Ghosts with:
    • Random wandering behavior
    • Pathfinding AI using Breadth-First Search (BFS) when Pacman is within detection range
  • Food pellets scattered across the map
  • Score tracking and lives system
  • "Game Over" screen with automatic restart after delay
  • Keyboard controls (Arrow keys / WASD)

Project Structure

├── assets/
│   ├── animations.gif  <- GIF animation for Pacman
│   └── ghost.png       <- Ghost images
├── index.html          <- Main HTML file
├── css/
│   └── styles.css      <- Styling for canvas and UI
├── js/
│   ├── ghost.js        <- Ghost enemy AI and movement logic
│   ├── main.js         <- Game loop, rendering, and initialization
│   └── pacman.js       <- Pacman character logic

Getting Started

  1. Clone the repository:

    git clone https://github.com/trigologiaa/pacman-in-javascript.git
    cd pacman-in-javascript
  2. Open the game:

    Open index.html in your preferred web browser.

Controls

Key Action
Arrow Keys Move Pacman
WASD Move Pacman

Ghost AI

  • Wandering: Ghosts select random targets from 4 preset map corners.
  • Chasing: When Pacman enters their detection range, ghosts use BFS to calculate the shortest path toward Pacman.

Customization

You can modify the game map, speed, or ghost behaviors by editing js/main.js and js/ghost.js:

  • Change map array to redesign levels
  • Adjust oneBlockSize for scaling
  • Tweak ghost speed or range for difficulty

License

This project is licensed under the MIT License. See LICENSE for details.

Contact

  • For questions or contributions, please open an issue or contact the author.

Legal Notice / Disclaimer

This project is an unofficial, fan-made clone inspired by the classic Pac-Man game.

It is created for educational purposes only and is not affiliated with or endorsed by Namco or Bandai Namco Entertainment.

All original Pac-Man trademarks, graphics, and sounds belong to their respective owners.

About

A browser-based Pacman clone built with HTML5, CSS3, and vanilla JavaScript. Includes smooth grid-based movement, basic ghost AI (wandering and chasing with BFS), score tracking, lives system, and a responsive canvas rendering engine. Play directly in your browser.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages