-
Notifications
You must be signed in to change notification settings - Fork 0
/
dust.lua
50 lines (42 loc) · 1.16 KB
/
dust.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
dust = {}
-- Constructor
function dust:new(x, y, width, height)
-- define our parameters here
local object = {
x = x,
y = y,
width = width,
height = height,
activatedTop = false,
activatedBottom = false,
activatedLeft = false,
activatedRight = false,
last = {},
current = {}
}
setmetatable(object, { __index = dust })
return object
end
function dust:draw()
g.rectangle("fill", self.x, self.y, self.width, self.height)
if debug then
g.setColor(0,0,255)
g.line(self:getRightEdge(), self.y - self.height, self:getRightEdge(), self.y + self.height * 2)
g.line(self:getLeftEdge(), self.y - self.height, self:getLeftEdge(), self.y + self.height * 2)
g.line(self.x - self.width, self:getTopEdge(), self.x + self.width * 2, self:getTopEdge())
g.line(self.x - self.width, self:getBottomEdge(), self.x + self.width * 2, self:getBottomEdge())
g.setColor(groundColor)
end
end
function dust:getRightEdge()
return self.x+self.width
end
function dust:getLeftEdge()
return self.x
end
function dust:getTopEdge()
return self.y
end
function dust:getBottomEdge()
return self.y + self.height
end