forked from ManalHasan/OOP-Project-Manal-Moiz-Naaseh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
46 lines (41 loc) · 1.2 KB
/
main.cpp
File metadata and controls
46 lines (41 loc) · 1.2 KB
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
#include "GameLoop.hpp"
// GameLoop* g = new GameLoop();
int main(int argc, char* argv[]) {
double first;
double last;
GameLoop* g = new GameLoop();
// Initialize the game loop and set highscore to 0
g->Initialize();
g->SetHighscore();
do {
g->setStartState(false);
g->bgMusic();
g->MainMenu();
g->Instructions();
g->SelectBird();
while (g->getGameState()) {
if (!g->getPauseState()) {
g->Event();
g->Update();
g->Render();
first = SDL_GetTicks();
if (first - last < 20.7) { // fps
SDL_Delay(20.7 - (first - last));
}
last = first;
} else {
g->Paused();
g->Event();
}
}
// End the game and check if restart is requested
std::cout<<"game end"<<std::endl;
std::cout<<g->getGameState()<<std::endl;
g->Endgame();
} while (g->getStartState());
g->Clear();
g->~GameLoop();
delete g; //free the allocated memory
g=nullptr;
return 0;
}