-
Notifications
You must be signed in to change notification settings - Fork 17
/
pedestal.lua
75 lines (63 loc) · 2.07 KB
/
pedestal.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
pedestal = class("pedestal")
function pedestal:init(x, y, r)
self.cox = x
self.coy = y
self.x = x-12/16
self.y = y-1
self.progress = 0
self.pickedup = false
self.blue = false
self.orange = false
self.r = {unpack(r)}
if #r >= 4 then
self.blue = r[3] == "true"
self.orange = r[4] == "true"
end
end
function pedestal:update(dt)
if not self.pickedup then
local col = checkrect(self.x, self.y, 8/16, 8/16, {"player"})
if #col > 0 then
for i = 2, #col, 2 do
print("!")
if self.blue then
if not objects["player"][col[i]].portalsavailable[1] then
self.pickedup = true
objects["player"][col[i]]:portalpickup(1)
end
end
if self.orange then
if not objects["player"][col[i]].portalsavailable[2] then
self.pickedup = true
objects["player"][col[i]]:portalpickup(2)
end
end
if self.pickedup then
break
end
end
end
elseif self.progress < pedestaltime then
self.progress = math.min(pedestaltime, self.progress + dt)
end
end
function pedestal:draw()
love.graphics.setColor(1, 1, 1)
if self.pickedup then
local prog = self.progress / pedestaltime
love.graphics.setScissor(math.floor((self.cox-1-xscroll)*16*scale), math.floor((self.coy-1.5-yscroll)*16*scale)+14*prog*scale, 16*scale, (14*(1-prog)+2)*scale)
end
love.graphics.draw(pedestalbaseimg, math.floor((self.cox-1-xscroll)*16*scale), math.floor((self.coy-1.5-yscroll)*16*scale), 0, scale, scale)
love.graphics.setScissor()
if not self.pickedup then
love.graphics.draw(pedestalgunimg, math.floor((self.cox-1-xscroll)*16*scale), math.floor((self.coy-1.5-yscroll)*16*scale), 0, scale, scale)
if self.blue or self.orange then
if self.blue then
love.graphics.setColor(objects["player"][1].portal1color)
elseif self.orange then
love.graphics.setColor(objects["player"][1].portal2color)
end
love.graphics.rectangle("fill", math.floor((self.cox-1-xscroll+7/16)*16*scale), math.floor((self.coy-1.5-yscroll+2/16)*16*scale), scale, scale)
end
end
end