You can pass the draw function a texture table to set the colours drawn so planet types can all be different colours etc.
Usage:
Code: Select all
--call your lib
local mg = require "/Lib/mapgen"
--Make a texture:
--The texture table is a numbered table with two values;
--cutoff: all values below the cutoff will be set to the colour.
--col: a table of 3 RGB percentages, the height is multiplied by these to get an RGB colour
-- and makes a nice gradient
local earthTexture = {
--the numbers in the col table are percentages of the height value so enter numbers 0-1
--Colours should be ordered lowest to highest, sea floor to mountain peaks.
[1] = {cutoff = 130, col = {0, .1, 1}},--Deep Blue
[2] = {cutoff = 150, col = {0, .3, .9}},--Lighter Blue
[3] = {cutoff = 155, col = {0, .5, .8}},--Cyan
[4] = {cutoff = 160, col = {1, 1, 0}},--Yellow
[5] = {cutoff = 200, col = {0, .5, 0}},--Green
[6] = {cutoff = 220, col = {0, .3, 0}},--Dark Green
[7] = {cutoff = 240, col = {.5, .5, .5}},--Grey
[8] = {cutoff = 260, col = {1, 1, 1}},--White
}
function love.load()
local seed = math.random(1, 1000000)--or any number you want.
local amp = math.random(50, 2000) --or any number you want
local freq = math.random(100, 400) --or any number you want
local oct = math.random(14, 20) --or any number you want High numbers here make it take longer to generate.
map = mapgen.generate(seed, mapWidth, mapHeight, amp, freq, oct) --Make a new map.
canvas = mapgen.drawCanvas(map, earthTexture) --to draw the planet to a canvas pass it
-- the planet map and a texture table.
end
function love.draw()
love.graphics.draw(canvas, 1, 1)
end
Let me know what you think.
![Smile :)](./images/smilies/ms-smile.png)