diff --git a/overlay/rootfs/usr/bin/snake b/overlay/rootfs/usr/bin/snake index 4f100a5..a731467 100755 Binary files a/overlay/rootfs/usr/bin/snake and b/overlay/rootfs/usr/bin/snake differ diff --git a/overlay/rootfs/usr/bin/tetris b/overlay/rootfs/usr/bin/tetris index 0f34ed5..d6d8988 100755 Binary files a/overlay/rootfs/usr/bin/tetris and b/overlay/rootfs/usr/bin/tetris differ diff --git a/prebuilt/games/usr/bin/snake b/prebuilt/games/usr/bin/snake index 4f100a5..a731467 100755 Binary files a/prebuilt/games/usr/bin/snake and b/prebuilt/games/usr/bin/snake differ diff --git a/prebuilt/games/usr/bin/tetris b/prebuilt/games/usr/bin/tetris index 0f34ed5..d6d8988 100755 Binary files a/prebuilt/games/usr/bin/tetris and b/prebuilt/games/usr/bin/tetris differ diff --git a/src/games/snake.cpp b/src/games/snake.cpp index 8c9cad9..67dca9a 100644 --- a/src/games/snake.cpp +++ b/src/games/snake.cpp @@ -228,7 +228,8 @@ static void step() { update_speed(); place_food(); } - nextTick = now_ms() + speed; + if (nextTick < now_ms()) nextTick = now_ms(); + nextTick += speed; } static void draw_text(int x, int y, int scale, unsigned long col, const char* s) { @@ -407,7 +408,7 @@ int main() { render(); int xfd = ConnectionNumber(dpy); - const unsigned long FRAME_MS = 1000 / 60; // 60 fps rendering + const unsigned long FRAME_MS = 1000 / 30; // 30 fps rendering unsigned long frameStart = now_ms(); while (running) { @@ -425,7 +426,8 @@ int main() { // Game logic step at its own rate if (now >= nextTick) { if (state == PLAYING) step(); - nextTick = now + (state == PLAYING ? speed : 80); + if (nextTick < now) nextTick = now; + nextTick += (state == PLAYING ? speed : 80); } // Render every frame diff --git a/src/games/tetris.cpp b/src/games/tetris.cpp index f539ac2..48ebfd1 100644 --- a/src/games/tetris.cpp +++ b/src/games/tetris.cpp @@ -520,7 +520,7 @@ int main() { render(); int xfd = ConnectionNumber(dpy); - const unsigned long FRAME_MS = 1000 / 60; // 60 fps rendering + const unsigned long FRAME_MS = 1000 / 30; // 30 fps rendering unsigned long frameStart = now_ms(); while (running) { @@ -538,7 +538,8 @@ int main() { // Game logic step at its own rate if (now >= nextTick) { if (state == PLAYING) step(); - nextTick = now + (state == PLAYING ? speed : 80); + if (nextTick < now) nextTick = now; + nextTick += (state == PLAYING ? speed : 80); } // Render every frame