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.

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