shadow work around complete
This commit is contained in:
18
src/lightWorldRectangleFix.lua
Normal file
18
src/lightWorldRectangleFix.lua
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
function lightWorldRectangleFix(world, x, y, w, h)
|
||||||
|
-- add half of width/height because lightWorld uses centered rectangles
|
||||||
|
local shadow = world:newRectangle(x + w / 2, y + h / 2, w, h)
|
||||||
|
-- fix ox/oy, width, height
|
||||||
|
shadow.ox = w / 2
|
||||||
|
shadow.oy = h / 2
|
||||||
|
shadow.width = w
|
||||||
|
shadow.height = h
|
||||||
|
-- fix data object
|
||||||
|
shadow.data = {
|
||||||
|
--4 pairs x/y, clockwise
|
||||||
|
x, y,
|
||||||
|
x + w, y,
|
||||||
|
x + w, y + h,
|
||||||
|
x, y + h
|
||||||
|
}
|
||||||
|
return shadow
|
||||||
|
end
|
34
src/main.lua
34
src/main.lua
@@ -1,4 +1,6 @@
|
|||||||
function love.load()
|
function love.load()
|
||||||
|
require "lightWorldRectangleFix"
|
||||||
|
|
||||||
local LightWorld = require "lib.light_world"
|
local LightWorld = require "lib.light_world"
|
||||||
lightWorld = LightWorld({
|
lightWorld = LightWorld({
|
||||||
drawBackground = drawBackground,
|
drawBackground = drawBackground,
|
||||||
@@ -12,40 +14,12 @@ function love.load()
|
|||||||
|
|
||||||
thompson = {
|
thompson = {
|
||||||
color = {255, 0, 0},
|
color = {255, 0, 0},
|
||||||
--[[x = 50,
|
x = 50,
|
||||||
y = 50,
|
y = 50,
|
||||||
w = 17,
|
w = 17,
|
||||||
h = 27]]
|
|
||||||
x = 500,
|
|
||||||
y = 50,
|
|
||||||
w = 170,
|
|
||||||
h = 27
|
h = 27
|
||||||
}
|
}
|
||||||
thompson.shadow = lightWorld:newRectangle(thompson.x + thompson.w / 2, thompson.y + thompson.h / 2, thompson.w, thompson.h)
|
thompson.shadow = lightWorldRectangleFix(lightWorld, thompson.x, thompson.y, thompson.w, thompson.h)
|
||||||
-- work arounds for broken constructor
|
|
||||||
thompson.shadow.ox = thompson.w / 2--* 2--/ 2
|
|
||||||
thompson.shadow.oy = thompson.h / 2--* 2--/ 2
|
|
||||||
thompson.shadow.width = thompson.w
|
|
||||||
thompson.shadow.height = thompson.h
|
|
||||||
thompson.shadow.data = {
|
|
||||||
--8 values, 4 x/y pairs, start at top left, clockwise
|
|
||||||
thompson.x,
|
|
||||||
thompson.y,
|
|
||||||
thompson.x + thompson.w,
|
|
||||||
thompson.y,
|
|
||||||
thompson.x + thompson.w,
|
|
||||||
thompson.y + thompson.h,
|
|
||||||
thompson.x,
|
|
||||||
thompson.y + thompson.h
|
|
||||||
}
|
|
||||||
|
|
||||||
-- temp logging for attempt to resolve issues
|
|
||||||
for k,v in pairs(thompson.shadow) do
|
|
||||||
print(k.."="..tostring(v))
|
|
||||||
end
|
|
||||||
for k,v in pairs(thompson.shadow.data) do
|
|
||||||
print(k.."="..tostring(v))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
|
Reference in New Issue
Block a user