Rubric of Pacman Game
Rubric of Pacman Game
Pacman
Session: 2024-2028
Submitted by:
Muhammad Sami Mughal 2024-CS-831
Supervised by:
Mr. Talha
Computer Science
University of Engineering and Technology Lahore
Pakistan
Users of Application:
The user can control Pacman using arrow keys to navigate the
maze, collect feeds, and avoid ghosts.
The user can view their final score and high scores saved from
previous gameplay.
Functional Requirements:
There are many functions in this program and some are written
below;
1. The movePacman function updates Pacman's position based on user input and handles
score increment when collecting feeds.
2. The moveGhost function controls the movement of ghosts randomly within the maze
and updates their positions accordingly.
#include <fstream>
#include <windows.h>
#include <conio.h>
#include <cstdlib>
#include <ctime>
void maze();
void movePacman(int &x, int &y, int dx, int dy, int &score);
void showHighScores();
char gameMaze[mazeHeight][mazeWidth];
int main()
string playerName;
int gx[6] = {18, 18, 59, 18, 74, 19}; // Ghost coordinates
system("color 04");
maze();
displayStatus(lives, score);
// Pacman movement
if (GetAsyncKeyState(VK_DOWN))
if (GetAsyncKeyState(VK_UP))
if (GetAsyncKeyState(VK_RIGHT))
if (GetAsyncKeyState(VK_LEFT))
// Ghosts movement
int dx = 0, dy = 0;
if (direction == 0)
dx = 1;
else if(direction == 1)
dx = -1;
else if (direction == 2)
dy = 1;
else if (direction == 3)
dy = -1;
lives--;
displayStatus(lives, score);
xycord(px, py);
Sleep(500);
if (lives <= 0)
cout << "Game Over! Final Score: " << score << endl;
saveScore(playerName, score);
showHighScores();
break;
Sleep(100);
return 0;
void maze() {
system("cls");
string mazeData[mazeHeight] = {
"###########################################################################
####",
"### . |%| . .|%| .|%| |%| .|%| . |%| . |%| . |%| .###",
"### . |%| . .|%| .|%|. . |%| .|%| . |%| . |%|. |%| .###",
"###########################################################################
####"
};
gameMaze[i][j] = mazeData[i][j];
void movePacman(int &x, int &y, int dx, int dy, int &score)
if (newX >= 0 && newX < mazeWidth && newY >= 0 && newY < mazeHeight)
if (nextPos == '.') {
score++;
xycord(x, y);
x = newX;
y = newY;
xycord(x, y);
if (newX >= 0 && newX < mazeWidth && newY >= 0 && newY < mazeHeight)
xycord(x, y);
x = newX;
y = newY;
xycord(x, y);
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
cout << "Lives: " << lives << " Score: " << score << " ";
if (file.is_open()) {
file << playerName << " " << score << endl;
file.close();
} else {
void showHighScores()
ifstream file("scores.txt");
string playerName;
int score;
if (file.is_open())
cout << playerName << ": " << score << endl;
file.close();
else
Wireframes:
Data Structure:
Arrays are used to store the coordinates of ghosts (gx[], gy[]) to track their
positions in the maze. They also store the maze data (gameMaze[]) to render the maze layout
and update the game state.
Function Prototypes:
Examples:
1. void movePacman(int &x, int &y, int dx, int dy, int &score);
This prototype declares the movePacman function, which moves Pacman and updates
the score.
2. void maze();
This prototype declares the maze function, which generates and displays the game’s
maze layout.
Start
Scores Lives
Weakness in Program:
My program is not very efficient. I should add a proper interface,
instructions and some other functions.
Future Directions:
I will add more functions in my program to make it better and more
efficient. I will also add colors and headers to make attractive this program.
… …