-
Notifications
You must be signed in to change notification settings - Fork 1
/
level.cpp
57 lines (46 loc) · 1.15 KB
/
level.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
/*
* level.cpp
*
* Created on: 2013-07-12
* Author: Liam
*/
#include "level.h"
#include "entityfactory.h"
#include "camera.h"
void levelLoad() {
deserializeEntities("level1.txt");
}
void levelInitialize() {
InitFrameRateController();
startFrame(frameStartTime);
for (int i = 0; i < g_Entities.getNumOfEntities(); ++i) {
Entity *current = g_Entities.getByIndex(i);
if (current->getProperties() & PLAYER) {
g_pPlayer = static_cast<Player *>(current);
}
}
g_Camera.initCamera({WIDTH / 2, HEIGHT / 2}, g_pPlayer);
writeBackground(consoleBuffer);
drawEntities();
copyBuffer(consoleBuffer, backgroundBuffer);
WriteConsoleOutputA(wHnd, consoleBuffer, characterBufferSize, characterPosition, &consoleWriteArea);
}
void levelUpdate() {
float dt = dtCalc();
updateInput();
updateEntities(dt);
stepEntities(dt);
g_Camera.update();
}
void levelDraw() {
writeBackground(backgroundBuffer);
drawEntities();
copyBuffer(consoleBuffer, backgroundBuffer);
WriteConsoleOutputA(wHnd, consoleBuffer, characterBufferSize, characterPosition, &consoleWriteArea);
}
void levelFree() {
}
void levelUnload() {
g_Entities.clear();
g_Camera.resetCamera();
}