Example #1
0
vector<Enemy*> Patern::spawn(Resources &res, TypeEnemy * typeenemy, bool pony, int displayEnemies,int height, int width)
{
	vector<Enemy*> e;
	sf::Vector2f pos;
	string position;
	tinyxml2::XMLElement *l = patern->FirstChildElement();

	while (l)
	{
		if (l->FirstChildElement()->GetText() == to_string(time))
		{
			int randomTExture = rand() % 4;
			position = l->FirstChildElement()->NextSiblingElement()->GetText();
			for (int i = 0; i < displayEnemies; i++)
			{
				int k = i % 7;
				if (position.substr(k, 1) == to_string(1))
					e.push_back(new Enemy(res.getImg()->getEnemy_t(),res, sf::Vector2f(width, 100 * i + height), typeenemy, randomTExture, pony));
			}
		}
		l = l->NextSiblingElement();
	}

	time++;

	return e;
}
Example #2
0
Spaceship::Spaceship(Resources &res) : anim(0,0), weapon(Weapon(res)),SpaceObject(res.getImg()->getSpaceship_t(),res,HEALTH_MAX = 1500,5)
{
	sprite.setTextureRect(sf::IntRect(anim.x, anim.y, 100, 94));
	sprite.setScale(sf::Vector2f(0.6, 0.6));
	sprite.setPosition(100, 100);
}
SpaceObject::SpaceObject(sf::Texture &t, Resources &res, int health, int speed) : explosionTexture(res.getImg()->getExplosion_t())
{
	//Create graphical object
	this->sprite.setTexture(t);

	//Set properties values
	this->health = health;
	this->speed = speed;

	//Set the explosion sound buffer
	this->explosionSound.setBuffer(res.getExplosionSnd());
	this->explosionSound.setVolume(res.getConfigXML()->getSettings()->getVolumeSound());
}