]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
better pausing
authorClyne Sullivan <tullivan99@gmail.com>
Fri, 20 Oct 2017 12:14:01 +0000 (08:14 -0400)
committerClyne Sullivan <tullivan99@gmail.com>
Fri, 20 Oct 2017 12:14:01 +0000 (08:14 -0400)
assets/style/winter/bg/bgFarMountain.png
include/gametime.hpp
main.cpp
src/gametime.cpp
xcf/snowmtns.xcf

index 7db9b2e3d89128e2094a84c64b23ec27bf12f24f..3e3dee1e4917f2f947f302779a9fd611ebfa9e13 100644 (file)
Binary files a/assets/style/winter/bg/bgFarMountain.png and b/assets/style/winter/bg/bgFarMountain.png differ
index 7999f1c2f98290a1b577b21615b09843ff1db5ba..2433b28e9cae7f3c552f438fad24b6423075318b 100644 (file)
@@ -9,6 +9,7 @@ namespace game {
     namespace time {
                void togglePause(void);
                void togglePause(bool state);
+               bool isPaused(void);
 
                /**
                 * Sets the game's tick count to the desired amount.
index c05a7873a6cf1517d8eb0d0d3d0a0af746c4ab4f..fad13155ba9f3f46898d9b7811309260919ae3d7 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -137,7 +137,8 @@ int main(int argc, char *argv[])
                        for (auto& e : clone)
                                game::events.emit<MainSDLEvent>(e);
 
-                       game::engine.update(game::time::getDeltaTime());
+                       if (!game::time::isPaused())
+                               game::engine.update(game::time::getDeltaTime());
                        std::this_thread::sleep_for(1ms);
                });
                
index 6f6ac0e3eb0e6fe7489cd7c727dfaf582261c2cc..7ef824c8bb08c0d7ba1d3aa9d2ff3ddf4e413b80 100644 (file)
@@ -17,6 +17,10 @@ namespace game {
                        paused = state;
                }
 
+               bool isPaused(void) {
+                       return paused;
+               }
+
         void setTickCount(unsigned int t) {
             tickCount = t;
         }
@@ -30,11 +34,13 @@ namespace game {
         }
 
         void tick(void) {
-            tickCount++;
+                       if (!paused)
+                   tickCount++;
         }
 
         void tick(unsigned int ticks) {
-            tickCount += ticks;
+                       if (!paused)
+                   tickCount += ticks;
         }
 
         void mainLoopHandler(void) {
@@ -52,7 +58,7 @@ namespace game {
                        static unsigned int accum = 0;
 
             accum += deltaTime;
-            if (accum > MSEC_PER_TICK) {
+            if (!paused && accum > MSEC_PER_TICK) {
                        accum = 0.0f;
                 return true;
                }
index 663e714e98ff967883862070a926501d48408802..4106d1e8f7332f73f072400ecf2f0331a48c4b84 100644 (file)
Binary files a/xcf/snowmtns.xcf and b/xcf/snowmtns.xcf differ