A pong clone, but with a twist!

1308 lines
49 KiB

  1. function basegame(dt)
  2. if gameMode == "reversegame" then
  3. reversegame(dt)
  4. end
  5. if player1nukescore > 300 then
  6. player1nukescore = 300
  7. end
  8. if player2nukescore > 300 then
  9. player2nukescore = 300
  10. end
  11. speedControl()
  12. balancer()
  13. if t < shakeDuration then
  14. t = t + dt
  15. end
  16. --print("T = " .. tostring(t))
  17. serveBot()
  18. if gameState == 'play' then
  19. if (AGAINST_AI == 1) then
  20. AI(player2, maxBalls, AI_LEVEL)
  21. end
  22. if (love.keyboard.isDown(p1control.up)) then
  23. player1.dy = (paddle_SPEED + p1bonus) * -1
  24. elseif (love.keyboard.isDown(p1control.down)) then
  25. player1.dy = paddle_SPEED + p1bonus
  26. else
  27. player1.dy = 0
  28. end
  29. if (AGAINST_AI == 0) then
  30. if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.up)) ) then
  31. player2.dy = (paddle_SPEED + p2bonus) * -1
  32. elseif ((globalState ~= "nettest" and love.keyboard.isDown(p2control.down))) then
  33. player2.dy = paddle_SPEED + p2bonus
  34. elseif (globalState ~= "nettest") then
  35. player2.dy = 0
  36. end
  37. end
  38. --print(areanuclear .. striken .. player1score .. player2score)
  39. for i = 1, maxBalls do
  40. if rules("p1hit", i) then
  41. if (areanuclear == 0 and striken == 1 and (player1score > ptw-2 or player2score > ptw-2)) then
  42. --print("Calling animation")
  43. print("AREA NUCLEAR?" .. areanuclear)
  44. superanimator("tensehit", 1)
  45. end
  46. if gameMode == "practice" then
  47. player1score = player1score + 1
  48. end
  49. t = 0
  50. if (ballSpeed > 200) then
  51. shakeMagnitude = ballSpeed / 200
  52. else
  53. shakeMagnitude = 0
  54. end
  55. shakeDuration = 1
  56. randomtext = love.math.random(1, #textphrases)
  57. TEXT = textphrases[randomtext]
  58. soundtype = love.math.random(1, 1.2)
  59. if (player1striken == 1) then
  60. TEXT = "PLAYER 1 STRIKES"
  61. ballSpeed = ballSpeed + player1nukescore
  62. potentialnuke1 = 0
  63. player1striken = 0
  64. player1nukescore = 0
  65. potentialstrike1 = 0
  66. striken = 1
  67. if areanuclear == 0 then
  68. sounds["striking"]:setPitch(ballSpeed / 250)
  69. sounds["striking"]:play()
  70. else
  71. sounds["nuclearhit"]:setPitch(1)
  72. sounds["nuclearhit"]:play()
  73. end
  74. print("AREA NUCLEAR?" .. areanuclear)
  75. if areanuclear == 0 then
  76. superanimator("tensehit", 1)
  77. end
  78. else
  79. if areanuclear == 0 then
  80. sounds["beep"]:setPitch(ballSpeed / 250)
  81. sounds["beep"]:play()
  82. else
  83. sounds["nuclearhit"]:setPitch(1)
  84. sounds["nuclearhit"]:play()
  85. end
  86. end
  87. if (striken == 1) then
  88. player1nukescore = player1nukescore * 1.5
  89. if (synctype == 0) then
  90. paddle_SPEED = paddle_SPEED * 1.10
  91. elseif (synctype == 1) then
  92. paddle_SPEED = ballSpeed
  93. end
  94. if (synctype == 0) then
  95. AI_SPEED = AI_SPEED * 1.10
  96. end
  97. if (synctype == 1) then
  98. AI_SPEED = ballSpeed * 1.1 / 10
  99. end
  100. ballSpeed = ballSpeed * 1.10
  101. end
  102. player1nukescore = player1nukescore + 10
  103. ball[i].dx = -ball[i].dx
  104. ball[i].x = player1.x + 30
  105. if (love.keyboard.isDown(p1control.up)) then
  106. select = math.random(1, 5)
  107. if select == 1 then
  108. ball[i].dy = -1
  109. elseif select == 2 then
  110. ball[i].dy = -1.2
  111. elseif select == 3 then
  112. ball[i].dy = -1.5
  113. elseif select == 4 then
  114. ball[i].dy = -1.8
  115. elseif select == 5 then
  116. ball[i].dy = -2
  117. end
  118. elseif love.keyboard.isDown(p1control.down) then
  119. select = math.random(1, 5)
  120. if select == 1 then
  121. ball[i].dy = 1
  122. elseif select == 2 then
  123. ball[i].dy = 1.2
  124. elseif select == 3 then
  125. ball[i].dy = 1.5
  126. elseif select == 4 then
  127. ball[i].dy = 1.8
  128. elseif select == 5 then
  129. ball[i].dy = 2
  130. end
  131. else
  132. if ball[i].dy < 0 then
  133. select = math.random(1, 5)
  134. if select == 1 then
  135. ball[i].dy = -1
  136. elseif select == 2 then
  137. ball[i].dy = -1.2
  138. elseif select == 3 then
  139. ball[i].dy = -1.5
  140. elseif select == 4 then
  141. ball[i].dy = -1.8
  142. elseif select == 5 then
  143. ball[i].dy = -2
  144. end
  145. else
  146. select = math.random(1, 5)
  147. if select == 1 then
  148. ball[i].dy = 1
  149. elseif select == 2 then
  150. ball[i].dy = 1.2
  151. elseif select == 3 then
  152. ball[i].dy = 1.5
  153. elseif select == 4 then
  154. ball[i].dy = 1.8
  155. elseif select == 5 then
  156. ball[i].dy = 2
  157. end
  158. end
  159. end
  160. end
  161. if rules("p2hit", i) then
  162. --ameState = 'quickanim'
  163. t = 0
  164. shakeDuration = 1
  165. if
  166. (areanuclear == 0 and
  167. (striken == 1 and (player1score > ptw-2 or player2score > ptw-2)))
  168. then
  169. print("AREA NUCLEAR?" .. areanuclear)
  170. superanimator("tensehit", 2)
  171. end
  172. if (ballSpeed > 200) then
  173. shakeMagnitude = ballSpeed / 200
  174. else
  175. shakeMagnitude = 0
  176. end
  177. randomtext = love.math.random(1, #textphrases)
  178. TEXT = textphrases[randomtext]
  179. soundtype = love.math.random(1, 1.2)
  180. if (player2striken == 1) then
  181. TEXT = "PLAYER 2 STRIKES"
  182. ballSpeed = ballSpeed + player2nukescore
  183. striken = 1
  184. player2striken = 0
  185. potentialnuke2 = 0
  186. player2nukescore = 0
  187. potentialstrike2 = 0
  188. print("AREA NUCLEAR?" .. areanuclear)
  189. if areanuclear == 0 then
  190. superanimator("tensehit", 2)
  191. end
  192. if areanuclear == 0 then
  193. sounds["striking"]:setPitch(ballSpeed / 250)
  194. sounds["striking"]:play()
  195. else
  196. sounds["nuclearhit"]:setPitch(1)
  197. sounds["nuclearhit"]:play()
  198. end
  199. elseif (striken == 1) then
  200. player2nukescore = player2nukescore * 1.5
  201. if (synctype == 0) then
  202. paddle_SPEED = paddle_SPEED * 1.10
  203. end
  204. if (synctype == 1) then
  205. paddle_SPEED = ballSpeed
  206. end
  207. if (synctype == 0) then
  208. AI_SPEED = AI_SPEED * 1.10
  209. end
  210. if (synctype == 1) then
  211. AI_SPEED = ballSpeed * 1.1 / 10
  212. end
  213. ballSpeed = ballSpeed * 1.10
  214. if areanuclear == 0 then
  215. sounds["beep"]:setPitch(ballSpeed / 250)
  216. sounds["beep"]:play()
  217. else
  218. sounds["nuclearhit"]:setPitch(1)
  219. sounds["nuclearhit"]:play()
  220. end
  221. else
  222. if areanuclear == 0 then
  223. sounds["beep"]:setPitch(ballSpeed / 250)
  224. sounds["beep"]:play()
  225. else
  226. sounds["nuclearhit"]:setPitch(1)
  227. sounds["nuclearhit"]:play()
  228. end
  229. end
  230. player2nukescore = player2nukescore + 10
  231. ball[i].dx = -ball[i].dx
  232. ball[i].x = player2.x - 30
  233. if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.up) ) or AI_SPEED < 0 or lastSentKeyClient == p2control.up) then
  234. select = math.random(1, 5)
  235. if select == 1 then
  236. ball[i].dy = -1
  237. elseif select == 2 then
  238. ball[i].dy = -1.2
  239. elseif select == 3 then
  240. ball[i].dy = -1.5
  241. elseif select == 4 then
  242. ball[i].dy = -1.8
  243. elseif select == 5 then
  244. ball[i].dy = -2
  245. end
  246. elseif (globalState ~= "nettest" and love.keyboard.isDown(p2control.down)) or AI_SPEED > 0 or lastSentKeyClient == p2control.down then
  247. select = math.random(1, 5)
  248. if select == 1 then
  249. ball[i].dy = 1
  250. elseif select == 2 then
  251. ball[i].dy = 1.2
  252. elseif select == 3 then
  253. ball[i].dy = 1.5
  254. elseif select == 4 then
  255. ball[i].dy = 1.8
  256. elseif select == 5 then
  257. ball[i].dy = 2
  258. end
  259. else
  260. if ball[i].dy < 0 then
  261. select = math.random(1, 5)
  262. if select == 1 then
  263. ball[i].dy = -1
  264. elseif select == 2 then
  265. ball[i].dy = -1.2
  266. elseif select == 3 then
  267. ball[i].dy = -1.5
  268. elseif select == 4 then
  269. ball[i].dy = -1.8
  270. elseif select == 5 then
  271. ball[i].dy = -2
  272. end
  273. else
  274. select = math.random(1, 5)
  275. if select == 1 then
  276. ball[i].dy = 1
  277. elseif select == 2 then
  278. ball[i].dy = 1.2
  279. elseif select == 3 then
  280. ball[i].dy = 1.5
  281. elseif select == 4 then
  282. ball[i].dy = 1.8
  283. elseif select == 5 then
  284. ball[i].dy = 2
  285. end
  286. end
  287. end
  288. end
  289. hitIdentifier()
  290. if ball[i].y <= 0 then
  291. soundtype = love.math.random(1, 5)
  292. sounds["wallhit"]:setPitch(ballSpeed / 250)
  293. sounds["wallhit"]:play()
  294. ball[i].y = 0
  295. ball[i].dy = -ball[i].dy
  296. end
  297. -- -4 to account for the ball's size
  298. if ball[i].y >= VIRTUAL_HEIGHT - 40 then
  299. soundtype = love.math.random(1, 5)
  300. sounds["wallhit"]:setPitch(ballSpeed / 250)
  301. sounds["wallhit"]:play()
  302. ball[i].y = VIRTUAL_HEIGHT - 40
  303. ball[i].dy = -ball[i].dy
  304. end
  305. --love.window.setTitle('Trying to update the ball')
  306. if timeIsSlow then
  307. if ballSpeed > originalSpeed / 3 then
  308. paddle_SPEED = 30
  309. ballSpeed = ballSpeed / (1 + (dt * 2))
  310. end
  311. player1nukescore = player1nukescore - (dt * 50)
  312. if player1nukescore < 1 or ball[1].dx > 0 then
  313. timeIsSlow = false
  314. player1reverbav = false
  315. ballSpeed = originalSpeed
  316. sounds["time"]:stop()
  317. paddle_SPEED = originalPaddle
  318. end
  319. end
  320. if timeIsSlow2 then
  321. if ballSpeed > originalSpeed / 3 then
  322. ballSpeed = ballSpeed / (1 + (dt * 2))
  323. end
  324. player2nukescore = player2nukescore - (dt * 50)
  325. if player2nukescore < 1 or ball[1].dx < 0 then
  326. paddle_SPEED = 30
  327. timeIsSlow2 = false
  328. player2reverbav = false
  329. ballSpeed = originalSpeed
  330. sounds["time"]:stop()
  331. paddle_SPEED = originalPaddle
  332. end
  333. end
  334. ball[i]:update(dt)
  335. end
  336. end
  337. goalManager()
  338. powerAvailability()
  339. player1:update(dt)
  340. player2:update(dt)
  341. end
  342. function debugCheck(dt)
  343. if (gameState == "menu") then
  344. updateTEXT = "0.7.7 Chalkboard Update"
  345. end
  346. dangerChecker()
  347. elapsed = elapsed + dt
  348. rotation = math.sin(elapsed * 2.5) * 0.7
  349. if gameState == "assign" then
  350. controlChanger()
  351. end
  352. editor()
  353. mapChanger()
  354. end
  355. function goalManager()
  356. for i = 1, maxBalls do
  357. if (rules("p1miss", i)) then
  358. ball[i].disabled = true
  359. ball[i].x = 2000
  360. if ballsAlive() == false then
  361. if (nuckemodactive == 0) then
  362. areanuclear = 0
  363. nuclearanimation = 3
  364. end
  365. striken = 0
  366. player1striken = 0
  367. player2striken = 0
  368. ballSpeed = ballSet
  369. if (synctype == 0) then
  370. paddle_SPEED = ballSet
  371. end
  372. if (synctype == 1) then
  373. paddle_SPEED = ballSpeed
  374. end
  375. AI_SPEED = difficultyl / 10
  376. for i = 1, maxBalls do
  377. ball[i]:reset(i, 2)
  378. end
  379. if (player2score == ptw and gameMode ~= "practice") then
  380. for i = 1, maxBalls do
  381. ball[i]:reset(i)
  382. end
  383. sounds["win"]:play()
  384. gameState = "done"
  385. TEXT = "Player 2 Won!"
  386. else
  387. if globalState ~= "clienttest" or (globalState == "clienttest" and gameState == "1serve") then
  388. gameState = "1serve"
  389. serveBot()
  390. ball[i]:reset(i, 1)
  391. end
  392. end
  393. end
  394. player2score = player2score + 1
  395. end
  396. if (rules("p2miss", i)) then
  397. ball[i].disabled = true
  398. ball[i].x = 2000
  399. if ballsAlive() == false then
  400. if (nuckemodactive == 0) then
  401. areanuclear = 0
  402. nuclearanimation = 3
  403. end
  404. striken = 0
  405. player1striken = 0
  406. player2striken = 0
  407. ballSpeed = ballSet
  408. if (synctype == 0) then
  409. paddle_SPEED = ballSet
  410. AI_SPEED = ballSet
  411. end
  412. if (synctype == 1) then
  413. paddle_SPEED = ballSpeed
  414. AI_SPEED = ballSpeed
  415. end
  416. AI_SPEED = difficultyl
  417. if (player1score == ptw) then
  418. ball[i]:reset(i)
  419. sounds["win"]:play()
  420. gameState = "done"
  421. TEXT = "Player 1 Won!"
  422. else
  423. if globalState ~= "nettest" or (globalState == "nettest" and gameState == "2serve") then
  424. gameState = "2serve"
  425. serveBot()
  426. ball[i]:reset(i, 2)
  427. end
  428. end
  429. end
  430. sounds["score"]:play()
  431. player1score = player1score + 1
  432. end
  433. end
  434. end
  435. function powerAvailability()
  436. if (player1nukescore >= 20 and player1nukescore < 140) then
  437. potentialstrike1 = 1
  438. if (((globalState ~= "clienttest" and love.keyboard.isDown(p1control.super)) or (globalState == "clienttest" and lastSentKeyP1 == p1control.super)) ) then
  439. player1striken = 1
  440. player1reverbav = 0
  441. end
  442. end
  443. if (player1nukescore >= 140) and timeIsSlow2 == false and timeIsSlow == false and (maxBalls > 1 or (ball[1].dx < 0 and ball[1].x < VIRTUAL_WIDTH/2))then
  444. player1reverbav = 1
  445. if ((globalState == "clienttest" and lastSentKeyP1 == p1control.counter) or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.counter))) then
  446. powerControl(1, "special")
  447. end
  448. end
  449. if (player1nukescore >= 200) then
  450. potentialnuke1 = 1
  451. if ((globalState == "clienttest" and lastSentKeyP1 == p1control.super)or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.super))) then
  452. sounds["nuke"]:play()
  453. if areanuclear == 1 then
  454. maxspeed = maxspeed + 50
  455. end
  456. areanuclear = 1
  457. potentialstrike1 = 0
  458. striken = 0
  459. ballSpeed = ballSpeed * 2
  460. if (synctype == 0) then
  461. paddle_SPEED = paddle_SPEED * 2
  462. end
  463. if (synctype == 1) then
  464. paddle_SPEED = ballSpeed
  465. end
  466. if (synctype == 0) then
  467. AI_SPEED = AI_SPEED * 2.2
  468. end
  469. if (synctype == 1) then
  470. AI_SPEED = ballSpeed * 1.1 / 10
  471. end
  472. player1nukescore = 0
  473. player1reverbav = 0
  474. potentialnuke1 = 0
  475. end
  476. end
  477. if (player2nukescore >= 20 and player2nukescore <= 140) then
  478. potentialstrike2 = 1
  479. if (AGAINST_AI == 0) then
  480. if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.super)) or lastSentKeyClient == p2control.super ) then
  481. player2striken = 1
  482. player2reverbav = 0
  483. end
  484. end
  485. end
  486. if (player2nukescore >= 140) and timeIsSlow == false and timeIsSlow2 == false and (maxBalls > 1 or (ball[1].dx > 0 and ball[1].x < VIRTUAL_WIDTH/2)) then
  487. player2reverbav = 1
  488. if (globalState ~= "nettest" and love.keyboard.isDown(p2control.counter)) or lastSentKeyClient == p2control.counter then
  489. sounds["time"]:play()
  490. player2reverbav = false
  491. timeIsSlow2 = true
  492. originalPaddle = paddle_SPEED
  493. originalSpeed = ballSpeed
  494. player2reverbav = 0
  495. potentialnuke2 = 0
  496. potentialstrike2 = 0
  497. end
  498. end
  499. if (player2nukescore >= 200) then
  500. potentialnuke2 = 1
  501. if (((globalState ~= "nettest" and love.keyboard.isDown(p2control.super)) or lastSentKeyClient == p2control.super)) and AGAINST_AI == 0 then
  502. sounds["nuke"]:play()
  503. if areanuclear == 1 then
  504. maxspeed = maxspeed + 50
  505. end
  506. potentialstrike2 = 0
  507. areanuclear = 1
  508. player2reverbav = 0
  509. ballSpeed = ballSpeed * 2
  510. if (synctype == 0) then
  511. paddle_SPEED = paddle_SPEED * 2
  512. end
  513. if (synctype == 1) then
  514. paddle_SPEED = ballSpeed
  515. end
  516. if (synctype == 0) then
  517. AI_SPEED = AI_SPEED * 2.2
  518. end
  519. if (synctype == 1) then
  520. AI_SPEED = ballSpeed * 1.1 / 10
  521. end
  522. player2nukescore = 0
  523. potentialnuke2 = 0
  524. end
  525. end
  526. end
  527. function editor()
  528. if (gameState == "editor") then
  529. if debug then
  530. --print("Editor is active!")
  531. end
  532. local mx, my = love.mouse.getPosition()
  533. mx = mx * DIFFERENCE_X
  534. my = my * DIFFERENCE_Y
  535. if (love.mouse.isDown(2)) then
  536. wallbreaker(mx, my)
  537. end
  538. if (love.mouse.isDown(3)) then
  539. table.insert(walls, newWall(mx, my, 10, wall1width))
  540. end
  541. end
  542. end
  543. function nuclearDraw()
  544. love.graphics.setColor(1, 1, 1, 1)
  545. for i = 1, maxBalls do
  546. love.graphics.circle("fill", ball[i].x, ball[i].y, explosionRange * 100, 100)
  547. end
  548. player1.RED, player1.GREEN, player1.BLUE, player2.RED, player2.GREEN, player2.BLUE =
  549. nuclearanimation / 3,
  550. nuclearanimation / 3,
  551. nuclearanimation / 3,
  552. nuclearanimation / 3,
  553. nuclearanimation / 3,
  554. nuclearanimation / 3
  555. for i = 1, maxBalls do
  556. love.graphics.setColor(nuclearanimation / 3, nuclearanimation / 3, nuclearanimation / 3, 1)
  557. ball[i]:render("controlled")
  558. end
  559. player1:render()
  560. player2:render()
  561. end
  562. function normalDraw()
  563. if (areanuclear == 1) then
  564. love.graphics.clear(1, 1, 1, 1)
  565. else
  566. love.graphics.clear(40 / 255, 40 / 255, 40 / 255, 1)
  567. end
  568. staticanimator()
  569. if MAP_TYPE == 1 then
  570. love.graphics.setColor(1, 0, 0.20, 1)
  571. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, 0, 10, VIRTUAL_HEIGHT * 0.3)
  572. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, VIRTUAL_HEIGHT * 0.7, 10, VIRTUAL_HEIGHT * 0.3)
  573. love.graphics.setColor(1, 1, 1, 1)
  574. end
  575. if MAP_TYPE == 2 then
  576. for i, wall in ipairs(walls) do
  577. love.graphics.setColor(1, 1, 1, 1)
  578. love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
  579. end
  580. end
  581. pongDraw()
  582. love.graphics.setFont(smallfont)
  583. for i = 1, maxBalls do
  584. if areanuclear == 1 then
  585. --love.window.setTitle('rendering black')
  586. ball[i]:render("black")
  587. else
  588. --love.window.setTitle('rendering white')
  589. ball[i]:render(" ")
  590. end
  591. end
  592. end
  593. function pongDraw()
  594. --print("Drawing classic pong")
  595. love.graphics.setColor(1, 1, 1, 1)
  596. love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
  597. love.graphics.setFont(smallfont)
  598. love.graphics.setFont(scorefont)
  599. if (areanuclear == 1) then
  600. love.graphics.setColor(0, 0, 0, 1)
  601. end
  602. love.graphics.print(tostring(math.floor(player1score)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 12)
  603. love.graphics.print(tostring(math.floor(player2score)), VIRTUAL_WIDTH / 2 + 400, VIRTUAL_HEIGHT / 12)
  604. love.graphics.setColor(1, 1, 1, 1)
  605. displayPoints()
  606. player1:render()
  607. player2:render()
  608. end
  609. function practiceDraw()
  610. player1:render()
  611. love.graphics.rectangle("fill", VIRTUAL_WIDTH-10, 0, 10, VIRTUAL_HEIGHT)
  612. love.graphics.setColor(1, 1, 1, 1)
  613. love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
  614. love.graphics.setFont(smallfont)
  615. love.graphics.setFont(scorefont)
  616. love.graphics.print(tostring(math.floor(player1score)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 12)
  617. end
  618. function menuDraw()
  619. love.graphics.setColor(1, 1, 1, 1)
  620. love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
  621. love.graphics.setFont(smallfont)
  622. love.graphics.printf(updateTEXT, 0, VIRTUAL_HEIGHT * 0.95, VIRTUAL_WIDTH, "left")
  623. if MAP_TYPE == 1 then
  624. love.graphics.setColor(1, 0, 0.20, 1)
  625. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, 0, 10, VIRTUAL_HEIGHT * 0.3)
  626. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, VIRTUAL_HEIGHT * 0.7, 10, VIRTUAL_HEIGHT * 0.3)
  627. love.graphics.setColor(1, 1, 1, 1)
  628. end
  629. if MAP_TYPE == 2 then
  630. for i, wall in ipairs(walls) do
  631. love.graphics.setColor(1, 1, 1, 1)
  632. love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
  633. end
  634. end
  635. if gameState == "windowsettings" then
  636. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, settings, sounds, "right")
  637. love.keyboard.mouseisReleased = false
  638. end
  639. if gameState == "editor" then
  640. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, editorpicks, sounds, "right")
  641. love.keyboard.mouseisReleased = false
  642. end
  643. if gameState == "speedSettings" then
  644. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, speedParameters, sounds, "middle")
  645. love.keyboard.mouseisReleased = false
  646. end
  647. if gameState == "controlSettings" then
  648. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, controlSettings, sounds, "control")
  649. love.keyboard.mouseisReleased = false
  650. end
  651. if gameState == "gameMode" then
  652. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, modeSelectorButtons, sounds, "middle")
  653. love.keyboard.mouseisReleased = false
  654. end
  655. if gameState == "chooseIP" then
  656. IPselect = {}
  657. table.insert(
  658. IPselect,
  659. newButton(
  660. "LANHost",
  661. function()
  662. globalState = "selfhost"
  663. AGAINST_AI = 0
  664. gameState = "1serve"
  665. ball[1]:reset(1, 1)
  666. end
  667. )
  668. )
  669. if status == "offline" then
  670. love.graphics.printf("UNABLE TO CONNECT", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  671. elseif status == "nettest" then
  672. table.insert(
  673. IPselect,
  674. newButton(
  675. "Connect as Host",
  676. function()
  677. globalState = "nettest"
  678. AGAINST_AI = 0
  679. gameState = "1serve"
  680. ball[1]:reset(1, 1)
  681. end
  682. )
  683. )
  684. elseif status == "clienttest" then
  685. table.insert(
  686. IPselect,
  687. newButton(
  688. "Connect as Guest",
  689. function()
  690. globalState = "clienttest"
  691. AGAINST_AI = 0
  692. gameState = "1serve"
  693. ball[1]:reset(1, 1)
  694. end
  695. )
  696. )
  697. elseif status == "full" then
  698. love.graphics.printf("SERVER FULL", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  699. end
  700. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, IPselect, sounds, "middle")
  701. love.graphics.printf(IP, 0, VIRTUAL_HEIGHT / 4, VIRTUAL_WIDTH, "center")
  702. love.keyboard.mouseisReleased = false
  703. end
  704. if gameState == "menu" then
  705. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds, "middle")
  706. love.keyboard.mouseisReleased = false
  707. end
  708. if gameState == "difficulty" then
  709. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, difbuttons, sounds, "middle")
  710. love.keyboard.mouseisReleased = false
  711. end
  712. if gameState == "multiMode" then
  713. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, playerCountButtons, sounds, "playercount")
  714. love.keyboard.mouseisReleased = false
  715. end
  716. if gameState == "prdiff" then
  717. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, pracdiff, sounds, "playercount")
  718. love.keyboard.mouseisReleased = false
  719. end
  720. if gameState == 'start' then
  721. love.graphics.push()
  722. love.graphics.translate(VIRTUAL_WIDTH * 0.4, VIRTUAL_HEIGHT * 0.5)
  723. love.graphics.rotate(rotation)
  724. love.graphics.setFont(smallfont)
  725. love.graphics.print("Press Enter to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8)
  726. love.graphics.setColor(255, 255, 255, 255)
  727. love.graphics.pop()
  728. end
  729. end
  730. function baseDraw()
  731. love.graphics.clear(40 / 255, 40 / 255, 40 / 255, 1)
  732. if shakeDuration > t then
  733. local dx = love.math.random(-shakeMagnitude, shakeMagnitude)
  734. local dy = love.math.random(-shakeMagnitude, shakeMagnitude)
  735. love.graphics.translate(dx, dy)
  736. end
  737. if globalState == 'menu' then
  738. --print("Drawing menuDraw")
  739. if gameState == 'animation' then
  740. --print("Drawing animation")
  741. intro()
  742. end
  743. if gameState ~= 'animation' then
  744. --print("Drawing notanimtaion")
  745. love.graphics.setFont(scorefont)
  746. menuDraw()
  747. end
  748. end
  749. if globalState == 'base' or globalState == 'reverse' or globalState == 'nettest' or globalState == 'clienttest' then
  750. love.graphics.setFont(smallfont)
  751. if gameState == 'nuclearExplosion' then
  752. nuclearDraw()
  753. end
  754. if gameState == 'play' or gameState == '1serve' or gameState == '2serve' or gameState == 'done' then
  755. print("Drawing normally")
  756. normalDraw()
  757. end
  758. end
  759. end
  760. function renderEditor()
  761. if not blockinput then
  762. love.graphics.setColor(1, 0, 0, 1)
  763. love.graphics.rectangle("fill", mx, my, 10, wall1width)
  764. love.graphics.setColor(1, 1, 1, 1)
  765. end
  766. for i, wall in ipairs(walls) do
  767. love.graphics.setColor(1, 1, 1, 1)
  768. love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
  769. end
  770. end
  771. function intro()
  772. love.graphics.setColor(255, 255, 255, light / 255)
  773. love.graphics.draw(image, 0, 0)
  774. end
  775. function displayPoints()
  776. love.graphics.setFont(smallfont)
  777. if areanuclear == 1 then
  778. love.graphics.setColor(0,0,0,1)
  779. end
  780. if (potentialstrike1 == 1 and potentialnuke1 == 0 and player1reverbav == 0) then --FLAG: AVAILABLE SUPER
  781. if (player1striken == 0) then
  782. love.graphics.print(
  783. tostring(math.floor(player1nukescore) .. "[" .. p1control.super .. "]"),
  784. VIRTUAL_WIDTH / 2 - 500,
  785. VIRTUAL_HEIGHT / 60
  786. )
  787. else
  788. love.graphics.print(tostring("READY"), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60)
  789. end
  790. elseif (player1reverbav == 1 and potentialnuke1 == 0 ) then
  791. love.graphics.print(
  792. tostring(
  793. math.floor(player1nukescore) .. "[" .. p1control.super .. "]" .. " [" .. p1control.counter .. "]"
  794. ),
  795. VIRTUAL_WIDTH / 2 - 500,
  796. VIRTUAL_HEIGHT / 60
  797. )
  798. elseif (potentialnuke1 == 1) then
  799. love.graphics.setColor(255, 0, 0, 255)
  800. love.graphics.print(
  801. tostring(
  802. math.floor(player1nukescore) .. "[" .. p1control.super .. "]" .. " [" .. p1control.counter .. "]"
  803. ),
  804. VIRTUAL_WIDTH / 2 - 500,
  805. VIRTUAL_HEIGHT / 60
  806. )
  807. love.graphics.setColor(255, 255, 255, 255)
  808. elseif (potentialnuke1 == 1) then
  809. love.graphics.setColor(255, 0, 0, 255)
  810. love.graphics.print(
  811. tostring(
  812. math.floor(player1nukescore) .. "[" .. p1control.super .. "]"
  813. ),
  814. VIRTUAL_WIDTH / 2 - 500,
  815. VIRTUAL_HEIGHT / 60
  816. )
  817. love.graphics.setColor(255, 255, 255, 255)
  818. else
  819. love.graphics.print(tostring(math.floor(player1nukescore)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60)
  820. end
  821. if (potentialstrike2 == 1 and player2reverbav == 0) then
  822. if (player2striken == 0) then
  823. love.graphics.print(
  824. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "]"),
  825. VIRTUAL_WIDTH / 2 + 430,
  826. VIRTUAL_HEIGHT / 60
  827. )
  828. else
  829. love.graphics.print(tostring("READY"), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60)
  830. end
  831. elseif (potentialnuke2 == 1) then
  832. love.graphics.setColor(255, 0, 0, 255)
  833. love.graphics.print(
  834. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "] [" .. p2control.counter .. "]"),
  835. VIRTUAL_WIDTH / 2 + 400,
  836. VIRTUAL_HEIGHT / 60
  837. )
  838. love.graphics.setColor(255, 255, 255, 255)
  839. elseif (potentialnuke2 == 1 and maxBalls > 1) then
  840. love.graphics.setColor(255, 0, 0, 255)
  841. love.graphics.print(
  842. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "]"),
  843. VIRTUAL_WIDTH / 2 + 430,
  844. VIRTUAL_HEIGHT / 60
  845. )
  846. love.graphics.setColor(255, 255, 255, 255)
  847. elseif (player2reverbav == 1 and potentialnuke2 == 0 ) then
  848. love.graphics.print(
  849. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "] [" .. p2control.counter .. "]"),
  850. VIRTUAL_WIDTH / 2 + 400,
  851. VIRTUAL_HEIGHT / 60
  852. )
  853. else
  854. love.graphics.print(tostring(math.floor(player2nukescore)), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60)
  855. end
  856. end
  857. function hitIdentifier()
  858. if (gameMode == "practice") then
  859. MAP_TYPE = 0
  860. if ball[i].x > VIRTUAL_WIDTH * 0.99 then
  861. soundtype = love.math.random(1, 5)
  862. sounds["wallhit"]:setPitch(ballSpeed / 250)
  863. sounds["wallhit"]:play()
  864. if (ball[i].dx > 0) then
  865. ball[i].x = ball[i].x - 20
  866. else
  867. ball[i].x = ball[i].x + 20
  868. end
  869. ball[i].dx = -ball[i].dx
  870. end
  871. end
  872. if (MAP_TYPE == 1) then
  873. if
  874. ball[i].y < VIRTUAL_HEIGHT * 0.3 and ball[i].x > VIRTUAL_WIDTH * 0.5 and
  875. ball[i].x < VIRTUAL_WIDTH * 0.5 + 5
  876. then
  877. soundtype = love.math.random(1, 5)
  878. sounds["wallhit"]:setPitch(ballSpeed / 250)
  879. sounds["wallhit"]:play()
  880. if (ball[i].dx > 0) then
  881. ball[i].x = ball[i].x - 20
  882. else
  883. ball[i].x = ball[i].x + 20
  884. end
  885. ball[i].dx = -ball[i].dx
  886. end
  887. if
  888. ball[i].y > VIRTUAL_HEIGHT * 0.7 and ball[i].x > VIRTUAL_WIDTH * 0.5 and
  889. ball[i].x < VIRTUAL_WIDTH * 0.5 + 5
  890. then
  891. soundtype = love.math.random(1, 5)
  892. sounds["wallhit"]:setPitch(ballSpeed / 250)
  893. sounds["wallhit"]:play()
  894. if (ball[i].dx > 0) then
  895. ball[i].x = ball[i].x - 20
  896. else
  897. ball[i].x = ball[i].x + 20
  898. end
  899. ball[i].dx = -ball[i].dx
  900. end
  901. end
  902. if (MAP_TYPE == 2) then
  903. for i, wall in ipairs(walls) do
  904. if
  905. (ball[1].y > wall.wally and ball[1].y < wall.wally + wall.wallheight and
  906. ball[1].x > wall.wallx - ballSpeed / 200 and
  907. ball[1].x < wall.wallx + 10 + ballSpeed / 200)
  908. then
  909. controllerSer()
  910. soundtype = love.math.random(1, 5)
  911. sounds["wallhit"]:setPitch(ballSpeed / 250)
  912. sounds["wallhit"]:play()
  913. if (ball[1].dx > 0) then
  914. ball[1].x = ball[1].x - 1
  915. else
  916. ball[1].x = ball[1].x + 1
  917. end
  918. ball[1].dx = -ball[1].dx
  919. elseif
  920. (ball[1].y > wall.wally - 15 and ball[1].y < wall.wally + wall.wallheight + 10 and
  921. ball[1].x > wall.wallx and
  922. ball[1].x < wall.wallx + 10)
  923. then
  924. controllerSer()
  925. soundtype = love.math.random(1, 5)
  926. sounds["wallhit"]:setPitch(ballSpeed / 250)
  927. sounds["wallhit"]:play()
  928. if (ball[1].dy > 0) then
  929. ball[1].y = ball[1].y - 1
  930. else
  931. ball[1].y = ball[1].y + 1
  932. end
  933. ball[1].dy = -ball[1].dy
  934. end
  935. end
  936. end
  937. end
  938. function rules(query, i)
  939. if query == "p1hit" then
  940. if gameMode == "normal" then
  941. return ball[i]:collides(player1)
  942. elseif gameMode == "reversegame" then
  943. return ball[i].x < 0 and ball[i].disabled == false
  944. end
  945. end
  946. if query == "p2hit" then
  947. if gameMode == "normal" then
  948. return ball[i]:collides(player2)
  949. elseif gameMode == "reversegame" then
  950. return ball[i].x > VIRTUAL_WIDTH-10 and ball[i].disabled == false
  951. end
  952. end
  953. if query == "p1miss" then
  954. if gameMode == "reversegame" then
  955. return ball[i]:collides(player1)
  956. elseif gameMode == "normal" then
  957. return ball[i].x < 0 and ball[i].disabled == false
  958. end
  959. end
  960. if query == "p2miss" then
  961. if gameMode == "reversegame" then
  962. return ball[i]:collides(player2)
  963. elseif gameMode == "normal" then
  964. return ball[i].x > VIRTUAL_WIDTH-10 and ball[i].disabled == false
  965. end
  966. end
  967. end
  968. function clientsBaseGame(dt)
  969. if gameMode == "reverse" then
  970. reversegame(dt)
  971. end
  972. if player1nukescore > 300 then
  973. player1nukescore = 300
  974. end
  975. if player2nukescore > 300 then
  976. player2nukescore = 300
  977. end
  978. speedControl()
  979. balancer()
  980. if t < shakeDuration then
  981. t = t + dt
  982. end
  983. if (lastSentKeyP1 == p1control.up) then
  984. player1.dy = (paddle_SPEED + p2bonus) * -1
  985. print("moving player1 up")
  986. elseif (lastSentKeyP1 == p1control.down) then
  987. player1.dy = paddle_SPEED + p2bonus
  988. print("moving player1 down")
  989. else
  990. player1.dy = 0
  991. -- print("stopping player")
  992. end
  993. if ((love.keyboard.isDown(p2control.up))) then
  994. player2.dy = (paddle_SPEED + p2bonus) * -1
  995. elseif ((love.keyboard.isDown(p2control.down))) then
  996. player2.dy = paddle_SPEED + p2bonus
  997. else
  998. player2.dy = 0
  999. end
  1000. --print("T = " .. tostring(t))
  1001. serveBot()
  1002. if gameState == 'play' then
  1003. if (AGAINST_AI == 1) then
  1004. AI(player2, maxBalls, AI_LEVEL)
  1005. end
  1006. --print(areanuclear .. striken .. player1score .. player2score)
  1007. for i = 1, maxBalls do
  1008. if rules("p1hit", i) then
  1009. if (areanuclear == 0 and striken == 1 and (player1score > ptw-2 or player2score > ptw-2)) then
  1010. --print("Calling animation")
  1011. superanimator("tensehit", 1)
  1012. print("AREA NUCLEAR?" .. areanuclear)
  1013. end
  1014. if gameMode == "practice" then
  1015. player1score = player1score + 1
  1016. end
  1017. t = 0
  1018. if (ballSpeed > 200) then
  1019. shakeMagnitude = ballSpeed / 200
  1020. else
  1021. shakeMagnitude = 0
  1022. end
  1023. shakeDuration = 1
  1024. randomtext = love.math.random(1, #textphrases)
  1025. TEXT = textphrases[randomtext]
  1026. soundtype = love.math.random(1, 1.2)
  1027. if (player1striken == 1) then
  1028. TEXT = "PLAYER 1 STRIKES"
  1029. ballSpeed = ballSpeed + player1nukescore
  1030. potentialnuke1 = 0
  1031. player1striken = 0
  1032. player1nukescore = 0
  1033. potentialstrike1 = 0
  1034. striken = 1
  1035. if areanuclear == 0 then
  1036. sounds["striking"]:setPitch(ballSpeed / 250)
  1037. sounds["striking"]:play()
  1038. else
  1039. sounds["nuclearhit"]:setPitch(1)
  1040. sounds["nuclearhit"]:play()
  1041. end
  1042. if areanuclear == 0 then
  1043. superanimator("tensehit", 1)
  1044. end
  1045. else
  1046. if areanuclear == 0 then
  1047. sounds["beep"]:setPitch(ballSpeed / 250)
  1048. sounds["beep"]:play()
  1049. else
  1050. sounds["nuclearhit"]:setPitch(1)
  1051. sounds["nuclearhit"]:play()
  1052. end
  1053. end
  1054. if (striken == 1) then
  1055. player1nukescore = player1nukescore * 1.5
  1056. if (synctype == 0) then
  1057. paddle_SPEED = paddle_SPEED * 1.10
  1058. elseif (synctype == 1) then
  1059. paddle_SPEED = ballSpeed
  1060. end
  1061. if (synctype == 0) then
  1062. AI_SPEED = AI_SPEED * 1.10
  1063. end
  1064. if (synctype == 1) then
  1065. AI_SPEED = ballSpeed * 1.1 / 10
  1066. end
  1067. ballSpeed = ballSpeed * 1.10
  1068. end
  1069. player1nukescore = player1nukescore + 10
  1070. ball[i].dx = -ball[i].dx
  1071. ball[i].x = player1.x + 30
  1072. end
  1073. if rules("p2hit", i) then
  1074. --ameState = 'quickanim'
  1075. t = 0
  1076. shakeDuration = 1
  1077. if
  1078. (areanuclear == 0 and
  1079. (striken == 1 and (player1score > ptw-2 or player2score > ptw-2)))
  1080. then
  1081. print("AREA NUCLEAR?" .. areanuclear)
  1082. superanimator("tensehit", 2)
  1083. end
  1084. if (ballSpeed > 200) then
  1085. shakeMagnitude = ballSpeed / 200
  1086. else
  1087. shakeMagnitude = 0
  1088. end
  1089. randomtext = love.math.random(1, #textphrases)
  1090. TEXT = textphrases[randomtext]
  1091. soundtype = love.math.random(1, 1.2)
  1092. if (player2striken == 1) then
  1093. TEXT = "PLAYER 2 STRIKES"
  1094. ballSpeed = ballSpeed + player2nukescore
  1095. striken = 1
  1096. player2striken = 0
  1097. potentialnuke2 = 0
  1098. player2nukescore = 0
  1099. potentialstrike2 = 0
  1100. print("AREA NUCLEAR?" .. areanuclear)
  1101. if areanuclear == 0 then
  1102. superanimator("tensehit", 2)
  1103. end
  1104. if areanuclear == 0 then
  1105. sounds["striking"]:setPitch(ballSpeed / 250)
  1106. sounds["striking"]:play()
  1107. else
  1108. sounds["nuclearhit"]:setPitch(1)
  1109. sounds["nuclearhit"]:play()
  1110. end
  1111. elseif (striken == 1) then
  1112. player2nukescore = player2nukescore * 1.5
  1113. if (synctype == 0) then
  1114. paddle_SPEED = paddle_SPEED * 1.10
  1115. end
  1116. if (synctype == 1) then
  1117. paddle_SPEED = ballSpeed
  1118. end
  1119. if (synctype == 0) then
  1120. AI_SPEED = AI_SPEED * 1.10
  1121. end
  1122. if (synctype == 1) then
  1123. AI_SPEED = ballSpeed * 1.1 / 10
  1124. end
  1125. ballSpeed = ballSpeed * 1.10
  1126. if areanuclear == 0 then
  1127. sounds["beep"]:setPitch(ballSpeed / 250)
  1128. sounds["beep"]:play()
  1129. else
  1130. sounds["nuclearhit"]:setPitch(1)
  1131. sounds["nuclearhit"]:play()
  1132. end
  1133. else
  1134. if areanuclear == 0 then
  1135. sounds["beep"]:setPitch(ballSpeed / 250)
  1136. sounds["beep"]:play()
  1137. else
  1138. sounds["nuclearhit"]:setPitch(1)
  1139. sounds["nuclearhit"]:play()
  1140. end
  1141. end
  1142. player2nukescore = player2nukescore + 10
  1143. ball[i].dx = -ball[i].dx
  1144. ball[i].x = player2.x - 30
  1145. if ((love.keyboard.isDown(p2control.up))) then
  1146. select = math.random(1, 5)
  1147. if select == 1 then
  1148. ball[i].dy = -1
  1149. elseif select == 2 then
  1150. ball[i].dy = -1.2
  1151. elseif select == 3 then
  1152. ball[i].dy = -1.5
  1153. elseif select == 4 then
  1154. ball[i].dy = -1.8
  1155. elseif select == 5 then
  1156. ball[i].dy = -2
  1157. end
  1158. elseif (love.keyboard.isDown(p2control.down))then
  1159. select = math.random(1, 5)
  1160. if select == 1 then
  1161. ball[i].dy = 1
  1162. elseif select == 2 then
  1163. ball[i].dy = 1.2
  1164. elseif select == 3 then
  1165. ball[i].dy = 1.5
  1166. elseif select == 4 then
  1167. ball[i].dy = 1.8
  1168. elseif select == 5 then
  1169. ball[i].dy = 2
  1170. end
  1171. else
  1172. if ball[i].dy < 0 then
  1173. select = math.random(1, 5)
  1174. if select == 1 then
  1175. ball[i].dy = -1
  1176. elseif select == 2 then
  1177. ball[i].dy = -1.2
  1178. elseif select == 3 then
  1179. ball[i].dy = -1.5
  1180. elseif select == 4 then
  1181. ball[i].dy = -1.8
  1182. elseif select == 5 then
  1183. ball[i].dy = -2
  1184. end
  1185. else
  1186. select = math.random(1, 5)
  1187. if select == 1 then
  1188. ball[i].dy = 1
  1189. elseif select == 2 then
  1190. ball[i].dy = 1.2
  1191. elseif select == 3 then
  1192. ball[i].dy = 1.5
  1193. elseif select == 4 then
  1194. ball[i].dy = 1.8
  1195. elseif select == 5 then
  1196. ball[i].dy = 2
  1197. end
  1198. end
  1199. end
  1200. end
  1201. hitIdentifier()
  1202. if ball[i].y <= 0 then
  1203. soundtype = love.math.random(1, 5)
  1204. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1205. sounds["wallhit"]:play()
  1206. ball[i].y = 0
  1207. ball[i].dy = -ball[i].dy
  1208. end
  1209. -- -4 to account for the ball's size
  1210. if ball[i].y >= VIRTUAL_HEIGHT - 40 then
  1211. soundtype = love.math.random(1, 5)
  1212. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1213. sounds["wallhit"]:play()
  1214. ball[i].y = VIRTUAL_HEIGHT - 40
  1215. ball[i].dy = -ball[i].dy
  1216. end
  1217. --love.window.setTitle('Trying to update the ball')
  1218. if timeIsSlow then
  1219. if ballSpeed > originalSpeed / 3 then
  1220. paddle_SPEED = 30
  1221. ballSpeed = ballSpeed / (1 + (dt * 2))
  1222. end
  1223. player1nukescore = player1nukescore - (dt * 50)
  1224. if player1nukescore < 1 or ball[1].dx > 0 then
  1225. timeIsSlow = false
  1226. player1reverbav = false
  1227. ballSpeed = originalSpeed
  1228. sounds["time"]:stop()
  1229. paddle_SPEED = originalPaddle
  1230. end
  1231. end
  1232. if timeIsSlow2 then
  1233. if ballSpeed > originalSpeed / 3 then
  1234. ballSpeed = ballSpeed / (1 + (dt * 2))
  1235. end
  1236. player2nukescore = player2nukescore - (dt * 50)
  1237. if player2nukescore < 1 or ball[1].dx < 0 then
  1238. paddle_SPEED = 30
  1239. timeIsSlow2 = false
  1240. player2reverbav = false
  1241. ballSpeed = originalSpeed
  1242. sounds["time"]:stop()
  1243. paddle_SPEED = originalPaddle
  1244. end
  1245. end
  1246. ball[i]:update(dt)
  1247. end
  1248. end
  1249. goalManager()
  1250. powerAvailability()
  1251. player1:update(dt)
  1252. love.event.quit()
  1253. player2:update(dt)
  1254. end