-
Notifications
You must be signed in to change notification settings - Fork 1
/
Engine.hpp
75 lines (58 loc) · 1.3 KB
/
Engine.hpp
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
67
68
69
70
71
72
73
74
#ifndef GAME_HPP
#define GAME_HPP
#include <vector>
#include <string>
#include <GL/glew.h>
#include "Cave.hpp"
#include "Player.hpp"
class Engine {
private:
Uint32 lastRun;
Uint32 runDelay;
bool running;
Player player;
Cave *map;
public:
Engine();
Cave *getMap();
Player *getPlayer();
void run();
void stop();
bool isRunning();
void update();
void drawGUI();
void draw();
};
Engine::Engine() : player(Player()) {
this->player.setPos(0.0, -2.0, 0.0);
this->player.setRotate(0.0, 20.0, 0.0);
this->player.setSpeed(1.0, 0.0009);
this->running = true;
this->map = new Cave();
}
Cave *Engine::getMap() { return this->map; }
Player *Engine::getPlayer() { return &this->player; }
void Engine::run() {
this->running = true;
debug("Start to run!", __LINE__);
}
void Engine::stop() {
this->running = false;
debug("Running stopped!", __LINE__);
}
bool Engine::isRunning() { return this->running; }
void Engine::update() {
if (!this->running) return;
if (this->getMap()->isHitting(this->player.nextPost())) {
this->player.posp.y = 0.0;
printf("Hitting!\n");
}
this->player.update();
}
void Engine::drawGUI() {
}
void Engine::draw() {
this->getMap()->draw();
drawGUI();
}
#endif