Ejemplo n.º 1
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);
      }
  }
Ejemplo n.º 2
0
bool	Controller::Peripheral::checkKeys(gdl::Input& input)
{
  Controller::Button	buttab[] =
    {
      BUTTON_PUTBOMB,
      BUTTON_MODE,
      BUTTON_X,
      BUTTON_START,
      BUTTON_BACK,
      BUTTON_RIGHTSHOULDER,
      BUTTON_LEFTSHOULDER
    };

  _but = BUTTON_INVALID;
  for (register size_t i = _playerkeys.size() - 1 ; i >= 4 ; i--)
    if (input.getInput(_playerkeys[i]))
      {
	_but = buttab[i - 4];
	break ;
      }
  double tabangle[] = {0.0f, -90.0f, 90.0f, 0.0f, 180.0f};
  _dir.setAngle(0);
  _dir.setSpeed(0);
  for (register size_t i = 4; i--;)
    if (input.getInput(_playerkeys[i]))
      {
	_dir.setAngle(tabangle[i + 1]);
	_dir.setSpeed(static_cast<int>(RAYON));
	return (true);
      }
  return (false);
}
Ejemplo n.º 3
0
  void MenuLabel::update(gdl::GameClock const & gameClock, gdl::Input & input)
  {
    if (this->MenuDecide == false) {
      if (input.isKeyDown(gdl::Keys::Up) == true)
	{
	  this->texture_ = gdl::Image::load("../GDL-library/textures/menu_big_play.png");
	  this->MenuCurr = 1;
	}
      if (input.isKeyDown(gdl::Keys::Left) == true)
	{
	  this->texture_ = gdl::Image::load("../GDL-library/textures/menu_big_load.png");
	  this->MenuCurr = 2;
	}
      if (input.isKeyDown(gdl::Keys::Right) == true)
	{
	  this->texture_ = gdl::Image::load("../GDL-library/textures/menu_big_save.png");
	  this->MenuCurr = 3;
	}
      if (input.isKeyDown(gdl::Keys::Down) == true)
	{
	  this->texture_ = gdl::Image::load("../GDL-library/textures/menu_big_exit.png");
	  this->MenuCurr = 4;
	}
      if (input.isKeyDown(gdl::Keys::Space) == true)
	{
	  this->MenuDecide = true;
	}
    }
  }
