reworked ups/fps/paused logic
[physics.git] / src / game.cpp
index 08f9530..5098ed8 100644 (file)
@@ -83,18 +83,24 @@ void game::handleInput()
 {
     creator::handleInput();
 
+    int last = active_States.size() -1;
 
-    if(running->pushMe())
+    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++ )
@@ -113,21 +119,18 @@ void game::handleInput()
 
 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;