-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
72 lines (66 loc) · 1.75 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
#include "Game.hpp"
void displayScore()
{
}
int main(int argc, char *args[])
{
srand(time(0));
cout << "Initializing..." << endl;
Game *game = new Game();
if (!game->initialize())
{
cout << "Failed to Initialize..." << endl;
return 0;
}
cout << "Successfully initialized!!" << endl;
cout << "Creating a map..." << endl;
if (!game->createMap())
{
cout << "Faild to create a map" << endl;
return 0;
}
cout << "Map created successfully!!" << endl;
cout << "Loading the map..." << endl;
if (!game->loadTiles())
{
cout << "Failed to load the map" << endl;
return 0;
}
cout << "Map loaded successfully!!" << endl;
cout << "Displaying the map..." << endl;
game->createMapSurface();
cout << "Map displayed successfully!!" << endl;
game->initBots();
const int FPS = 24;
const int frameDelay = 1000 / FPS;
Uint32 frameStart;
int frameTime;
if (game->running())
{
cout << "Game is now running!" << endl;
cout << "...//...WELCOME!!...//..." << endl;
}
while (game->running())
{
frameStart = SDL_GetTicks();
game->handleEvents();
game->update();
game->render();
frameTime = SDL_GetTicks() - frameStart;
if (frameDelay > frameTime)
{
SDL_Delay(frameDelay - frameTime);
}
}
cout << endl
<< "Game finished!!" << endl;
cout << "********************************" << endl
<< endl;
cout << "-------------Result---------------" << endl;
cout << endl
<< "********************************" << endl;
displayScore();
cout << "Cleaning the game..." << endl;
game->Cleanup();
return 0;
}