"Pace" represents the uniqueness of this clone, this clone would allow the player character to increase his speed
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.
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.
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.
- x - Wall
- o - Candy
- s - Empty Space/Tile
- b - Entry Point to the Ghost House
- 1,2.. - Red Ghost, Blue Ghost...
- @ - Player/Pace-Man
The following is a diagram created to simplify the internal program design and how every class interacts with one another: