51 lines
1.2 KiB
Lua
51 lines
1.2 KiB
Lua
local tex = love.graphics.newImage("mrmo3x.png")
|
|
tex:setFilter("nearest", "nearest")
|
|
|
|
local function dirt_color(layer)
|
|
if layer < 18 then
|
|
return layer / 26 / 2.5, layer / 52 / 2.5, 0.1
|
|
else
|
|
return 0.05, (layer - 18) / 10 + 0.3, 0.05
|
|
end
|
|
end
|
|
|
|
local function mountain_color(layer)
|
|
if layer < 29 then
|
|
local value = layer / 32 / 2.5
|
|
return value, value, value
|
|
else
|
|
local value = (layer - 29) / 10 + 0.7
|
|
return value, value, value
|
|
end
|
|
end
|
|
|
|
local BIG_BLOCK = love.graphics.newQuad(24 * 9, 24 * 9, 24, 24, tex)
|
|
|
|
local z = require("zprite").zchunk.new(tex, 384, 40)
|
|
z._height_scale = 10
|
|
|
|
local function update_map()
|
|
for i = -32, 32 do
|
|
for j = -32, 32 do
|
|
local layers = love.math.simplexNoise(i * 0.02, j * 0.02) * 34 + 6
|
|
z:put(i * 24, j * 24, BIG_BLOCK, math.floor(layers) + 1, layers < 23 and dirt_color or mountain_color)
|
|
coroutine.yield()
|
|
end
|
|
end
|
|
end
|
|
|
|
local co = coroutine.create(update_map)
|
|
|
|
local angle = 0
|
|
|
|
function love.update(dt)
|
|
if coroutine.status(co) == "suspended" then
|
|
coroutine.resume(co)
|
|
end
|
|
angle = math.fmod(angle + dt * 0.8, 2 * math.pi)
|
|
end
|
|
|
|
function love.draw()
|
|
z:draw(love.graphics.getWidth() / 2, love.graphics.getHeight() / 2 + 128, angle, 0.3, 0.3)
|
|
end
|