Add beaches and use different sprites
This commit is contained in:
parent
53c2840d1f
commit
e255ae4e85
BIN
circle.png
BIN
circle.png
Binary file not shown.
Before Width: | Height: | Size: 124 B |
48
main.lua
48
main.lua
@ -1,4 +1,4 @@
|
|||||||
local tex = love.graphics.newImage("circle.png")
|
local tex = love.graphics.newImage("atlas.png")
|
||||||
tex:setFilter("nearest", "nearest")
|
tex:setFilter("nearest", "nearest")
|
||||||
|
|
||||||
local function water_color(layer)
|
local function water_color(layer)
|
||||||
@ -6,6 +6,10 @@ local function water_color(layer)
|
|||||||
return value / 4, value / 2, value
|
return value / 4, value / 2, value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function sand_color(layer)
|
||||||
|
return layer / 32 + 0.2, layer / 32 + 0.15, 0.4
|
||||||
|
end
|
||||||
|
|
||||||
local function dirt_color(layer)
|
local function dirt_color(layer)
|
||||||
if layer < 32 then
|
if layer < 32 then
|
||||||
return layer / 40 / 2.5, layer / 80 / 2.5, 0.1
|
return layer / 40 / 2.5, layer / 80 / 2.5, 0.1
|
||||||
@ -16,7 +20,7 @@ end
|
|||||||
|
|
||||||
local function mountain_color(layer)
|
local function mountain_color(layer)
|
||||||
if layer < 58 then
|
if layer < 58 then
|
||||||
local value = layer / 64 / 2.5
|
local value = layer / 64 / 2 - 0.1
|
||||||
return value, value, value
|
return value, value, value
|
||||||
else
|
else
|
||||||
local value = (layer - 58) / 20 + 0.7
|
local value = (layer - 58) / 20 + 0.7
|
||||||
@ -27,6 +31,8 @@ end
|
|||||||
local function pick_colorfn(maxlayer)
|
local function pick_colorfn(maxlayer)
|
||||||
if maxlayer < 16 then
|
if maxlayer < 16 then
|
||||||
return water_color
|
return water_color
|
||||||
|
elseif maxlayer < 22 then
|
||||||
|
return sand_color
|
||||||
elseif maxlayer < 46 then
|
elseif maxlayer < 46 then
|
||||||
return dirt_color
|
return dirt_color
|
||||||
else
|
else
|
||||||
@ -38,9 +44,41 @@ local function ease(n)
|
|||||||
return 5 ^ (3.1 * (n ^ 0.3) - 3) + 1 - 1.1 ^ n
|
return 5 ^ (3.1 * (n ^ 0.3) - 3) + 1 - 1.1 ^ n
|
||||||
end
|
end
|
||||||
|
|
||||||
local BIG_BLOCK = love.graphics.newQuad(0, 0, 8, 8, tex)
|
local WATER = love.graphics.newQuad(1, 1, 8, 8, tex)
|
||||||
|
local SAND = love.graphics.newQuad(11, 1, 8, 8, tex)
|
||||||
|
local DIRT = love.graphics.newQuad(21, 1, 8, 8, tex)
|
||||||
|
local GRASS = love.graphics.newQuad(31, 1, 8, 8, tex)
|
||||||
|
local STONE = love.graphics.newQuad(1, 11, 8, 8, tex)
|
||||||
|
local SNOW = love.graphics.newQuad(11, 11, 8, 8, tex)
|
||||||
|
|
||||||
local z = require("zprite").zchunk.new(tex, 128, 32)
|
local function dirt_sprite(layer)
|
||||||
|
if layer < 32 then
|
||||||
|
return DIRT
|
||||||
|
end
|
||||||
|
return GRASS
|
||||||
|
end
|
||||||
|
|
||||||
|
local function mountain_sprite(layer)
|
||||||
|
if layer < 58 then
|
||||||
|
return STONE
|
||||||
|
end
|
||||||
|
return SNOW
|
||||||
|
end
|
||||||
|
|
||||||
|
local function pick_sprite(maxlayer)
|
||||||
|
if maxlayer < 16 then
|
||||||
|
return WATER
|
||||||
|
end
|
||||||
|
if maxlayer < 22 then
|
||||||
|
return SAND
|
||||||
|
end
|
||||||
|
if maxlayer < 46 then
|
||||||
|
return dirt_sprite
|
||||||
|
end
|
||||||
|
return mountain_sprite
|
||||||
|
end
|
||||||
|
|
||||||
|
local z = require("zprite").zchunk.new(tex, 128, 64)
|
||||||
|
|
||||||
local function update_map()
|
local function update_map()
|
||||||
z:clear()
|
z:clear()
|
||||||
@ -48,7 +86,7 @@ local function update_map()
|
|||||||
for j = -160, 160 do
|
for j = -160, 160 do
|
||||||
local noise_value = love.math.simplexNoise(i * 0.008, j * 0.008)
|
local noise_value = love.math.simplexNoise(i * 0.008, j * 0.008)
|
||||||
local layers = ease(noise_value) * 64
|
local layers = ease(noise_value) * 64
|
||||||
z:put(i * 8, j * 8, BIG_BLOCK, math.floor(layers) + 1, pick_colorfn(layers))
|
z:put(i * 8, j * 8, pick_sprite(layers), math.floor(layers) + 1, pick_colorfn(layers))
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
2
zprite
2
zprite
@ -1 +1 @@
|
|||||||
Subproject commit 6eba579c969700428afdfe4d67c670d5400405ae
|
Subproject commit ccfa075d244c87171799941125decd143c3fb37a
|
Loading…
x
Reference in New Issue
Block a user