Beispiel #1
0
bool		Explosion::update(gdl::GameClock &_clock) {
  if (this->_time == 0)
    this->_time = _clock.getTotalGameTime();
  if (this->_time + 2 < _clock.getTotalGameTime())
    return false;
  return true;
}
void ExplosionBlock::update(gdl::GameClock &clock)
{
  double    now = clock.getTotalGameTime();

  if (lastTime_ == -1.0f)
    lastTime_ = now;
  maxTime_ -= now - lastTime_;
  iter_ = 16 - (16 * maxTime_);
  lastTime_ = now;
}
Beispiel #3
0
void		Monster::update(gdl::GameClock& clock, gdl::Input& keys, std::list<AObject*>& objs)
{
  brainScript_->selectFct("thinkingMonster");
  brainScript_->addParam(pos_.x);
  brainScript_->addParam(pos_.y);
  brainScript_->callFct(1);
  update(clock, brainScript_->getDecision(), objs);
  h_ = fmod(clock.getTotalGameTime() / 2, 2);
  h_ = -((h_ - 1)*(h_ - 1)) + 1;
  h_ /= 3.0f;
  (void)keys;
}
Beispiel #4
0
void		Monster::update(gdl::GameClock& clock, eDirection direction, std::list<AObject*>& objs)
{
  std::list<AObject*>::iterator objIt;

  save_ = pos_;
  if (actionsMap_[direction])
    (this->*(actionsMap_[direction]))();
  for (objIt = objs.begin(); objIt != objs.end() && save_ != pos_; ++objIt)
    if (bBox_->collideWith(*objIt))
      (*objIt)->interact(this, objs);
  h_ = fmod(clock.getTotalGameTime() / 2, 2) / 5;
  h_ = -((h_ - 1)*(h_ - 1)) + 1;
  this->moveAnimation();
  this->model_.update(clock);
}
Beispiel #5
0
void TexturedCube::update(gdl::GameClock &clock)
{
  float		now = clock.getTotalGameTime();

  if (lastTime_ == -1)
    lastTime_ = now;
  if (startAnim_ > 0)
    startAnim_ -= (now - lastTime_);
  if (startAnim_ <= 0 && endAnim_ > 0)
    {
      coef_ = 1.0f - (endAnim_ / endAnimMax_);
      endAnim_ -= (now - lastTime_);
    }
  else if (endAnim_ <= 0)
    coef_ = 1.0f;
  lastTime_ = now;
}
Beispiel #6
0
void		Explosion::update(gdl::GameClock& clock, gdl::Input& keys, std::list<AObject*>& objs)
{
  float		now = clock.getTotalGameTime();

  (void)keys;
  (void)objs;
  if (lastTime_ == -1)
    lastTime_ = now;
  if (timeOnScreen_ <= 0)
    destroy();
  else
    {
      timeOnScreen_ -= now - lastTime_;
      lastTime_ = now;
    }
  model_.update(clock);
}
Beispiel #7
0
void		Bomberman::update(gdl::GameClock const & gameClock, gdl::Input & input)
{
  float		dist;

  if (_map->isOnFirePos(_position.x, _position.y))
    {
      _inLife = false;
      _rotation.x = 0;
      _rotation.y = 0;
      _rotation.z = 90;
    }
  if (_inLife)
    {
      _model.update(gameClock);
      if (_nextpos != _position)
	{
	  if (_moveend < gameClock.getTotalGameTime())
	    {
	      _position.x = _nextpos.x;
	      _position.y = _nextpos.y;
	      _moving = NO;
	      _model.stop_animation("Run");
	      _model.play("Take 001");
	      _model.stop_animation("Take 001");
	    }
	  else
	    {
	      dist = gameClock.getTotalGameTime() - _movetmp;
	      _movetmp += dist;
	      dist *= 250.0f;
	      if ((int)_nextpos.x > (int)_position.x)
		_position.x += dist;
	      else if ((int)_nextpos.x < (int)_position.x)
		_position.x -= dist;
	      else if ((int)_nextpos.y > (int)_position.y)
		_position.y += dist;
	      else if ((int)_nextpos.y < (int)_position.y)
		_position.y -= dist;
	    }
	}
      else
	{
	  if (input.isKeyDown(_putbomb))
	    _mygame->addBombe(_position.x, _position.y);
	  if (input.isKeyDown(_right) && _map->isEmptyPos(_position.x + 300, _position.y))
	    {
	      _nextpos.x = _position.x + 300;
	      _rotation.y = 90.0f;
	    }
	  else if (input.isKeyDown(_left) && _map->isEmptyPos(_position.x - 300, _position.y))
	    {
	      _nextpos.x = _position.x - 300;
	      _rotation.y = 270.0f;
	    }
	  else if (input.isKeyDown(_up) && _map->isEmptyPos(_position.x, _position.y + 300))
	    {
	      _nextpos.y = _position.y + 300;
	      _rotation.y = 180.0f;
	    }
	  else if (input.isKeyDown(_down) && _map->isEmptyPos(_position.x, _position.y - 300))
	    {
	      _nextpos.y = _position.y - 300;
	      _rotation.y = 0.0f;
	    }
	  if (_nextpos != _position)
	    {
	      _model.play("Run");
	      _movetmp = gameClock.getTotalGameTime();
	      _moveend = _movetmp + 1.2f;
	    }
	}
    }
}