better biomes, but not balanced

This commit is contained in:
2026-07-19 08:30:06 -06:00
parent cf72109178
commit bcfadc4800
+41 -19
View File
@@ -5,29 +5,47 @@ local lume = require "lib.lume"
local map = {} local map = {}
local biomes = { local biomes = {
water = { [1] = {
altitude = {min = 0, max = 0.2}, name = "water",
altitude = {min = 0, max = 0.9},
temperature = {min = 0.1, max = 0.9},
humidity = {min = 0.8, max = 1},
color = {0, 0, 1, 1}, color = {0, 0, 1, 1},
}, },
sand = { [2] = {
altitude = {min = 0.2, max = 0.215}, name = "sand",
altitude = {min = 0.2, max = 0.9},
temperature = {min = 0.2, max = 1},
humidity = {min = 0, max = 0.2},
color = {1, 1, 0, 1}, color = {1, 1, 0, 1},
}, },
grass = { [3] = {
altitude = {min = 0.215, max = 0.34}, name = "grass",
altitude = {min = 0.3, max = 0.9},
temperature = {min = 0.2, max = 0.8},
humidity = {min = 0.3, max = 0.6},
color = {0, 1, 0, 1}, color = {0, 1, 0, 1},
}, },
trees = { [4] = {
altitude = {min = 0.34, max = 0.72}, name = "trees",
altitude = {min = 0.4, max = 0.7},
temperature = {min = 0, max = 0.7},
humidity = {min = 0.1, max = 1},
color = {0, 0.67, 0, 1}, color = {0, 0.67, 0, 1},
}, },
stone = { [6] = {
altitude = {min = 0.72, max = 0.9}, name = "stone",
altitude = {min = 0, max = 1},
temperature = {min = 0, max = 1},
humidity = {min = 0, max = 1},
color = {0.67, 0.67, 0.67, 1}, color = {0.67, 0.67, 0.67, 1},
}, },
ice = { [5] = {
altitude = {min = 0.9, max = 1}, name = "ice",
color = {1, 1, 1, 1} altitude = {min = 0, max = 1},
temperature = {min = 0, max = 0.1},
humidity = {min = 0.1, max = 1},
color = {1, 1, 1, 1},
}, },
} }
@@ -55,7 +73,7 @@ love.load = function()
for x = 0, map.temperature.w do for x = 0, map.temperature.w do
for y = 0, map.temperature.h do for y = 0, map.temperature.h do
local distance = math.abs(y - center_y) local distance = math.abs(y - center_y)
map.temperature[x][y] = lume.clamp(map.temperature[x][y] - distance / map.size / 2, 0, 1) map.temperature[x][y] = lume.clamp(map.temperature[x][y] - distance / map.size, 0, 1)
end end
end end
heightmap.normalize(map.temperature, 0, 1) heightmap.normalize(map.temperature, 0, 1)
@@ -74,11 +92,13 @@ love.load = function()
map.terrain[x] = {} map.terrain[x] = {}
for y = 0, map.size do for y = 0, map.size do
if lume.distance(x, y, map.size / 2, map.size / 2, true) < radius then if lume.distance(x, y, map.size / 2, map.size / 2, true) < radius then
for name, biome in pairs(biomes) do for _, biome in ipairs(biomes) do
local value = map.altitude[x][y] local altitude = map.altitude[x][y]
-- this allows a non-deterministic change of terrain if altitude >= biome.altitude.min and altitude <= biome.altitude.max then
-- depending on which biome is checked first but I don't care right now] local temperature = map.temperature[x][y]
if value >= biome.altitude.min and value <= biome.altitude.max then if temperature >= biome.temperature.min and temperature <= biome.temperature.max then
local humidity = map.humidity[x][y]
if humidity >= biome.humidity.min and humidity <= biome.humidity.max then
map.terrain[x][y] = biome.color map.terrain[x][y] = biome.color
break break
end end
@@ -86,6 +106,8 @@ love.load = function()
end end
end end
end end
end
end
end end
love.update = function(dt) love.update = function(dt)