Esempio n. 1
0
int	Intro::GameIntro::update(gdl::Clock const& clock, gdl::Input &input)
{
  _introtime -= clock.getElapsed();
  if (_cam->getLookAt().y - clock.getElapsed() * 10 > 0)
    _cam->getLookAt().y -= clock.getElapsed() * 10;
  _cam->getCameraDiff().z += clock.getElapsed() * 5;
  if (_introtime <= 0 || input.getKey(SDLK_SPACE))
    return (0);
  return (4);
}
Esempio n. 2
0
 virtual void update(gdl::Clock const &clock, gdl::Input &input)
 {
   if (input.getKey(SDLK_UP))
     translate(glm::vec3(0, 0, 1) * static_cast<float>(clock.getElapsed()) * _speed);
   if (input.getKey(SDLK_DOWN))
     translate(glm::vec3(0, 0, -1) * static_cast<float>(clock.getElapsed()) * _speed);
   if (input.getKey(SDLK_LEFT))
     translate(glm::vec3(-1, 0, 0) * static_cast<float>(clock.getElapsed()) * _speed);
   if (input.getKey(SDLK_RIGHT))
     translate(glm::vec3(1, 0, 0) * static_cast<float>(clock.getElapsed()) * _speed);
 }
Esempio n. 3
0
/*
**	Update the player action.
*/
void	Bot::update(gdl::Clock const &clock, Field& map)
{
  float	add;
  int	action;

  if (_character->isDancing())
    return ;
  action = getNextAction(map);
  if (action < 0 || action == STAGN)
    {
      if (++_nbrStagnTurns > STAGN_LIMIT)
	action = PUT_BOMB;
    }
  else
    _nbrStagnTurns = 0;
  if ((add = 0.1f * static_cast<float>(clock.getElapsed()) * SPEED(_speed)) > BOT_MAX_SPEED)
    add = BOT_MAX_SPEED;
  if (action < 4)
    (_character->*_launchMove[action])(add);
  else
    {
      _character->pauseModel();
      if (action == PUT_BOMB && map.getMap()[_character->getY()][_character->getX()] == NULL && _bombs > 0)
	{
	  map.getMap()[_character->getY()][_character->getX()] = new Bomb(static_cast<int>(_character->getY()), static_cast<int>(_character->getX()), this, *map.getModels()["Bomb"]);
	  map.getMap()[_character->getY()][_character->getX()]->initialize();
	  _bombs--;
	}
    }
}
Esempio n. 4
0
void	Bomb::update(UNUSED gdl::Input &input, gdl::Clock const &clock)
{
  _obj->scale(glm::vec3(1.0025f, 1.0025f, 1.0025f));

  if (_status == BURNING || _time.update(clock.getElapsed()))
    this->explode(clock);
}
Esempio n. 5
0
  // Ici le cube bougera avec les fleches du clavier
  virtual void update(gdl::Clock const &clock, gdl::Input &input)
  {
    glm::vec3 pos = glm::vec3(0, 0, 0);
    float delta = static_cast<float>(clock.getElapsed()) * _speed;
    // On multiplie par le temps ecoule depuis la derniere image pour que la vitesse ne depende pas de la puissance de l'ordinateur
    if (input.getKey(SDLK_UP))
      {
	pos.x = 1;
	_rotation.y = -90;
	translate(pos * delta);  
      }
    if (input.getKey(SDLK_DOWN))
      {
	pos.x = -1;
	_rotation.y = 90;
	translate(pos * delta);
      }
    if (input.getKey(SDLK_LEFT))
      {
	pos.z = -1;
	_rotation.y = 180;
	translate(pos * delta);
      }
    if (input.getKey(SDLK_RIGHT))
      {
	pos.z = 1;
	_rotation.y = 0;
	translate(pos * delta);
      }
  }
