From: fredboy Date: Tue, 16 Apr 2024 11:59:20 +0000 (+0700) Subject: Add ocean X-Git-Tag: alpha0.4.2~9 X-Git-Url: https://deadsoftware.ru/gitweb?p=cavedroid.git;a=commitdiff_plain;h=1f0038c3cd76a2df8cf74aafcea9aea656d440a4 Add ocean --- diff --git a/core/src/ru/deadsoftware/cavedroid/game/world/GameWorldGenerator.kt b/core/src/ru/deadsoftware/cavedroid/game/world/GameWorldGenerator.kt index bc5ffa4..bf37f45 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/world/GameWorldGenerator.kt +++ b/core/src/ru/deadsoftware/cavedroid/game/world/GameWorldGenerator.kt @@ -91,6 +91,18 @@ object GameWorldGenerator { } } + private fun fillWater(foreMap: Array, 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 @@ -102,7 +114,7 @@ object GameWorldGenerator { 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 @@ -115,8 +127,10 @@ object GameWorldGenerator { 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) }