Add shadowing using latest library features
This commit is contained in:
parent
d4d6a140ef
commit
49ef00c94a
BIN
atlas.png
BIN
atlas.png
Binary file not shown.
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 287 B |
37
main.lua
37
main.lua
@ -6,7 +6,7 @@ tex:setFilter("nearest", "nearest")
|
||||
local gx = 0
|
||||
local gy = 0
|
||||
local angle = 0
|
||||
local scale = 1
|
||||
local scale = 0.35
|
||||
local dist = 5
|
||||
|
||||
local atlas = {
|
||||
@ -19,14 +19,27 @@ local atlas = {
|
||||
}
|
||||
|
||||
local alpha = 0.75
|
||||
local shadow_alpha = 0.15
|
||||
local colors = {}
|
||||
function colors.water(layer)
|
||||
if layer % 2 == 0 then
|
||||
return 0, 0, 0, shadow_alpha
|
||||
end
|
||||
layer = layer / 2
|
||||
return 0.1, layer / 16, layer / 8, alpha
|
||||
end
|
||||
function colors.sand(layer)
|
||||
if layer % 2 == 0 then
|
||||
return 0, 0, 0, shadow_alpha
|
||||
end
|
||||
layer = layer / 2
|
||||
return layer / 16 + 0.2, layer / 16 + 0.15, 0.4, alpha
|
||||
end
|
||||
function colors.dirt(layer)
|
||||
if layer % 2 == 0 then
|
||||
return 0, 0, 0, shadow_alpha
|
||||
end
|
||||
layer = layer / 2
|
||||
if layer < 16 then
|
||||
return layer / 40, layer / 80, 0.1, alpha
|
||||
else
|
||||
@ -34,19 +47,31 @@ function colors.dirt(layer)
|
||||
end
|
||||
end
|
||||
function colors.stone(layer)
|
||||
if layer % 2 == 0 then
|
||||
return 0, 0, 0, shadow_alpha
|
||||
end
|
||||
layer = layer / 2
|
||||
local value = layer / 48 - 0.2
|
||||
return value / 1.1, value, value * 1.1, alpha
|
||||
end
|
||||
function colors.snow(layer)
|
||||
if layer % 2 == 0 then
|
||||
return 0, 0, 0, shadow_alpha
|
||||
end
|
||||
layer = layer / 2
|
||||
local value = layer / 48 + 0.25
|
||||
return value / 1.1, value, value * 1.1, alpha
|
||||
end
|
||||
|
||||
local function offset_map(_)
|
||||
return -1, 1
|
||||
local function offset_map(layer)
|
||||
if layer % 2 == 0 then
|
||||
return 1, 7
|
||||
else
|
||||
return 0, 7
|
||||
end
|
||||
end
|
||||
|
||||
local z = zprite.zchunk.new(tex, 16 * 8, 40, dist * 2 + 1)
|
||||
local z = zprite.zchunk.new(tex, 16 * 8, 80, dist * 2 + 1)
|
||||
|
||||
local function layered_noise(x, y, layers, persistence)
|
||||
local freq = 1
|
||||
@ -114,7 +139,7 @@ end
|
||||
|
||||
local function generate(x, y)
|
||||
local height = heightmap(x, y)
|
||||
z:put(x, y, atlas.stone, math.ceil(height * 40), pick_color(height), offset_map)
|
||||
z:put(x, y, atlas.stone, math.ceil(height * 80), pick_color(height), offset_map)
|
||||
end
|
||||
|
||||
local generated = {}
|
||||
@ -199,7 +224,7 @@ end
|
||||
local t = love.math.newTransform()
|
||||
|
||||
function love.draw()
|
||||
z._height_scale = 18 * scale
|
||||
z._height_scale = scale * 1.4
|
||||
|
||||
t:reset()
|
||||
t:translate(love.graphics.getWidth() / 2, love.graphics.getHeight() / 2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user