add projectile death particle
This commit is contained in:
parent
96628b9a8b
commit
62bc32c97a
2 changed files with 39 additions and 0 deletions
|
|
@ -49,4 +49,10 @@ function Projectile:draw()
|
|||
love.graphics.circle('fill', self.x, self.y, self.s)
|
||||
end
|
||||
|
||||
---Kills Projectile
|
||||
function Projectile:kill()
|
||||
self.area:addGameObject('ProjectileDeathEffect', self.x, self.y, {w = self.s*3})
|
||||
self:destroy()
|
||||
end
|
||||
|
||||
return Projectile
|
||||
|
|
|
|||
33
obj/game/ProjectileDeathEffect.lua
Normal file
33
obj/game/ProjectileDeathEffect.lua
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
---@class ProjectileDeathEffect:GameObject
|
||||
local ProjectileDeathEffect = GameObject:extend()
|
||||
|
||||
function ProjectileDeathEffect:new(area, x, y, opts)
|
||||
ProjectileDeathEffect.super.new(self, area, x, y, opts)
|
||||
-- width
|
||||
self.w = opts.w or 12
|
||||
self.first = true
|
||||
self.timer:after(0.1, function()
|
||||
self.first = false
|
||||
self.second = true
|
||||
self.timer:after(0.15, function()
|
||||
self.second = false
|
||||
self:kill()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
---Updates ProjectileDeathEffect
|
||||
---@param dt number delta time
|
||||
function ProjectileDeathEffect:update(dt)
|
||||
ProjectileDeathEffect.super.update(self, dt)
|
||||
end
|
||||
|
||||
---Draws ProjectileDeathEffect
|
||||
function ProjectileDeathEffect:draw()
|
||||
ProjectileDeathEffect.super.draw(self)
|
||||
if self.first then love.graphics.setColor(COLORS.default)
|
||||
elseif self.second then love.graphics.setColor(COLORS.hp) end
|
||||
love.graphics.rectangle('fill', self.x - self.w/2, self.y - self.w/2, self.w, self.w)
|
||||
end
|
||||
|
||||
return ProjectileDeathEffect
|
||||
Loading…
Add table
Reference in a new issue