Pac_Man

Pac-Man Game

A classic Pac-Man game built with Next.js, TypeScript, and Tailwind CSS. This is a fully functional recreation of the classic arcade game with modern web technologies.

Features

Getting Started

Prerequisites

Installation

  1. Install the dependencies:
npm install
  1. Run the development server:
npm run dev
  1. Open http://localhost:3000 in your browser to play the game.

Building for Production

npm run build
npm start

Controls

Game Rules

  1. Objective: Collect all pellets (small dots) and power pellets (large dots) to complete the level
  2. Ghosts: Avoid ghosts in their normal state - they will cost you a life if they catch you
  3. Power Pellets: When you eat a power pellet, ghosts turn blue and become vulnerable for 6 seconds
  4. Eating Ghosts: Eat vulnerable ghosts for 200 points each
  5. Lives: You start with 3 lives. Lose all lives and itโ€™s game over
  6. Scoring:
    • Small pellet: 10 points
    • Power pellet: 50 points
    • Ghost (when vulnerable): 200 points
  7. Levels: Complete a level by collecting all pellets, then advance to the next level

Game Mechanics

Technologies Used

Project Structure

โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ page.tsx          # Main game page component
โ”‚   โ”œโ”€โ”€ layout.tsx         # Root layout with metadata
โ”‚   โ””โ”€โ”€ globals.css        # Global styles and Tailwind imports
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ PacMan.tsx         # Pac-Man character component
โ”‚   โ”œโ”€โ”€ Ghost.tsx          # Ghost character component
โ”‚   โ””โ”€โ”€ Maze.tsx           # Maze rendering component
โ”œโ”€โ”€ hooks/
โ”‚   โ””โ”€โ”€ useGame.ts         # Main game logic hook
โ”œโ”€โ”€ types/
โ”‚   โ””โ”€โ”€ game.ts            # TypeScript type definitions
โ”œโ”€โ”€ utils/
โ”‚   โ””โ”€โ”€ maze.ts            # Maze layout and utility functions
โ”œโ”€โ”€ package.json           # Dependencies and scripts
โ”œโ”€โ”€ tailwind.config.js     # Tailwind CSS configuration
โ”œโ”€โ”€ tsconfig.json          # TypeScript configuration
โ””โ”€โ”€ README.md              # This file

Customization

Adjusting Game Speed

Edit GAME_SPEED in hooks/useGame.ts:

const GAME_SPEED = 150; // milliseconds (lower = faster)

Changing Power Mode Duration

Edit POWER_MODE_DURATION in hooks/useGame.ts:

const POWER_MODE_DURATION = 6000; // milliseconds

Modifying Colors

Edit tailwind.config.js to customize the color scheme:

colors: {
  'pacman-yellow': '#FFD700',
  'ghost-red': '#FF0000',
  // ... etc
}

Browser Compatibility

Performance

Future Enhancements

Potential features to add:

License

This project is created for educational purposes. Feel free to use it as a learning resource or as a base for your own projects.

Credits

Inspired by the classic Pac-Man arcade game by Namco (1980).

Contributing

This is a university project, but suggestions and improvements are welcome!


Enjoy playing! ๐ŸŽฎ