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.

78 lines
1.8 KiB

  1. paddle = Class{}
  2. function paddle:init(x, y, width, height, player)
  3. self.RED = 255
  4. self.GREEN = 255
  5. self.BLUE = 255
  6. self.x = x
  7. self.y = y
  8. self.width = width
  9. self.height = height
  10. self.dy = 0
  11. self.xy = x
  12. self.yx = y
  13. self.velocity = 0
  14. self.shadowbonus = 0
  15. self.player = player
  16. end
  17. function paddle:update(dt)
  18. if areanuclear == 0 then
  19. self.RED = 1
  20. self.GREEN = 1
  21. self.BLUE = 1
  22. else
  23. self.RED = 0
  24. self.GREEN = 0
  25. self.BLUE = 0
  26. end
  27. if ((self.player == 1 and timeIsSlow2) or self.player == 2 and timeIsSlow) then
  28. self.dy = self.dy / 2
  29. end
  30. if (self.dy == 0) then
  31. self.velocity = self.velocity / 1.1
  32. if (self.velocity < 1 and self.velocity > -1) then
  33. self.velocity = 0
  34. end
  35. else
  36. self.velocity = self.velocity + self.dy*dt
  37. end
  38. if (self.velocity < 0) then
  39. if (self.y > 0) then
  40. self.y = self.y + self.velocity
  41. else
  42. self.velocity = 0
  43. end
  44. elseif (self.velocity > 0) then
  45. if (self.y < VIRTUAL_HEIGHT - 80) then
  46. self.y = self.y + self.velocity
  47. else
  48. self.velocity = 0
  49. end
  50. else
  51. self.velocity = 0
  52. end
  53. if ((timeIsSlow == false and self.player == 1) or (timeIsSlow2 == false and self.player == 2)) then
  54. if (math.abs(self.yx - self.y) < 11) then
  55. self.yx = self.y
  56. end
  57. if (self.yx < self.y) then
  58. self.yx = self.yx + math.abs(paddle_SPEED/1.7)
  59. elseif (self.yx > self.y) then
  60. self.yx = self.yx - math.abs(paddle_SPEED/1.7)
  61. end
  62. end
  63. end
  64. function paddle:render()
  65. love.graphics.setColor(self.RED, self.GREEN, self.BLUE, 60/255)
  66. love.graphics.rectangle('fill', self.xy, self.yx, self.width, self.height, 20, 20)
  67. love.graphics.setColor(self.RED, self.GREEN, self.BLUE, 255)
  68. love.graphics.rectangle('fill', self.x, self.y, self.width, self.height, 20, 20)
  69. love.graphics.setColor(255, 255, 255, 255)
  70. end