Changeset 75

User picture

Author: lau-ha_j

(2012/02/13 14:17) 3 months ago

ajout des mouvements du hero

Affected files

Updated Jeu/Sources/includes/hero.h Download diff

7475
18
	bool		deplace;
18
	bool		deplace;
19
19
20
	sf::Clock	mvt;
20
	sf::Clock	mvt;
21
	GLuint	*texture;
21
	GLuint		*texture;
22
22
23
public:
23
public:
24
	hero(int posX = 0, int posY = 0, int dir = BAS);
24
	hero(int posX = 0, int posY = 0, int dir = BAS);

Updated Jeu/Sources/srcs/hero.cpp Download diff

7475
9
	this->boxX = 40;
9
	this->boxX = 40;
10
	this->boxY = 25;
10
	this->boxY = 25;
11
	this->deplace = false;
11
	this->deplace = false;
12
	this->mvt.Reset();
12
13
14
13
	GLuint *identifiant_texture = new GLuint();
15
	GLuint *identifiant_texture = new GLuint();
14
16
15
	sf::Image	*Image = new sf::Image();
17
	sf::Image	*Image = new sf::Image();
...
...
37
	this->posY = y;
39
	this->posY = y;
38
}
40
}
39
41
40
void		hero::setDeplace(bool deplace)
42
void		hero::setDeplace(bool dep)
41
{
43
{
42
	this->deplace = deplace;
44
	this->deplace = dep;
43
}
45
}
44
46
45
int			hero::getBoxX()	const
47
int			hero::getBoxX()	const
...
...
64
66
65
void			hero::Move()
67
void			hero::Move()
66
{
68
{
67
	  float		y1;
69
	float		y1;
68
  float		y2;
70
	float		y2;
69
  double	x;
71
	double	x;
70
72
71
  if (this->dir == HAUT)
73
	if (this->dir == HAUT)
72
    {
74
	{
73
      y1 = 0.f;
75
		y1 = 0.f;
74
      y2 = 1/4.f;
76
		y2 = 1/4.f;
75
    }
77
	}
76
  else if (this->dir == GAUCHE)
78
	else if (this->dir == GAUCHE)
77
    {
79
	{
78
      y1 = 1/4.f;
80
		y1 = 1/4.f;
79
      y2 = 2/4.f;
81
		y2 = 2/4.f;
80
    }
82
	}
81
  else if (this->dir == BAS)
83
	else if (this->dir == BAS)
82
    {
84
	{
83
      y1 = 2/4.f;
85
		y1 = 2/4.f;
84
      y2 = 3/4.f;
86
		y2 = 3/4.f;
85
    }
87
	}
86
  else if (this->dir == DROITE)
88
	else if (this->dir == DROITE)
87
    {
89
	{
88
      y1 = 3/4.f;
90
		y1 = 3/4.f;
89
      y2 = 1.f;
91
		y2 = 1.f;
90
    }
92
	}
91
  if (deplace == true)
93
	if (this->deplace == true)
92
    {
94
	{
93
		x = 1/3.f;
95
		int t = this->mvt.GetElapsedTime() * 10;
94
    }
96
		x = (t%3)/3.f;
95
  else
97
	}
96
    x = 1/3.f;
98
	else
97
  glPushMatrix();
99
	x = 1/3.f;
98
  glEnable(GL_ALPHA_TEST);
100
	glPushMatrix();
99
  glAlphaFunc(GL_GREATER, 0.0f);
101
	glEnable(GL_ALPHA_TEST);
102
	glAlphaFunc(GL_GREATER, 0.0f);
100
103
101
	  glBindTexture(GL_TEXTURE_2D, *this->texture);
104
		glBindTexture(GL_TEXTURE_2D, *this->texture);
102
	  glBegin(GL_QUADS);
105
		glBegin(GL_QUADS);
103
	  glTexCoord2f(x + 1/3.f , y2);
106
		glTexCoord2f(x + 1/3.f , y2);
104
	  glVertex3f(this->posX, this->posY, 0);
107
		glVertex3f(this->posX, this->posY, 0);
105
	  glTexCoord2f(x + 1/3.f , y1);
108
		glTexCoord2f(x + 1/3.f , y1);
106
	  glVertex3f(this->posX, this->posY + 50, 50);
109
		glVertex3f(this->posX, this->posY + 50, 50);
107
	  glTexCoord2f(x ,y1);
110
		glTexCoord2f(x ,y1);
108
	  glVertex3f(this->posX + this->boxX, this->posY + 50, 50);
111
		glVertex3f(this->posX + this->boxX, this->posY + 50, 50);
109
	  glTexCoord2f(x , y2);
112
		glTexCoord2f(x , y2);
110
	  glVertex3f(this->posX + this->boxX, this->posY, 0);
113
		glVertex3f(this->posX + this->boxX, this->posY, 0);
111
114
112
  glEnd();
115
	glEnd();
113
  glDisable(GL_ALPHA_TEST);
116
	glDisable(GL_ALPHA_TEST);
114
117
115
  glPopMatrix();
118
	glPopMatrix();
116
119
117
}
120
}
118
121

Updated Jeu/Sources/srcs/Jeu.cpp Download diff

7475
106
{
106
{
107
  const sf::Input& Input = this->App->GetInput();
107
  const sf::Input& Input = this->App->GetInput();
108
108
109
	perso->setDeplace(false);
109
  for (unsigned int i = 0; i < this->touche.size(); i++)
110
  for (unsigned int i = 0; i < this->touche.size(); i++)
110
    {
111
    {
111
		bool	KeyDown = Input.IsKeyDown((sf::Key::Code)this->touche[i].second);
112
		bool	KeyDown = Input.IsKeyDown((sf::Key::Code)this->touche[i].second);
112
		perso->setDeplace(false);
113
		if (KeyDown == true && this->menu != i)
113
		if (KeyDown == true && this->menu != i)
114
		{
114
		{
115
			(this->*condition[this->touche[i].first].second)();
115
			(this->*condition[this->touche[i].first].second)();

Updated Jeu/Sources/srcs/Texture.cpp Download diff

7475
476
	glBindTexture(GL_TEXTURE_2D, *_texture);
476
	glBindTexture(GL_TEXTURE_2D, *_texture);
477
	glBegin(GL_QUADS);
477
	glBegin(GL_QUADS);
478
		glTexCoord2d(81/160.f, 151/250.f);
478
		glTexCoord2d(81/160.f, 151/250.f);
479
		glVertex3i(_posX, _posY + 100, 100);
479
		glVertex3i(_posX, _posY + 100, 70);
480
		glTexCoord2d(159/160.f, 151/250.f);
480
		glTexCoord2d(159/160.f, 151/250.f);
481
		glVertex3i(_posX + 80, _posY + 100, 100);
481
		glVertex3i(_posX + 80, _posY + 100, 70);
482
		glTexCoord2d(159/160.f, 249/250.f);
482
		glTexCoord2d(159/160.f, 249/250.f);
483
		glVertex3i(_posX + 80, _posY, 0);
483
		glVertex3i(_posX + 80, _posY, 0);
484
		glTexCoord2d(81/160.f, 249/250.f);
484
		glTexCoord2d(81/160.f, 249/250.f);