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.

100 lines
2.3 KiB

  1. eball = Class{}
  2. function eball:init(x, y, width, height)
  3. self.x = x
  4. self.y = y
  5. self.width = width
  6. self.height = height
  7. self.dy = math.random(-1, 1)
  8. self.dx = 1
  9. self.disabled = false
  10. end
  11. function eball:collides(paddle)
  12. if paddle.player == 2 and gameMode == 'practice' then return false
  13. else
  14. if self.x > paddle.x + paddle.width or paddle.x > self.x + self.width then
  15. return false
  16. end
  17. if self.y > paddle.y + paddle.height or paddle.y > self.y + self.height then
  18. return false
  19. end
  20. return true
  21. end
  22. end
  23. function eball:reset(ballnum)
  24. if (gameMode == 'practice') then
  25. if (self.x < 1) then
  26. --love.window.setTitle(self.x)
  27. self.x = VIRTUAL_WIDTH /2 - 2
  28. self.y = VIRTUAL_HEIGHT /2 - 2
  29. self.dy = math.random(-1, 1)
  30. self.dx = math.random(-1,1)
  31. else self.x = self.x self.y = self.y self.dx = -1 end
  32. else
  33. if (ballnum == 2) then
  34. self.dx = ball_DIR * -1
  35. else
  36. self.dx = ball_DIR
  37. end
  38. self.disabled = false
  39. self.x = VIRTUAL_WIDTH /2 - 2
  40. self.y = VIRTUAL_HEIGHT /2 - 2
  41. self.dy = math.random(-1, 1)
  42. --love.window.setTitle("LMAOOOOOO")
  43. end
  44. end
  45. function eball:update(dt)
  46. if player1nukescore > 20 then
  47. potentialstrike1 = 1
  48. else
  49. potentialstrike1 = 0
  50. end
  51. if player1nukescore > 140 then
  52. player1reverbav = 1
  53. else
  54. player1reverbav = 0
  55. end
  56. if player1nukescore > 200 then
  57. potentialnuke1 = 1
  58. else
  59. potentialnuke1 = 0
  60. end
  61. if player2nukescore > 20 then
  62. potentialstrike2 = 1
  63. else
  64. potentialstrike2 = 0
  65. end
  66. if player2nukescore > 140 then
  67. player2reverbav = 1
  68. else
  69. player2reverbav = 0
  70. end
  71. if player2nukescore > 200 then
  72. potentialnuke2 = 1
  73. else
  74. potentialnuke2 = 0
  75. end
  76. if self.disabled == false then
  77. self.x = self.x + ballSpeed * self.dx * dt
  78. self.y = self.y + ballSpeed * self.dy * dt
  79. end
  80. end
  81. function eball:render(color)
  82. if color == 'black' then
  83. love.graphics.setColor(0,0,0,1)
  84. love.graphics.rectangle('fill', self.x, self.y, self.width, self.height)
  85. elseif color == 'controlled' then
  86. love.graphics.rectangle('fill', self.x, self.y, self.width, self.height)
  87. else
  88. love.graphics.setColor(1,1,1,1)
  89. love.graphics.rectangle('fill', self.x, self.y, self.width, self.height)
  90. end
  91. end