9f6e693886a11db7386bebeb2b9a3f7f4ced59dc
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 int[][] foreMap
, backMap
;
9 private static int[] hMap
;
11 static int[] genLandscape(int width
, int mid
, int min
, int max
) {
12 RandomXS128 rand
= new RandomXS128(TimeUtils
.millis());
13 int[] res
= new int[width
];
16 for (int i
=1; i
<width
; i
++) {
17 t
= rand
.nextInt(3)-1;
18 res
[i
] = res
[i
-1] + t
;
19 if (res
[i
]<min
) res
[i
] = min
;
20 if (res
[i
]>max
) res
[i
] = max
;
25 static void genWorld(int width
, int height
) {
26 foreMap
= new int[width
][height
];
27 backMap
= new int[width
][height
];
28 hMap
= genLandscape(width
, height
/2, height
/4, height
/4*3);
29 for (int x
=0; x
<width
; x
++) {
30 for (int y
= height
- hMap
[x
]; y
<height
; y
++) {
31 if (y
==height
- hMap
[x
]) {
34 } else if (y
<height
- hMap
[x
]+4) {
45 static int[][] getForeMap() {
49 static int[][] getBackMap() {