Esempio n. 6
0
void		Trantorien::draw(t_player *tmp, gdl::AShader &shader, gdl::Clock const &clock)
{
  tmp->time += clock.getElapsed();
  // Set la position
  _position = glm::vec3(tmp->x + 1.5, 0.5, tmp->y + 1.5);
  _scale = glm::vec3(tmp->l / 2.0f, tmp->l / 2.0f, tmp->l / 2.0f);
  
  // set L'orientation
  _orient = getOrient(_posCam);
  float		angle;
  angle  = scalaire(glm::vec2(0, 1), glm::vec2(_position.z - _posCam.z,
					       _position.x - _posCam.x));
  if (_position.z < _posCam.z)
    rotate(glm::vec3(0, 1, 0), (angle) * 180 / PI);
  else
    rotate(glm::vec3(0, -1, 0), (angle) * 180 / PI);
  int a = _orient + tmp->o;
  if (a > 4)
    a -= 4;
  // Set l'animation
  if (tmp->anime > _nb_anime - 1)
    tmp->anime = 0;
  // Bind la texture et draw
  (void)clock;
  _geometry[a - 1][tmp->anime].draw(shader, getTransformation(), GL_QUADS);
  _rotation = glm::vec3(0, 0, 0);
}
Esempio n. 7
0
void				Player::update(gdl::Clock const& clock,
					       gdl::Input& input)
{
  _timeReload -= clock.getElapsed();
  if (_timeReload <= 0.0f)
    {
      _bombCount = ((_bombCount < _maxBombCount) ? _maxBombCount : _bombCount);
      _timeReload = 1.5f;
    }
  if (input.getKey(_controls[DROPBOMB], false))
    dropBomb(clock);
  for (int i = TOP; i != NONE; i++)
    {
      if (input.getKey(_controls[static_cast<e_dir>(i)], false))
	{
	  moveTo(static_cast<e_dir>(i), clock);
	  return ;
	}
    }
  if (_hasToStop == true)
    {
      _model->setCurrentSubAnim("end", false);
      _hasToStop = false;
    }
  checkPlayerDeath();
}
Esempio n. 8
0
void Bomb::update(gdl::Clock &clock)
{
  this->time -= clock.getElapsed();
  if (this->time <= 0)
    {
      this->used = false;
      throw Explosion();
    }
}
Esempio n. 9
0
  virtual void update(const gdl::Clock& clock, const gdl::Input& input)
  {
    _timeout += static_cast<float>(clock.getElapsed());
    if (_timeout > 3.0f)
      {
	_exploded = true;
	_timeout = 0.0f;
      }
  }
