diff --git a/core/src/ru/deadsoftware/cavedroid/game/world/GameWorldGenerator.kt b/core/src/ru/deadsoftware/cavedroid/game/world/GameWorldGenerator.kt
index e00a0ea4dd2cd3397b632650b69b635cdc1ec24f..004a56b01a945ec581dd084a5e26c390da3de190 100644 (file)
val bedrock = gameItemsHolder.getBlock("bedrock")
val dirt = gameItemsHolder.getBlock("dirt")
val stone = gameItemsHolder.getBlock("stone")
val bedrock = gameItemsHolder.getBlock("bedrock")
val dirt = gameItemsHolder.getBlock("dirt")
val stone = gameItemsHolder.getBlock("stone")
+ val snow = gameItemsHolder.getBlock("snow")
foreMap[x][surfaceHeight] = grass
foreMap[x][config.height - 1] = bedrock
backMap[x][surfaceHeight] = grass
backMap[x][config.height - 1] = bedrock
foreMap[x][surfaceHeight] = grass
foreMap[x][config.height - 1] = bedrock
backMap[x][surfaceHeight] = grass
backMap[x][config.height - 1] = bedrock
+ if (surfaceHeight - 1 < config.seaLevel) {
+ foreMap[x][surfaceHeight - 1] = snow
+ }
+
for (y in min(surfaceHeight + 1, config.seaLevel) ..< config.height - 1) {
if (y <= surfaceHeight) {
backMap[x][y] = dirt
for (y in min(surfaceHeight + 1, config.seaLevel) ..< config.height - 1) {
if (y <= surfaceHeight) {
backMap[x][y] = dirt
}
backMap[x][y] = foreMap[x][y]
}
}
backMap[x][y] = foreMap[x][y]
}
+
+ val plant = random.nextInt(100)
+ if (surfaceHeight < config.seaLevel) {
+ if (plant < 10) {
+ generateSpruce(x)
+ }
+ }
}
private fun plainsBiome(x: Int) {
}
private fun plainsBiome(x: Int) {
}
}
}
}
+ private fun generateSpruce(x: Int) {
+ val log = gameItemsHolder.getBlock("log_spruce")
+ val leaves = gameItemsHolder.getBlock("leaves_spruce")
+ val h = heights[x] - 1
+ val treeH = random.nextInt(7, 9)
+ val height = max(0, h - treeH)
+
+ val top = height - 1
+ if (top >= 0) {
+ foreMap[x][top] = leaves
+ backMap[x][top] = leaves
+ }
+
+ for (x1 in max(0, x - 1) .. min(config.width - 1, x + 1)) {
+ val y = height
+ foreMap[x1][y] = leaves
+ backMap[x1][y] = leaves
+ }
+
+ for (y in 1..2) {
+ for (x1 in max(0, x - y) .. min(config.width - 1, x + y)) {
+ foreMap[x1][height + 1 + y] = leaves
+ backMap[x1][height + 1 + y] = leaves
+ }
+ }
+
+ for (y in h downTo height) {
+ backMap[x][y] = log
+ }
+ }
+
private fun generateTallGrass(x: Int) {
val tallGrass = gameItemsHolder.getBlock(plainsPlants.random(random))
val h = heights[x] - 1
private fun generateTallGrass(x: Int) {
val tallGrass = gameItemsHolder.getBlock(plainsPlants.random(random))
val h = heights[x] - 1