diff --git a/src/main.lua b/src/main.lua index d6b7d64..e3bebff 100644 --- a/src/main.lua +++ b/src/main.lua @@ -5,46 +5,67 @@ local lume = require "lib.lume" local map = {} local biomes = { - [1] = { - 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}, - }, - [2] = { - 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}, - }, - [3] = { - 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}, - }, - [4] = { - 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}, + [5] = { + name = "ocean", + altitude = {min = 0, max = 0.2}, -- bottom of world is the only part that matters + temperature = {min = 0, max = 1}, + humidity = {min = 0, max = 1}, + color = {0, 0, 0.67, 1}, }, [6] = { + name = "beach", + altitude = {min = 0.2, max = 0.205}, -- just above ocean + temperature = {min = 0, max = 1}, + humidity = {min = 0, max = 0.8}, -- excluding upper humidity for swamp + color = {1, 1, 0.33, 1}, -- brighter yellow to distinguish from sand + }, + [8] = { + name = "swamp", -- fun idea, but generates between ocean and water too often? + altitude = {min = 0, max = 1}, + temperature = {min = 0.5, max = 1}, + humidity = {min = 0.95, max = 1}, + color = {0, 0.5, 0.33, 1}, + }, + [10] = { + name = "water", + altitude = {min = 0, max = 0.9}, -- top excluded because it should've gone downhill + temperature = {min = 0.1, max = 0.9}, -- bottom should be ice, top should evaporate + humidity = {min = 0.8, max = 1}, -- only the wettest places + color = {0, 0, 1, 1}, + }, + [20] = { + name = "sand", + altitude = {min = 0.2, max = 0.9}, -- top falls down, bottom is underwater + temperature = {min = 0, max = 1}, + humidity = {min = 0, max = 0.2}, -- only where dry makes more sense for a desert + color = {1, 1, 0, 1}, + }, + [30] = { + name = "grass", + altitude = {min = 0.3, max = 0.9}, -- top of the world not enough air, bottom too wet / leaving space for others + temperature = {min = 0.2, max = 0.8}, -- not very sensitive to temperature + humidity = {min = 0.2, max = 0.6}, -- not very sensitive to humidity; but excluded from the worst + color = {0, 1, 0, 1}, + }, + [40] = { + name = "trees", + altitude = {min = 0.4, max = 0.7}, -- more sensitive than grass + temperature = {min = 0, max = 0.7}, + humidity = {min = 0.3, max = 0.8}, -- these are not desert trees, they need more water + color = {0, 0.67, 0, 1}, + }, + [60] = { 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}, }, - [5] = { + [50] = { name = "ice", altitude = {min = 0, max = 1}, - temperature = {min = 0, max = 0.1}, - humidity = {min = 0.1, max = 1}, + temperature = {min = 0, max = 0.01}, + humidity = {min = 0.2, max = 1}, color = {1, 1, 1, 1}, }, } @@ -87,13 +108,21 @@ love.load = function() end -- planetizer! + local biome_order = {} + for order in pairs(biomes) do + biome_order[#biome_order + 1] = order + end + table.sort(biome_order) + map.terrain = {w = map.size, h = map.size} local radius = (map.size / 2)^2 for x = 0, map.size do map.terrain[x] = {} for y = 0, map.size do if lume.distance(x, y, map.size / 2, map.size / 2, true) < radius then - for _, biome in ipairs(biomes) do + -- for _, biome in ipairs(biomes) do + for _, order in ipairs(biome_order) do + local biome = biomes[order] local altitude = map.altitude[x][y] if altitude >= biome.altitude.min and altitude <= biome.altitude.max then local temperature = map.temperature[x][y]