本文整理汇总了C++中gdl::Clock::getElapsed方法的典型用法代码示例。如果您正苦于以下问题:C++ Clock::getElapsed方法的具体用法?C++ Clock::getElapsed怎么用?C++ Clock::getElapsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdl::Clock
的用法示例。
在下文中一共展示了Clock::getElapsed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
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);
}
示例2: 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);
}
示例3: getNextAction
/*
** 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--;
}
}
}
示例4:
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);
}
示例5: 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);
}
}
示例6: getOrient
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);
}
示例7: 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();
}
示例8: update
void Bomb::update(gdl::Clock &clock)
{
this->time -= clock.getElapsed();
if (this->time <= 0)
{
this->used = false;
throw Explosion();
}
}
示例9: update
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;
}
}
示例10: updateIntro
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;
}
示例11: update
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();
}
}
示例12: draw
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()));
}
示例13: getTransformation
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());
}
示例14: update
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);
}
示例15: if
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;
}