C++ programming fundamental, Cheat Sheet of Computer science

this is helpful which is a full paccmann game in C++ programming fundamental

Typology: Cheat Sheet

2024/2025

Available from 03/24/2026

muhammad-rehan-12
muhammad-rehan-12 🇸🇬

8 documents

1 / 17

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Pacman game
Pacman Game
Session: 2025– 2029
Submitted by:
Muhammad Rehan Ashraf
2025-CS-1278
Submitted to:
Sir. Talha Mubashir
Department of Computer Science
University of Engineering and Technology
Lahore Pakistan
Short Description:
Pac-Man, circular adventurer, lives in a maze filled with dots and haunted by four evil ghosts:
Blinky, Pinky, Inky, and Clyde. While the ghosts try to catch him, Pac-Man hunts for power
pellets to turn the tables and defeat them. With courage and cunning, he clears the maze, eats all
Muhammad Rehan Ashraf 2025-CS1278
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download C++ programming fundamental and more Cheat Sheet Computer science in PDF only on Docsity!

Pacman Game

Session: 202 5 – 202 9

Submitted by:

Muhammad Rehan Ashraf

2025 -CS- 1278

Submitted to:

Sir. Talha Mubashir

Department of Computer Science

University of Engineering and Technology

Lahore Pakistan

Short Description:

Pac-Man, circular adventurer, lives in a maze filled with dots and haunted by four evil ghosts: Blinky, Pinky, Inky, and Clyde. While the ghosts try to catch him, Pac-Man hunts for power pellets to turn the tables and defeat them. With courage and cunning, he clears the maze, eats all

the dots, and becomes a hero. His determination and bravery inspire players of all ages to take on the challenge and keep the legend alive. Users of the game: There is only a single Player in this Game. Functional Requirements: In this game there will be five ghosts and the pacman will have to eat all the dots by avoiding hitting the ghost if the pacman hits the ghost its one life will reduce and if all the lives are lost then the game will be over. Wire frames: Function prototypes:

