You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.4 KiB

  1. explosion = Class{}
  2. function explosion:init(x, y, v, color, type)
  3. self.color = color
  4. self.type = 0
  5. self.x = x
  6. self.y = y
  7. self.v = v
  8. self.range = 0
  9. self.maxRange = WINDOW_WIDTH*2
  10. self.killed = false
  11. if type ~= nil then
  12. self.type = type
  13. end
  14. --print(self.i)
  15. end
  16. function explosion:update(dt)
  17. self.range = self.range + dt * 24
  18. if (self.type == 0) then
  19. --print("my range is " .. self.range)
  20. end
  21. self.maxRange = WINDOW_WIDTH*2
  22. if self.type == 1 then
  23. self.maxRange = WINDOW_WIDTH*6
  24. elseif self.type == 2 then
  25. self.maxRange = 200
  26. end
  27. if self.range * self.v > self.maxRange then
  28. --print("killing myself with range" .. self.range .. " " .. self.v .. " " .. self.maxRange .. " and type " .. self.type)
  29. self.killed = true
  30. end
  31. end
  32. function explosion:render(toggle)
  33. --print("rendering myself" .. self.x .. " " .. self.y .. " " .. self.range .. " " .. self.v)
  34. love.graphics.setColor(unpack(self.color))
  35. if self.type == 2 then
  36. love.graphics.setColor(1,1,1,0.7/(self.range))
  37. -- print(self.range)
  38. elseif self.type == 1 then
  39. love.graphics.setColor(1,1,1,0.01*(76.32-(self.range*2)))
  40. --print(self.range)
  41. end
  42. love.graphics.circle("fill", self.x, self.y, self.range * self.v, 100)
  43. love.graphics.setColor(1,1,1,1)
  44. end