reworked ups/fps/paused logic
[physics.git] / src / game.cpp
index 3b7a34b..5098ed8 100644 (file)
@@ -65,9 +65,7 @@ void game::init()
 
     effect::init();
 
-#ifdef DEBUGGING
-    cout << "World Created" << endl;
-#endif
+    DPF(0, "World Created");
 }
 
 void game::clean()
@@ -81,19 +79,28 @@ void game::clean()
     delete running;
 }
 
-void game::input()
+void game::handleInput()
 {
-    if(running->pushMe())
+    creator::handleInput();
+
+    int last = active_States.size() -1;
+
+    if(active_States[last] != running && running->pushMe())
+    {
         push_State = running;
+    }
 
-    if(paused->pushMe())
+    if(active_States[last] != paused && paused->pushMe())
+    {
         push_State = paused;
+    }
 
-    if(creating_Polygon->pushMe())
+    if(active_States[last] != creating_Polygon && creating_Polygon->pushMe())
+    {
         push_State = creating_Polygon;
+    }
 
 
-    int last = active_States.size() -1;
     for( int i = 0;
          i <= last;
          i++ )
@@ -112,21 +119,18 @@ void game::input()
 
 void game::update(float time_step)
 {
-    if(push_State != NULL)
-    {
-        // don't want to pop and push same state, pop wins arbitrary
-        if(!pop_State)
-            active_States.push_back(push_State);
-
-        push_State = NULL;
-    }
-
     if(pop_State)
     {
         active_States.pop_back();
         pop_State = false;
     }
 
+    if(push_State != NULL)
+    {
+        active_States.push_back(push_State);
+        push_State = NULL;
+    }
+
     int last = active_States.size() -1;
     for( int i = 0;
          i <= last;