Ejemplo n.º 4
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();
}
Ejemplo n.º 5
0
bool		Event::eventInGame(std::vector<AObject *> & players,
				   gdl::Input & input, gdl::Clock & clock, int _nb_player)
{
  for (unsigned int i = 0; i < players.size(); i++)
    {
      if ((i < 2 && _nb_player == 2) || (i < 1 && _nb_player == 1))
	{
	  if (!players[i]->isDead() &&
	      (input.getKey(static_cast<Player *>(players[i])->_event.getTop())
	       || input.getKey(static_cast<Player *>(players[i])->_event.getBot())
	       || input.getKey(static_cast<Player *>(players[i])->_event.getRight())
	       || input.getKey(static_cast<Player *>(players[i])->_event.getLeft())))
	    if ((static_cast<Bomber *>(players[i]->getObject()))->launchWalkAnim() == false)
	      return (false);
	  if (!players[i]->isDead())
	    static_cast<Player *>(players[i])->checkEvent(input, clock);
	}
      else
	{
	  if (!players[i]->isDead())
	    if (!static_cast<Player *>(players[i])->handleActionIa(clock))
	      return (false);
	}
    }
  return (true);
}
Ejemplo n.º 6
0
void	AdventureGame::update(gdl::Input& input, gdl::GameClock& gClock, StatesManager *sMg, CarrouselHandler * cH)
{
  (void)cH;
  pressEnter_.update(gClock);
  if (input.isKeyDown(gdl::Keys::Return) && !returnHit_)
    sMg->pushState(new AdventureState);
  returnHit_ = input.isKeyDown(gdl::Keys::Return);
}
Ejemplo n.º 7
0
int		Menu::updateMain(gdl::Input & input_)
{
  if (input_.isKeyDown(gdl::Keys::Up))
    {
      ((choice > 0 ? choice-- && usleep(300000) : 0));
      this->string[choice].setSize(60);
      if (choice == 0)
	{
	  this->string[1].setSize(40);
	  this->string[2].setSize(40);
	}
      else if (choice == 1)
	{
	  this->string[2].setSize(40);
	  this->string[0].setSize(40);
	}
      else
	{
	  this->string[1].setSize(40);
	  this->string[0].setSize(40);
	}
    }
  else if (input_.isKeyDown(gdl::Keys::Down))
    {
      ((choice < 2 ? choice++ && usleep(300000) : 0));
      this->string[choice].setSize(60);
      if (choice == 0)
	{
	  this->string[1].setSize(40);
	  this->string[2].setSize(40);
	}
      else if (choice == 1)
	{
	  this->string[2].setSize(40);
	  this->string[0].setSize(40);
	}
      else
	{
	  this->string[1].setSize(40);
	  this->string[0].setSize(40);
	}
    }
  else if (input_.isKeyDown(gdl::Keys::Return))
    {
      usleep(300000);
      this->string[0].setSize(60);
      this->string[1].setSize(40);
      this->string[2].setSize(40);
      this->which = choice + 1;
      this->choice = 0;
      if (this->which == 3)
	exit(0);
    }
  return (0);
}
Ejemplo n.º 8
0
void	Draw::update(gdl::Input& input, gdl::GameClock& gClock, StatesManager *sMg, CarrouselHandler *cH)
{
  (void)gClock;
  (void)cH;
  if (input.isKeyDown(gdl::Keys::Return) && !returnHit_)
    {
      sMg->popState();
      sMg->popState();
    }
  returnHit_ = input.isKeyDown(gdl::Keys::Return);
}
Ejemplo n.º 9
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);
 }
