summaryrefslogtreecommitdiffstats
path: root/src/rpgedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpgedit.cpp')
-rw-r--r--src/rpgedit.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/rpgedit.cpp b/src/rpgedit.cpp
index 8dcd472..c507880 100644
--- a/src/rpgedit.cpp
+++ b/src/rpgedit.cpp
@@ -56,17 +56,15 @@ int main(__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
bool running = true;
uint32_t ticks = SDL_GetTicks();
+ uint32_t lastFrameTicks = ticks;
while (true) {
- SDL_Event event;
- while (running) {
- int timeout = ticks + MIN_FRAME_DELAY - SDL_GetTicks();
- if (timeout < 0)
+ int timeout = lastFrameTicks + MIN_FRAME_DELAY - SDL_GetTicks();
+ if (timeout < 0)
timeout = 0;
- if (!SDL_WaitEventTimeout(&event, timeout))
- break;
-
+ SDL_Event event;
+ if (SDL_WaitEventTimeout(&event, timeout)) {
switch (event.type) {
case SDL_KEYDOWN:
inputHandler.keyPressed(event.key.keysym.scancode);
@@ -90,8 +88,13 @@ int main(__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
ticks = newTicks;
+ if (!SDL_TICKS_PASSED(SDL_GetTicks(), lastFrameTicks + MIN_FRAME_DELAY))
+ continue;
+
std::pair<float, float> pos = map->getPlayerEntity().getPosition();
mapView->render(pos.first, pos.second);
+
+ lastFrameTicks = ticks;
}
}