added more utility functions

This commit is contained in:
2021-05-13 20:22:47 +02:00
parent 688a0b9f18
commit 7ddb16e430

View File

@@ -7,6 +7,10 @@ utils.getCenterByXY = function (x, y, w, h)
return { x = (x + (w/2)), y = (y + h/2) } return { x = (x + (w/2)), y = (y + h/2) }
end end
utils.getXYByCenter = function (x, y, w, h)
return { x = (x - (w/2)), y = (y - (h/2)) }
end
utils.spawnStaticRectangleBySize = function (world, x, y, w, h) utils.spawnStaticRectangleBySize = function (world, x, y, w, h)
local center = utils.getCenterByXY(x, y, w, h) local center = utils.getCenterByXY(x, y, w, h)
local rect = world:addRectangle(center.x, center.y, w, h) local rect = world:addRectangle(center.x, center.y, w, h)