Example #1
0
	void Level::Update(double deltaTime)
	{
		for (const auto& toUpdate : mGameObjects)
		{
			GameObjectPtr gameObject = toUpdate.second;
			RigidBodyPtr rigidBody = gameObject->GetRigidBody();
			if (rigidBody != nullptr)
			{
				gameObject->GetRigidBody()->Update(deltaTime);
				gameObject->SetTranslation(gameObject->GetRigidBody()->GetPosition());
			}
		}
		for (const auto& toUpdate : mGameObjects)
		{
			toUpdate.second->Update(deltaTime);
		}

		auto it = mGameObjects.begin();
		while(it != mGameObjects.end()) {
			if (!it->second || it->second->MarkedForDestroy()) it = mGameObjects.erase(it); 
			else it++;
		}
	}