-
Notifications
You must be signed in to change notification settings - Fork 1
/
pickup.lua
63 lines (52 loc) · 1.15 KB
/
pickup.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
pickup = class:new()
pickups = {}
function pickup:init(x, y)
self.x = x
self.y = y
self.type = "pickup"
self.loader = loader.step
local droptype = lume.weightedchoice({
["health"] = 1,
["weapon"] = 4,
})
if droptype == "health" then -- health pickup
self.droptype = "health"
else -- sub weapon pickup
self.droptype = "weapon"
self.weptype = lume.weightedchoice({
["frisbee"] = 1,
["cannon"] = 1,
["steamypb"] = 1,
})
end
bumpwrld:add(self, x, y, 35, 35)
end
function pickup:update(dt)
self.y = self.y + 3 * 60 * dt
local function filter(i, o)
if o.type == "ground" then return "touch" end
return "cross"
end
local ax, ay, cols, len = bumpwrld:move(self, self.x, self.y, filter)
self.x = ax
self.y = ay
end
function pickup:draw()
lg.push()
lg.translate(self.x, self.y)
if self.droptype == "health" then
lg.scale(3,2)
polygon.draw(ui_heart)
polygon.draw(ui_heartcase)
elseif self.droptype == "weapon" then
lg.scale(0.5, 0.5)
polygon.draw(ui_subweapons[self.weptype])
end
lg.pop()
end
function pickup:delete()
bumpwrld:remove(self)
if not self.deletenoscore then
ent_player.score = ent_player.score + 20
end
end