From: fred-boy Date: Sat, 28 Sep 2019 16:49:05 +0000 (+0700) Subject: Inspect code X-Git-Tag: alpha0.4~36 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=ef32f2e88b9c0daa411d0c304ce62b1235541fb1;p=cavedroid.git Inspect code --- diff --git a/.gitignore b/.gitignore index 6d842f2..ac624d2 100644 --- a/.gitignore +++ b/.gitignore @@ -101,13 +101,6 @@ nb-configuration.xml /local.properties .gradle/ gradle-app.setting -/build/ -/android/build/ -/core/build/ -/desktop/build/ -/html/build/ -/ios/build/ -/ios-moe/build/ ## OS Specific .DS_Store diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index dbde2a4..014587c 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -6,7 +6,8 @@ android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" - android:theme="@style/GdxTheme" tools:ignore="GoogleAppIndexingWarning"> + android:theme="@style/GdxTheme" tools:ignore="GoogleAppIndexingWarning" + android:fullBackupContent="@xml/backup_descriptor"> + + + diff --git a/core/src/ru/deadsoftware/cavedroid/GameScreen.java b/core/src/ru/deadsoftware/cavedroid/GameScreen.java index fc82bf2..09604fd 100644 --- a/core/src/ru/deadsoftware/cavedroid/GameScreen.java +++ b/core/src/ru/deadsoftware/cavedroid/GameScreen.java @@ -26,7 +26,7 @@ public class GameScreen implements Screen { private MenuRenderer menuRenderer; private InputHandlerGame inputHandlerGame; - private InputHandlerMenu inputHandlerMenu; + private final InputHandlerMenu inputHandlerMenu; public GameScreen() { Assets.load(); diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameFluidsThread.java b/core/src/ru/deadsoftware/cavedroid/game/GameFluidsThread.java index 57c7470..1f0302c 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameFluidsThread.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameFluidsThread.java @@ -7,7 +7,7 @@ import java.util.Arrays; import static ru.deadsoftware.cavedroid.GameScreen.GP; import static ru.deadsoftware.cavedroid.game.GameItems.*; -public class GameFluidsThread extends Thread { +class GameFluidsThread extends Thread { private static final int FLUID_UPDATE_INTERVAL_MS = 100; private static final int FLUID_STATES = 5; diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameItems.java b/core/src/ru/deadsoftware/cavedroid/game/GameItems.java index 82c4b33..9945b06 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameItems.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameItems.java @@ -13,11 +13,11 @@ import java.util.HashMap; public class GameItems { - private static HashMap blocksIds = new HashMap<>(); - private static HashMap itemsIds = new HashMap<>(); + private static final HashMap blocksIds = new HashMap<>(); + private static final HashMap itemsIds = new HashMap<>(); - private static ArrayMap blocks = new ArrayMap<>(); - private static ArrayMap items = new ArrayMap<>(); + private static final ArrayMap blocks = new ArrayMap<>(); + private static final ArrayMap items = new ArrayMap<>(); static boolean isFluid(int id) { return getBlock(id).isFluid(); diff --git a/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java b/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java index 25709bd..7e12e53 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GamePhysics.java @@ -17,7 +17,7 @@ class GamePhysics { static final int PL_SPEED = 2; - private Vector2 gravity = new Vector2(0, .9f); + private final Vector2 gravity = new Vector2(0, .9f); private boolean checkJump(Rectangle rect, int dir) { int bl; diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameProc.java b/core/src/ru/deadsoftware/cavedroid/game/GameProc.java index 60be6eb..245f0dc 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameProc.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameProc.java @@ -1,6 +1,5 @@ package ru.deadsoftware.cavedroid.game; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.utils.Disposable; import ru.deadsoftware.cavedroid.CaveGame; import ru.deadsoftware.cavedroid.GameScreen; @@ -32,9 +31,9 @@ public class GameProc implements Serializable, Disposable { transient GamePhysics physics; public ControlMode controlMode; - public Player player; - public ArrayList mobs; - ArrayList drops; + public final Player player; + public final ArrayList mobs; + final ArrayList drops; public void resetRenderer() { int scale = CaveGame.TOUCH ? 320 : 480; diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameWorld.java b/core/src/ru/deadsoftware/cavedroid/game/GameWorld.java index e921b98..0c44350 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameWorld.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameWorld.java @@ -9,9 +9,10 @@ import static ru.deadsoftware.cavedroid.GameScreen.GP; @SuppressWarnings("WeakerAccess") public class GameWorld { - private int WIDTH, HEIGHT; - private int[][] foreMap; - private int[][] backMap; + private final int WIDTH; + private final int HEIGHT; + private final int[][] foreMap; + private final int[][] backMap; GameWorld(int width, int height) { WIDTH = width; diff --git a/core/src/ru/deadsoftware/cavedroid/game/WorldGen.java b/core/src/ru/deadsoftware/cavedroid/game/WorldGen.java index b6ab59e..f820190 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/WorldGen.java +++ b/core/src/ru/deadsoftware/cavedroid/game/WorldGen.java @@ -3,7 +3,7 @@ package ru.deadsoftware.cavedroid.game; import com.badlogic.gdx.math.RandomXS128; import com.badlogic.gdx.utils.TimeUtils; -public class WorldGen { +class WorldGen { private static RandomXS128 rand; private static long seed; diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java index bcab586..32c63cc 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java +++ b/core/src/ru/deadsoftware/cavedroid/game/mobs/Mob.java @@ -14,11 +14,12 @@ public abstract class Mob implements Serializable { public static final int LEFT = 0; public static final int RIGHT = 1; - private float width, height; + private final float width; + private final float height; private int dir; public boolean flyMode; - public Vector2 pos; + public final Vector2 pos; public Vector2 mov; private boolean dead; @@ -36,7 +37,7 @@ public abstract class Mob implements Serializable { * @param dir integer representing a direction where 0 is left and 1 is right. * You should use {@link #LEFT} and {@link #RIGHT} constants */ - public Mob(float x, float y, float width, float height, int dir) { + protected Mob(float x, float y, float width, float height, int dir) { pos = new Vector2(x, y); mov = new Vector2(0, 0); this.width = width; diff --git a/core/src/ru/deadsoftware/cavedroid/game/objects/Block.java b/core/src/ru/deadsoftware/cavedroid/game/objects/Block.java index 8cda832..c99f505 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/objects/Block.java +++ b/core/src/ru/deadsoftware/cavedroid/game/objects/Block.java @@ -5,12 +5,20 @@ import com.badlogic.gdx.math.Rectangle; public class Block { - private int x, y, w, h; - private int hp; - private String drop, meta; - private Sprite tex; - - private boolean coll, bg, tp, rb, fluid; + private final int x; + private final int y; + private final int w; + private final int h; + private final int hp; + private final String drop; + private final String meta; + private final Sprite tex; + + private final boolean coll; + private final boolean bg; + private final boolean tp; + private final boolean rb; + private final boolean fluid; /** * diff --git a/core/src/ru/deadsoftware/cavedroid/game/objects/Drop.java b/core/src/ru/deadsoftware/cavedroid/game/objects/Drop.java index 00bc317..cda629d 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/objects/Drop.java +++ b/core/src/ru/deadsoftware/cavedroid/game/objects/Drop.java @@ -10,9 +10,10 @@ import static ru.deadsoftware.cavedroid.GameScreen.GP; public class Drop implements Serializable { - private int id; + private final int id; public boolean pickedUp = false; - public Vector2 move, pos; + public final Vector2 move; + public final Vector2 pos; public Drop(float x, float y, int id) { this.id = id; diff --git a/core/src/ru/deadsoftware/cavedroid/game/objects/Item.java b/core/src/ru/deadsoftware/cavedroid/game/objects/Item.java index a619a1b..0083001 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/objects/Item.java +++ b/core/src/ru/deadsoftware/cavedroid/game/objects/Item.java @@ -4,8 +4,9 @@ import com.badlogic.gdx.graphics.g2d.Sprite; public class Item { - private String name, type; - private Sprite tex; + private final String name; + private final String type; + private final Sprite tex; public Item(String name, String type, Sprite tex) { this.name = name; diff --git a/core/src/ru/deadsoftware/cavedroid/game/objects/Player.java b/core/src/ru/deadsoftware/cavedroid/game/objects/Player.java index 1c12f03..11863b7 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/objects/Player.java +++ b/core/src/ru/deadsoftware/cavedroid/game/objects/Player.java @@ -12,9 +12,9 @@ import static ru.deadsoftware.cavedroid.GameScreen.GP; public class Player extends Mob implements Serializable { - public int[] inventory; + public final int[] inventory; public int slot; - public int gameMode; + public final int gameMode; public boolean swim; public Player(int gameMode) { diff --git a/core/src/ru/deadsoftware/cavedroid/menu/MenuRenderer.java b/core/src/ru/deadsoftware/cavedroid/menu/MenuRenderer.java index 74fbf95..fe1834d 100644 --- a/core/src/ru/deadsoftware/cavedroid/menu/MenuRenderer.java +++ b/core/src/ru/deadsoftware/cavedroid/menu/MenuRenderer.java @@ -19,8 +19,8 @@ import static ru.deadsoftware.cavedroid.misc.Assets.*; public class MenuRenderer extends Renderer { - public Array