Ejemplo n.º 10
0
void	SoundConfig::update(gdl::Input& input, gdl::GameClock& gClock, StatesManager *sMg, CarrouselHandler *cH)
{
  (void)gClock;
  (void)sMg;
  (void)cH;
  for (std::map<gdl::Keys::Key, t_paramFunc>::iterator it = paramMap_.begin(); it != paramMap_.end(); ++it)
    if (input.isKeyDown(it->first))
      (this->*(it->second))();
  upHit_ = input.isKeyDown(gdl::Keys::Up);
  downHit_ = input.isKeyDown(gdl::Keys::Down);
  returnHit_ = input.isKeyDown(gdl::Keys::Return);
}
Ejemplo n.º 11
0
int		Menu::updateNew(gdl::Input & input_)
{
  if (input_.isKeyDown(gdl::Keys::Up))
    {
      ((choice > 3 ? choice-- && usleep(200000) : 0));
      this->string[choice].setSize(60);
      if (choice == 3)
	{
	  this->string[5].setSize(40);
	  this->string[4].setSize(40);
	}
      else if (choice == 4)
	{
	  this->string[3].setSize(40);
	  this->string[5].setSize(40);
	}
      else
	{
	  this->string[3].setSize(40);
	  this->string[4].setSize(40);
	}
    }
  else if (input_.isKeyDown(gdl::Keys::Down))
    {
      ((choice < 5 ? choice++ && usleep(200000) : 0));
      this->string[choice].setSize(60);
      if (choice == 3)
	{
	  this->string[5].setSize(40);
	  this->string[4].setSize(40);
	}
      else if (choice == 4)
	{
	  this->string[3].setSize(40);
	  this->string[5].setSize(40);
	}
      else
	{
	  this->string[3].setSize(40);
	  this->string[4].setSize(40);
	}
    }
  else if (input_.isKeyDown(gdl::Keys::Return))
    {
      this->string[3].setSize(60);
      this->string[4].setSize(40);
      this->string[5].setSize(40);
      usleep(200000);
      this->choice = 0;
      this->which = 3;
    }
  return (0);
}
Ejemplo n.º 12
0
void		Menu::PlayMenu(gdl::Input &input)
{
  if (input.getKey(SDLK_UP))
    {
      _cursor == 5 ? _cursor = 8 : _cursor--;
      usleep(100000);
    }
  else if (input.getKey(SDLK_DOWN))
    {
      _cursor <= 7 ? _cursor++ : _cursor = 5;
      usleep(100000);
    }
  if (_cursor == 5)
    {
      if (input.getKey(SDLK_RIGHT))
	_nbr_players = 2;
      else if (input.getKey(SDLK_LEFT))
	_nbr_players = 1;
    }
  if (_cursor == 6)
    {
      int	nbmax = _size_x / 3;
      if (input.getKey(SDLK_RIGHT))
	{
	  _nbr_enemies >= nbmax ? _nbr_enemies = 1 : _nbr_enemies += 1;
	  usleep(100000);
	}
      else if (input.getKey(SDLK_LEFT))
	{
	  _nbr_enemies >= 2 ? _nbr_enemies -= 1 : _nbr_enemies = nbmax;
	  usleep(100000);
	}
    }
  if (_cursor == 7)
    {
      if (input.getKey(SDLK_RIGHT))
	{
	  _size_x >= 100 ? _size_x = 10 : _size_x += 1;
	  _size_y >= 100 ? _size_y = 10 : _size_y += 1;
	  usleep(100000);
	}
      else if (input.getKey(SDLK_LEFT))
	{
	  _size_x > 10 ? _size_x -= 1 : _size_x = 100;
	  _size_y > 10 ? _size_y -= 1 : _size_y = 100;
	  usleep(100000);
	}
      if (_nbr_enemies > static_cast<int>(_size_x / 3))
	_nbr_enemies = _size_x/3;
    }
  if (_cursor == 8 &&
      getMapY() != 0 &&
      getMapX() != 0 &&
      getNbrEnemies() != 0 &&
      getNbrPlayers() != 0 &&
      input.getKey(SDLK_RETURN))
    _cursor = 11;
}
Ejemplo n.º 13
0
void PremadeMap::update(gdl::Input &input, gdl::GameClock &gClock, StatesManager *sMg,
                         CarrouselHandler * cH)
{
    (void)gClock;
    (void)cH;

    for (std::map<gdl::Keys::Key, void(PremadeMap::*)(StatesManager *)>::iterator it = paramMap_.begin(); it != paramMap_.end(); ++it)
    if (input.isKeyDown(it->first))
        (this->*(it->second))(sMg);

    up_ = input.isKeyDown(gdl::Keys::Up);
    down_ = input.isKeyDown(gdl::Keys::Down);
    enter_ = input.isKeyDown(gdl::Keys::Return);
}
Ejemplo n.º 14
0
bool		Window::update(gdl::Input &input) {
  _context.updateClock(_clock);
  _context.updateInputs(input);
  if (input.getInput(SDL_QUIT))
    return (false);
  return (true);
}
Ejemplo n.º 15
0
bool RandomMenu::update(gdl::Clock& clock, gdl::Input& input)
{
  _command->exec(_inputManager->getTouche(input), clock);
  if (input.getInput(SDL_BUTTON_LEFT, true) == true)
    this->getNameOfButton(input);
  return true;
}
Ejemplo n.º 16
0
void	QuickGame::update(gdl::Input& input, gdl::GameClock& gClock, StatesManager *sMg, CarrouselHandler *cH)
{
  (void)cH;
  pressEnter_.update(gClock);
  if (input.isKeyDown(gdl::Keys::Return) && !returnHit_)
    {
      try {
        Character::CharacterId = 0;
        Map	map(13, 13, 2, 0, 0);

        sMg->pushState(new PlayState(&map.getTerrain()), false);
      } catch (Map::Failure& e) {
        std::cerr << e.what() << std::endl;
      }
    }
  returnHit_ = input.isKeyDown(gdl::Keys::Return);
}
Ejemplo n.º 17
0
bool		Event::checkEvent(gdl::Input & input,
				  gdl::Clock & clock,
				  std::vector<AObject *> & players,
				  Pause & pause,
				  Menu & menu,
				  int _nb_players)
{
  // EVENT IN GAME
  if (!pause.isPaused() && !menu.isMenu() && pause.isLoading() == 0)
    {
      if (!eventInGame(players, input, clock, _nb_players))
	return (false);
    }
  // EVENT IN PAUSE
  else if (pause.isPaused() || pause.isLoading() == 3)
    {
      if (!pause.update(input, clock))
	return (false);
      if (pause.isLoading() == 0)
	{
	  if (pause.isMenu())
	    menu.setMenu(true);
	  if (!pause.isPaused())
	    desactivePause(players, pause);
	}
    }
  // EVENT IN MENU
  else
    if (!menu.update(input, clock))
      return (false);


  if (input.getInput(SDL_QUIT))
    return (false);
  if (input.getKey(SDLK_ESCAPE, true))
    {
      if (pause.isPaused())
	desactivePause(players, pause);
      else if (!menu.isMenu())
	activePause(players, pause);
    }

  return (true);
}
Ejemplo n.º 18
0
void    Character::Action(gdl::Input &input)
{
  if ((this->alive && input.isKeyDown(this->Down) == true) &&
      ((this->map->getPos(this->getPosX(), this->getPosY() + 1) >= 5) && ((this->map->getPos(this->getPosX(), this->getPosY() + 1) <= 9))))
    {
      this->rotation_->x = 0;
      this->map->setPos(9, this->getPosX(), this->getPosY());
      this->setPosY(this->getPosY() + 1);
      checkBonus(this->map->getPos(this->getPosX(), this->getPosY()));
    }

  if ((this->alive && input.isKeyDown(this->Up) == true) &&
      ((this->map->getPos(this->getPosX(), this->getPosY() - 1) >= 5) && ((this->map->getPos(this->getPosX(), this->getPosY() - 1) <= 9))))
    {
      this->rotation_->x = 180;
      this->map->setPos(9, this->getPosX(), this->getPosY());
      this->setPosY(this->getPosY() - 1);
      checkBonus(this->map->getPos(this->getPosX(), this->getPosY()));

    }
  if ((this->alive && input.isKeyDown(this->Right) == true) &&
      ((this->map->getPos(this->getPosX() + 1, this->getPosY()) >= 5) && ((this->map->getPos(this->getPosX() + 1, this->getPosY()) <= 9))))
    {
      this->rotation_->x = 90;
      this->map->setPos(9, this->getPosX(), this->getPosY());
      this->setPosX(this->getPosX() + 1);
      checkBonus(this->map->getPos(this->getPosX(), this->getPosY()));
    }
  if ((this->alive && input.isKeyDown(this->Left) == true) &&
      ((this->map->getPos(this->getPosX() - 1, this->getPosY()) >= 5) && ((this->map->getPos(this->getPosX() - 1, this->getPosY()) <= 9))))
    {
      this->rotation_->x = 270;
      this->map->setPos(9, this->getPosX(), this->getPosY());
      this->setPosX(this->getPosX() - 1);
      checkBonus(this->map->getPos(this->getPosX(), this->getPosY()));
    }
  if (this->alive && input.isKeyDown(this->Space) == true)
    {
      this->map->setPos(4, this->getPosX(), this->getPosY());
      this->dropBomb();
      //    this->map->affMap();
      //this->bomb->add_positions(new Vector3f(this->position_->x, 0.0f, this->position_->z), this->_power);
    }
}
Ejemplo n.º 19
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);
}
Ejemplo n.º 20
0
void		Menu::OptionMenu(gdl::Input &input)
{
  if (_cursor == 9 && input.getKey(SDLK_SPACE))
    {
      _cursor = 1;
      _sound = true;
      _menu_type = COMMON_MENU;
    }
  if (input.getKey(SDLK_RIGHT) || input.getKey(SDLK_LEFT))
    {
      _cursor == 9 ? _cursor = 10: _cursor = 9;
      usleep(100000);
    }
  if (_cursor == 10 && input.getKey(SDLK_SPACE))
    {
      _cursor = 1;
      _sound = false;
      _menu_type = COMMON_MENU;
    }
}
Ejemplo n.º 21
0
void FreeCam::moveCam(gdl::Input & input, float delta)
{
    if (input.getKey(SDLK_UP) || input.getKey(SDLK_z))
        translate(_target * (_speed * delta));
    if (input.getKey(SDLK_DOWN) || input.getKey(SDLK_s))
        translate(-_target * (_speed * delta));
    if (input.getKey(SDLK_LEFT) || input.getKey(SDLK_q))
        translate(_left * (_speed * delta));
    if (input.getKey(SDLK_RIGHT) || input.getKey(SDLK_d))
        translate(-_left * (_speed * delta));

    _forward = _pos + _target;
}
Ejemplo n.º 22
0
void		Menu::CommonMenu(gdl::Input &input)
{
  if (input.getKey(SDLK_UP))
    {
      _cursor >= 2 ? _cursor-- : _cursor = 4;
      usleep(100000);
    }
  else if (input.getKey(SDLK_DOWN))
    {
      _cursor <= 3 ? _cursor++ : _cursor = 1;
      usleep(100000);
    }
  if (input.getKey(SDLK_RETURN))
    {
      switch (_cursor)
	{
	case 1:
	  {
	    _menu_type = PLAY_MENU;
	    break;
	  }
	case 2:
	  {
	    _menu_type = LOAD_MENU;
	    break;

	  }
	case 3:
	  {
	    _menu_type = OPTION_MENU;
	    _sound ? _cursor = 9 : _cursor = 10;
	    break;
	  }
	case 4:
	  {
	    _menu_type = QUIT_MENU;
	    break;
	  }
	}
    }
}
Ejemplo n.º 23
0
void		Bomberman::MainMenuPlaySolo::update(const gdl::GameClock &, gdl::Input &input)
{
  Bomberman::Sound::getInstance()->playTrack(Bomberman::T_MENU);
  this->_width = this->_game->getWindow().getWidth();
  this->_height = this->_game->getWindow().getHeight();
  if (KeyHandler::handle(input, gdl::Keys::Escape))
    this->_game->getWindow().close();
  if (KeyHandler::handle(input, gdl::Mouse::Left))
    {
      int		x = input.getMousePositionX();
      int		y = input.getMousePositionY();

      manageNbrPlayers(x, y);
      manageSelectMap(x, y);
      if ((x >= getRealPosX(100) && x < getRealPosX(360)) &&
  	       (y >= getRealPosY(535) && y <= getRealPosY(555)))
  	this->startNewGame();
      if ((x >= getRealPosX(30) && x <= getRealPosX(200)))
  	{
  	  int		tmp = 335;
  	  int		i = 0;

  	  while (tmp <= 435)
  	    {
  	      if (y >= getRealPosY(tmp) && y <= getRealPosY(tmp + 10))
  		getSelected(i);
  	      tmp += 20;
  	      i++;
  	    }
  	}
      if ((x >= getRealPosX(405) && x <= getRealPosX(650)) &&
	  (y >= getRealPosY(535) && y <= getRealPosY(556)))
	this->_game->setCurrentView(new Bomberman::MainMenuLoadGame(this->_game));
      if ((x >= getRealPosX(690) && x <= getRealPosX(790)) &&
	  (y >= getRealPosY(24) && y <= getRealPosY(43)))
	this->_game->setCurrentView(new Bomberman::MainMenuCredit(this->_game));
    }
  this->getInputKeyboard(input);
}
Ejemplo n.º 24
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);
}
Ejemplo n.º 25
0
void	Pause::update(gdl::Clock const & clock, gdl::Input & input)
{
  (void)clock;
  (void)input;
  if (input.getKey(SDLK_s))
    {
      _cMode != mode::pause::QUIT ? _cMode += 1 : _cMode = mode::pause::RESUME;
      _ping.play();
      usleep(100000);
    }
  else if (input.getKey(SDLK_z))
    {
      _cMode != mode::pause::RESUME ? _cMode -= 1 : _cMode = mode::pause::QUIT;
      _ping.play();
      usleep(100000);
    }
  else if (input.getKey(SDLK_RETURN, true))
    {
      _mode = _cMode;
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    }
}
Ejemplo n.º 26
0
int		Menu::updatePlayer(gdl::Input & input_)
{
   if (input_.isKeyDown(gdl::Keys::Up))
    {
      ((choice > 0 ? choice-- && usleep(200000) : 0));
      this->string[7].setSize(60);
      this->string[8].setSize(40);
      this->nbPlay = 3;
    }
  else if (input_.isKeyDown(gdl::Keys::Down))
    {
      ((choice < 2 ? choice++ && usleep(200000) : 0));
      this->string[7].setSize(40);
      this->string[8].setSize(60);
      this->nbPlay = 4;
    }
  else if (input_.isKeyDown(gdl::Keys::Return))
    {
      usleep(200000);
      return (this->nbPlay);
    }
   return (0);
}
Ejemplo n.º 27
0
int		Menu::updateLoad(gdl::Input & input_)
{
  this->checkwd();
  if (input_.isKeyDown(gdl::Keys::Up))
    {
      ((choice > 3 ? choice-- && usleep(200000) : 0));
      this->string[6].setSize(60);
      this->fic.setSize(40);
    }
  else if (input_.isKeyDown(gdl::Keys::Down))
    {
      ((choice < 5 ? choice++ && usleep(200000) : 0));
      this->string[6].setSize(40);
      this->fic.setSize(60);
    }
  else if (input_.isKeyDown(gdl::Keys::Return))
    {
      this->string[6].setSize(60);
      this->fic.setSize(40);
      usleep(200000);
    }
  return (0);
}
Ejemplo n.º 28
0
int		Menu::update(gdl::Input & input_)
{
  int		ret;
  
  if (input_.isKeyDown(gdl::Keys::Back) && this->which != 0)
    this->which = 0;
  if (this->which == 0)
    ret = updateMain(input_);
  else if (this->which == 1)
    ret = updateNew(input_);
  else if (this->which == 2)
    ret = updateLoad(input_);
  else if (this->which == 3)
    ret = updatePlayer(input_);
  return (ret);
}
Ejemplo n.º 29
0
void Marvin::update(gdl::Clock const &clock,
                    gdl::Input &     input)
{
    this->saveCurrentState();
    
    for (std::vector<inputStructure>::iterator it = _inputs.begin(); it != _inputs.end(); ++it) {
        
        //Replace getKeyDown which is not implemented yet
        if (input.getKey(it -> value)) {
            if (it -> isPressed == false) {
                it -> isPressed = true;
                (this->*it -> functionPressed)(clock);
            }
            
            // Call the method pointer
            (this->*it -> function)(clock);
            
        } else if (it -> isPressed) { //Replace getKeyUp which is not implemented yet
            it -> isPressed = false;
            (this->*it -> functionReleased)(clock);
        }
    }
    
}
Ejemplo n.º 30
0
void newin::Light::update(gdl::GameClock const & c, gdl::Input & i) {
    (void) c;
    if (_sindex == "1") {
	if (i.isKeyDown(gdl::Keys::I)) {
	    _pos.setZ(_pos.getZ() - 0.1);
	    _changed = true;
	}
	if (i.isKeyDown(gdl::Keys::K)) {
	    _pos.setZ(_pos.getZ() + 0.1);
	    _changed = true;
	}
	if (i.isKeyDown(gdl::Keys::J)) {
	    _pos.setX(_pos.getX() - 0.1);
	    _changed = true;
	}
	if (i.isKeyDown(gdl::Keys::L)) {
	    _pos.setX(_pos.getX() + 0.1);
	    _changed = true;
	}
	if (i.isKeyDown(gdl::Keys::U)) {
	    _pos.setY(_pos.getY() - 0.1);
	    _changed = true;
	}
	if (i.isKeyDown(gdl::Keys::O)) {
	    _pos.setY(_pos.getY() + 0.1);
	    _changed = true;
	}
    }
    if (!_prgm) {
	throw newin::ShaderException("cannot use light without shader");
    }
    if (_changed){
	_changed = false;
	_prgm->setVariable("L[" + _sindex + "].Pos", _pos.getX(), _pos.getY(), _pos.getZ());
    }
}