-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstrawberry.lua
64 lines (48 loc) · 1.19 KB
/
strawberry.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
local lt = love.timer
strawberry = class:new()
strawberrys = {}
local strawb_spr = polygon.new("soda/strawberry.soda")
my_time = 0
function strawberry:init(x, y)
self.x = x
self.y = y
self.isEnemy = true
self.loader = loader.step
self.type = "strawberry"
self.timeroffset = math.random()*math.pi
bumpwrld:add(self, self.x, self.y, 40, 40)
end
function strawberry:update(dt)
my_time = lt.getTime()
end
function strawberry:draw()
lg.push()
lg.translate(self.x, self.y+30*math.sin(my_time*2+self.timeroffset))
lg.scale(1.5, 1.5)
polygon.draw(strawb_spr)
lg.pop()
end
function strawberry:damage()
sfx_enemy_pop:stop()
sfx_enemy_pop:setPitch(0.9 + math.random(4)/10)
sfx_enemy_pop:play()
self.deleteself = true
for i=1,4 do
gibs[#gibs+1] = gib:new(self.x+30, self.y,
math.pi*math.random(), math.random(-60*6, 60*6),
-math.random(500, 1000), math.pi/2*math.random(-60, 60))
end
end
function strawberry:delete()
bumpwrld:remove(self)
if not self.deletenoscore then
local spawndrop = lume.weightedchoice({
[true] = 1,
[false] = 4*1.5
})
if spawndrop then
pickups[#pickups+1] = pickup:new(self.x, self.y+10)
end
ent_player.score = ent_player.score + 5
end
end