fix tick method running at the reciprocal of TPS
This commit is contained in:
parent
686f6c26e2
commit
68c60a2245
1 changed files with 3 additions and 2 deletions
|
@ -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--;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue