Ejemplo n.º 1
0
void		Map::setPlayersMap()
{
  std::pair<int, int>	p;
  int			cornerX;
  int			cornerY;
  status		who;

  who = P1;
  srand(time(NULL));
  cornerX = 1 + (-2 * (rand() % 2));
  cornerY = 1 + (-2 * (rand() % 2));
  for (int i = 0; i < getNbPlayers(); ++i)
    {
      if (i == 1)
	{
	  who = P2;
	  cornerX = -1 * cornerX;
	  cornerY = -1 * cornerY;
	}
      p.second = (cornerX * (rand() % (getWidth()/10)+2)) + (((cornerX * -1)+1) * (getWidth()/2));
      p.first = (cornerY * (rand() % (getHeight()/10)+2)) + (((cornerY * -1)+1) * (getHeight()/2));
      setBox(std::make_pair(p.first, p.second), who);
      popTmpMap(p);
      createL(p);
    }
}
Ejemplo n.º 2
0
Shape::Shape()
{
    transformIndex = 0;
    mainBlock = sf::Vector2i(5,1);
    
    int randomBelowSeven = rand() % 7;
    
    switch (randomBelowSeven)
    {
        case 0:
            createI();
            break;
        case 1:
            createJ();
            break;
        case 2:
            createS();
            break;
        case 3:
            createO();
            break;
        case 4:
            createZ();
            break;
        case 5:
            createL();
            break;
        case 6:
            createT();
            break;
    }
    
    applyTransform(transformIndex);
}
Ejemplo n.º 3
0
void		Map::setBotsMap()
{
  std::pair<int, int>	p;

  srand(time(NULL));
  for (int i = 0; i < getNbBots(); ++i)
    {
      while (checkIfCharacter(p = getTmpMap()[rand() % getTmpMap().size()], P1) == 0
	     || checkIfCharacter(p, P2) == 0 || checkIfCharacter(p, BOT) == 0)
	;
      setBox(std::make_pair(p.first, p.second), BOT);
      popTmpMap(p);
      createL(p);
    }
}