-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGameObject.hpp
75 lines (59 loc) · 1.6 KB
/
GameObject.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
75
#pragma once
#include "Camera.hpp"
#include "CursorObject.hpp"
#include "Intelligence.hpp"
#include "Soccer.hpp"
#include "BackgroundObject.hpp"
#include "SoccerObject.hpp"
struct GameObject {
Camera cam;
BackgroundObject backgrObj;
SoccerObject soccerObject;
ui::CursorObject &cursor; // no ownership, but may modify
size_t w_width;
size_t w_height;
Timer::time_t current_time = 0.;
GameObject(Soccer &soccer, Intelligence<IntelligenceType::ABSTRACT> &intelligence, ui::CursorObject &cursor, const std::string &dir):
backgrObj(dir),
soccerObject(soccer, intelligence, dir),
cursor(cursor)
{}
bool is_active() {
return !soccerObject.intelligence.has_quit();
}
void init() {
Logger::Info("gobject: intiialized\n");
backgrObj.init();
soccerObject.init();
}
void set_winsize(size_t w, size_t h) {
w_width=w,w_height=h;
cam.update(float(w_width)/w_height);
}
void keyboard(GLFWwindow *window) {
cam.keyboard(window, double(w_width)/w_height);
}
void keypress(int key, int mods) {
soccerObject.keypress(key, mods);
}
void mouse(double m_x, double m_y) {
cam.mouse(m_x, m_y);
soccerObject.set_cursor(cursor, m_x, m_y, w_width, w_height, cam);
}
void mouse_click(int button, int action) {
soccerObject.mouse_click(button, action);
}
void idle() {
soccerObject.intelligence.idle(current_time);
}
void display() {
if(!is_active())return;
backgrObj.display(cam);
soccerObject.display(cam);
}
void clear() {
Logger::Info("gobject: clearance\n");
backgrObj.clear();
soccerObject.clear();
}
};