diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2017-10-20 08:14:01 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2017-10-20 08:14:01 -0400 |
commit | 1a4780bad1cc40b43ebe6d93baba0f89572194d4 (patch) | |
tree | 13751f28b667a778c6b6e2c268384ad1133be051 | |
parent | a9c145a4694d23ad6e9ee1e9816a0e7e4aeddfe2 (diff) |
better pausing
-rw-r--r-- | assets/style/winter/bg/bgFarMountain.png | bin | 28237 -> 28404 bytes | |||
-rw-r--r-- | include/gametime.hpp | 1 | ||||
-rw-r--r-- | main.cpp | 3 | ||||
-rw-r--r-- | src/gametime.cpp | 12 | ||||
-rw-r--r-- | xcf/snowmtns.xcf | bin | 421662 -> 423735 bytes |
5 files changed, 12 insertions, 4 deletions
diff --git a/assets/style/winter/bg/bgFarMountain.png b/assets/style/winter/bg/bgFarMountain.png Binary files differindex 7db9b2e..3e3dee1 100644 --- a/assets/style/winter/bg/bgFarMountain.png +++ b/assets/style/winter/bg/bgFarMountain.png diff --git a/include/gametime.hpp b/include/gametime.hpp index 7999f1c..2433b28 100644 --- a/include/gametime.hpp +++ b/include/gametime.hpp @@ -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. @@ -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); }); diff --git a/src/gametime.cpp b/src/gametime.cpp index 6f6ac0e..7ef824c 100644 --- a/src/gametime.cpp +++ b/src/gametime.cpp @@ -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; } diff --git a/xcf/snowmtns.xcf b/xcf/snowmtns.xcf Binary files differindex 663e714..4106d1e 100644 --- a/xcf/snowmtns.xcf +++ b/xcf/snowmtns.xcf |