-
Notifications
You must be signed in to change notification settings - Fork 3
/
map.lua
36 lines (32 loc) · 876 Bytes
/
map.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
mapClass = {}
function mapClass.new(t)
t = t or {}
setmetatable(t, {__index=mapClass})
return t
end
function mapClass:add(object)
self.Objects[#self.Objects+1] = assert(loadobject(#self.Objects+1, object[1], game.world, object[2], object[3], object[4], object[5]))
end
local function inCategory(shape, layer)
local categories = {shape:getCategory()}
for i, v in ipairs(categories) do
if v == layer then
return true
end
end
return false
end
local function active(shape)
return inCategory(shape, game.activelayer)
end
function mapClass:drawLayers()
for k, v in pairs(self.Objects) do
if k ~= 'player' then
local translucent = not active(v._shapes[1])
if translucent then love.graphics.setColor(100, 100, 100, 150) end
LBP.draw(v)
if translucent then love.graphics.setColor(255, 255, 255, 255) end
end
end
LBP.draw(self.Objects.player)
end