Exemplo n.º 1
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();
}
Exemplo n.º 2
0
void GameScene::keyReleaseEvent(QKeyEvent *keyEvent)
{
    int idx = keyIndex(keyEvent);
    if (idx == -1)
        return;

    double value = keys[idx] + (KEY_EVENT_MAX_LATENCY - timer->remainingTime());
    keys[idx] = -1;
    switch (idx) {
    case Keys::UP:
        emit moveUp(double{value} / 1000.);
        break;
    case Keys::RIGHT:
        emit moveRight(double{value} / 1000.);
        break;
    case Keys::DOWN:
        emit moveDown(double{value} / 1000.);
        break;
    case Keys::LEFT:
        emit moveLeft(double{value} / 1000.);
        break;
    case Keys::DROP_BOMB:
        emit dropBomb();
    }
}
Exemplo n.º 3
0
void Alien::update(int dt){

	AnimatedSprite::update();

	int random = rand() % 400 + 1;

		if (random == 1 && clearBelow()){
		dropBomb();
		}

	if (dir == right && getX() > GameEngine::getInstance()->getScreenWidth() - 41)
		{
			for (auto& a : GameEngine::getInstance()->getStateManager()->getCurrentState()->getObjects())
			{
			if (a->getName() == "AlienController"){
				static_cast<AlienController*>(a)->setCollideRight();
				}
			}
		}
	else if (dir == left && getX() < 10)
	{
		for (auto& a : GameEngine::getInstance()->getStateManager()->getCurrentState()->getObjects())
		{
			if (a->getName() == "AlienController"){
				static_cast<AlienController*>(a)->setCollideLeft();
		}
		}
	}
}
Exemplo n.º 4
0
int main()
{
	char x;
	
	deaths=0;
	
	for(;;)
	{
	printf("press ~ then enter to escape\n");
	printf("press Enter to drop bomb\n");
	x=getchar();
	fflush(stdin);
	if (x=='~') 
	{
		break;
		}
	dropBomb();
	printf("%d people killed by bombing!\n",deaths);
	}
	return(0);
	
}
Exemplo n.º 5
0
int bomb(int socket, t_env *e)
{
    dropBomb(e, socket);
    return 0;
}