This project is a web-based implementation of the classic Pac-Man game. The game features Pac-Man navigating through a maze, collecting dots and power pellets while avoiding ghosts. The game includes a main menu, pause functionality, and a timer.
- Classic Pac-Man gameplay
- Main menu with start button
- Pause and resume functionality
- Timer to track game duration
- Ghosts with different behaviors
- Power pellets that make ghosts vulnerable
- Score tracking
- Game over screen
-
Clone the repository:
git clone https://github.com/rodneyo1/pacman cd pacman -
Open the project directory:
cd pacman -
Open index.html in your web browser to start the game.
- Use the arrow keys to navigate Pac-Man through the maze.
- Collect all the dots and power pellets to complete the level.
- Avoid the ghosts or eat them when they are vulnerable after collecting a power pellet.
- The game ends when you lose all your lives or the timer runs out.
- Arrow Keys: Move Pac-Man
- ESC: Pause/Resume the game
- Enter: Start the game from the main menu
- D: Toggle debug overlay
- index.html: The main HTML file for the game.
- style.css: The main CSS file for styling the game.
- maze.js: Contains the logic for the maze, Pac-Man movement, and dot rendering.
- ghosts.js: Contains the logic for ghost behavior and movement.
- pause.js: Contains the logic for the pause menu and timer.
- score.js: Contains the logic for score tracking.
- assets: Contains images and other assets used in the game.
initializePacman(): Initializes Pac-Man's position and style.resetPacmanPosition(): Resets Pac-Man to the starting position.renderRandomDots(): Renders dots and power pellets in the maze.ghostLoop(): Main game loop for ghost movement.updateGhosts(): Updates the position and behavior of ghosts.createTimer(): Creates and updates the game timer.togglePause(): Toggles the pause state of the game.
- The debug overlay can be toggled using the
Dkey. This overlay helps visualize the game state and debug issues.
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch
- Make your changes and commit them:
git commit -m "Description of your changes" - Push to the branch:
git push origin feature-branch
- Create a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.