Skip to content

Pac Man clone written in C++ SFML using polymorphism and inheritance. "Pace-Man" represents how the player would be able to change their pace in the full release

Notifications You must be signed in to change notification settings

realaryann/Pace-Man

Folders and files

NameName
Last commit message
Last commit date

Latest commit

65a74b7 · Nov 6, 2024

History

48 Commits
Nov 6, 2024
Nov 6, 2024
Nov 6, 2024
Jan 18, 2024
May 12, 2024
Nov 6, 2024
Nov 6, 2024
Nov 6, 2024

Repository files navigation

Pace-Man : A Pac-Man Clone

Pace-Man is a project created using C++ SFML

"Pace" represents the uniqueness of this clone, this clone would allow the player character to increase his speed

General Discussion

This project is a clone of the Pac-Man game created by Toru Iwatani and Atari in 1980. Being one of the staples of video games, I decided to create my version of this game and modify some aspects of the game. The project has an overarching World class that contains information about every aspect of the game. It stores essential details like the height and width of the board, current player score, Coordinates for the player and ghosts, and a two dimensional vector to hold tile pointers. This matrix is known as (lowercase) world

a Tile is a mostly abstract base class used to represent free space on the map. It contains the world (the matrix of tiles) by reference, as a Tile may need to perform swaps to move around in the world. This ability is granted by the move() and move(Coordinate) methods that are overloaded by classes Player, Red Ghost, and Blue Ghost. The overloaded move(Coordinate) takes in the coordinate of the player and is used by the Blue Ghost to follow the player around on the map of tiles.

The main loop is used for event handling and carrying out polling instructions to simulate steps on the world. The entire state of the game can be reset to default conditions by pressing the 'R' key anytime during the game. The Player's movements are handled by polling for WASD/Arrow Keys. Whenever the player moves to a Candy Tile, the score is updated in the World class and the Candy tile is turned into a space/empty tile. Moving the player once will move the player in that direction until a new direction is polled for.

If the Player or any of the Ghosts move in the direction of each other, the ghost will devour the player and reduce one of its lives. The player will then be reset to his spawn position and the game continues until all of the player lives deplete.

Data Storage

The project utilizes a vector matrix (2D) of Tile pointers to represent all tiles. A tile is an abstract base class that can appear as a Wall, a Candy, a Ghost, or the Player at runtime. Movable tiles include the Player and the Ghosts.

Map Design

Pace-Man is capable of reading in custom symbol maps with the height and width specified at the top of the map
as an example, the following is the default map supplied with the game.

image image

Symbol Table

  • x - Wall
  • o - Candy
  • s - Empty Space/Tile
  • b - Entry Point to the Ghost House
  • 1,2.. - Red Ghost, Blue Ghost...
  • @ - Player/Pace-Man

Class Hierarchy Diagram

The following is a diagram created to simplify the internal program design and how every class interacts with one another:

image

Movement Controls

W/Up Arrow - Up

A/Left Arrow - Left

S/Down Arrow - Down

D/Right Arrow - Right

Ghost Rules

Red Ghost - Randomly chooses any direction and moves to it

Blue Ghost - Calculates how far the player character is and chases the player, but sometimes chooses a random direction

About

Pac Man clone written in C++ SFML using polymorphism and inheritance. "Pace-Man" represents how the player would be able to change their pace in the full release

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages