-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathcheckpoint.lua
More file actions
40 lines (34 loc) · 786 Bytes
/
checkpoint.lua
File metadata and controls
40 lines (34 loc) · 786 Bytes
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
Checkpoint = {}
Checkpoint.__index = Checkpoint
function Checkpoint.create(x,y,prop)
local self = {}
setmetatable(self, Checkpoint)
self.x = x
self.y = y
self.alive = true
self.dir = prop.dir or 1
return self
end
function Checkpoint:draw()
if self.alive == true then
love.graphics.draw(imgObjects, quads.orb, self.x, self.y)
end
end
function Checkpoint:collidePlayer(pl)
if self.alive ==true then
if pl.x-5.5 > self.x+16 or pl.x+5.5 < self.x
or pl.y+2 > self.y+16 or pl.y+20 < self.y then
return false
else
self.alive = false
map.startx = self.x+8
map.starty = self.y-0.01
map.startdir = self.dir
addSparkle(self.x+8, self.y, 32, COLORS.lightblue)
love.audio.play(snd.Checkpoint)
commitCoins()
return true
end
end
return false
end