-
Notifications
You must be signed in to change notification settings - Fork 0
/
number.hpp
111 lines (97 loc) · 2.27 KB
/
number.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef NUMBER_HPP_
# define NUMBER_HPP_
#include <Game.hh>
#include <SdlContext.hh>
#include <BasicShader.hh>
#include <Input.hh>
#include "AObject.hpp"
#include "Texture.hh"
#include "Geometry.hh"
class Number : public AObject
{
private:
gdl::Texture _texture;
gdl::Geometry _geometry;
float _speed;
int _pos;
int _position;
int _value;
int _option;
size_t option;
bool setting;
std::map<int, std::string> _path;
std::string winner;
public:
Number(int Px, int Py, int Pz, int Rx, int Ry, int Rz, std::map<int, std::string> path) : AObject(Px, Py, Pz, Rx, Ry ,Rz){ _path = path;}
virtual ~Number() { }
virtual bool initialize()
{
_speed = 10.0f;
setting = false;
_pos = 0;
_position = 0;
_value = 9;
if (_texture.load(_path[SDLK_KP_0]) == false)
return (false);
_geometry.pushVertex(glm::vec3(3, -3, 3));
_geometry.pushVertex(glm::vec3(3, 3, 3));
_geometry.pushVertex(glm::vec3(-3, 3, 3));
_geometry.pushVertex(glm::vec3(-3, -3, 3));
_geometry.pushUv(glm::vec2(0.0f, 0.0f));
_geometry.pushUv(glm::vec2(1.0f, 0.0f));
_geometry.pushUv(glm::vec2(1.0f, 1.0f));
_geometry.pushUv(glm::vec2(0.0f, 1.0f));
_geometry.build();
return (true);
}
virtual void update(gdl::Clock const &clock, gdl::Input &input)
{
static_cast<void>(clock);
if (input.getKey(SDLK_ESCAPE))
exit (0);
else
catchKey(input);
setting = true;
}
virtual char getLetter() const
{
return _letter;
}
void catchKey(gdl::Input &input)
{
int i = 0;
for (std::map<int, std::string>::iterator it = _path.begin();
it != _path.end(); ++it)
{
if (input.getKey((*it).first, true)) {
_texture.load((*it).second);
_value = i;
return;
}
++i;
}
}
int getNbValue() const {
return _value;
}
virtual bool getSetting()
{
AObject::setSetting(setting);
return setting;
}
virtual int getPosition()
{
return _position;
}
virtual void setSetting(bool _setting)
{
setting = _setting;
}
virtual void draw(gdl::AShader &shader, gdl::Clock const &clock)
{
static_cast<void>(clock);
_texture.bind();
_geometry.draw(shader, getTransformation(), GL_QUADS);
}
};
#endif