Weeeeee/modules/floors.lua

28 lines
886 B
Lua
Raw Normal View History

2022-03-03 13:13:17 +01:00
local floors = {}
floors.addFloor = function(self, name, game, x, y, w, h, r, g, b, a)
local floor = {}
floor.name = name
floor.x = x
floor.y = y
floor.width = w
floor.height = h
floor.userdata = "floor"
floor.color = {r, g, b, a}
floor.body = love.physics.newBody(game.world, x + w / 2, y, "static")
floor.shape = love.physics.newRectangleShape(w, h)
floor.fixture = love.physics.newFixture(floor.body, floor.shape)
floor.fixture:setUserData(floor.userdata)
table.insert(self, floor)
game.objects.floors = self.floors
end
floors.listFloors = function(self)
allstr = ""
for i,v in pairs(self) do
--if v is not a function
if type(v) ~= "function" then
allstr = allstr .. (v.name..": \""..v.body:getX().."\"; y: \""..v.body:getY().."\";;;")
end
end
return allstr
end
return floors