-- Playground.levelgen goalDist = (255/10)*2 function startVelocity(res, resCoords) res:setVel(point.new(-resCoords.x, -resCoords.y)) end function matchResource(res, zone) local resObject = levelgen:findObjectById(res) local resCoords = resObject:getPos() local resVel = resObject:getVel() if (resVel.x == 0 and resVel.y == 0) then startVelocity(resObject, resCoords) end local upLeft = point.new(resCoords.x - goalDist, resCoords.y - goalDist) local botLeft = point.new(resCoords.x - goalDist, resCoords.y + goalDist) local upRight = point.new(resCoords.x + goalDist, resCoords.y - goalDist) local downRight = point.new(resCoords.x + goalDist, resCoords.y + goalDist) local goal = levelgen:findObjectById(zone) goal:setGeom(upLeft, upRight, downRight, botLeft) end function onTick() matchResource(1,2) matchResource(3,4) matchResource(5,6) matchResource(7,8) end function main() subscribe(Event.Tick) end