-
Notifications
You must be signed in to change notification settings - Fork 1
/
explosion.lua
43 lines (33 loc) · 907 Bytes
/
explosion.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
local la = love.audio
explosion = class:new()
explosions = {}
random_color = 0
function explosion:init(x, y, maxradius, radiusvel)
self.x = x
self.y = y
self.radius = 1
self.maxradius = maxradius
self.radiusvel = radiusvel
sfx_explode:clone():play()
end
function explosion:update(dt)
random_color = math.random()
local function filter(i)
return i.isEnemy or i.type == "player"
end
local items, len = bumpwrld:queryRect(self.x-self.radius/2, self.y-self.radius/2, self.radius, self.radius, filter)
for i,v in ipairs(items) do
v:damage(self)
end
self.radius = self.radius + self.radiusvel * dt
if self.radius >= self.maxradius then
self.deleteself = true
end
end
function explosion:draw()
lg.setColor(1, random_color*0.75, 0, 1)
lg.rectangle("fill", self.x-self.radius/2, self.y-self.radius/2, self.radius, self.radius)
lg.setColor(1,1,1)
end
function explosion:delete()
end