-
Notifications
You must be signed in to change notification settings - Fork 0
/
Application.cpp
73 lines (57 loc) · 1.82 KB
/
Application.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
#include "Application.h"
#include "ModuleWindow.h"
#include "ModuleRender.h"
#include "ModuleInput.h"
#include "ModuleTextures.h"
#include "ModuleAudio.h"
#include "ModuleCollision.h"
#include "ModuleFonts.h"
#include "ModulePlayer.h"
#include "ModuleBackground.h"
#include "ModuleUI.h"
Application::Application()
{
int i = 0;
modules[i++] = window = new ModuleWindow();
modules[i++] = render = new ModuleRender();
modules[i++] = input = new ModuleInput();
modules[i++] = textures = new ModuleTextures();
modules[i++] = fonts = new ModuleFonts();
modules[i++] = audio = new ModuleAudio();
modules[i++] = background = new ModuleBackground();
modules[i++] = player = new ModulePlayer();
modules[i++] = collision = new ModuleCollision();
modules[i++] = UI = new ModuleUI();
}
Application::~Application()
{
for (int i = NUM_MODULES - 1; i >= 0; --i)
delete modules[i];
}
bool Application::Init()
{
bool ret = true;
for (int i = 0; i < NUM_MODULES && ret == true; ++i)
ret = modules[i]->Init();
for (int i = 0; i < NUM_MODULES && ret == true; ++i)
ret = modules[i]->IsEnabled() ? modules[i]->Start() : true;
return ret;
}
update_status Application::Update()
{
update_status ret = UPDATE_CONTINUE;
for (int i = 0; i < NUM_MODULES && ret == UPDATE_CONTINUE; ++i)
ret = modules[i]->IsEnabled() ? modules[i]->PreUpdate() : UPDATE_CONTINUE;
for (int i = 0; i < NUM_MODULES && ret == UPDATE_CONTINUE; ++i)
ret = modules[i]->IsEnabled() ? modules[i]->Update() : UPDATE_CONTINUE;
for (int i = 0; i < NUM_MODULES && ret == UPDATE_CONTINUE; ++i)
ret = modules[i]->IsEnabled() ? modules[i]->PostUpdate() : UPDATE_CONTINUE;
return ret;
}
bool Application::CleanUp()
{
bool ret = true;
for (int i = NUM_MODULES - 1; i >= 0 && ret == true; --i)
if (modules[i]->IsEnabled() == true) ret = modules[i]->CleanUp();
return ret;
}