v3.1.1: various stability improvements for low/inconsistent FPS:

- game now has a max delta time of 200ms
- added some checks to ensure non-looped animations do not complete twice
- adjusted 'enemy' reference in hero to 'attackTarget'
This commit is contained in:
Evan Debenham
2025-06-11 17:27:41 -04:00
parent 9fb18b3b45
commit b6dee52811
8 changed files with 32 additions and 30 deletions

View File

@@ -283,7 +283,9 @@ public class Game implements ApplicationListener {
}
protected void update() {
Game.elapsed = Game.timeScale * Gdx.graphics.getDeltaTime();
//game will not process more than 200ms of graphics time per frame
float frameDelta = Math.min(0.2f, Gdx.graphics.getDeltaTime());
Game.elapsed = Game.timeScale * frameDelta;
Game.timeTotal += Game.elapsed;
Game.realTime = TimeUtils.millis();

View File

@@ -63,9 +63,11 @@ public class MovieClip extends Image {
while (frameTimer > curAnim.delay) {
frameTimer -= curAnim.delay;
if (curFrame >= curAnim.frames.length - 1) {
curFrame = curAnim.frames.length - 1;
if (curAnim.looped) {
curFrame = 0;
} else {
curFrame = curAnim.frames.length - 1;
frameTimer = 0;
}
finished = true;
if (listener != null) {