Fix variable naming from r to phi in shadow calculation function
This commit is contained in:
parent
03070cfff7
commit
cd5c844c52
@ -16,32 +16,34 @@ local function makeGradientMesh(w, h, topColor, bottomColor)
|
|||||||
return mesh
|
return mesh
|
||||||
end
|
end
|
||||||
|
|
||||||
local function getFakeShadow(r)
|
--- @param phi number угол, под которым падает свет
|
||||||
|
--- @return boolean, number: рисуем ли тень * её прозрачность
|
||||||
|
local function getFakeShadow(phi)
|
||||||
local pi = math.pi
|
local pi = math.pi
|
||||||
|
|
||||||
if r <= pi / 4 then
|
if phi <= pi / 4 then
|
||||||
-- 1
|
-- 1
|
||||||
return false, 1
|
return false, 1
|
||||||
end
|
end
|
||||||
if r <= pi / 2 then
|
if phi <= pi / 2 then
|
||||||
-- 2
|
-- 2
|
||||||
return true, 1 - (r - pi / 4) / (pi / 4)
|
return true, 1 - (phi - pi / 4) / (pi / 4)
|
||||||
end
|
end
|
||||||
if r <= 3 * pi / 4 then
|
if phi <= 3 * pi / 4 then
|
||||||
-- 3
|
-- 3
|
||||||
return true, (r - pi / 2) / (pi / 4)
|
return true, (phi - pi / 2) / (pi / 4)
|
||||||
end
|
end
|
||||||
if r <= 5 * pi / 4 then
|
if phi <= 5 * pi / 4 then
|
||||||
-- 4
|
-- 4
|
||||||
return false, 1
|
return false, 1
|
||||||
end
|
end
|
||||||
if r <= 3 * pi / 2 then
|
if phi <= 3 * pi / 2 then
|
||||||
-- 5
|
-- 5
|
||||||
return true, 1 - (r - 5 * pi / 4) / (pi / 4)
|
return true, 1 - (phi - 5 * pi / 4) / (pi / 4)
|
||||||
end
|
end
|
||||||
if r <= 7 * pi / 4 then
|
if phi <= 7 * pi / 4 then
|
||||||
-- 6
|
-- 6
|
||||||
return true, (r - 3 * pi / 2) / (pi / 4)
|
return true, (phi - 3 * pi / 2) / (pi / 4)
|
||||||
end
|
end
|
||||||
-- 1
|
-- 1
|
||||||
return false, 1
|
return false, 1
|
||||||
@ -67,10 +69,10 @@ function behavior:draw()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local r = love.timer.getTime() % (2 * math.pi)
|
local phi = love.timer.getTime() % (2 * math.pi)
|
||||||
|
|
||||||
local drawFakeShadow, opacity = getFakeShadow(r)
|
local drawFakeShadow, opacity = getFakeShadow(phi)
|
||||||
local nangle = (math.pi + r) % (2 * math.pi)
|
local nangle = (math.pi + phi) % (2 * math.pi)
|
||||||
love.graphics.rotate(nangle)
|
love.graphics.rotate(nangle)
|
||||||
|
|
||||||
love.graphics.setColor(0, 0, 0, math.min(opacity * opacity, 0.5))
|
love.graphics.setColor(0, 0, 0, math.min(opacity * opacity, 0.5))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user