summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e7a1e15)
raw | patch | inline | side by side (parent: e7a1e15)
author | fredboy <fredboy@protonmail.com> | |
Tue, 16 Apr 2024 11:59:20 +0000 (18:59 +0700) | ||
committer | fredboy <fredboy@protonmail.com> | |
Tue, 16 Apr 2024 11:59:20 +0000 (18:59 +0700) |
core/src/ru/deadsoftware/cavedroid/game/world/GameWorldGenerator.kt | patch | blob | history |
diff --git a/core/src/ru/deadsoftware/cavedroid/game/world/GameWorldGenerator.kt b/core/src/ru/deadsoftware/cavedroid/game/world/GameWorldGenerator.kt
index bc5ffa4cc4afdaf382e2b626844667fb0fe96e3e..bf37f454c3ad36851a40062e5d74b2ffad7cdfde 100644 (file)
}
}
+ private fun fillWater(foreMap: Array<IntArray>, width: Int, height: Int, waterLevel: Int) {
+ for (x in 0 until width) {
+ for (y in waterLevel until height) {
+ if (foreMap[x][y] != 0) {
+ break
+ }
+
+ foreMap[x][y] = GameItems.getBlockId("water")
+ }
+ }
+ }
+
/**
* Generates world of given width and height with given seed
* @param width world width
val random = Random(seed)
val foreMap = Array(width) { IntArray(height) }
val backMap = Array(width) { IntArray(width) }
- val heightsMap = generateHeights(width, height / 2, height * 3 / 4, random)
+ val heightsMap = generateHeights(width, height / 4, height * 3 / 4, random)
val biomesMap = generateBiomes(width, random)
var biome = Biome.PLAINS
Biome.PLAINS -> plainsBiome(foreMap, backMap, width, height, x, xHeight, random)
Biome.DESERT -> desertBiome(foreMap, backMap, width, height, x, xHeight, random)
}
-
}
+
+ fillWater(foreMap, width, height, height / 2)
+
return Pair(foreMap, backMap)
}