1 package ru
.deadsoftware
.cavecraft
.game
;
3 import com
.badlogic
.gdx
.math
.RandomXS128
;
4 import com
.badlogic
.gdx
.utils
.TimeUtils
;
6 public class WorldGen
{
8 private static RandomXS128 rand
;
9 private static long seed
;
11 private static int[][] foreMap
, backMap
;
12 private static int[] hMap
;
14 public static long getSeed() {
18 static int[] genLandscape(int width
, int mid
, int min
, int max
) {
19 int[] res
= new int[width
];
22 for (int i
=1; i
<width
; i
++) {
23 t
= rand
.nextInt(3)-1;
24 res
[i
] = res
[i
-1] + t
;
25 if (res
[i
]<min
) res
[i
] = min
;
26 if (res
[i
]>max
) res
[i
] = max
;
31 static void genWorld(int width
, int height
) {
32 genWorld(width
, height
, TimeUtils
.millis());
35 static void genWorld(int width
, int height
, long s
) {
38 rand
= new RandomXS128(seed
);
39 foreMap
= new int[width
][height
];
40 backMap
= new int[width
][height
];
41 hMap
= genLandscape(width
, height
/2, height
/4, height
/4*3);
42 for (int x
=0; x
<width
; x
++) {
43 dirtH
= 4+rand
.nextInt(2);
44 for (int y
= height
- hMap
[x
]; y
<height
; y
++) {
45 if (y
==height
- hMap
[x
]) {
48 } else if (y
<height
-hMap
[x
]+dirtH
) {
59 static int[][] getForeMap() {
63 static int[][] getBackMap() {