-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEngine.cpp
More file actions
65 lines (46 loc) · 1.11 KB
/
Engine.cpp
File metadata and controls
65 lines (46 loc) · 1.11 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "Engine.h"
#include <crtdbg.h>
bool Engine::Initialize()
{
//enable memory leaks
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
m_renderer = std::make_unique<Renderer>();
m_input = std::make_unique<Input>();
m_audio = std::make_unique<Audio>();
m_time = std::make_unique<Time>();
m_ps = std::make_unique<ParticleSystem>();
m_renderer->Initialize();
m_renderer->CreateWindow("Game Engine", 800, 600);
m_input->Initialize();
m_audio->Initialize();
return true;
}
bool Engine::isQuit()
{
return quit;
}
void Engine::Shutdown()
{
m_renderer->Shutdown();
m_input->Shutdown();
m_audio->Shutdown();
//disable memory leakes
_CrtMemDumpAllObjectsSince(NULL);
}
void Engine::Update()
{
SDL_Event event;
SDL_PollEvent(&event);
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
quit = true;
}
if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) {
quit = true;
}
}
m_input->Update();
m_audio->Update();
m_ps->Update(m_time->GetDeltaTime());
m_time->Tick();
}