fixed a mismatced new[] with a delete[]
[physics.git] / src / game.cpp
index 32a9e0b..1aabda2 100644 (file)
@@ -1,10 +1,11 @@
+#include "game.h"
+#include "debug.h"
+
 #include <vector>
 using std::vector;
 
-#include "game.h"
-
-#include "debug.h"
 #include "entityCreator.h"
+#include "effectManager.h"
 
 #include "GameStates/GameState.h"
 #include "GameStates/Running.h"
@@ -31,9 +32,12 @@ void gameInit()
     creating_Polygon = new CreatingPolygon();
 
     // create starting entities
-
     creator::init();
 
+    active_States.push_back(running);
+
+    effect::init();
+
 #ifdef DEBUGGING
     cout << "World Created" << endl;
 #endif
@@ -41,6 +45,8 @@ void gameInit()
 
 void gameClean()
 {
+    effect::clean();
+
     creator::clean();
 
     delete creating_Polygon;
@@ -50,27 +56,26 @@ void gameClean()
 
 void gameInput()
 {
-    int size = active_States.size();
+    int last = active_States.size() -1;
     for( int i = 0;
-         i < size;
+         i <= last;
          i++ )
     {
-        if( i-1 == size )
+        if( i == last )
             active_States[i]->handleInput(true);
         else
             active_States[i]->handleInput(false);
     }
-
 }
 
 void gameUpdate(float time_step)
 {
-    int size = active_States.size();
+    int last = active_States.size() -1;
     for( int i = 0;
-         i < size;
+         i <= last;
          i++ )
     {
-        if( i-1 == size )
+        if( i == last )
             active_States[i]->update(time_step, true);
         else
             active_States[i]->update(time_step, false);
@@ -79,12 +84,12 @@ void gameUpdate(float time_step)
 
 void gameDraw()
 {
-    int size = active_States.size();
+    int last = active_States.size() -1;
     for( int i = 0;
-         i < size;
+         i <= last;
          i++ )
     {
-        if( i-1 == size )
+        if( i == last )
             active_States[i]->draw(true);
         else
             active_States[i]->draw(false);