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.

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