int main() { system("Color 0A"); read(); maze(); printScore(score, lives, high); while (gameover) { xycord(x, y); if (GetAsyncKeyState(VK_UP)) { char next = getCharAtxy(x, y - 1); if (next == ' ' || next == '.' || next == '$') { erasepm(x, y); y = y - 1; printpm(x, y); if (next == '.') { score+ +; } if (next == '$') { lives++; } printScore(score, lives, high); } } if (GetAsyncKeyState(VK_DOWN)) {

char next = getCharAtxy(x, y + 1); if (next == ' ' || next == '.' || next == '$') { erasepm(x, y); y = y + 1; printpm(x, y); if (next == '.') { score++; } if (next == '$') { lives++; } printScore(score, lives, high); } } if (GetAsyncKeyState(VK_LEFT)) { char next = getCharAtxy(x - 1, y); if (next == ' ' || next == '.' || next == '$') { erasepm(x, y); x = x - 1; printpm(x, y); if (next == '.') { score++; } if (next ==

{ high = large; printScore(score, lives, high); } // Ghost 1 erasepm(gx[0], gy[0]); if (g[0]) { if (getCharAtxy(gx[0] + 1, gy[0]) == '.') { xycord(gx[0], gy[0]); cout << "."; } gx[0]++; if (gx[0] > 96) { g[0] = false; } } else { if (getCharAtxy(gx[0] - 1, gy[0]) == '.') { xycord(gx[0], gy[0]); cout << "."; } gx[0]--; if (gx[0] < 3) { g[0] = true; } } printg(gx[0], gy[0]); // ghost 2

erasepm(gx[1], gy[1]); if (g[1]) { if (getCharAtxy(gx[1] + 1, gy[1]) == '.') { xycord(gx[1], gy[1]); cout << "."; } gx[1]++; if (gx[1] > 37) { g[1] = false; } } else { if (getCharAtxy(gx[1] - 1, gy[1]) == '.') { xycord(gx[1], gy[1]); cout << "."; } gx[1]--; if (gx[1] < 3) { g[1] = true; } } printg(gx[1], gy[1]); // ghost 3 erasepm(gx[2], gy[2]); if (g[2]) { if (getCharAtxy(gx[2], gy[2] + 1) == '.')

else { if (getCharAtxy(gx[3], gy[3] - 1) == '.') { xycord(gx[3], gy[3]); cout << "."; } gy[3]--; if (gy[3] < 3) { g[3] = true; } } printg(gx[3], gy[3]); // ghost 5 erasepm(gx[4], gy[4]); if (g[4]) { if (getCharAtxy(gx[4] + 1, gy[4]) == '.') { xycord(gx[4], gy[4]); cout << "."; } gx[4]++; if (gx[4] >

{ g[4] = false; } } else { if (getCharAtxy(gx[4] - 1, gy[4]) == '.')

{ xycord(gx[4], gy[4]); cout << "."; } gx[4]--; if (gx[4] < 27) { g[4] = true; } } printg(gx[4], gy[4]); for (int i = 0; i < 5; i++) { if (x == gx[i] && y == gy[i]) { lives--; printScore(score, lives, high); if (lives == 0) { high = score; score_data.open("Scoring File.txt", ios ::out); score_data << high; score_data.close(); gameover = false; system("cls"); xycord(0, 0); gameoover(); //cout << "Game Over!!" << endl;

cout << "##.......%%........%%.......%% %%.......%% %%.......%% %%......%%...........##" << endl; cout << "##.......%%........%%.......%% %%.......%% %%.......%%%%%%%%%%%%%......% %%%%%%......##" << endl; cout << "##.......%%........%%.......%% %%.......%% %%.......%%.....%%...............%%......##" << endl; cout << "##.......%%........%%.......%% %%.......%% %%....$..%%.......%%.....................##" << endl; cout << "##.......%%........%%.......%%%%%%%%%%%%.......%%%%%%%%%%%%.......%%........ .%% %%%%%%%%%%%.....##" << endl; cout << "##......................%%.................................................................%%.....##" << endl; cout << "##...%%........%%.......%%....%%%%%%%%%............%%%%%%%%%%%........%%.....% %%%%%%%%%....%%.....##" << endl; cout << "##...%%........%%.......%%...........%%....%%......%%.................%%.....%%............%%.....##" << endl; cout << "##...%%........%%....................%%....%%......%%....%%...%%%%%%%%%%%%...%%...% %%%%%%%%%%.....##" << endl; cout << "##...%%........%%%%%%%%%% .$.........%%....%%......%%....%%.........%%.......%%...................##" << endl; cout << "##...%%....................................%%......%%....%%...%%....%%.................%%.........##" << endl; cout << "##...%%......................%%%%%%%%%%%%%%%%............%%...%%....%%.....%%......... .%%.........##" << endl; cout << "##...%%.........%%%%%%%%%.......................%%%%%%%%%%%...%%....%%.....%%.... ......%%.........##" << endl; cout << "##...%%.........%%.....%%.....................................%%...........%%....%%%%%%%%%%%%

%%...##" << endl; cout << "##...%%%%.......%%.....%%.......%%%%%%%%%%.......%%%%%%%%%%%%%%%% %%........%%..........%%.........##" << endl; cout << "##..............%%.....%%.......%%.......................%%................%%..........%%.........##" << endl; cout << "##.......%%.....%%.....%%.......%%........%%%%%%%%%%%....%%........%%%%%%%%% %....%%....%%.........##" << endl; cout << "##.......%%............%%.......%%.................%%....%%............%%........%%...............##" << endl; cout << "##.......%%............%%%%%%%%%%%.....%%..........%%....%%............%%........%%.......... $....##" << endl; cout << "##....%%%%%%%%%%%%%%.....$.............%%..........%%..................%%........%%%%% %%%%%.......##" << endl; cout << "##.....................................%%.........................................................##" << endl; cout << "########################################################################## ##########################" << endl; } void xycord(int x, int y) { COORD coordinates; coordinates.X = x; coordinates.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coordinates); } char getCharAtxy(short int x, short int y) { CHAR_INFO ci; COORD xy = {0, 0};

xycord(x, y); cout << "g"; } void read() { score_data.open("Scoring File.txt", ios ::in); score_data >> high; score_data.close(); } void gameoover() { cout<<"____________________________________________________________________ _________________________________"< Weakness in application: In this Game the User Interface is Not very good if there will be graphics added for that game than this game will be prefect. And also there can be different levels added in the game to make the game interesting and engaging. Future directions: In future we can add different levels to the game and also the game working can be improved and game can be made more engaging by just adding multiplayers to the game.