setup to start modifying other maps
This commit is contained in:
+6
-2
@@ -67,16 +67,20 @@ love.draw = function()
|
||||
love.graphics.translate(window_width / 2 - (map.size * map.tile_size) / 2 - camera.x, window_height / 2 - (map.size * map.tile_size) / 2 - camera.y)
|
||||
|
||||
for x = 1, map.size do
|
||||
if map.biome[x] then
|
||||
for y = 1, map.size do
|
||||
-- print(x, y) -- TEMP why am I getting an out of bounds?
|
||||
local value = map.biome[x][y]
|
||||
-- local value = map.biome[x][y]
|
||||
local value = map.temperature[x][y]
|
||||
if value then
|
||||
love.graphics.setColor(value)
|
||||
-- love.graphics.setColor(value)
|
||||
love.graphics.setColor(value, 0, 0, 1)
|
||||
love.graphics.rectangle("fill", x * map.tile_size, y * map.tile_size, map.tile_size, map.tile_size)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
love.keypressed = function(key)
|
||||
if key == "escape" then
|
||||
|
||||
+18
-5
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user