Files
chuchu/utils.lua

22 lines
523 B
Lua

-- Chuchu by Makaron
-- Some milescenious (not sure about how to write it) functions
local utils = { }
utils.getCenterByXY = function (x, y, w, h)
return { x = (x + (w/2)), y = (y + h/2) }
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)
local center = utils.getCenterByXY(x, y, w, h)
local rect = world:addRectangle(center.x, center.y, w, h)
rect:setType('static')
return rect
end
return utils