fix tick method running at the reciprocal of TPS

This commit is contained in:
James 2024-04-20 16:01:31 +01:00
parent 686f6c26e2
commit 68c60a2245

View file

@ -26,7 +26,6 @@ public class Game extends ApplicationAdapter {
private final static int TICKS_PER_SECOND = 60; private final static int TICKS_PER_SECOND = 60;
private double tickProgress = 0; private double tickProgress = 0;
@Override @Override
public void create() { public void create() {
batch = new SpriteBatch(); batch = new SpriteBatch();
@ -40,11 +39,13 @@ public class Game extends ApplicationAdapter {
public void tick() { public void tick() {
actors.forEach(Actor::tick); actors.forEach(Actor::tick);
dice.forEach(Die::roll);
} }
@Override @Override
public void render() { public void render() {
tickProgress += Gdx.graphics.getDeltaTime() / TICKS_PER_SECOND; tickProgress += Gdx.graphics.getDeltaTime() * TICKS_PER_SECOND;
while (tickProgress >= 1) { //tick as many times as needed while (tickProgress >= 1) { //tick as many times as needed
tick(); tick();
tickProgress--; tickProgress--;