Game Change Levels

Get answers to all your basic programming questions. No Ogre questions, please!
marcalaque
Kobold
Posts: 29
Joined: Sun Jul 21, 2013 9:51 am

Game Change Levels

Post by marcalaque »

I have a problem on my game on how to change levels if the player finishes the quest
Example the player finishes the quest in level 1 then after the player will be going to the level 2 and finish again the quest
I am thinking of using the DotSceneLoader to load different scenes for each level (but I am still on the theory correct me if I am wrong :D )
I would like to implement this kind of code

Code: Select all

DotSceneLoader* pDotSceneLoader = new DotSceneLoader();
	pDotSceneLoader->parseDotScene("test.scene", "General", m_pSceneMgr, m_pSceneMgr->getRootSceneNode());
	delete pDotSceneLoader;
Is it okay for me to try this kind of implementation for changing levels in my game? My game is a first person shooting game
Any comment and opinions? :D
diortem
Gnoblar
Posts: 17
Joined: Sat Dec 18, 2010 10:33 pm

Re: Game Change Levels

Post by diortem »

I use dotscene to load my levels. When my level is over, I call a method that cleans up the scene. Then I can load another dotscene level. The trick is to make sure you clean up everything before loading the next level. You want to free all the memory allocated for the first level before loading the next. I have a function I call that does things like this:

Code: Select all

//Delete all the objects I have created
...

//Then
Ogre::ResourceGroupManager::getSingleton().unloadResourceGroup(resourceGroupName);
Ogre::ResourceGroupManager::getSingleton().destroyResourceGroup(resourceGroupName);
Ogre::FontManager::getSingleton().unloadAll(); 
Ogre::OverlayManager::getSingleton().destroyAllOverlayElements();
Ogre::OverlayManager::getSingleton().destroyAll();

mSceneMgr->clearScene();
mSceneMgr->destroyCamera(camera);
root->destroySceneManager(mSceneMgr);
window->removeAllViewports();
mSceneMgr = root->createSceneManager(Ogre::ST_GENERIC, "SceneManager");