-
Notifications
You must be signed in to change notification settings - Fork 0
/
Slide.hpp
118 lines (107 loc) · 2.34 KB
/
Slide.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
112
113
114
115
116
117
118
#include <Game.hh>
#include <SdlContext.hh>
#include <BasicShader.hh>
#include <Input.hh>
#include "AObject.hpp"
#include "Texture.hh"
#include "Geometry.hh"
class Slide : public AObject
{
private:
gdl::Texture _texture;
gdl::Geometry _geometry;
float _speed;
int _pos;
int position;
int _option;
size_t option;
bool setting;
std::vector<std::string> _path;
std::string winner;
public:
Slide(int Px, int Py, int Pz, int Rx, int Ry, int Rz, std::vector<std::string> path, int option) : AObject(Px, Py, Pz, Rx, Ry ,Rz){ _path = path; _option = option;
}
virtual ~Slide() { }
virtual bool initialize()
{
_speed = 10.0f;
setting = false;
_pos = 0;
if (_texture.load(_path.at(_option)) == false)
return (false);
_geometry.pushVertex(glm::vec3(45, -45, 45));
_geometry.pushVertex(glm::vec3(45, 45, 45));
_geometry.pushVertex(glm::vec3(-45, 45, 45));
_geometry.pushVertex(glm::vec3(-45, -45, 45));
_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, std::string mode)
{
static_cast<void>(clock);
if (input.getKey(SDLK_ESCAPE, true))
exit(0);
if (mode != "over")
{
// left
if (input.getKey(SDLK_LEFT,true))
{
if (_pos > 0)
_pos--;
_texture.load(_path.at(_pos));
}
// right
if (input.getKey(SDLK_RIGHT, true))
{
if (_pos < (int)_path.size() - 1)
_pos++;
_texture.load(_path.at(_pos));
}
// enter
if (input.getKey(SDLK_RETURN, true))
{
position = _pos;
setting = true;
}
}
else
{
// enter
if (input.getKey(SDLK_RETURN, true))
{
position = 1;
}
else
{
position = -1;
}
}
}
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);
}
virtual char getLetter() const
{
return _letter;
}
};