Esempio n. 10
0
bool Intro::updateIntro(UNUSED gdl::Input &input, const gdl::Clock &clock)
{
  if (_state == Running)
    {
      if (_pos.x > 0.0)
        {
          _pos.x += -(clock.getElapsed() * _speed);
          _logo->translate(glm::vec3(-(clock.getElapsed() * _speed), 0, 0));
          _bomb->translate(glm::vec3(-(clock.getElapsed() * _speed), 0, 0));
          // _bomb->rotate(glm::vec3(0, 1, 0), 1.0f);
          if (input.getKey(SDLK_RETURN, true) || _skipMenu)
            {
              _logo->translate(glm::vec3(-(_pos.x), 0, 0));
              _bomb->translate(glm::vec3(-(_pos.x), 0, 0));
              _pos.x = 0.0;
            }
        }
      else
        {
          _player->translate(glm::vec3(0.0, 0.5f, 0.0));
          //          _logo->translate(glm::vec3(0, 5, 0));
          _state = Menu;
          _menu = new ::Menu(_cam);
        }
    }
  else if (_state == Menu)
    {
      if (_menu->finish())
        _state = Finished;
      if (_pos.y < 4.0)
        {
          _pos.y += clock.getElapsed() * _speed;
          _logo->translate(glm::vec3(0, clock.getElapsed() * _speed, 0));
          _bomb->translate(glm::vec3(0, clock.getElapsed() * _speed, 0));
        }
      if (_pos2.y > 27.5)
        {
          _player->translate(glm::vec3(_pos2.y, 0, 0));
          _pos2.y = 0.0;
        }
      else
        {
          _bomb->scale(glm::vec3(1.00001f, 1.00001f, 1.00001f));
          //_bomb->rotate(glm::vec3(0, 1, 0), 1.0f);
          _pos2.y += clock.getElapsed() * _speed;
          _player->translate(glm::vec3(-(clock.getElapsed() * _speed), 0, 0));
        }
      return _menu->updateMenu(input, clock);
    }
  _pos2.y += clock.getElapsed() * _speed;
  _player->translate(glm::vec3(-(clock.getElapsed() * _speed), 0, 0));
  _cam->update(glm::vec2(_pos.x, _pos.y));
  return true;
}
Esempio n. 11
0
void Bomb::update(const gdl::Clock& clock, gdl::Input& input) {

    this->_time += clock.getElapsed();
    
    if (this -> _time >= BOMBTIME) {
        this -> die();
        this -> createFire();
        this -> _parentObject -> addBombToBag();
    }
}
Esempio n. 12
0
 virtual void draw(gdl::AShader &shader, gdl::Clock const &clock)
 {
   (void)clock;
   // On bind la texture pour dire que l'on veux l'utiliser
   // Et on dessine notre cube
   // std::cout << static_cast<float>(clock.getElapsed()) * _speed << std::endl;
   // std::cout << "pos x: " << _position.x <<  " pos y: " << _position.y <<  "pos z: " << _position.z << std::endl;
   // std::cout << _rotation << std::endl;
   this->bomberman.draw(shader, getTransformation(), static_cast<float>(clock.getElapsed()));
 }
