forked from GuillemFP/DoubleDragon3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
75 lines (69 loc) · 1.46 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
#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
};
Application* App = nullptr;
int main(int argc, char ** argv)
{
int main_return = EXIT_FAILURE;
int update_return = NULL;
main_states state = MAIN_CREATION;
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_FINISH;
}
else
{
LOG("Application Update --------------------");
state = MAIN_UPDATE;
}
break;
case MAIN_UPDATE:
update_return = App->Update();
if (update_return != UPDATE_CONTINUE)
{
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;
}
}
return main_return;
}