diff --git a/core/src/ru/deadsoftware/cavedroid/game/WorldGen.java b/core/src/ru/deadsoftware/cavedroid/game/WorldGen.java
index faacb252ba36fd2dfd06b8f5c748d44203742a3d..cc02aea03f2dff4af2151175d451cb3c751c7f23 100644 (file)
import com.badlogic.gdx.math.RandomXS128;
import com.badlogic.gdx.utils.TimeUtils;
-public class WorldGen {
+import javax.annotation.CheckForNull;
+class WorldGen {
+
+ @CheckForNull
private static RandomXS128 rand;
private static long seed;
+ @CheckForNull
private static int[][] foreMap, backMap;
+ @CheckForNull
private static int[] hMap;
+ @CheckForNull
private static int[] bMap; //biomes, 0-plains, 1-desert
public static long getSeed() {
res[0] = mid;
for (int i = 1; i < width; i++) {
t = rand.nextInt(7) - 3;
- if (t > -3 && t < 3) t = 0;
- else t /= Math.abs(t);
+ if (t > -3 && t < 3) {
+ t = 0;
+ } else {
+ t /= Math.abs(t);
+ }
if (i > width - (max - min)) {
- if (res[i - 1] + t < res[0]) t = Math.abs(t);
- else if (res[i - 1] + t > res[0]) t = -Math.abs(t);
+ if (res[i - 1] + t < res[0]) {
+ t = Math.abs(t);
+ } else if (res[i - 1] + t > res[0]) {
+ t = -Math.abs(t);
+ }
}
res[i] = res[i - 1] + t;
- if (res[i] < min) res[i] = min;
- if (res[i] > max) res[i] = max;
- if (i >= width / 2) {
- bMap[i] = 1;
- if (res[i] < 60) res[i] = 60;
- } else {
- bMap[i] = 0;
+ if (res[i] < min) {
+ res[i] = min;
+ }
+ if (res[i] > max) {
+ res[i] = max;
}
+ bMap[i] = 0;
+// if (i >= width / 2) {
+// bMap[i] = 1;
+// if (res[i] < 60) res[i] = 60;
+// } else {
+// bMap[i] = 0;
+// }
+ }
+ if (res[0] < res[width - 1]) {
+ res[width - 1] = res[0];
}
- if (res[0] < res[width - 1]) res[width - 1] = res[0];
return res;
}
private static void genCactus(int x, int y) {
+ assert foreMap != null;
foreMap[x][y] = 59;
foreMap[x][y - 1] = 59;
foreMap[x][y - 2] = 59;
}
private static void genOak(int x, int y) {
+ assert foreMap != null && backMap != null;
backMap[x][y] = 15;
backMap[x][y - 1] = 15;
backMap[x][y - 2] = 15;
}
static int[][] getForeMap() {
+ assert foreMap != null;
return foreMap;
}
static int[][] getBackMap() {
+ assert backMap != null;
return backMap;
}
static void clear() {
- foreMap = null;
- backMap = null;
hMap = null;
bMap = null;
}