Author: lau-ha_j
(2012/02/13 14:17) 3 months ago
ajout des mouvements du hero
18
bool deplace;
19
20
sf::Clock mvt;
21
GLuint *texture;
22
23
public:
24
hero(int posX = 0, int posY = 0, int dir = BAS);
9
this->boxX = 40;
10
this->boxY = 25;
11
this->deplace = false;
12
this->mvt.Reset();
13
14
GLuint *identifiant_texture = new GLuint();
15
16
sf::Image *Image = new sf::Image();
17
...
37
this->posY = y;
39
38
}
40
41
void hero::setDeplace(bool deplace)
42
void hero::setDeplace(bool dep)
{
43
this->deplace = deplace;
44
this->deplace = dep;
45
46
int hero::getBoxX() const
47
64
66
65
void hero::Move()
67
68
float y1;
69
float y2;
70
double x;
71
72
if (this->dir == HAUT)
73
74
y1 = 0.f;
75
y2 = 1/4.f;
76
77
else if (this->dir == GAUCHE)
78
79
y1 = 1/4.f;
80
y2 = 2/4.f;
81
82
else if (this->dir == BAS)
83
84
y1 = 2/4.f;
85
y2 = 3/4.f;
86
87
else if (this->dir == DROITE)
88
89
y1 = 3/4.f;
90
y2 = 1.f;
91
92
if (deplace == true)
93
if (this->deplace == true)
94
x = 1/3.f;
95
int t = this->mvt.GetElapsedTime() * 10;
96
x = (t%3)/3.f;
else
97
98
glPushMatrix();
99
glEnable(GL_ALPHA_TEST);
100
glAlphaFunc(GL_GREATER, 0.0f);
101
102
103
glBindTexture(GL_TEXTURE_2D, *this->texture);
104
glBegin(GL_QUADS);
105
glTexCoord2f(x + 1/3.f , y2);
106
glVertex3f(this->posX, this->posY, 0);
107
glTexCoord2f(x + 1/3.f , y1);
108
glVertex3f(this->posX, this->posY + 50, 50);
109
glTexCoord2f(x ,y1);
110
glVertex3f(this->posX + this->boxX, this->posY + 50, 50);
111
glTexCoord2f(x , y2);
112
glVertex3f(this->posX + this->boxX, this->posY, 0);
113
114
glEnd();
115
glDisable(GL_ALPHA_TEST);
116
117
glPopMatrix();
118
119
120
121
const sf::Input& Input = this->App->GetInput();
perso->setDeplace(false);
for (unsigned int i = 0; i < this->touche.size(); i++)
bool KeyDown = Input.IsKeyDown((sf::Key::Code)this->touche[i].second);
if (KeyDown == true && this->menu != i)
(this->*condition[this->touche[i].first].second)();
476
glBindTexture(GL_TEXTURE_2D, *_texture);
477
478
glTexCoord2d(81/160.f, 151/250.f);
479
glVertex3i(_posX, _posY + 100, 100);
glVertex3i(_posX, _posY + 100, 70);
480
glTexCoord2d(159/160.f, 151/250.f);
481
glVertex3i(_posX + 80, _posY + 100, 100);
glVertex3i(_posX + 80, _posY + 100, 70);
482
glTexCoord2d(159/160.f, 249/250.f);
483
glVertex3i(_posX + 80, _posY, 0);
484
glTexCoord2d(81/160.f, 249/250.f);
GLuint *texture;void hero::setDeplace(bool deplace){{this->deplace = deplace;{{float y1;float y2;float y2;double x;double x;if (this->dir == HAUT)if (this->dir == HAUT){{y1 = 0.f;y1 = 0.f;y2 = 1/4.f;y2 = 1/4.f;}}else if (this->dir == GAUCHE)else if (this->dir == GAUCHE){{y1 = 1/4.f;y1 = 1/4.f;y2 = 2/4.f;y2 = 2/4.f;}}else if (this->dir == BAS)else if (this->dir == BAS){{y1 = 2/4.f;y1 = 2/4.f;y2 = 3/4.f;y2 = 3/4.f;}}else if (this->dir == DROITE)else if (this->dir == DROITE){{y1 = 3/4.f;y1 = 3/4.f;y2 = 1.f;y2 = 1.f;}}if (deplace == true)if (this->deplace == true){{x = 1/3.f;int t = this->mvt.GetElapsedTime() * 10;}x = (t%3)/3.f;else}x = 1/3.f;elseglPushMatrix();x = 1/3.f;glEnable(GL_ALPHA_TEST);glPushMatrix();glAlphaFunc(GL_GREATER, 0.0f);glEnable(GL_ALPHA_TEST);glAlphaFunc(GL_GREATER, 0.0f);glBindTexture(GL_TEXTURE_2D, *this->texture);glBindTexture(GL_TEXTURE_2D, *this->texture);glBegin(GL_QUADS);glBegin(GL_QUADS);glTexCoord2f(x + 1/3.f , y2);glTexCoord2f(x + 1/3.f , y2);glVertex3f(this->posX, this->posY, 0);glVertex3f(this->posX, this->posY, 0);glTexCoord2f(x + 1/3.f , y1);glTexCoord2f(x + 1/3.f , y1);glVertex3f(this->posX, this->posY + 50, 50);glVertex3f(this->posX, this->posY + 50, 50);glTexCoord2f(x ,y1);glTexCoord2f(x ,y1);glVertex3f(this->posX + this->boxX, this->posY + 50, 50);glVertex3f(this->posX + this->boxX, this->posY + 50, 50);glTexCoord2f(x , y2);glTexCoord2f(x , y2);glVertex3f(this->posX + this->boxX, this->posY, 0);glVertex3f(this->posX + this->boxX, this->posY, 0);glEnd();glEnd();glDisable(GL_ALPHA_TEST);glDisable(GL_ALPHA_TEST);glPopMatrix();glPopMatrix();{{{{perso->setDeplace(false);{{glVertex3i(_posX, _posY + 100, 100);glVertex3i(_posX, _posY + 100, 70);glVertex3i(_posX + 80, _posY + 100, 100);glVertex3i(_posX + 80, _posY + 100, 70);