better sizing of current status
This commit is contained in:
@@ -556,4 +556,21 @@ function simplex.Seed(seed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TODO test functionality
|
||||||
|
function simplex.FractalBrownianMotion2D(x, y, octaves, lacunarity, gain)
|
||||||
|
octaves = octaves or 4
|
||||||
|
lacunarity = lacunarity or 2
|
||||||
|
gain = gain or 0.5
|
||||||
|
|
||||||
|
local total, amplitude, frequency, peak_amplitude = 0, 1, 1, 0
|
||||||
|
for i = 1, octaves do
|
||||||
|
total = total + amplitude * simplex.Noise2D(x * frequency, y * frequency)
|
||||||
|
peak_amplitude = peak_amplitude + amplitude
|
||||||
|
amplitude = amplitude * gain
|
||||||
|
frequency = frequency * lacunarity
|
||||||
|
end
|
||||||
|
|
||||||
|
return total / peak_amplitude -- normalize to [-1, 1]
|
||||||
|
end
|
||||||
|
|
||||||
return simplex
|
return simplex
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
math.randomseed(os.time())
|
||||||
|
|
||||||
local map_generator = require "map_nextgen"
|
local map_generator = require "map_nextgen"
|
||||||
local lovebird = require "lib.lovebird"
|
local lovebird = require "lib.lovebird"
|
||||||
local lume = require "lib.lume"
|
local lume = require "lib.lume"
|
||||||
@@ -81,5 +83,9 @@ love.keypressed = function(key)
|
|||||||
love.event.quit()
|
love.event.quit()
|
||||||
elseif key == "r" then
|
elseif key == "r" then
|
||||||
love.load()
|
love.load()
|
||||||
|
elseif key == "=" then
|
||||||
|
map.tile_size = map.tile_size * 2
|
||||||
|
elseif key == "-" then
|
||||||
|
map.tile_size = map.tile_size / 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+2
-2
@@ -54,7 +54,7 @@ simplex_map.generate = function(size, scale, min, max)
|
|||||||
for x = 1, map.size do
|
for x = 1, map.size do
|
||||||
map[x] = {}
|
map[x] = {}
|
||||||
for y = 1, map.size do
|
for y = 1, map.size do
|
||||||
map[x][y] = simplex.Noise2D(x * scale, y * scale)
|
map[x][y] = simplex.FractalBrownianMotion2D(x * scale, y * scale, 7)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ local generate = function()
|
|||||||
local map = {}
|
local map = {}
|
||||||
map.size = 500
|
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.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.005, 0, 1) -- meters
|
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.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.rainfall = simplex_map.generate(map.size, 0.005, 18, 3240) -- millimeters rainfall
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user