smokescreen.lua 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. local Smokescreen = {}
  2. Smokescreen.code = 'smokescreen'
  3. Smokescreen.duration = 6
  4. Smokescreen.radius = 180
  5. Smokescreen.image = data.media.graphics.effects.smoke
  6. function Smokescreen:activate(mx, my)
  7. self.timer = Smokescreen.duration
  8. self.angle = love.math.random() * math.pi * 2
  9. self.x, self.y = mx, my
  10. ctx.event:emit('sound.play', {sound = 'smoke', x = self.x, y = self.y})
  11. end
  12. function Smokescreen:update()
  13. if self.owner.cloak < 1 and math.distance(self.x, self.y, self.owner.x, self.owner.y) < self.radius then
  14. self.owner.cloak = math.min(self.owner.cloak + (3 * tickRate), 1)
  15. end
  16. self.timer = timer.rot(self.timer, function() ctx.spells:deactivate(self) end)
  17. end
  18. function Smokescreen:draw()
  19. local scale = self.radius / self.image:getWidth() * 2
  20. local r, g, b
  21. if self.owner.team == purple then r, g, b = 190, 160, 200
  22. else r, g, b = 240, 160, 140 end
  23. love.graphics.setColor(r, g, b, math.min(self.timer, 1) * .6 * 255)
  24. love.graphics.circle('line', self.x, self.y, self.radius)
  25. love.graphics.setColor(r, g, b, math.min(self.timer, 1) * .9 * 255)
  26. love.graphics.draw(self.image, self.x, self.y, self.angle, scale, scale, self.image:getWidth() / 2, self.image:getHeight() / 2)
  27. end
  28. return Smokescreen