-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
86 lines (69 loc) · 1.61 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
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <random>
#include "game/PushBlocks.h"
void winScreen();
void clear();
int main() {
SetConsoleOutputCP(CP_UTF8);
PushBlocks game;
game.loadGame();
while (true) {
if (game.win()){
winScreen();
game.loadGame();
}
clear();
std::cout << "level: " << game.get_level() << "\n";
game.displayMap();
std::cout << "R-Recreate Q-Exit";
char input = tolower(_getch());
switch (input){
case ('w'):
game.moveUp();
break;
case ('s'):
game.moveDown();
break;
case ('d'):
game.moveRight();
break;
case ('a'):
game.moveLeft();
break;
case ('r'):
game.loadGame();
break;
case ('q'):
exit(0);
}
}
}
void winScreen() {
// Print Win Screen
char input;
clear();
std::cout << " \n\n\n";
std::cout << " Next level!";
std::cout << " \n\n\n\n";
std::cout << " Q-EXIT C-CONTINUE\n";
while (true) {
do {
input = _getch();
if (tolower(input) == 'q') {
exit(0);
} else if (tolower(input) == 'c') {
return;
}
} while (input!='q'<<'c');
}
}
void clear() {
// clear the screen
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
}