summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4f65284)
raw | patch | inline | side by side (parent: 4f65284)
author | fred-boy <fredboy@protonmail.com> | |
Mon, 23 Dec 2019 14:04:52 +0000 (21:04 +0700) | ||
committer | fred-boy <fredboy@protonmail.com> | |
Mon, 23 Dec 2019 14:04:52 +0000 (21:04 +0700) |
core/src/ru/deadsoftware/cavedroid/GameScreen.java | patch | blob | history | |
core/src/ru/deadsoftware/cavedroid/game/GameProc.java | patch | blob | history |
diff --git a/core/src/ru/deadsoftware/cavedroid/GameScreen.java b/core/src/ru/deadsoftware/cavedroid/GameScreen.java
index 286ba49ed846779c741b282246d9f3bbb9e0e6ef..e3278d1bf4c92eb973439dafe1178e9f2a3e8107 100644 (file)
import ru.deadsoftware.cavedroid.misc.states.GameState;
import ru.deadsoftware.cavedroid.misc.states.MenuState;
+import javax.annotation.Nullable;
+
public class GameScreen implements Screen {
public static GameProc GP;
private Renderer renderer;
private MenuProc menuProc;
- private InputHandlerGame inputHandlerGame;
+ @Nullable private InputHandlerGame inputHandlerGame;
public GameScreen() {
Assets.load();
break;
case LOAD:
- GP.resetRenderer();
- renderer = GP.renderer;
+ renderer = GP.resetRenderer();
if (inputHandlerGame == null) {
inputHandlerGame = new InputHandlerGame();
}
renderer = menuProc;
break;
case GAME:
- GP.resetRenderer();
- renderer = GP.renderer;
+ renderer = GP.resetRenderer();
break;
}
}
diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameProc.java b/core/src/ru/deadsoftware/cavedroid/game/GameProc.java
index afd91343eeda6c06ce04cd02c0a3c4ed68830956..ea5296a4f226aa93c4d3bb594d0071de41c8ec91 100644 (file)
import ru.deadsoftware.cavedroid.game.objects.Drop;
import ru.deadsoftware.cavedroid.misc.ControlMode;
+import javax.annotation.Nullable;
import java.io.Serializable;
import java.util.LinkedList;
public transient GameInput input;
public ControlMode controlMode;
transient GamePhysics physics;
- private transient GameFluidsThread fluidThread;
+ @Nullable private transient GameFluidsThread fluidThread;
public GameProc(int gameMode) {
world = new GameWorld(WORLD_WIDTH, WORLD_HEIGHT);
physics = new GamePhysics();
input = new GameInput();
controlMode = CaveGame.TOUCH ? ControlMode.WALK : ControlMode.CURSOR;
- resetRenderer();
+ renderer = resetRenderer();
startFluidThread();
}
- public void resetRenderer() {
+ public GameRenderer resetRenderer() {
int scale = CaveGame.TOUCH ? 320 : 480;
- renderer = new GameRenderer(scale, scale * GameScreen.getHeight() / GameScreen.getWidth());
+ renderer = new GameRenderer(scale, scale * GameScreen.getHeight() / GameScreen.getWidth());
+ return renderer;
}
private void startFluidThread() {
@Override
public void dispose() {
- fluidThread.interrupt();
+ if (fluidThread != null) {
+ fluidThread.interrupt();
+ }
}
}