integrated the mirroring part
This commit is contained in:
21
main.lua
21
main.lua
@@ -39,6 +39,8 @@ local side = {
|
||||
local velocity = {0, 0}
|
||||
local current = { }
|
||||
|
||||
local tempAttached = nil
|
||||
|
||||
function love.load()
|
||||
love.window.setMode(512, 512)
|
||||
|
||||
@@ -83,6 +85,25 @@ function love.update(dt)
|
||||
-- this is temp, ofc, it's ugly af
|
||||
if input:pressed('switch') then
|
||||
velocity = {0, 0}
|
||||
|
||||
-- first, let's take care of the attached crates
|
||||
for key in pairs(crates:getAttached()) do
|
||||
current.x, current.y = crates.attached[key].collider:getPosition()
|
||||
|
||||
if magnet.side == 'LEFT' then
|
||||
current.x = current.x - CONST_SIDES.LEFT[1]
|
||||
|
||||
-- then, we need to mirror it onto the other side
|
||||
current.x = CONST_SIDES.RIGHT[1] + CONST_SIDES.WIDTH - current.x
|
||||
else
|
||||
current.x = current.x - CONST_SIDES.RIGHT[1]
|
||||
|
||||
current.x = CONST_SIDES.LEFT[1] + CONST_SIDES.WIDTH - current.x
|
||||
end
|
||||
|
||||
crates.attached[key].collider:setPosition(current.x, current.y)
|
||||
end
|
||||
|
||||
current.x, current.y = magnet.collider:getPosition()
|
||||
|
||||
-- i want a relative x position, for easier use, so first
|
||||
|
||||
Reference in New Issue
Block a user