Пример #1
0
	void GameState::DeleteGameObject(GameObject* go) {

		if (!physics_scene_->get_fetching_results()) {
			RemoveGameObject(go);
			go->release();
			//delete go;
		}
		else {
			if (std::find<std::list<GameObject*>::iterator, GameObject*>(gameobjects_to_delete_.begin(), gameobjects_to_delete_.end(), go) == gameobjects_to_delete_.end()) {
				gameobjects_to_delete_.push_back(go);
			}
		}
	}
Пример #2
0
	bool GameState::PostUpdate() {
		if (gameobjects_to_delete_.size() > 0) {
			std::list<GameObject*>::iterator itr = gameobjects_to_delete_.begin();
			for (; itr != gameobjects_to_delete_.end(); itr++) {
				GameObject* temp = *itr;
				RemoveGameObject(temp);
				temp->release();
				//delete temp;
			}
			gameobjects_to_delete_.clear();
		}
		KeyListenerPost();
		MouseListenerPost();
		JoyStickListenerPost();

		return true;
	}
Пример #3
0
void World::Update()
{
	//update all game objects- sometimes they want to die, so we need to tread carefully...

	for( int i = 0, c = mGameObjects.size(); i < c; ++i )
	{
		GameObjectPtr go = mGameObjects[ i ];
		

		if( !go->DoesWantToDie() )
		{
			go->Update();
		}
		//you might suddenly want to die after your update, so check again
		if( go->DoesWantToDie() )
		{
			RemoveGameObject( go );
			go->HandleDying();
			--i;
			--c;
		}
	}
}
Пример #4
0
void GameObjectManager::CheckBubbleSize(){
	if (m_bubbles.size() >= m_max_bubbles){
		RemoveGameObject(m_bubbles.front());
		m_bubbles.pop_front();
	}
}