-
Notifications
You must be signed in to change notification settings - Fork 108
/
quad.lua
56 lines (47 loc) · 1.08 KB
/
quad.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
quad = class:new()
--COLLIDE?
--INVISIBLE?
--BREAKABLE?
--COINBLOCK?
--COIN?
--_NOT_ PORTALABLE?
function quad:init(img, imgdata, x, y, width, height)
--get if empty?
self.image = img
self.quad = love.graphics.newQuad((x-1)*17, (y-1)*17, 16, 16, width, height)
--get collision
self.collision = false
local r, g, b, a = imgdata:getPixel(x*17-1, (y-1)*17)
if a > 0.5 then
self.collision = true
end
--get invisible
self.invisible = false
local r, g, b, a = imgdata:getPixel(x*17-1, (y-1)*17+1)
if a > 0.5 then
self.invisible = true
end
--get breakable
self.breakable = false
local r, g, b, a = imgdata:getPixel(x*17-1, (y-1)*17+2)
if a > 0.5 then
self.breakable = true
end
--get coinblock
self.coinblock = false
local r, g, b, a = imgdata:getPixel(x*17-1, (y-1)*17+3)
if a > 0.5 then
self.coinblock = true
end
--get coin
self.coin = false
local r, g, b, a = imgdata:getPixel(x*17-1, (y-1)*17+4)
if a > 0.5 then
self.coin = true
end
self.portalable = true
local r, g, b, a = imgdata:getPixel(x*17-1, (y-1)*17+5)
if a > 0.5 then
self.portalable = false
end
end