summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 226f349)
raw | patch | inline | side by side (parent: 226f349)
author | fred-boy <fred-boy@protonmail.com> | |
Fri, 6 Apr 2018 16:42:44 +0000 (23:42 +0700) | ||
committer | fred-boy <fred-boy@protonmail.com> | |
Fri, 6 Apr 2018 16:42:44 +0000 (23:42 +0700) |
diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java
index 42bd07e21c7b20004514d3613709134272c6c8a4..3c6d7b38b7aa26b3ee4ec750220c0c1862867b9c 100644 (file)
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 96aedf3be559de55122d66030c3c0d6a0c4ee84d..84f0ae1b7591fe64d52368e6f3bc9019223186c9 100644 (file)
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; i<width; i++) {
+ t = rand.nextInt(3)-1;
+ res[i] = res[i-1] + t;
+ if (res[i]<min) res[i] = min;
+ if (res[i]>max) 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<width; x++) {
- for (int y=height-8; y<height; y++) {
- if (y==height-8) {
+ for (int y=height-noise[x]; y<height; y++) {
+ if (y==height-noise[x]) {
foreMap[x][y] = 3;
backMap[x][y] = 3;
- } else if (y<height-4) {
+ } else if (y<height-noise[x]+4) {
foreMap[x][y] = 2;
backMap[x][y] = 2;
} else {
diff --git a/desktop/src/ru/deadsoftware/cavecraft/desktop/DesktopLauncher.java b/desktop/src/ru/deadsoftware/cavecraft/desktop/DesktopLauncher.java
index 2f0d7b020ac0c6da2679d44251655adb0c13a5c6..e640ebb3f436a6e84b45ab428846fde3c88805ef 100644 (file)
config.foregroundFPS = 60;
config.title = "CaveCraft";
config.width = 960;
- config.height = 720;
+ config.height = 540;
new LwjglApplication(new CaveGame(), config);
}
}