integrated the mirroring part

This commit is contained in:
2021-05-08 17:33:00 +02:00
parent 686f085f5b
commit 050157a47e
2 changed files with 28 additions and 1 deletions

View File

@@ -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