aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2017-10-20 08:14:01 -0400
committerClyne Sullivan <tullivan99@gmail.com>2017-10-20 08:14:01 -0400
commit1a4780bad1cc40b43ebe6d93baba0f89572194d4 (patch)
tree13751f28b667a778c6b6e2c268384ad1133be051
parenta9c145a4694d23ad6e9ee1e9816a0e7e4aeddfe2 (diff)
better pausing
-rw-r--r--assets/style/winter/bg/bgFarMountain.pngbin28237 -> 28404 bytes
-rw-r--r--include/gametime.hpp1
-rw-r--r--main.cpp3
-rw-r--r--src/gametime.cpp12
-rw-r--r--xcf/snowmtns.xcfbin421662 -> 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
index 7db9b2e..3e3dee1 100644
--- a/assets/style/winter/bg/bgFarMountain.png
+++ b/assets/style/winter/bg/bgFarMountain.png
Binary files differ
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.
diff --git a/main.cpp b/main.cpp
index c05a787..fad1315 100644
--- 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);
});
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
index 663e714..4106d1e 100644
--- a/xcf/snowmtns.xcf
+++ b/xcf/snowmtns.xcf
Binary files differ