Esempio n. 13
0
void			Player::draw(gdl::AShader& shader, gdl::Clock const& clock)
{
  if (_isAnim)
    _frameRate += 1;
  if (_frameRate == _frameDuration)
    {
      _frameRate = 0;
      _isAnim = false;
    }
  _model->draw(shader, getTransformation(), clock.getElapsed());
}
Esempio n. 14
0
void FreeCam::update(gdl::Input& input, const gdl::Clock& clock)
{
    float delta;

    delta = static_cast<float>(clock.getElapsed());

    glm::ivec2 motion = input.getMouseDelta();
    _theta += (_sensivity * static_cast<float>(motion.x));
    _phi -= (_sensivity * static_cast<float>(motion.y));
    vectorsFromAngles();

    moveCam(input, delta);
}
Esempio n. 15
0
bool			Player::moveTo(const e_dir direction, gdl::Clock const &clock)
{
  glm::vec3		possibleTranslate = _directionVector[direction] * static_cast<float>(clock.getElapsed()) * _speed;
  e_dir			directionTmp;

  _hasToStop = true;
  if (!_isAnim && (_isAnim = true))
    _model->setCurrentSubAnim("move", false);
  if (checkCollision(_position + possibleTranslate))
    {
      _lastTranslate = translate(possibleTranslate);
    }
  else if ((directionTmp = checkAutoMove(direction)) != NONE)
    {
      possibleTranslate = _directionVector[directionTmp] * static_cast<float>(clock.getElapsed()) * _speed;
      if (checkCollision(_position + possibleTranslate))
	_lastTranslate = translate(possibleTranslate);
    }
  setRotate(_rotationVector[direction]);
  checkPlayerDeath();
  return true;
}
Esempio n. 16
0
void			Cloud::update(gdl::Clock & clock, Scene *scene)
{
  (void)scene;
  if (this->_current) {
    if (this->_dir == 1)
      this->translate(glm::vec3(this->_range, 0, 0) * static_cast<float>(50 * clock.getElapsed()));
    else
      this->translate(glm::vec3(this->_range * -1.0f, 0, 0) * static_cast<float>(50 * clock.getElapsed()));
    if (this->getPos().x > this->_originalPos.x + this->_gap)
      this->_dir = 0;
    else if (this->getPos().x < this->_originalPos.x - this->_gap)
      this->_dir = 1;
  }
}
Esempio n. 17
0
void GameInput::move(Display *display, APlayer *player, Map &map, const gdl::Clock &clock) {
    glm::vec3 translation(0, 0, 0);

    if (this->turnLeft()) {
        translation = glm::vec3(0, 0, 1) * static_cast<float>(clock.getElapsed()) * 3.0f;
    } else if (this->turnRight()) {
        translation = glm::vec3(0, 0, -1) * static_cast<float>(clock.getElapsed()) * 3.0f;
    } else if (this->turnUp()) {
        translation = glm::vec3(-1, 0, 0) * static_cast<float>(clock.getElapsed()) * 3.0f;
    } else if (this->turnDown()) {
        translation = glm::vec3(1, 0, 0) * static_cast<float>(clock.getElapsed()) * 3.0f;
    }

    display->setTranslation(translation);
    player->translate(translation);

    glm::vec3 pos(-player->getPosition().x, player->getPosition().y, -player->getPosition().z);

    if (map.canMoveAt(pos)) {
        display->setTranslation(-translation);
        player->translate(-translation);
    }
}
Esempio n. 18
0
void	Bomb::explode(gdl::Clock const &clock)
{
  if (_status == DESTROY)
    return ;
  _status = BURNING;
  if (!_distance)
    SoundManager::getInstance()->manageSound(SoundManager::BOMB_EXPLOSION, SoundManager::PLAY);
  _distance += clock.getElapsed() * _speed;
  if (_distance >= _range)
    _distance = _range;
  this->spread();
  if (_status != DESTROY && _distance >= _range && _staytime.update(clock.getElapsed()))
    {
      _fireList.clear();
      _status = DESTROY;
      _player->setStockBomb(_player->getStockBomb() + 1);
      for (std::vector<ABonus *>::iterator it = _generatedBonus.begin();
           it != _generatedBonus.end(); ++it)
        {
          _map->addEntity(*it);
        }
      _generatedBonus.clear();
    }
}
Esempio n. 19
0
void ArtificialPlayer::update(const gdl::Clock &clock, std::vector<std::vector<AObject *> > &map, std::list<APlayer *> &players)
{
  (void)players;
  this->_elapse = clock.getElapsed();
  if (this->_x != this->_objX || this->_y != this->_objY)
    {
      if (this->_x + (this->_w + this->_w / 10) < this->_objX)
	this->goRight(map, clock);
      else if (this->_x > this->_objX)
	this->goLeft(map, clock);
      else if (this->_y + (this->_h + this->_h / 10) < this->_objY)
	this->goDown(map, clock);
      else if (this->_y > this->_objY)
	this->goUp(map, clock);
      else
	{
	  this->_objX = this->_x;
	  this->_objY = this->_y;
	  this->wait();
	}
    }
  else if (this->isDanger(map, this->_x, this->_y))
    {
      if (!map[this->_y - 1][this->_x] && !this->isDanger(map, this->_x, this->_y - 1))
	this->_objY -= 0.9;
      else if (!map[this->_y][this->_x + 1] && !this->isDanger(map, this->_x + 1, this->_y))
	this->_objX += 0.9;
      else if (!map[this->_y + 1][this->_x] && !this->isDanger(map, this->_x, this->_y + 1))
	this->_objY += 0.9;
      else if (!map[this->_y][this->_x - 1] && !this->isDanger(map, this->_x - 1, this->_y))
	this->_objX -= 0.9;
    }
  else
    {
      this->_objX = this->_x;
      this->_objY = this->_y;
    }
}
Esempio n. 20
0
void Animation::update(const gdl::Clock & clock) {
  _timePassed += clock.getElapsed();
}
Esempio n. 21
0
void ItemRange::update(const gdl::Clock& clock, gdl::Input &input) {
    (void)input;

    _elapsed_time += clock.getElapsed();
}
Esempio n. 22
0
void		IA::draw(gdl::AShader &shader, gdl::Clock const& clock)
{
  this->_ia.draw(shader, getTransformation(), clock.getElapsed());
}
Esempio n. 23
0
void	Egg::draw(gdl::AShader& shader, gdl::Clock const & clock)
{
  _model->draw(shader, getTransformation(), clock.getElapsed());
}
Esempio n. 24
0
void		IA::move(gdl::Clock const& clock, int input, std::vector<AObject*>&object)
{
  float move_val;

  move_val = 1 * static_cast<float>(clock.getElapsed()) * _speed;
  if (input == 0)
    {
      if (_map[round(_x)][round(_y + move_val + 0.4)] != NULL)
	return ;
      _y += 1 * static_cast<float>(clock.getElapsed()) * _speed;
      if (_y >= _height - 2)
	{
	  _y = _height - 2;
	  return ;
	}
      translate(glm::vec3(0, 0, 1) * static_cast<float>(clock.getElapsed()) * _speed);
    }
  if (input == 1)
    {
      if (_y > 2)
	if (_map[round(_x)][round(_y - move_val - 0.4)] != NULL)
	  return ;
      _y -= 1 * static_cast<float>(clock.getElapsed()) * _speed;
      if (_y < 1)
	{
	  _y = 1;
	  return ;
	}
      translate(glm::vec3(0, 0, -1) * static_cast<float>(clock.getElapsed()) * _speed);
    }
  if (input == 2)
    {
      if (_map[round(_x + move_val + 0.4)][round(_y)] != NULL)
	return ;
      _x += 1 * static_cast<float>(clock.getElapsed()) * _speed;
      if (_x >= _widht - 2)
	{
	  _x = _widht - 2;
	  return ;
	}
      translate(glm::vec3(1, 0, 0) * static_cast<float>(clock.getElapsed()) * _speed);
    }    
  if (input == 3)
    {
      if (_map[round(_x - move_val - 0.4)][round(_y)] != NULL)
	return ;
      _x -= 1 * static_cast<float>(clock.getElapsed()) * _speed;
      if (_x < 1)
	{
	  _x = 1;
	  return;
	}
      translate(glm::vec3(-1, 0, 0) * static_cast<float>(clock.getElapsed()) * _speed);
    }
  if (input == 4 && this->_nbbomb != 0)
    {
      AObject *bomb = new Bomb(round(_x), round(_y));
      this->_bomb.push_back(bomb);
      if(bomb->initialize() == false)
	{
	  std::cerr << "Cannot load the bomb" << std::endl;
	  return ;
	}
      object.push_back(bomb);
      this->_nbbomb = 0;
    }
  this->_nbbomb = 1; 
}
Esempio n. 25
0
void Bomb::show(gdl::AShader &shader, gdl::Clock &clock)
{
  this->model.draw(shader, this->getTransformation(), clock.getElapsed());
}
Esempio n. 26
0
void			GameButton::update(gdl::Clock & clock, Scene *scene)
{
  (void)scene;
  if (this->_current)
    this->rotate(glm::vec3(1, 0, 0), (50 * clock.getElapsed()));
}
Esempio n. 27
0
bool			Human::update(gdl::AShader &s, const gdl::Clock &c, gdl::Input &i, const std::vector<Block *> &list, const std::vector<Block *> &wall, std::vector<Bonus *> &listBonus)
{
  glm::mat4		transformation;

  transformation = glm::lookAt(glm::vec3(this->_position.x, this->_position.y - 3, 5), glm::vec3(this->_position.x, this->_position.y, this->_position.z), glm::vec3(0, 1, 0));
  s.setUniform("view", transformation);
  if (this->_number == 0)
    {
      if (i.getKey(SDLK_DOWN))
	{
	  double	x = round(this->_position.x);
	  double	y = round(this->_position.y - 0.5);
	  for (double i = 0; i < list.size(); ++i)
	    {
	      if (x == round(list[i]->getPos().x) && y == round(list[i]->getPos().y) && this->_position.z == list[i]->getPos().z)
		return (true);
	    }
	  for (double i = 0; i < wall.size(); ++i)
	    {
	      if (x == round(wall[i]->getPos().x) && y == round(wall[i]->getPos().y) && this->_position.z == wall[i]->getPos().z)
		return (true);
	    }
	  for (double i = 0; i < listBonus.size(); i++)
	    {
	      if (x == round(listBonus[i]->getPos().x) && y == round(listBonus[i]->getPos().y))
		{
		  this->pickUpBonus(listBonus, i);
		}
	    }
	  switch (this->_dir)
	    {
	    case Player::UP:
	      this->rotate(glm::vec3(0, -1, 0), 180);
	      break;
	    case Player::LEFT:
	      this->rotate(glm::vec3(0, -1, 0), 270);
	      break;
	    case Player::RIGHT:
	      this->rotate(glm::vec3(0, -1, 0), 90);
	      break;
	    }
	  this->_dir = Player::DOWN;      
	  this->translate(glm::vec3(0, -1, 0) * static_cast<float>(c.getElapsed()) * this->speed);
	}
      if (i.getKey(SDLK_UP))
	{
	  double	x = round(this->_position.x);
	  double	y = round(this->_position.y + 0.5);
 
	  for (double i = 0; i < list.size(); ++i)
	    {
	      if (x == round(list[i]->getPos().x) && y == round(list[i]->getPos().y) && this->_position.z == list[i]->getPos().z)
		return (true);
	    }
	  for (double i = 0; i < wall.size(); ++i)
	    {
	      if (x == round(wall[i]->getPos().x) && y == round(wall[i]->getPos().y) && this->_position.z == wall[i]->getPos().z)
		return (true);
	    }
	  for (double i = 0; i < listBonus.size(); i++)
	    if (x == round(listBonus[i]->getPos().x) && y == round(listBonus[i]->getPos().y))
	      this->pickUpBonus(listBonus, i);
	  switch (this->_dir)
	    {
	    case Player::DOWN:
	      this->rotate(glm::vec3(0, -1, 0), 180);
	      break;
	    case Player::LEFT:
	      this->rotate(glm::vec3(0, -1, 0), 90);
	      break;
	    case Player::RIGHT:
	      this->rotate(glm::vec3(0, -1, 0), 270);
	      break;
	    }
	  this->_dir = Player::UP;    
	  this->translate(glm::vec3(0, 1, 0) * static_cast<float>(c.getElapsed()) * this->speed);
	}
      if (i.getKey(SDLK_RIGHT))
	{
	  double	x = round(this->_position.x + 0.5);
	  double	y = round(this->_position.y);

	  for (double i = 0; i < list.size(); ++i)
	    {
	      if (x == round(list[i]->getPos().x) && y == round(list[i]->getPos().y) && this->_position.z == list[i]->getPos().z)
		return (true);
	    }
	  for (double i = 0; i < wall.size(); ++i)
	    {
	      if (x == round(wall[i]->getPos().x) && y == round(wall[i]->getPos().y) && this->_position.z == wall[i]->getPos().z)
		return (true);
	    }    
	  for (double i = 0; i < listBonus.size(); i++)
	    if (x == round(listBonus[i]->getPos().x) && y == round(listBonus[i]->getPos().y))
	      this->pickUpBonus(listBonus, i);
	  switch (this->_dir)
	    {
	    case Player::UP:
	      this->rotate(glm::vec3(0, -1, 0), 90);
	      break;
	    case Player::LEFT:
	      this->rotate(glm::vec3(0, -1, 0), 180);
	      break;
	    case Player::DOWN:
	      this->rotate(glm::vec3(0, -1, 0), 270);
	      break;
	    }
	  this->_dir = Player::RIGHT;    
	  this->translate(glm::vec3(1, 0, 0) * static_cast<float>(c.getElapsed()) * this->speed);
	}
      if (i.getKey(SDLK_LEFT))
	{
	  double	x = round(this->_position.x - 0.5);
	  double	y = round(this->_position.y);

	  for (double i = 0; i < list.size(); ++i)
	    {
	      if (x == round(list[i]->getPos().x) && y == round(list[i]->getPos().y) && this->_position.z == list[i]->getPos().z)
		return (true);
	    }
	  for (double i = 0; i < wall.size(); ++i)
	    {
	      if (x == round(wall[i]->getPos().x) && y == round(wall[i]->getPos().y) && this->_position.z == wall[i]->getPos().z)
		return (true);
	    }
	  for (double i = 0; i < listBonus.size(); i++)
	    if (x == round(listBonus[i]->getPos().x) && y == round(listBonus[i]->getPos().y))
	      this->pickUpBonus(listBonus, i);
	  switch (this->_dir)
	    {
	    case Player::RIGHT:
	      this->rotate(glm::vec3(0, -1, 0), 180);
	      break;
	    case Player::UP:
	      this->rotate(glm::vec3(0, -1, 0), 270);
	      break;
	    case Player::DOWN:
	      this->rotate(glm::vec3(0, -1, 0), 90);
	      break;
	    }
	  this->_dir = Player::LEFT;
	  this->translate(glm::vec3(-1, 0, 0) * static_cast<float>(c.getElapsed()) * this->speed);
	}
    }  
  if (this->_number == 1)
    {
      if (i.getKey(SDLK_s))
	{
	  double	x = round(this->_position.x);
	  double	y = round(this->_position.y - 0.5);

	  for (double i = 0; i < list.size(); ++i)
	    {
	      if (x == round(list[i]->getPos().x) && y == round(list[i]->getPos().y) && this->_position.z == list[i]->getPos().z)
		return (true);
	    }

	  for (double i = 0; i < wall.size(); ++i)
	    {
	      if (x == round(wall[i]->getPos().x) && y == round(wall[i]->getPos().y) && this->_position.z == wall[i]->getPos().z)
		return (true);
	    }
	  for (double i = 0; i < listBonus.size(); i++)
	    if (x == round(listBonus[i]->getPos().x) && y == round(listBonus[i]->getPos().y))
	      this->pickUpBonus(listBonus, i);
	  switch (this->_dir)
	    {
	    case Player::UP:
	      this->rotate(glm::vec3(0, -1, 0), 180);
	      break;
	    case Player::LEFT:
	      this->rotate(glm::vec3(0, -1, 0), 270);
	      break;
	    case Player::RIGHT:
	      this->rotate(glm::vec3(0, -1, 0), 90);
	      break;
	    }
	  this->_dir = Player::DOWN;      
	  this->translate(glm::vec3(0, -1, 0) * static_cast<float>(c.getElapsed()) * this->speed);
	}
      if (i.getKey(SDLK_z))
	{
	  double	x = round(this->_position.x);
	  double	y = round(this->_position.y + 0.5);

	  for (double i = 0; i < list.size(); ++i)
	    {
	      if (x == round(list[i]->getPos().x) && y == round(list[i]->getPos().y) && this->_position.z == list[i]->getPos().z)
		return (true);
	    }        
	  for (double i = 0; i < wall.size(); ++i)
	    {
	      if (x == round(wall[i]->getPos().x) && y == round(wall[i]->getPos().y) && this->_position.z == wall[i]->getPos().z)
		return (true);
	    }
	  for (double i = 0; i < listBonus.size(); i++)
	    if (x == round(listBonus[i]->getPos().x) && y == round(listBonus[i]->getPos().y))
	      this->pickUpBonus(listBonus, i);
	  switch (this->_dir)
	    {
	    case Player::DOWN:
	      this->rotate(glm::vec3(0, -1, 0), 180);
	      break;
	    case Player::LEFT:
	      this->rotate(glm::vec3(0, -1, 0), 90);
	      break;
	    case Player::RIGHT:
	      this->rotate(glm::vec3(0, -1, 0), 270);
	      break;
	    }
	  this->_dir = Player::UP;    
	  this->translate(glm::vec3(0, 1, 0) * static_cast<float>(c.getElapsed()) * this->speed);
	}
      if (i.getKey(SDLK_d))
	{
	  double	x = round(this->_position.x + 0.5);
	  double	y = round(this->_position.y);

	  for (double i = 0; i < list.size(); ++i)
	    {
	      if (x == round(list[i]->getPos().x) && y == round(list[i]->getPos().y) && this->_position.z == list[i]->getPos().z)
		return (true);
	    }
	  for (double i = 0; i < wall.size(); ++i)
	    {
	      if (x == round(wall[i]->getPos().x) && y == round(wall[i]->getPos().y) && this->_position.z == wall[i]->getPos().z)
		return (true);
	    }
	  for (double i = 0; i < listBonus.size(); i++)
	    if (x == round(listBonus[i]->getPos().x) && y == round(listBonus[i]->getPos().y))
	      this->pickUpBonus(listBonus, i);
	  switch (this->_dir)
	    {
	    case Player::UP:
	      this->rotate(glm::vec3(0, -1, 0), 90);
	      break;
	    case Player::LEFT:
	      this->rotate(glm::vec3(0, -1, 0), 180);
	      break;
	    case Player::DOWN:
	      this->rotate(glm::vec3(0, -1, 0), 270);
	      break;
	    }
	  this->_dir = Player::RIGHT;    
	  this->translate(glm::vec3(1, 0, 0) * static_cast<float>(c.getElapsed()) * this->speed);
	}
      if (i.getKey(SDLK_q))
	{
	  double	x = round(this->_position.x - 0.5);
	  double	y = round(this->_position.y);

	  for (double i = 0; i < list.size(); ++i)
	    {
	      if (x == round(list[i]->getPos().x) && y == round(list[i]->getPos().y) && this->_position.z == list[i]->getPos().z)
		return (true);
	    }
	  for (double i = 0; i < wall.size(); ++i)
	    {
	      if (x == round(wall[i]->getPos().x) && y == round(wall[i]->getPos().y) && this->_position.z == wall[i]->getPos().z)
		return (true);
	    }
	  for (double i = 0; i < listBonus.size(); i++)
	    if (x == round(listBonus[i]->getPos().x) && y == round(listBonus[i]->getPos().y))
	      this->pickUpBonus(listBonus, i);
	  switch (this->_dir)
	    {
	    case Player::RIGHT:
	      this->rotate(glm::vec3(0, -1, 0), 180);
	      break;
	    case Player::UP:
	      this->rotate(glm::vec3(0, -1, 0), 270);
	      break;
	    case Player::DOWN:
	      this->rotate(glm::vec3(0, -1, 0), 90);
	      break;
	    }
	  this->_dir = Player::LEFT;
	  this->translate(glm::vec3(-1, 0, 0) * static_cast<float>(c.getElapsed()) * this->speed);
	}
    }
  transformation = glm::lookAt(glm::vec3(this->_position.x, this->_position.y - 3, 5), glm::vec3(this->_position.x, this->_position.y, this->_position.z), glm::vec3(0, 1, 0));
  s.setUniform("view", transformation);
  return (true);
}
Esempio n. 28
0
void ItemRange::draw(gdl::AShader& shader, const gdl::Clock& clock) {
    _model.draw(shader, getTransformation(), clock.getElapsed());
}
Esempio n. 29
0
 void	animatedVertex::draw(gdl::AShader &shader, gdl::Clock const& clock) {
   _model.draw(shader, getTransformation(), clock.getElapsed());
 }
Esempio n. 30
0
void SkyBox::update(gdl::Clock const &clock)
{
  _cube->rotate(glm::vec3(1, 1, 0.6), 1.2f * clock.getElapsed());
}