setup to start modifying other maps

This commit is contained in:
2026-08-19 01:59:25 -06:00
parent c04b9d4574
commit 03fd2ea05e
2 changed files with 28 additions and 11 deletions
+18 -5
View File
@@ -38,11 +38,15 @@ simplex_map.normalize = function(map, new_min, new_max)
return map -- superfluous
end
simplex_map.generate = function(size, scale, min, max)
simplex_map.generate = function(size, scale, min, max, octaves, lacunarity, gain)
if type(size) == "table" then
scale = size.scale
min = size.min
max = size.max
octaves = size.octaves
lacunarity = size.lacunarity
gain = size.gain
size = size.size
end
@@ -54,7 +58,7 @@ simplex_map.generate = function(size, scale, min, max)
for x = 1, map.size do
map[x] = {}
for y = 1, map.size do
map[x][y] = simplex.FractalBrownianMotion2D(x * scale, y * scale, 7)
map[x][y] = simplex.FractalBrownianMotion2D(x * scale, y * scale, octaves, lacunarity, gain)
end
end
@@ -117,9 +121,18 @@ local generate = function()
local map = {}
map.size = 500
map.tile_size = 1 -- TODO tile_size really shouldn't be the responsibility of the map generator - it's a rendering detail, not a map feature
map.altitude = simplex_map.generate(map.size, 0.001, 0, 1) -- meters
map.temperature = simplex_map.generate(map.size, 0.005, -89.2, 56.7) -- celsius
map.rainfall = simplex_map.generate(map.size, 0.005, 18, 3240) -- millimeters rainfall
map.altitude = simplex_map.generate{ -- will be converted to meters
size = map.size, scale = 0.001, min = 0, max = 1,
octaves = 7, lacunarity = 2, gain = 0.5,
}
map.temperature = simplex_map.generate{ -- in celsius
size = map.size, scale = 0.005, min = 0, max = 1, -- min = -89.2, max = 56.7,
octaves = 1, lacunarity = 2, gain = 0.5,
}
map.rainfall = simplex_map.generate{ -- in millimeters of rainfall
size = map.size, scale = 0.005, -- min = 18, max = 3240,
octaves = 1, lacunarity = 2, gain = 0.5,
}
local function earthlike_altitude_adjustment(altitude)
-- TODO replace with a simpler function?