-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGame.cpp
executable file
·58 lines (45 loc) · 1.73 KB
/
Game.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
#include "Game.h"
#include <LinearMath/btVector3.h>
Universe Game::universe;
Renderer Game::renderer;
using namespace std;
void Game::configureGLUT() // Deprecated
{
glutIgnoreKeyRepeat(GLUT_KEY_REPEAT_DEFAULT);
glutTimerFunc(KEY_REPEAT_PERIOD, keyboard, 0);
glutReshapeFunc(windowResizingHandler);
glutWindowStatusFunc(windowStatusHandler);
#ifdef __APPLE__
glutWMCloseFunc(windowClosingHandler);
#endif
glutDisplayFunc(displayHandler);
glutSpecialFunc(specialKeyDown);
glutKeyboardFunc(keyDown);
glutKeyboardUpFunc(keyUp);
glutMouseFunc(mouseHandler);
glutMotionFunc(motionHandler);
glutIdleFunc(tick);
setGame(this);
}
Game::Game()
{
glClearColor(BACKGROUND_COLOR);
configureGLUT();
glutMainLoop();
}
void Game::event(const unique_ptr<Event>& event)
{
if (event->getType() == Event::REFRESH) {
if (((const unique_ptr<RefreshEvent>&) event)->getRefreshType()
& RefreshEvent::IMAGE)
renderer.render();
// if (((const unique_ptr<RefreshEvent>&) event)->getRefreshType()
// & RefreshEvent::LEVEL)
// universe.calculateLevel(cameras[0]); // TODO ask Vianney
if (((const unique_ptr<RefreshEvent>&) event)->getRefreshType()
& RefreshEvent::PHYSICS)
universe.physics(0.1); // TODO ask Antonin
}
universe.event(event);
// interface.event(event);
}