summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2c3594c)
raw | patch | inline | side by side (parent: 2c3594c)
author | fred-boy <fredboy@protonmail.com> | |
Fri, 27 Sep 2019 11:53:15 +0000 (18:53 +0700) | ||
committer | fred-boy <fredboy@protonmail.com> | |
Sun, 29 Sep 2019 04:39:17 +0000 (11:39 +0700) |
core/src/ru/deadsoftware/cavedroid/game/GameFluidsThread.java | patch | blob | history |
diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameFluidsThread.java b/core/src/ru/deadsoftware/cavedroid/game/GameFluidsThread.java
index d404c43aca84b79aaca1bd7b5aac1d1db923238b..8f4a891930bc570ce868899a99e965da9329d492 100644 (file)
public class GameFluidsThread extends Thread {
- private static final int FLUID_UPDATE_INTERVAL_MS = 150;
+ private static final int FLUID_UPDATE_INTERVAL_MS = 100;
private static final int FLUID_STATES = 5;
private static final int[] WATER_IDS = {8, 60, 61, 62, 63};
private void fluidUpdater() {
int midScreen = (int) (GP.renderer.getCamX() + GP.renderer.getWidth() / 2) / 16;
- for (int y = 0; y < GP.world.getHeight(); y++) {
- for (int x = 0; x < (int) (GP.renderer.getWidth() / 2) / 16 + 1; x++) {
+ for (int y = GP.world.getHeight() - 1; y >= 0; y--) {
+ for (int x = 0; x <= GP.world.getWidth() / 2; x++) {
updateFluids(midScreen + x, y);
updateFluids(midScreen - x, y);
}
}
}
+ private boolean timeToUpdate() {
+ if (System.currentTimeMillis() - fluidLastUpdateTimestamp >= FLUID_UPDATE_INTERVAL_MS) {
+ fluidLastUpdateTimestamp = System.currentTimeMillis();
+ return true;
+ }
+ return false;
+ }
+
@Override
public void run() {
while (!this.isInterrupted()) {
- if (System.currentTimeMillis() - fluidLastUpdateTimestamp > FLUID_UPDATE_INTERVAL_MS) {
+ if (timeToUpdate()) {
fluidUpdater();
- fluidLastUpdateTimestamp = System.currentTimeMillis();
}
}
}