summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 02ca99e)
raw | patch | inline | side by side (parent: 02ca99e)
author | fredboy <fredboy@protonmail.com> | |
Mon, 15 Apr 2024 16:07:43 +0000 (23:07 +0700) | ||
committer | fredboy <fredboy@protonmail.com> | |
Mon, 15 Apr 2024 16:07:43 +0000 (23:07 +0700) |
diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameProc.java b/core/src/ru/deadsoftware/cavedroid/game/GameProc.java
index 8c4fefbffc683801228073cb9bba571e4c9de8c9..d5a1a95ad3745072fe0f2758905eb8d28cc9cf0c 100644 (file)
mGamePhysics = gamePhysics;
mGameInput = gameInput;
mGameRenderer = gameRenderer;
-
- mGameWorld.startFluidsThread();
}
public void update(float delta) {
diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Player.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Player.java
index 272992a29973735c1d38c7b6c10bd2c68d225ae4..cb3c2a5dfdcdd3e577a910b2a1ca9bfa06a7606d 100644 (file)
public void draw(SpriteBatch spriteBatch, float x, float y, float delta) {
final float correctedAnimationDelta = mAnimDelta * delta;
- if (mVelocity.x != 0 || Math.abs(Assets.playerSprite[0][2].getRotation()) > Math.abs(correctedAnimationDelta)) {
+ if (mVelocity.x != 0f || Math.abs(Assets.playerSprite[0][2].getRotation()) > Math.abs(correctedAnimationDelta)) {
Assets.playerSprite[0][2].rotate(correctedAnimationDelta);
Assets.playerSprite[1][2].rotate(-correctedAnimationDelta);
Assets.playerSprite[0][3].rotate(-correctedAnimationDelta);
diff --git a/core/src/ru/deadsoftware/cavedroid/game/world/GameFluidsThread.java b/core/src/ru/deadsoftware/cavedroid/game/world/GameFluidsThread.java
index 570b2c191fbd359f543e74b9a28255b6b516acbb..7d80855ea3c772f4fb21c1d64a13b2bae1b4cd0c 100644 (file)
import ru.deadsoftware.cavedroid.game.mobs.MobsController;
import java.util.Arrays;
+import java.util.TimerTask;
import static ru.deadsoftware.cavedroid.game.GameItems.*;
-class GameFluidsThread extends Thread {
+class GameFluidsThread extends TimerTask {
- private static final int FLUID_UPDATE_INTERVAL_MS = 100;
+ public 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};
@Override
public void run() {
- while (!this.isInterrupted() && mMainThread.isAlive()) {
- if (timeToUpdate()) {
- fluidUpdater();
- }
- }
+ fluidUpdater();
}
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/world/GameWorld.java b/core/src/ru/deadsoftware/cavedroid/game/world/GameWorld.java
index 18afcd4b3eec1c725a4675c5b8b429c317256da4..60a34e14353704bc0c76d52b505efa80cb9f7b58 100644 (file)
import javax.annotation.CheckForNull;
import javax.inject.Inject;
+import java.sql.Time;
+import java.util.Timer;
@GameScope
public class GameWorld implements Disposable {
private final DropController mDropController;
private final MobsController mMobsController;
+
+ private final Timer mGameFluidsTimer;
private final GameFluidsThread mGameFluidsThread;
private final int mWidth;
}
mGameFluidsThread = new GameFluidsThread(this, mMobsController, Thread.currentThread());
+
+ mGameFluidsTimer = new Timer();
+ mGameFluidsTimer.scheduleAtFixedRate(mGameFluidsThread, 0, GameFluidsThread.FLUID_UPDATE_INTERVAL_MS);
}
public int getWidth() {
}
mShouldUpdate = false;
}
-
- if (!mGameFluidsThread.isAlive()) {
- mGameFluidsThread.start();
- }
- }
-
- public void startFluidsThread() {
- mGameFluidsThread.start();
}
@Override
public void dispose() {
- mGameFluidsThread.interrupt();
+ mGameFluidsTimer.cancel();
}
}
\ No newline at end of file