-
Notifications
You must be signed in to change notification settings - Fork 1
/
menu.cpp
66 lines (52 loc) · 1.35 KB
/
menu.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
/*
* menu.cpp
*
* Created on: 2013-09-28
* Author: Liam
*/
#include "menu.h"
#include "camera.h"
#include "gamestatemanager.h"
#include "input.h"
void menuLoad() {}
void menuInitialize() {
InitFrameRateController();
startFrame(frameStartTime);
g_Camera.initCamera({WIDTH / 2, HEIGHT / 2}, NULL);
}
void menuUpdate() {
dtCalc();
updateInput();
if (gInputs.Key_P) {
nextState = Level;
gInputs.Key_P = false;
} else if (gInputs.Key_E) {
nextState = Editor;
} else if (gInputs.Key_Q) {
nextState = Quit;
}
}
void menuDraw() {
for (int i = 0; i < WIDTH * HEIGHT; ++i) {
backgroundBuffer[i].Char.AsciiChar = ' ';
backgroundBuffer[i].Attributes = 0;
}
vec2d pos(0, 0);
g_Camera.writeString("Welcome to the Little Engine That Could!", pos);
pos.setY(2);
g_Camera.writeString("Please choose from the following options: ", pos);
pos.setY(4);
g_Camera.writeString(" P: Play the game", pos);
pos.setY(5);
g_Camera.writeString(" E: Enter the level editor", pos);
pos.setY(6);
g_Camera.writeString(" Q: Quit the engine demo", pos);
pos.setY(8);
g_Camera.writeString("Press escape to return to this menu at any time.", pos);
copyBuffer(consoleBuffer, backgroundBuffer);
WriteConsoleOutputA(wHnd, consoleBuffer, characterBufferSize, characterPosition, &consoleWriteArea);
}
void menuFree() {
g_Camera.resetCamera();
}
void menuUnload() {}