53 lines
1.2 KiB
Lua
53 lines
1.2 KiB
Lua
local tex = love.graphics.newImage("circle.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(0, 0, 8, 8, tex)
|
|
|
|
local z = require("zprite").zchunk.new(tex, 128, 32)
|
|
z._height_scale = 8
|
|
|
|
local function update_map()
|
|
z:clear()
|
|
for i = -64, 64 do
|
|
for j = -64, 64 do
|
|
local layers = love.math.simplexNoise(i * 0.02, j * 0.02) * 29 + 3
|
|
z:put(i * 8, j * 8, 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)
|
|
for _ = 1, 4 do
|
|
if coroutine.status(co) == "suspended" then
|
|
coroutine.resume(co)
|
|
end
|
|
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, 1, 1)
|
|
end
|