Пример #1
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;
}
Пример #2
0
void IonCanonSatellite::process(int step)
{
	AbilityExecutor::process(step);


	int unitStep = (step + m_initialStep) % GAME_STEP_PER_SECOND;
	bool process = (unitStep % m_procStepSize) == 0;

	if(process && m_active)
	{
		m_currentAngle += m_rotation;
		if(m_currentAngle >= 360)
			m_currentAngle -= 360;

		setDirection(m_currentAngle);

		if(m_attackSecX == (getMapX() - 1) && !m_attack)
		{
			m_attack = true;
			int x = m_attackSecX;
			int y = getMapY();
			Building* target = ObjectController::getInstance()->getBuilding(x, y);

			if(target != nullptr)
			{
				m_bullet->setMapCoord(x, y, true);
				m_bullet->setTarget(target);
			}
		}
		else if(m_steps == 0)
		{
			returnToBase();
			m_freeState = true;
			m_active = false;
		}
	}
}