From: fred-boy Date: Fri, 6 Apr 2018 16:42:44 +0000 (+0700) Subject: Add landscape X-Git-Tag: alpha0.1~20 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=2d94431f674b2b604e03f32c9de4cf91c7fa715b;p=cavedroid.git Add landscape --- diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java index 42bd07e..3c6d7b3 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java +++ b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java @@ -105,6 +105,7 @@ public class GameRenderer { drawPlayer(gameProc.player); drawGUI(); spriteBatch.end(); + shapeRenderer.begin(ShapeRenderer.ShapeType.Line); shapeRenderer.setColor(Color.ORANGE); drawRect(gameProc.cursorX*16-camera.position.x, diff --git a/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java b/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java index 96aedf3..84f0ae1 100644 --- a/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java +++ b/core/src/ru/deadsoftware/cavecraft/game/WorldGen.java @@ -1,18 +1,37 @@ package ru.deadsoftware.cavecraft.game; +import com.badlogic.gdx.math.RandomXS128; +import com.badlogic.gdx.utils.TimeUtils; + public class WorldGen { private static int[][] foreMap, backMap; + private static int[] noise; + + static int[] genNoise(int width, int mid, int min, int max) { + RandomXS128 rand = new RandomXS128(TimeUtils.millis()); + int[] res = new int[width]; + int t; + res[0] = mid; + for (int i=1; imax) res[i] = max; + } + return res; + } static void genWorld(int width, int height) { foreMap = new int[width][height]; backMap = new int[width][height]; + noise = genNoise(width, height/2, 1, height); for (int x=0; x