// Jason Brillante "Damdoshi"
// Hanged Bunny Studio 2014-2015
//
// Sewer Glue

#include			"Ingame.hpp"

void				hbs::Ingame::NewPeople(void)
{
  Element			el;

  if ((el.subtype = rand() % 9) < 6)
    el.subtype %= 2;
  else
    el.subtype -= 4;
  el.people.setTexture(ressources[PEOPLE]);
  el.anim = 0;
  el.people.setTextureRect(sf::IntRect(el.subtype * 30 + ((int)el.anim % 2) * 15, 0, 15, 27));
  el.people.setOrigin(7, 0);

  el.layer = (Position)(rand() % 2);
  if (rand() % 2)
    {
      el.x = -el.people.getLocalBounds().width;
      el.speed = (rand() % levels[level].people_frequency) / 10.0 + 1;
    }
  else
    {
      el.x = ressources[BACKGROUND].getSize().x + el.people.getLocalBounds().width;
      el.speed = -(rand() % levels[level].people_frequency) / 10.0 - 1;
    }
  people.push_back(el);
}
