本文整理汇总了C++中gdl::Input类的典型用法代码示例。如果您正苦于以下问题:C++ Input类的具体用法?C++ Input怎么用?C++ Input使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Input类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
// 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);
}
}
示例2: return
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);
}
示例3: update
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;
}
}
}
示例4: dropBomb
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();
}
示例5: return
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);
}
示例6:
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);
}
示例7: if
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);
}
示例8:
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);
}
示例9: update
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);
}
示例10:
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);
}
示例11: if
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;
}
示例12: update
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);
}
示例13: return
bool Window::update(gdl::Input &input) {
_context.updateClock(_clock);
_context.updateInputs(input);
if (input.getInput(SDL_QUIT))
return (false);
return (true);
}
示例14: update
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;
}
示例15: PlayState
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);
}