-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
48 lines (40 loc) · 881 Bytes
/
main.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
#include "GI/IGame.h"
#ifdef OPEN_GL_GAME
#include "GL/freeglut.h"
#endif
using namespace RhythmGame;
#ifdef OPEN_GL_GAME // OpenGL part NOT implemented yet.
using Game = RhythmGame::GLRhythmGame;
void onKeyboardEvent(unsigned char key, int x, int y) {
game.ui->onUserKeyboardInput(key);
}
void onDisplayUpdate() {
game.ui->onFrameUpdate();
}
#else
using Game = RhythmGame::RhythmGameCLI;
#endif
int main(int argc, char* argv[]) {
#ifdef OPEN_GL_GAME
glutInit(&argc, argv);
#endif
Game game;
if (argc >= 3 && strcmp(argv[1], "--config") == 0) {
game.create(argv[2]);
}
else {
game.create();
}
#ifdef OPEN_GL_GAME
glutDisplayFunc(onDisplayUpdate);
glutKeyboardFunc(onKeyboardEvent);
#endif
game.calibrate();
while (game.lastEvent != EventType::GAME_EXIT) {
game.run();
if (game.lastEvent != EventType::GAME_RESTART) {
game.over();
}
}
return 0;
}