-
Notifications
You must be signed in to change notification settings - Fork 1
/
level2.cpp
57 lines (46 loc) · 1.16 KB
/
level2.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
/*
* level2.cpp
*
* Created on: 2013-09-03
* Author: Liam
*/
#include "level2.h"
#include "camera.h"
#include "entitymanager.h"
void level2Load() {
deserializeEntities("level2.txt");
}
void level2Initialize() {
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 level2Update() {
float dt = dtCalc();
updateInput();
updateEntities(dt);
stepEntities(dt);
g_Camera.update();
}
void level2Draw() {
writeBackground(backgroundBuffer);
drawEntities();
copyBuffer(consoleBuffer, backgroundBuffer);
WriteConsoleOutputA(wHnd, consoleBuffer, characterBufferSize, characterPosition, &consoleWriteArea);
}
void level2Free() {
}
void level2Unload() {
g_Entities.clear();
g_Camera.resetCamera();
}