forked from PyAlaie/pacman-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
96 lines (77 loc) · 2.23 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <iostream>
#include <conio.h>
#include "game.h"
using namespace std;
int main(){
int **map;
// printing the splash screen
system(CLEAR);
typeEffect("\nWelcome to Kokonut Pacman!\n", "green");
usleep(700000);
// initializing database object
sqlite3 *db;
initializeDB(db);
// creating pacman and ghost objects
Pacman pacman;
Ghost ghost1;
Ghost ghost2;
Ghost ghost3;
Ghost ghost4;
int action;
int n, m;
while(true){
showMenu();
cin >> action;
vector<ranking> rr; // to get rankings
vector<string> savedGames; // to get saved games name
mapData gameToLoad; // in case of loading a game ...
switch(action){
case 1:
cout << "Pleace enter the dimensions of the game(x, y): ";
cin >> n >> m;
system(CLEAR);
if(m % 2 == 0){
m++; // for that mirror thing ... :)
}
// creating the matrix
map = initializeMatrix(n,m);
pacman.lives = 3;
setPlay(map, pacman, ghost1, ghost2, ghost3, ghost4, n, m);
Play(map, pacman, ghost1, ghost2, ghost3, ghost4, n, m, db);
break;
case 2:
getSavedGames(savedGames);
for(int i = 0; i< savedGames.size(); i++){
if (!(savedGames[i] == ".." || savedGames[i] == ".")){
cout<<i<<". "<<savedGames[i]<<endl;
}
}
coloredCout("\nEnter The Index Of Game You Want To Load: ", "blue");
int a;
cin >> a;
system(CLEAR);
readGameData(savedGames[a], gameToLoad);
loadGame(map, pacman, ghost1, ghost2, ghost3, ghost4, n, m, gameToLoad);
Play(map, pacman, ghost1, ghost2, ghost3, ghost4, n, m, db);
break;
case 3:
rr = getTopScores(db,10);
for(int i = 0; i< rr.size(); i++){
cout<<i+1<<". ";
coloredCout(rr[i].username, "yellow");
cout<<"\t\t";
coloredCout(to_string(rr[i].score), "green");
cout<<endl;
}
char b;
cin>>b;
break;
case 4:
return 0;
break;
default:
break;
}
}
return 0;
}