Beispiel #1
0
void Level::collideWithDynamicTiles(LevelMovableGameObject* mob, const sf::FloatRect* boundingBox) const
{
	for (auto& it : *m_dynamicTiles)
	{
		DynamicTile* tile = dynamic_cast<DynamicTile*>(it);
		if (tile != nullptr && (tile->getBoundingBox()->intersects(*boundingBox)))
		{
			tile->onHit(mob);
		}
	}
}
Beispiel #2
0
void Level::collideWithDynamicTiles(Spell* spell, const sf::FloatRect* boundingBox) const
{
	size_t size = m_dynamicTiles->size(); // Note: this loop type allows objects to be added to the back of the list while iterating over it.
	for (size_t i = 0; i < size; ++i)
	{
		DynamicTile* tile = dynamic_cast<DynamicTile*>(m_dynamicTiles->at(i));
		if (tile != nullptr && (tile->getBoundingBox()->intersects(*boundingBox)))
		{
			tile->onHit(spell);
		}
	}
}