void GameEngine::UpdateSprites()
{
	//Update the sprites in the sprite vector
	RECT			rcOldSpritePos;
	SPRITEACTION	saSpriteAction;
	vector<Sprite*>::iterator siSprite;
	for (siSprite = m_vSprites.begin(); siSprite != m_vSprites.end(); siSprite++)
	{
		//Save the old sprite position in case we need to restore it
		rcOldSpritePos = (*siSprite)->GetPosition();

		//Update the sprite
		saSpriteAction = (*siSprite)->Update();

		//Handle the SA_KILL sprite action
		if (saSpriteAction & SA_KILL)
		{
			delete (*siSprite);
			siSprite = m_vSprites.erase(siSprite);
			continue;
		}

		//See if the sprite collided with any others
		if (CheckSpriteCollision(*siSprite))
			//Restore old sprite position
			(*siSprite)->SetPosition(rcOldSpritePos);
	}
}
void GameEngine::UpdateSprites()
{
  // Update the sprites in the sprite vector
  SDL_Rect      rcOldSpritePos;
  SPRITEACTION  saSpriteAction;
  vector<Sprite*>::iterator siSprite;

  //merge the sprite list with the sprite to add vector (if any)
  m_vSprites.insert(m_vSprites.begin(),
		    m_vSpritesToAdd.begin(),
		    m_vSpritesToAdd.end());
  m_vSpritesToAdd.clear();
  
  for (siSprite = m_vSprites.begin(); siSprite != m_vSprites.end(); siSprite++)
  {
    // Save the old sprite position in case we need to restore it
    rcOldSpritePos = (*siSprite)->GetPosition();

    // Update the sprite
    saSpriteAction = (*siSprite)->Update();

    // Handle the SA_ADDSPRITE sprite action
    if (saSpriteAction & SA_ADDSPRITE)
      // Allow the sprite to add its sprite
      AddSprite((*siSprite)->AddSprite());
    
    // Handle the SA_KILL sprite action
    if (saSpriteAction & SA_KILL)
    {
      // Notify the game that the sprite is dying
      m_game->SpriteDying(*siSprite);
      
      // Kill the sprite
      delete (*siSprite);
      m_vSprites.erase(siSprite);
      siSprite--;
      continue;
    }

    // See if the sprite collided with any others
    if (CheckSpriteCollision(*siSprite))
      // Restore the old sprite position
      (*siSprite)->SetPosition(rcOldSpritePos);
  }
}
void GameEngine::UpdateSprites()
{
	//Update the sprites in the sprite vector
	RECT			rcOldSpritePos;
	SPRITEACTION	saSpriteAction;
	vector<Sprite*>::iterator siSprite;
	siSprite = m_vSprites.begin(); 
	while (siSprite != m_vSprites.end())
	{
		//Save the old sprite position in case we need to restore it
		rcOldSpritePos = (*siSprite)->GetPosition();

		//Update the sprite
		saSpriteAction = (*siSprite)->Update();

		//Handle the SA_ADDSPRITE sprite action
		if (saSpriteAction & SA_ADDSPRITE)
			//Allow the sprite to add its sprite
			AddSprite((*siSprite)->AddSprite());

		//Handle the SA_KILL sprite action
		if (saSpriteAction & SA_KILL)
		{
			//Notify the game that the sprite is dying
			SpriteDying(*siSprite);

			siSprite = m_vSprites.erase(siSprite);
			continue;
		}

		//See if the sprite collided with any others
		if (CheckSpriteCollision(*siSprite))
			//Restore old sprite position
			(*siSprite)->SetPosition(rcOldSpritePos);

		if (siSprite == m_vSprites.end() || m_vSprites.size() == 0)
		{
			break;
		}
			++siSprite;
	}
}