Added a power meter.
Added a power meter.

--- a/CoinGame.cpp
+++ b/CoinGame.cpp
@@ -4,6 +4,8 @@
 
 #include <kkengine/DotSceneLoader.h>
 #include <kkengine/DotSceneBulletSubloader.h>
+
+#define POWERTRIGGER 20
 
 CoinGame::CoinGame()
   : BulletApp(),
@@ -27,6 +29,11 @@
   return _score;
 }
 
+float CoinGame::powerMeter()
+{
+  return _powerMeter;
+}
+
 bool CoinGame::initialize()
 {
   if(!BulletApp::initialize())
@@ -104,6 +111,7 @@
 
   /// Initialize a new game
   _score=5;
+  _powerMeter=0;
   _updateTime=0;
   createCoinField();
 }
@@ -143,6 +151,12 @@
   _coins.push_back(coin);
 }
 
+void CoinGame::triggerPower()
+{
+  _powerMeter-=POWERTRIGGER;
+  printf("POWER TRIGGERED!\n");
+}
+
 void CoinGame::createCoinField()
 {
   for(int j=-1;j<=5;j++)
@@ -166,7 +180,12 @@
 
 bool CoinGame::frameRenderingQueued(const Ogre::FrameEvent &evt)
 {
+  // Update counters
   _updateTime+=evt.timeSinceLastFrame;
+  if(_powerMeter>0.5) // Make sure that the power is never 0
+    _powerMeter-=0.5;
+  else
+    _powerMeter=0;
 
   if(_piston)
     {
@@ -185,7 +204,6 @@
   if(_pointTrigger)
     {
       int numObjectsInGhost = _pointTrigger->getNumOverlappingObjects();
-      ///printf("number of objects inside ghost: %d\n", numObjectsInGhost);
       for(int i=0; i<numObjectsInGhost;++i)
 	{
 	  btCollisionObject* obj = _pointTrigger->getOverlappingObject(i);
@@ -199,11 +217,10 @@
 		{ // Found it!
 		  _score+=coin->value();
 		  coin->triggerPoint();
+		  _powerMeter+=1;
 		  break;
 		}
 	    }
-	  
-	  ///printf("obj[%d] = %p\n",i, obj);
 	}
     }
   if(_destroyTrigger)
@@ -227,7 +244,11 @@
 	}
     }
 
-
+  // Check the power meter, to see if a new powerup should happen
+  if(_powerMeter>POWERTRIGGER)
+    {
+      triggerPower();
+    }
 
   return BulletApp::frameRenderingQueued(evt);
 }

file:a/CoinGame.h -> file:b/CoinGame.h
--- a/CoinGame.h
+++ b/CoinGame.h
@@ -13,6 +13,7 @@
   ~CoinGame();
 
   int score();
+  float powerMeter();
 
 protected:
   virtual bool initialize();
@@ -30,7 +31,10 @@
   void createCoinField();
   void dropCoin(Ogre::Vector3 pos);
 
+  void triggerPower();
+
   int _score;
+  float _powerMeter;
 
   Ogre::Real _updateTime;
   std::vector<Coin*> _coins;

--- a/DebugCoinGame.cpp
+++ b/DebugCoinGame.cpp
@@ -10,15 +10,18 @@
   : DebugHUD("CoinGame"),_coinGame(coinGame)
 { 
   _scoreDebug=Ogre::OverlayManager::getSingletonPtr()->getOverlayElement("Debug/CoinGame/Score");
+  _powerMeterDebug=Ogre::OverlayManager::getSingletonPtr()->getOverlayElement("Debug/CoinGame/PowerMeter");
 }
 
 void DebugCoinGame::update()
 {
   DebugHUD::update();
 
-  // FPS
   Ogre::Real score=_coinGame->score();
   _scoreDebug->setCaption(Ogre::StringConverter::toString(score));
+
+  Ogre::Real powerMeter=_coinGame->powerMeter();
+  _powerMeterDebug->setCaption(Ogre::StringConverter::toString(powerMeter));
 
 }
 

--- a/DebugCoinGame.h
+++ b/DebugCoinGame.h
@@ -18,6 +18,7 @@
   CoinGame *_coinGame;
 
   Ogre::OverlayElement *_scoreDebug;
+  Ogre::OverlayElement *_powerMeterDebug;
 };
 
 #endif // DEBUGCOINGAME_H_

--- a/media/overlays/debugcoingame.overlay
+++ b/media/overlays/debugcoingame.overlay
@@ -24,6 +24,25 @@
 		caption 100
 	}
 
+	element TextArea(CoinGame/PowerMeterLabel) : Debug/Template/BasicText
+	{
+		left 10
+		top 25
+		width 100
+		height 10
+		caption Power:
+	}
+
+	element TextArea(CoinGame/PowerMeter) : Debug/Template/BasicText
+	{
+		left 50
+		top 25
+		width 100
+		height 10
+		caption 100
+	}
+
+
 
 }