-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cpp
88 lines (70 loc) · 1.51 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
#include <stdlib.h>
#include "Application.h"
#include "Globals.h"
#include "SDL/include/SDL.h"
#pragma comment( lib, "SDL/libx86/SDL2.lib" )
#pragma comment( lib, "SDL/libx86/SDL2main.lib" )
enum main_states
{
MAIN_CREATION,
MAIN_START,
MAIN_UPDATE,
MAIN_FINISH,
MAIN_EXIT
};
int main(int argc, char ** argv)
{
LOG("Starting game '%s'...", TITLE);
int main_return = EXIT_FAILURE;
main_states state = MAIN_CREATION;
Application* App = NULL;
while (state != MAIN_EXIT)
{
switch (state)
{
case MAIN_CREATION:
LOG("-------------- Application Creation --------------");
App = new Application();
state = MAIN_START;
break;
case MAIN_START:
LOG("-------------- Application Init --------------");
if (App->Init() == false)
{
LOG("Application Init exits with ERROR");
state = MAIN_EXIT;
}
else
{
state = MAIN_UPDATE;
LOG("-------------- Application Update --------------");
}
break;
case MAIN_UPDATE:
{
int update_return = App->Update();
if (update_return == UPDATE_ERROR)
{
LOG("Application Update exits with ERROR");
state = MAIN_EXIT;
}
if (update_return == UPDATE_STOP)
state = MAIN_FINISH;
}
break;
case MAIN_FINISH:
LOG("-------------- Application CleanUp --------------");
if (App->CleanUp() == false)
{
LOG("Application CleanUp exits with ERROR");
}
else
main_return = EXIT_SUCCESS;
state = MAIN_EXIT;
break;
}
}
delete App;
LOG("Exiting game '%s'...\n", TITLE);
return main_return;
}