Pressing N starts a new game.
Pressing N starts a new game.

--- a/CoinGame.cpp
+++ b/CoinGame.cpp
@@ -40,28 +40,28 @@
 {
   // Scene
   createBase();
-  createCoinField();
 
   // Gravity
   setGravity(btVector3(0,-100,0));
+
+  newGame();
 }
 
 bool CoinGame::keyReleased(const OIS::KeyEvent &e)
 {
-  if(!BulletApp::keyReleased(e)) return false;
-  
   switch(e.key)
     {
-    case OIS::KC_SPACE:
+    case OIS::KC_N:
       {
-	dropCoin(Ogre::Vector3(0,10,20));
+	newGame();
+	return false;
       }
       break;
     default:
       break;
     }
 
-  return true;
+  return BulletApp::keyReleased(e);
 }
 
 bool CoinGame::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID mid)
@@ -88,6 +88,24 @@
     }
 
   return BulletApp::mouseReleased(e,mid);
+}
+
+void CoinGame::newGame()
+{
+  /// Destroy any of the old coins
+  for(std::vector<Coin*>::iterator iter=_coins.begin();
+      iter!=_coins.end();
+      iter++)
+    {
+      (*iter)->remove();
+      delete (*iter);
+    }
+  _coins.erase(_coins.begin(),_coins.end());
+
+  /// Initialize a new game
+  _score=5;
+  _updateTime=0;
+  createCoinField();
 }
 
 void CoinGame::createBase()

file:a/CoinGame.h -> file:b/CoinGame.h
--- a/CoinGame.h
+++ b/CoinGame.h
@@ -24,6 +24,8 @@
   bool frameRenderingQueued(const Ogre::FrameEvent &evt);
 
 private:
+  void newGame();
+
   void createBase();
   void createCoinField();
   void dropCoin(Ogre::Vector3 pos);