28 lines
886 B
Lua
28 lines
886 B
Lua
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 |