Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

1682 linhas
63 KiB

  1. local counter = 0
  2. function basegame(dt)
  3. if gameMode == "reversegame" then
  4. reversegame(dt)
  5. end
  6. if player1nukescore > 300 then
  7. player1nukescore = 300
  8. end
  9. if player2nukescore > 300 then
  10. player2nukescore = 300
  11. end
  12. speedControl()
  13. balancer()
  14. effectControl()
  15. if t < shakeDuration then
  16. t = t + dt
  17. end
  18. --print("T = " .. tostring(t))
  19. serveBot()
  20. if gameState == 'play' then
  21. if (AGAINST_AI == 1) then
  22. AI(player2, maxBalls, AI_LEVEL)
  23. end
  24. if (love.keyboard.isDown(p1control.up) or sectortouched(2)) then
  25. player1.dy = (paddle_SPEED + p1bonus) * -1
  26. elseif (love.keyboard.isDown(p1control.down) or sectortouched(3)) then
  27. player1.dy = paddle_SPEED + p1bonus
  28. else
  29. player1.dy = 0
  30. end
  31. if (AGAINST_AI == 0) then
  32. if ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.up) or sectortouched(1))) ) then
  33. player2.dy = (paddle_SPEED + p2bonus) * -1
  34. elseif ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.down) or sectortouched(4)))) then
  35. player2.dy = paddle_SPEED + p2bonus
  36. elseif (globalState ~= "nettest") then
  37. player2.dy = 0
  38. end
  39. end
  40. --print(areanuclear .. striken .. player1score .. player2score)
  41. for i = 1, maxBalls do
  42. if rules("p1hit", i) then
  43. --print("inserted")
  44. if (areanuclear == 0 and striken == 1 and (player1score > ptw*0.8 or player2score > ptw*0.8)) then
  45. --print("Calling animation")
  46. --print("AREA NUCLEAR?" .. areanuclear)
  47. superanimator("tensehit", 1)
  48. end
  49. if gameMode == "practice" then
  50. player1score = player1score + 1
  51. end
  52. t = 0
  53. if (ballSpeed > 200) then
  54. shakeMagnitude = ballSpeed / 200
  55. else
  56. shakeMagnitude = 0
  57. end
  58. shakeDuration = 1
  59. randomtext = love.math.random(1, #textphrases)
  60. TEXT = textphrases[randomtext]
  61. soundtype = love.math.random(1, 1.2)
  62. if (player1striken == 1) then
  63. TEXT = "PLAYER 1 STRIKES"
  64. ballSpeed = ballSpeed + player1nukescore
  65. background_scroll_speed = ballSpeed / 20
  66. potentialnuke1 = 0
  67. player1striken = 0
  68. player1nukescore = 0
  69. potentialstrike1 = 0
  70. striken = 1
  71. if areanuclear == 0 then
  72. sounds["striking"]:setPitch(ballSpeed / 250)
  73. sounds["striking"]:play()
  74. else
  75. sounds["nuclearhit"]:setPitch(1)
  76. sounds["nuclearhit"]:play()
  77. end
  78. --print("AREA NUCLEAR?" .. areanuclear)
  79. if areanuclear == 0 then
  80. superanimator("tensehit", 1)
  81. end
  82. else
  83. if areanuclear == 0 then
  84. sounds["beep"]:setPitch(ballSpeed / 250)
  85. sounds["beep"]:play()
  86. else
  87. sounds["nuclearhit"]:setPitch(1)
  88. sounds["nuclearhit"]:play()
  89. end
  90. end
  91. if (striken == 1) then
  92. player1nukescore = player1nukescore * 1.5
  93. if (synctype == 0) then
  94. paddle_SPEED = paddle_SPEED * 1.10
  95. elseif (synctype == 1) then
  96. paddle_SPEED = ballSpeed
  97. end
  98. if (synctype == 0) then
  99. AI_SPEED = AI_SPEED * 1.10
  100. end
  101. if (synctype == 1) then
  102. AI_SPEED = ballSpeed * 1.1 / 10
  103. end
  104. ballSpeed = ballSpeed * 1.10
  105. background_scroll_speed = ballSpeed / 20
  106. end
  107. player1nukescore = player1nukescore + 10
  108. ball[i].dx = -ball[i].dx
  109. ball[i].x = player1.x + 30
  110. if (love.keyboard.isDown(p1control.up) or sectortouched(2)) then
  111. select = math.random(1, 5)
  112. if select == 1 then
  113. ball[i].dy = -1
  114. elseif select == 2 then
  115. ball[i].dy = -1.2
  116. elseif select == 3 then
  117. ball[i].dy = -1.5
  118. elseif select == 4 then
  119. ball[i].dy = -1.8
  120. elseif select == 5 then
  121. ball[i].dy = -2
  122. end
  123. elseif love.keyboard.isDown(p1control.down) or sectortouched(3) then
  124. select = math.random(1, 5)
  125. if select == 1 then
  126. ball[i].dy = 1
  127. elseif select == 2 then
  128. ball[i].dy = 1.2
  129. elseif select == 3 then
  130. ball[i].dy = 1.5
  131. elseif select == 4 then
  132. ball[i].dy = 1.8
  133. elseif select == 5 then
  134. ball[i].dy = 2
  135. end
  136. else
  137. if ball[i].dy < 0 then
  138. select = math.random(1, 5)
  139. if select == 1 then
  140. ball[i].dy = -1
  141. elseif select == 2 then
  142. ball[i].dy = -1.2
  143. elseif select == 3 then
  144. ball[i].dy = -1.5
  145. elseif select == 4 then
  146. ball[i].dy = -1.8
  147. elseif select == 5 then
  148. ball[i].dy = -2
  149. end
  150. else
  151. select = math.random(1, 5)
  152. if select == 1 then
  153. ball[i].dy = 1
  154. elseif select == 2 then
  155. ball[i].dy = 1.2
  156. elseif select == 3 then
  157. ball[i].dy = 1.5
  158. elseif select == 4 then
  159. ball[i].dy = 1.8
  160. elseif select == 5 then
  161. ball[i].dy = 2
  162. end
  163. end
  164. end
  165. end
  166. if rules("p2hit", i) then
  167. --ameState = 'quickanim'
  168. t = 0
  169. shakeDuration = 1
  170. if
  171. (areanuclear == 0 and
  172. (striken == 1 and (player1score > ptw*0.8 or player2score > ptw*0.8)))
  173. then
  174. --print("AREA NUCLEAR?" .. areanuclear)
  175. superanimator("tensehit", 2)
  176. end
  177. if (ballSpeed > 200) then
  178. shakeMagnitude = ballSpeed / 200
  179. else
  180. shakeMagnitude = 0
  181. end
  182. randomtext = love.math.random(1, #textphrases)
  183. TEXT = textphrases[randomtext]
  184. soundtype = love.math.random(1, 1.2)
  185. if (player2striken == 1) then
  186. TEXT = "PLAYER 2 STRIKES"
  187. ballSpeed = ballSpeed + player2nukescore
  188. background_scroll_speed = ballSpeed / 20
  189. striken = 1
  190. player2striken = 0
  191. potentialnuke2 = 0
  192. player2nukescore = 0
  193. potentialstrike2 = 0
  194. --print("AREA NUCLEAR?" .. areanuclear)
  195. if areanuclear == 0 then
  196. superanimator("tensehit", 2)
  197. end
  198. if areanuclear == 0 then
  199. sounds["striking"]:setPitch(ballSpeed / 250)
  200. sounds["striking"]:play()
  201. else
  202. sounds["nuclearhit"]:setPitch(1)
  203. sounds["nuclearhit"]:play()
  204. end
  205. elseif (striken == 1) then
  206. player2nukescore = player2nukescore * 1.5
  207. if (synctype == 0) then
  208. paddle_SPEED = paddle_SPEED * 1.10
  209. end
  210. if (synctype == 1) then
  211. paddle_SPEED = ballSpeed
  212. end
  213. if (synctype == 0) then
  214. AI_SPEED = AI_SPEED * 1.10
  215. end
  216. if (synctype == 1) then
  217. AI_SPEED = ballSpeed * 1.1 / 10
  218. end
  219. ballSpeed = ballSpeed * 1.10
  220. background_scroll_speed = ballSpeed / 20
  221. if areanuclear == 0 then
  222. sounds["beep"]:setPitch(ballSpeed / 250)
  223. sounds["beep"]:play()
  224. else
  225. sounds["nuclearhit"]:setPitch(1)
  226. sounds["nuclearhit"]:play()
  227. end
  228. else
  229. if areanuclear == 0 then
  230. sounds["beep"]:setPitch(ballSpeed / 250)
  231. sounds["beep"]:play()
  232. else
  233. sounds["nuclearhit"]:setPitch(1)
  234. sounds["nuclearhit"]:play()
  235. end
  236. end
  237. player2nukescore = player2nukescore + 10
  238. ball[i].dx = -ball[i].dx
  239. ball[i].x = player2.x - 30
  240. if ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.up) or sectortouched(1)) ) or AI_SPEED < 0 or lastSentKeyClient == p2control.up) then
  241. select = math.random(1, 5)
  242. if select == 1 then
  243. ball[i].dy = -1
  244. elseif select == 2 then
  245. ball[i].dy = -1.2
  246. elseif select == 3 then
  247. ball[i].dy = -1.5
  248. elseif select == 4 then
  249. ball[i].dy = -1.8
  250. elseif select == 5 then
  251. ball[i].dy = -2
  252. end
  253. elseif (globalState ~= "nettest" and (love.keyboard.isDown(p2control.down)or sectortouched(4))) or AI_SPEED > 0 or lastSentKeyClient == p2control.down then
  254. select = math.random(1, 5)
  255. if select == 1 then
  256. ball[i].dy = 1
  257. elseif select == 2 then
  258. ball[i].dy = 1.2
  259. elseif select == 3 then
  260. ball[i].dy = 1.5
  261. elseif select == 4 then
  262. ball[i].dy = 1.8
  263. elseif select == 5 then
  264. ball[i].dy = 2
  265. end
  266. else
  267. if ball[i].dy < 0 then
  268. select = math.random(1, 5)
  269. if select == 1 then
  270. ball[i].dy = -1
  271. elseif select == 2 then
  272. ball[i].dy = -1.2
  273. elseif select == 3 then
  274. ball[i].dy = -1.5
  275. elseif select == 4 then
  276. ball[i].dy = -1.8
  277. elseif select == 5 then
  278. ball[i].dy = -2
  279. end
  280. else
  281. select = math.random(1, 5)
  282. if select == 1 then
  283. ball[i].dy = 1
  284. elseif select == 2 then
  285. ball[i].dy = 1.2
  286. elseif select == 3 then
  287. ball[i].dy = 1.5
  288. elseif select == 4 then
  289. ball[i].dy = 1.8
  290. elseif select == 5 then
  291. ball[i].dy = 2
  292. end
  293. end
  294. end
  295. end
  296. hitIdentifier()
  297. if ball[i].y <= 0 then
  298. soundtype = love.math.random(1, 5)
  299. sounds["wallhit"]:setPitch(ballSpeed / 250)
  300. sounds["wallhit"]:play()
  301. ball[i].y = 0
  302. ball[i].dy = -ball[i].dy
  303. end
  304. -- -4 to account for the ball's size
  305. if ball[i].y >= VIRTUAL_HEIGHT - 40 then
  306. soundtype = love.math.random(1, 5)
  307. sounds["wallhit"]:setPitch(ballSpeed / 250)
  308. sounds["wallhit"]:play()
  309. ball[i].y = VIRTUAL_HEIGHT - 40
  310. ball[i].dy = -ball[i].dy
  311. end
  312. --love.window.setTitle('Trying to update the ball')
  313. if timeIsSlow then
  314. if ballSpeed > originalSpeed / 3 then
  315. paddle_SPEED = 300
  316. ballSpeed = ballSpeed / (1 + (dt * 2))
  317. background_scroll_speed = ballSpeed / 20
  318. end
  319. player1nukescore = player1nukescore - (dt * 50)
  320. if player1nukescore < 1 or ball[1].dx > 0 then
  321. timeIsSlow = false
  322. player1reverbav = false
  323. ballSpeed = originalSpeed
  324. background_scroll_speed = ballSpeed / 20
  325. sounds["time"]:stop()
  326. paddle_SPEED = originalPaddle
  327. end
  328. end
  329. if timeIsSlow2 then
  330. if ballSpeed > originalSpeed / 3 then
  331. ballSpeed = ballSpeed / (1 + (dt * 2))
  332. background_scroll_speed = ballSpeed / 20
  333. end
  334. player2nukescore = player2nukescore - (dt * 50)
  335. if player2nukescore < 1 or ball[1].dx < 0 then
  336. paddle_SPEED = 300
  337. timeIsSlow2 = false
  338. player2reverbav = false
  339. ballSpeed = originalSpeed
  340. background_scroll_speed = ballSpeed / 20
  341. sounds["time"]:stop()
  342. paddle_SPEED = originalPaddle
  343. end
  344. end
  345. ball[i]:update(dt)
  346. end
  347. end
  348. goalManager()
  349. powerAvailability()
  350. player1:update(dt)
  351. player2:update(dt)
  352. end
  353. function debugCheck(dt)
  354. if (gameState == "menu") then
  355. updateTEXT = "0.8 Galaxy"
  356. end
  357. dangerChecker()
  358. elapsed = elapsed + dt
  359. rotation = math.sin(elapsed * 2.5) * 0.7
  360. editor()
  361. mapChanger()
  362. end
  363. function goalManager()
  364. for i = 1, maxBalls do
  365. if (rules("p1miss", i)) then
  366. ball[i].disabled = true
  367. ball[i].x = 2000
  368. if ballsAlive() == false then
  369. if (nuckemodactive == 0) then
  370. areanuclear = 0
  371. nuclearanimation = 3
  372. end
  373. striken = 0
  374. player1striken = 0
  375. player2striken = 0
  376. ballSpeed = ballSet
  377. background_scroll_speed = ballSpeed / 20
  378. if (synctype == 0) then
  379. paddle_SPEED = ballSet
  380. end
  381. if (synctype == 1) then
  382. paddle_SPEED = ballSpeed
  383. end
  384. AI_SPEED = difficultyl
  385. for i = 1, maxBalls do
  386. ball[i]:reset(i, 2)
  387. end
  388. if (player2score+1 == ptw+maxBalls-1 and gameMode ~= "practice") then
  389. for i = 1, maxBalls do
  390. ball[i]:reset(i)
  391. end
  392. sounds["win"]:play()
  393. gameState = "done"
  394. TEXT = "Player 2 Won!"
  395. else
  396. if globalState ~= "clienttest" or (globalState == "clienttest" and gameState == "1serve") then
  397. gameState = "1serve"
  398. serveBot()
  399. ball[i]:reset(i, 1)
  400. end
  401. end
  402. end
  403. player2score = player2score + 1
  404. end
  405. if (rules("p2miss", i)) then
  406. ball[i].disabled = true
  407. ball[i].x = 2000
  408. if ballsAlive() == false then
  409. if (nuckemodactive == 0) then
  410. areanuclear = 0
  411. nuclearanimation = 3
  412. end
  413. striken = 0
  414. player1striken = 0
  415. player2striken = 0
  416. ballSpeed = ballSet
  417. background_scroll_speed = ballSpeed / 20
  418. if (synctype == 0) then
  419. paddle_SPEED = ballSet
  420. AI_SPEED = ballSet
  421. end
  422. if (synctype == 1) then
  423. paddle_SPEED = ballSpeed
  424. AI_SPEED = ballSpeed
  425. end
  426. AI_SPEED = difficultyl
  427. if (player1score+1 == ptw+maxBalls-1) then
  428. ball[i]:reset(i)
  429. sounds["win"]:play()
  430. gameState = "done"
  431. TEXT = "Player 1 Won"
  432. else
  433. if globalState ~= "nettest" or (globalState == "nettest" and gameState == "2serve") then
  434. gameState = "2serve"
  435. serveBot()
  436. ball[i]:reset(i, 2)
  437. end
  438. end
  439. end
  440. sounds["score"]:play()
  441. player1score = player1score + 1
  442. end
  443. end
  444. end
  445. function powerAvailability()
  446. if (player1nukescore >= 20 and player1nukescore < 200) then
  447. potentialstrike1 = 1
  448. if (((globalState ~= "clienttest" and (love.keyboard.isDown(p1control.super) or doubleclick1 == true)) or (globalState == "clienttest" and lastSentKeyP1 == p1control.super)) ) then
  449. player1striken = 1
  450. doubleclick1 = false
  451. player1reverbav = 0
  452. end
  453. end
  454. 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
  455. player1reverbav = 1
  456. if ((globalState == "clienttest" and lastSentKeyP1 == p1control.counter) or (globalState ~= "clienttest" and (love.keyboard.isDown(p1control.counter) or hold1 == true))) then
  457. powerControl(1, "special")
  458. end
  459. end
  460. if (player1nukescore >= 200) then
  461. potentialnuke1 = 1
  462. if ((globalState == "clienttest" and (lastSentKeyP1 == p1control.super or doubleclick1 == true))or (globalState ~= "clienttest" and (love.keyboard.isDown(p1control.super) or doubleclick1 == true))) then
  463. sounds["nuke"]:play()
  464. doubleclick1 = false
  465. if areanuclear == 1 then
  466. maxspeed = maxspeed + 50
  467. end
  468. areanuclear = 1
  469. potentialstrike1 = 0
  470. striken = 0
  471. ballSpeed = ballSpeed * 2
  472. background_scroll_speed = ballSpeed / 20
  473. if (synctype == 0) then
  474. paddle_SPEED = paddle_SPEED * 2
  475. end
  476. if (synctype == 1) then
  477. paddle_SPEED = ballSpeed
  478. end
  479. if (synctype == 0) then
  480. AI_SPEED = AI_SPEED * 2.2
  481. end
  482. if (synctype == 1) then
  483. AI_SPEED = ballSpeed * 1.1 / 10
  484. end
  485. player1nukescore = 0
  486. player1reverbav = 0
  487. potentialnuke1 = 0
  488. end
  489. end
  490. if (player2nukescore >= 20 and player2nukescore < 200) then
  491. potentialstrike2 = 1
  492. if (AGAINST_AI == 0) then
  493. if ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.super) or doubleclick2)) or lastSentKeyClient == p2control.super ) then
  494. player2striken = 1
  495. player2reverbav = 0
  496. doubleclick2 = false
  497. end
  498. end
  499. end
  500. 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
  501. player2reverbav = 1
  502. --print("Available counter, " .. globalState .. tostring(love.keyboard.isDown(p2control.counter)))
  503. if (globalState ~= "nettest" and (love.keyboard.isDown(p2control.counter) or hold2)) or lastSentKeyClient == p2control.counter then
  504. sounds["time"]:play()
  505. player2reverbav = false
  506. timeIsSlow2 = true
  507. originalPaddle = paddle_SPEED
  508. originalSpeed = ballSpeed
  509. player2reverbav = 0
  510. potentialnuke2 = 0
  511. potentialstrike2 = 0
  512. end
  513. end
  514. if (player2nukescore >= 200) then
  515. potentialnuke2 = 1
  516. if (((globalState ~= "nettest" and (love.keyboard.isDown(p2control.super) or doubleclick2)) or lastSentKeyClient == p2control.super)) and AGAINST_AI == 0 then
  517. sounds["nuke"]:play()
  518. doubleclick2 = false
  519. if areanuclear == 1 then
  520. maxspeed = maxspeed + 50
  521. end
  522. potentialstrike2 = 0
  523. areanuclear = 1
  524. player2reverbav = 0
  525. ballSpeed = ballSpeed * 2
  526. background_scroll_speed = ballSpeed / 20
  527. if (synctype == 0) then
  528. paddle_SPEED = paddle_SPEED * 2
  529. end
  530. if (synctype == 1) then
  531. paddle_SPEED = ballSpeed
  532. end
  533. if (synctype == 0) then
  534. AI_SPEED = AI_SPEED * 2.2
  535. end
  536. if (synctype == 1) then
  537. AI_SPEED = ballSpeed * 1.1 / 10
  538. end
  539. player2nukescore = 0
  540. potentialnuke2 = 0
  541. end
  542. end
  543. end
  544. function editor()
  545. if (gameState == "editor") then
  546. if debug then
  547. --print("Editor is active!")
  548. end
  549. local mx, my = love.mouse.getPosition()
  550. mx = mx * DIFFERENCE_X
  551. my = my * DIFFERENCE_Y
  552. if (love.mouse.isDown(2)) then
  553. wallbreaker(mx, my)
  554. end
  555. if (love.mouse.isDown(3)) then
  556. table.insert(walls, newWall(mx, my, 10, wall1width))
  557. end
  558. end
  559. end
  560. function nuclearDraw()
  561. love.graphics.setColor(1, 1, 1, 1)
  562. for i = 1, maxBalls do
  563. love.graphics.circle("fill", ball[i].x, ball[i].y, explosionRange * 100, 100)
  564. end
  565. player1.RED, player1.GREEN, player1.BLUE, player2.RED, player2.GREEN, player2.BLUE =
  566. nuclearanimation / 3,
  567. nuclearanimation / 3,
  568. nuclearanimation / 3,
  569. nuclearanimation / 3,
  570. nuclearanimation / 3,
  571. nuclearanimation / 3
  572. for i = 1, maxBalls do
  573. love.graphics.setColor(nuclearanimation / 3, nuclearanimation / 3, nuclearanimation / 3, 1)
  574. ball[i]:render("controlled")
  575. end
  576. player1:render()
  577. player2:render()
  578. end
  579. function winDraw(who)
  580. love.graphics.setColor(0, 0, 0, 1)
  581. if who == 1 then
  582. love.graphics.circle("fill", player2.x, player2.y, explosionRange * 100, 100)
  583. love.graphics.setColor(0.7, 0.1, 0.1, 1)
  584. love.graphics.circle("fill", player2.x, player2.y, explosionRange * 90, 100)
  585. love.graphics.setColor(0.1, 0.7, 0.1, 1)
  586. love.graphics.circle("fill", player2.x, player2.y, explosionRange * 80, 100)
  587. love.graphics.setColor(0.1, 0.1, 0.7, 1)
  588. love.graphics.circle("fill", player2.x, player2.y, explosionRange * 70, 100)
  589. love.graphics.setColor(0, 0, 0, 1)
  590. love.graphics.circle("fill", player2.x, player2.y, explosionRange * 60, 100)
  591. --print("cicrleexplostion at " .. explosionRange)
  592. else
  593. love.graphics.circle("fill", player1.x, player1.y, explosionRange * 100, 100)
  594. love.graphics.setColor(0.7, 0.1, 0.1, 1)
  595. love.graphics.circle("fill", player1.x, player1.y, explosionRange * 90, 100)
  596. love.graphics.setColor(0.1, 0.7, 0.1, 1)
  597. love.graphics.circle("fill", player1.x, player1.y, explosionRange * 80, 100)
  598. love.graphics.setColor(0.1, 0.1, 0.7, 1)
  599. love.graphics.circle("fill", player1.x, player1.y, explosionRange * 70, 100)
  600. love.graphics.setColor(0, 0, 0, 1)
  601. love.graphics.circle("fill", player1.x, player1.y, explosionRange * 60, 100)
  602. end
  603. love.graphics.setColor(1, 1, 1, 1)
  604. love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
  605. end
  606. function normalDraw()
  607. if (areanuclear == 1) then
  608. love.graphics.clear(1, 1, 1, 1)
  609. else
  610. love.graphics.clear(40 / 255, 40 / 255, 40 / 255, 1)
  611. if (lowcpu) then
  612. --love.graphics.draw(background, 0,0)
  613. else
  614. love.graphics.draw(background, 0,-backgroundScroll)
  615. end
  616. end
  617. if gameState == "assign" then
  618. love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
  619. love.graphics.printf("SELECT BUTTON", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  620. end
  621. for i, explosion in ipairs(explosions) do
  622. explosion:render()
  623. --print("exploding")
  624. end
  625. staticanimator()
  626. if MAP_TYPE == 1 then
  627. love.graphics.setColor(1, 0, 0.20, 1)
  628. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, 0, 10, VIRTUAL_HEIGHT * 0.3)
  629. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, VIRTUAL_HEIGHT * 0.7, 10, VIRTUAL_HEIGHT * 0.3)
  630. love.graphics.setColor(1, 1, 1, 1)
  631. end
  632. if MAP_TYPE == 2 then
  633. for i, wall in ipairs(walls) do
  634. love.graphics.setColor(1, 1, 1, 1)
  635. love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
  636. end
  637. end
  638. pongDraw()
  639. love.graphics.setFont(smallfont)
  640. for i = 1, maxBalls do
  641. if areanuclear == 1 then
  642. --love.window.setTitle('rendering black')
  643. ball[i]:render("black")
  644. else
  645. --love.window.setTitle('rendering white')
  646. ball[i]:render(" ")
  647. end
  648. end
  649. end
  650. function pongDraw()
  651. --print("Drawing classic pong")
  652. love.graphics.setColor(1, 1, 1, 1)
  653. love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
  654. love.graphics.setFont(smallfont)
  655. love.graphics.setFont(scorefont)
  656. if (areanuclear == 1) then
  657. love.graphics.setColor(0, 0, 0, 1)
  658. end
  659. love.graphics.print(tostring(math.floor(player1score)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 12)
  660. love.graphics.print(tostring(math.floor(player2score)), VIRTUAL_WIDTH / 2 + 400, VIRTUAL_HEIGHT / 12)
  661. love.graphics.setColor(1, 1, 1, 1)
  662. displayPoints()
  663. player1:render()
  664. player2:render()
  665. end
  666. function practiceDraw()
  667. player1:render()
  668. love.graphics.rectangle("fill", VIRTUAL_WIDTH-10, 0, 10, VIRTUAL_HEIGHT)
  669. love.graphics.setColor(1, 1, 1, 1)
  670. love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
  671. love.graphics.setFont(smallfont)
  672. love.graphics.setFont(scorefont)
  673. love.graphics.print(tostring(math.floor(player1score)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 12)
  674. end
  675. function menuDraw()
  676. love.graphics.setColor(1, 1, 1, 1)
  677. love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
  678. love.graphics.setFont(smallfont)
  679. love.graphics.printf(updateTEXT, 0, VIRTUAL_HEIGHT * 0.95, VIRTUAL_WIDTH, "left")
  680. if MAP_TYPE == 1 then
  681. love.graphics.setColor(1, 0, 0.20, 1)
  682. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, 0, 10, VIRTUAL_HEIGHT * 0.3)
  683. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, VIRTUAL_HEIGHT * 0.7, 10, VIRTUAL_HEIGHT * 0.3)
  684. love.graphics.setColor(1, 1, 1, 1)
  685. elseif MAP_TYPE == 2 then
  686. for i, wall in ipairs(walls) do
  687. love.graphics.setColor(1, 1, 1, 1)
  688. love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
  689. end
  690. end
  691. player1:render()
  692. player2:render()
  693. ball[1]:render("controlled")
  694. if gameState == "touchcontrols" then
  695. if doubleclick1 or doubleclick2 then
  696. gameState = "menu"
  697. globalState = "menu"
  698. resettinggenius()
  699. end
  700. love.graphics.setFont(smallfont)
  701. love.graphics.printf("The green zones are for moving up and down, double tap the red zone for special attack or to start the serve.", 10, 150, VIRTUAL_WIDTH, "center")
  702. love.graphics.printf("Swipe from red to green for stopping time", 10, 450, VIRTUAL_WIDTH, "center")
  703. elseif gameState == "windowsettings" then
  704. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, settings, sounds, "right")
  705. love.keyboard.mouseisReleased = false
  706. elseif gameState == "editor" then
  707. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, editorpicks, sounds, "right")
  708. love.keyboard.mouseisReleased = false
  709. elseif gameState == "speedSettings" then
  710. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, speedParameters, sounds, "middle")
  711. love.keyboard.mouseisReleased = false
  712. elseif gameState == "controlSettings" then
  713. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, controlSettings, sounds, "control")
  714. love.keyboard.mouseisReleased = false
  715. elseif gameState == "gameMode" then
  716. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, modeSelectorButtons, sounds, "middle")
  717. love.keyboard.mouseisReleased = false
  718. elseif gameState == "chooseIP" then
  719. IPselect = {}
  720. if isAndroid then
  721. table.insert(
  722. IPselect,
  723. newButton(
  724. IPnew,
  725. function()
  726. love.keyboard.setTextInput( true, 0, VIRTUAL_HEIGHT, VIRTUAL_WIDTH, VIRTUAL_HEIGHT/3)
  727. end,
  728. true,
  729. 1
  730. )
  731. )
  732. end
  733. table.insert(
  734. IPselect,
  735. newButton(
  736. "LANHost",
  737. function()
  738. globalState = "selfhost"
  739. AGAINST_AI = 0
  740. gameState = "1serve"
  741. ball[1]:reset(1, 1)
  742. player2.dy = 0
  743. end,
  744. true, 1
  745. )
  746. )
  747. table.insert(
  748. IPselect,
  749. newButton(
  750. "Check Server",
  751. function()
  752. IP = IPnew
  753. counter = 0
  754. end,
  755. true, 1
  756. )
  757. )
  758. if status == "offline" then
  759. animateConnection()
  760. elseif status == "nettest" and IP == IPnew then
  761. table.insert(
  762. IPselect,
  763. newButton(
  764. "Connect as Host",
  765. function()
  766. resettinggenius()
  767. globalState = "nettest"
  768. AGAINST_AI = 0
  769. gameState = "1serve"
  770. ball[1]:reset(1, 1)
  771. player2.dy = 0
  772. end,
  773. false, 1
  774. )
  775. )
  776. elseif status == "clienttest" and IP == IPnew then
  777. table.insert(
  778. IPselect,
  779. newButton(
  780. "Connect as Guest",
  781. function()
  782. resettinggenius()
  783. globalState = "clienttest"
  784. AGAINST_AI = 0
  785. gameState = "1serve"
  786. ball[1]:reset(1, 1)
  787. player2.dy = 0
  788. end,
  789. false, 1
  790. )
  791. )
  792. elseif status == "full" then
  793. love.graphics.printf("SERVER FULL", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  794. end
  795. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, IPselect, sounds, "middle")
  796. love.keyboard.mouseisReleased = false
  797. if not isAndroid then
  798. love.graphics.printf(IPnew, 0, VIRTUAL_HEIGHT / 4, VIRTUAL_WIDTH, "center")
  799. end
  800. love.keyboard.mouseisReleased = false
  801. elseif gameState == "menu" then
  802. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds, "middle")
  803. love.keyboard.mouseisReleased = false
  804. elseif gameState == "difficulty" then
  805. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, difbuttons, sounds, "middle")
  806. love.keyboard.mouseisReleased = false
  807. elseif gameState == "multiMode" then
  808. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, playerCountButtons, sounds, "middle")
  809. love.keyboard.mouseisReleased = false
  810. elseif gameState == "prdiff" then
  811. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, pracdiff, sounds, "playercount")
  812. love.keyboard.mouseisReleased = false
  813. elseif gameState == 'start' then
  814. love.graphics.push()
  815. love.graphics.translate(VIRTUAL_WIDTH * 0.4, VIRTUAL_HEIGHT * 0.5)
  816. love.graphics.rotate(rotation)
  817. love.graphics.setFont(smallfont)
  818. love.graphics.setColor(200/255, 200/255, 200/255, 1)
  819. if isAndroid then
  820. love.graphics.print("Tap to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8)
  821. else
  822. love.graphics.print("Press Enter to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8)
  823. end
  824. love.graphics.setColor(255, 255, 255, 255)
  825. love.graphics.pop()
  826. end
  827. end
  828. function baseDraw()
  829. love.graphics.setColor(255, 255, 255, 1)
  830. if (lowcpu) then
  831. -- love.graphics.draw(background, 0,0)
  832. else
  833. love.graphics.draw(background, 0,-backgroundScroll)
  834. end
  835. if shakeDuration > t then
  836. local dx = love.math.random(-shakeMagnitude, shakeMagnitude)
  837. local dy = love.math.random(-shakeMagnitude, shakeMagnitude)
  838. love.graphics.translate(dx, dy)
  839. end
  840. if globalState == 'menu' then
  841. --print("Drawing menuDraw")
  842. if gameState == 'animation' then
  843. --print("Drawing animation")
  844. intro()
  845. end
  846. if gameState ~= 'animation' then
  847. --print("Drawing notanimtaion")
  848. love.graphics.setFont(scorefont)
  849. menuDraw()
  850. end
  851. end
  852. if globalState == 'base' or globalState == 'reverse' or globalState == 'nettest' or globalState == 'clienttest' then
  853. love.graphics.setFont(smallfont)
  854. if gameState == 'nuclearExplosion' then
  855. nuclearDraw()
  856. end
  857. if gameState == 'play' or gameState == '1serve' or gameState == '2serve' or gameState == 'done' then
  858. --print("Drawing normally")
  859. normalDraw()
  860. end
  861. if gameState == 'done' and player1score > player2score then
  862. winDraw(1)
  863. elseif gameState == 'done' and player1score < player2score then
  864. winDraw(2)
  865. end
  866. end
  867. if paused then
  868. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, pauseButtons, sounds, "middle")
  869. love.keyboard.mouseisReleased = false
  870. end
  871. if gameState == "done" then
  872. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, doneButtons, sounds, "middle")
  873. love.keyboard.mouseisReleased = false
  874. end
  875. if gameState == "assign" then
  876. love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
  877. love.graphics.printf("SELECT BUTTON", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  878. end
  879. end
  880. function androidDraw()
  881. --HOME BUTTON HERE
  882. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, androidButtons, sounds, "android")
  883. if showTouchControls then
  884. love.graphics.setColor(15/255, 255/255, 15/255, 0.5)
  885. love.graphics.rectangle("fill", 0, 0, 100, VIRTUAL_HEIGHT)
  886. love.graphics.setColor(15/255, 255/255, 15/255, 0.5)
  887. love.graphics.rectangle("fill", VIRTUAL_WIDTH-100, 0, 50, VIRTUAL_HEIGHT)
  888. love.graphics.setColor(255/255, 15/255, 15/255, 0.5)
  889. love.graphics.rectangle("fill", 100, 0, VIRTUAL_WIDTH/2-100, VIRTUAL_HEIGHT)
  890. love.graphics.rectangle("fill", VIRTUAL_WIDTH/2, 0, VIRTUAL_WIDTH/2-100, VIRTUAL_HEIGHT)
  891. love.graphics.setColor(0, 0, 0, 0.5)
  892. love.graphics.rectangle("fill", VIRTUAL_WIDTH/2-5, 0, 10, VIRTUAL_HEIGHT)
  893. end
  894. end
  895. function renderEditor()
  896. if not blockinput then
  897. love.graphics.setColor(1, 0, 0, 1)
  898. love.graphics.rectangle("fill", mx, my, 10, wall1width)
  899. love.graphics.setColor(1, 1, 1, 1)
  900. end
  901. for i, wall in ipairs(walls) do
  902. love.graphics.setColor(1, 1, 1, 1)
  903. love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
  904. end
  905. end
  906. function intro()
  907. love.graphics.draw(background, 0,0)
  908. love.graphics.setColor(255, 255, 255, light / 255)
  909. love.graphics.draw(image, 0, 0)
  910. end
  911. function displayPoints()
  912. love.graphics.setFont(smallfont)
  913. if areanuclear == 1 then
  914. love.graphics.setColor(0,0,0,1)
  915. end
  916. if (potentialstrike1 == 1 and potentialnuke1 == 0 and player1reverbav == 0) then --FLAG: AVAILABLE SUPER
  917. if (player1striken == 0) then
  918. love.graphics.print(
  919. tostring(math.floor(player1nukescore) .. "[" .. p1control.super .. "]"),
  920. VIRTUAL_WIDTH / 2 - 500,
  921. VIRTUAL_HEIGHT / 60
  922. )
  923. else
  924. love.graphics.print(tostring("READY"), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60)
  925. end
  926. elseif (player1reverbav == 1 and potentialnuke1 == 0 ) then
  927. love.graphics.print(
  928. tostring(
  929. math.floor(player1nukescore) .. "[" .. p1control.super .. "]" .. " [" .. p1control.counter .. "]"
  930. ),
  931. VIRTUAL_WIDTH / 2 - 500,
  932. VIRTUAL_HEIGHT / 60
  933. )
  934. elseif (potentialnuke1 == 1) then
  935. love.graphics.setColor(255, 0, 0, 255)
  936. love.graphics.print(
  937. tostring(
  938. math.floor(player1nukescore) .. "[" .. p1control.super .. "]" .. " [" .. p1control.counter .. "]"
  939. ),
  940. VIRTUAL_WIDTH / 2 - 500,
  941. VIRTUAL_HEIGHT / 60
  942. )
  943. love.graphics.setColor(255, 255, 255, 255)
  944. elseif (potentialnuke1 == 1) then
  945. love.graphics.setColor(255, 0, 0, 255)
  946. love.graphics.print(
  947. tostring(
  948. math.floor(player1nukescore) .. "[" .. p1control.super .. "]"
  949. ),
  950. VIRTUAL_WIDTH / 2 - 500,
  951. VIRTUAL_HEIGHT / 60
  952. )
  953. love.graphics.setColor(255, 255, 255, 255)
  954. else
  955. love.graphics.print(tostring(math.floor(player1nukescore)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60)
  956. end
  957. if (potentialstrike2 == 1 and player2reverbav == 0) then
  958. if (player2striken == 0) then
  959. love.graphics.print(
  960. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "]"),
  961. VIRTUAL_WIDTH / 2 + 430,
  962. VIRTUAL_HEIGHT / 60
  963. )
  964. else
  965. love.graphics.print(tostring("READY"), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60)
  966. end
  967. elseif (potentialnuke2 == 1) then
  968. love.graphics.setColor(255, 0, 0, 255)
  969. love.graphics.print(
  970. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "] [" .. p2control.counter .. "]"),
  971. VIRTUAL_WIDTH / 2 + 400,
  972. VIRTUAL_HEIGHT / 60
  973. )
  974. love.graphics.setColor(255, 255, 255, 255)
  975. elseif (potentialnuke2 == 1 and maxBalls > 1) then
  976. love.graphics.setColor(255, 0, 0, 255)
  977. love.graphics.print(
  978. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "]"),
  979. VIRTUAL_WIDTH / 2 + 430,
  980. VIRTUAL_HEIGHT / 60
  981. )
  982. love.graphics.setColor(255, 255, 255, 255)
  983. elseif (player2reverbav == 1 and potentialnuke2 == 0 ) then
  984. love.graphics.print(
  985. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "] [" .. p2control.counter .. "]"),
  986. VIRTUAL_WIDTH / 2 + 400,
  987. VIRTUAL_HEIGHT / 60
  988. )
  989. else
  990. love.graphics.print(tostring(math.floor(player2nukescore)), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60)
  991. end
  992. end
  993. function hitIdentifier()
  994. if (gameMode == "practice") then
  995. MAP_TYPE = 0
  996. if ball[i].x > VIRTUAL_WIDTH * 0.99 then
  997. soundtype = love.math.random(1, 5)
  998. sounds["wallhit"]:setPitch(ballSpeed / 250)
  999. sounds["wallhit"]:play()
  1000. if (ball[i].dx > 0) then
  1001. ball[i].x = ball[i].x - 20
  1002. else
  1003. ball[i].x = ball[i].x + 20
  1004. end
  1005. ball[i].dx = -ball[i].dx
  1006. end
  1007. end
  1008. if (MAP_TYPE == 1) then
  1009. if
  1010. ball[i].y < VIRTUAL_HEIGHT * 0.3 and ball[i].x > VIRTUAL_WIDTH * 0.5 and
  1011. ball[i].x < VIRTUAL_WIDTH * 0.5 + 5
  1012. then
  1013. soundtype = love.math.random(1, 5)
  1014. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1015. sounds["wallhit"]:play()
  1016. if (ball[i].dx > 0) then
  1017. ball[i].x = ball[i].x - 20
  1018. else
  1019. ball[i].x = ball[i].x + 20
  1020. end
  1021. ball[i].dx = -ball[i].dx
  1022. end
  1023. if
  1024. ball[i].y > VIRTUAL_HEIGHT * 0.7 and ball[i].x > VIRTUAL_WIDTH * 0.5 and
  1025. ball[i].x < VIRTUAL_WIDTH * 0.5 + 5
  1026. then
  1027. soundtype = love.math.random(1, 5)
  1028. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1029. sounds["wallhit"]:play()
  1030. if (ball[i].dx > 0) then
  1031. ball[i].x = ball[i].x - 20
  1032. else
  1033. ball[i].x = ball[i].x + 20
  1034. end
  1035. ball[i].dx = -ball[i].dx
  1036. end
  1037. end
  1038. if (MAP_TYPE == 2) then
  1039. for i, wall in ipairs(walls) do
  1040. if
  1041. (ball[1].y > wall.wally and ball[1].y < wall.wally + wall.wallheight and
  1042. ball[1].x > wall.wallx - ballSpeed / 200 and
  1043. ball[1].x < wall.wallx + 10 + ballSpeed / 200)
  1044. then
  1045. controllerSer()
  1046. soundtype = love.math.random(1, 5)
  1047. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1048. sounds["wallhit"]:play()
  1049. if (ball[1].dx > 0) then
  1050. ball[1].x = ball[1].x - 1
  1051. else
  1052. ball[1].x = ball[1].x + 1
  1053. end
  1054. ball[1].dx = -ball[1].dx
  1055. elseif
  1056. (ball[1].y > wall.wally - 15 and ball[1].y < wall.wally + wall.wallheight + 10 and
  1057. ball[1].x > wall.wallx and
  1058. ball[1].x < wall.wallx + 10)
  1059. then
  1060. controllerSer()
  1061. soundtype = love.math.random(1, 5)
  1062. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1063. sounds["wallhit"]:play()
  1064. if (ball[1].dy > 0) then
  1065. ball[1].y = ball[1].y - 1
  1066. else
  1067. ball[1].y = ball[1].y + 1
  1068. end
  1069. ball[1].dy = -ball[1].dy
  1070. end
  1071. end
  1072. end
  1073. end
  1074. function rules(query, i)
  1075. if query == "p1hit" then
  1076. if gameMode == "normal" then
  1077. return ball[i]:collides(player1)
  1078. elseif gameMode == "reversegame" then
  1079. return ball[i].x < 0 and ball[i].disabled == false
  1080. end
  1081. end
  1082. if query == "p2hit" then
  1083. if gameMode == "normal" then
  1084. return ball[i]:collides(player2)
  1085. elseif gameMode == "reversegame" then
  1086. return ball[i].x > VIRTUAL_WIDTH-10 and ball[i].disabled == false
  1087. end
  1088. end
  1089. if query == "p1miss" then
  1090. if gameMode == "reversegame" then
  1091. return ball[i]:collides(player1)
  1092. elseif gameMode == "normal" then
  1093. return ball[i].x < -10 and ball[i].disabled == false
  1094. end
  1095. end
  1096. if query == "p2miss" then
  1097. if gameMode == "reversegame" then
  1098. return ball[i]:collides(player2)
  1099. elseif gameMode == "normal" then
  1100. return ball[i].x > VIRTUAL_WIDTH and ball[i].disabled == false
  1101. end
  1102. end
  1103. end
  1104. function clientsBaseGame(dt)
  1105. if gameMode == "reverse" then
  1106. reversegame(dt)
  1107. end
  1108. if player1nukescore > 300 then
  1109. player1nukescore = 300
  1110. end
  1111. if player2nukescore > 300 then
  1112. player2nukescore = 300
  1113. end
  1114. speedControl()
  1115. balancer()
  1116. effectControl()
  1117. if t < shakeDuration then
  1118. t = t + dt
  1119. end
  1120. if (lastSentKeyP1 == p1control.up) then
  1121. player1.dy = (paddle_SPEED + p2bonus) * -1
  1122. --print("moving player1 up")
  1123. elseif (lastSentKeyP1 == p1control.down) then
  1124. player1.dy = paddle_SPEED + p2bonus
  1125. --print("moving player1 down")
  1126. else
  1127. player1.dy = 0
  1128. ----print("stopping player")
  1129. end
  1130. if ((love.keyboard.isDown(p2control.up) or sectortouched(1))) then
  1131. player2.dy = (paddle_SPEED + p2bonus) * -1
  1132. elseif ((love.keyboard.isDown(p2control.down)) or sectortouched(4)) then
  1133. player2.dy = paddle_SPEED + p2bonus
  1134. else
  1135. player2.dy = 0
  1136. end
  1137. --print("T = " .. tostring(t))
  1138. serveBot()
  1139. if gameState == 'play' then
  1140. if (AGAINST_AI == 1) then
  1141. AI(player2, maxBalls, AI_LEVEL)
  1142. end
  1143. --print(areanuclear .. striken .. player1score .. player2score)
  1144. for i = 1, maxBalls do
  1145. if rules("p1hit", i) then
  1146. if (areanuclear == 0 and striken == 1 and (player1score > ptw*0.8 or player2score > ptw*0.8)) then
  1147. --print("Calling animation")
  1148. superanimator("tensehit", 1)
  1149. --print("AREA NUCLEAR?" .. areanuclear)
  1150. end
  1151. if gameMode == "practice" then
  1152. player1score = player1score + 1
  1153. end
  1154. t = 0
  1155. if (ballSpeed > 200) then
  1156. shakeMagnitude = ballSpeed / 200
  1157. else
  1158. shakeMagnitude = 0
  1159. end
  1160. shakeDuration = 1
  1161. randomtext = love.math.random(1, #textphrases)
  1162. TEXT = textphrases[randomtext]
  1163. soundtype = love.math.random(1, 1.2)
  1164. if (player1striken == 1) then
  1165. TEXT = "PLAYER 1 STRIKES"
  1166. ballSpeed = ballSpeed + player1nukescore
  1167. background_scroll_speed = ballSpeed / 20
  1168. potentialnuke1 = 0
  1169. player1striken = 0
  1170. player1nukescore = 0
  1171. potentialstrike1 = 0
  1172. striken = 1
  1173. if areanuclear == 0 then
  1174. sounds["striking"]:setPitch(ballSpeed / 250)
  1175. sounds["striking"]:play()
  1176. else
  1177. sounds["nuclearhit"]:setPitch(1)
  1178. sounds["nuclearhit"]:play()
  1179. end
  1180. if areanuclear == 0 then
  1181. superanimator("tensehit", 1)
  1182. end
  1183. else
  1184. if areanuclear == 0 then
  1185. sounds["beep"]:setPitch(ballSpeed / 250)
  1186. sounds["beep"]:play()
  1187. else
  1188. sounds["nuclearhit"]:setPitch(1)
  1189. sounds["nuclearhit"]:play()
  1190. end
  1191. end
  1192. if (striken == 1) then
  1193. player1nukescore = player1nukescore * 1.5
  1194. if (synctype == 0) then
  1195. paddle_SPEED = paddle_SPEED * 1.10
  1196. elseif (synctype == 1) then
  1197. paddle_SPEED = ballSpeed
  1198. end
  1199. if (synctype == 0) then
  1200. AI_SPEED = AI_SPEED * 1.10
  1201. end
  1202. if (synctype == 1) then
  1203. AI_SPEED = ballSpeed * 1.1 / 10
  1204. end
  1205. ballSpeed = ballSpeed * 1.10
  1206. background_scroll_speed = ballSpeed / 20
  1207. end
  1208. player1nukescore = player1nukescore + 10
  1209. ball[i].dx = -ball[i].dx
  1210. ball[i].x = player1.x + 30
  1211. end
  1212. if rules("p2hit", i) then
  1213. --ameState = 'quickanim'
  1214. t = 0
  1215. shakeDuration = 1
  1216. if
  1217. (areanuclear == 0 and
  1218. (striken == 1 and (player1score > ptw*0.8 or player2score > ptw*0.8)))
  1219. then
  1220. --print("AREA NUCLEAR?" .. areanuclear)
  1221. superanimator("tensehit", 2)
  1222. end
  1223. if (ballSpeed > 200) then
  1224. shakeMagnitude = ballSpeed / 200
  1225. else
  1226. shakeMagnitude = 0
  1227. end
  1228. randomtext = love.math.random(1, #textphrases)
  1229. TEXT = textphrases[randomtext]
  1230. soundtype = love.math.random(1, 1.2)
  1231. if (player2striken == 1) then
  1232. TEXT = "PLAYER 2 STRIKES"
  1233. ballSpeed = ballSpeed + player2nukescore
  1234. background_scroll_speed = ballSpeed / 20
  1235. striken = 1
  1236. player2striken = 0
  1237. potentialnuke2 = 0
  1238. player2nukescore = 0
  1239. potentialstrike2 = 0
  1240. --print("AREA NUCLEAR?" .. areanuclear)
  1241. if areanuclear == 0 then
  1242. superanimator("tensehit", 2)
  1243. end
  1244. if areanuclear == 0 then
  1245. sounds["striking"]:setPitch(ballSpeed / 250)
  1246. sounds["striking"]:play()
  1247. else
  1248. sounds["nuclearhit"]:setPitch(1)
  1249. sounds["nuclearhit"]:play()
  1250. end
  1251. elseif (striken == 1) then
  1252. player2nukescore = player2nukescore * 1.5
  1253. if (synctype == 0) then
  1254. paddle_SPEED = paddle_SPEED * 1.10
  1255. end
  1256. if (synctype == 1) then
  1257. paddle_SPEED = ballSpeed
  1258. end
  1259. if (synctype == 0) then
  1260. AI_SPEED = AI_SPEED * 1.10
  1261. end
  1262. if (synctype == 1) then
  1263. AI_SPEED = ballSpeed * 1.1 / 10
  1264. end
  1265. ballSpeed = ballSpeed * 1.10
  1266. background_scroll_speed = ballSpeed / 20
  1267. if areanuclear == 0 then
  1268. sounds["beep"]:setPitch(ballSpeed / 250)
  1269. sounds["beep"]:play()
  1270. else
  1271. sounds["nuclearhit"]:setPitch(1)
  1272. sounds["nuclearhit"]:play()
  1273. end
  1274. else
  1275. if areanuclear == 0 then
  1276. sounds["beep"]:setPitch(ballSpeed / 250)
  1277. sounds["beep"]:play()
  1278. else
  1279. sounds["nuclearhit"]:setPitch(1)
  1280. sounds["nuclearhit"]:play()
  1281. end
  1282. end
  1283. player2nukescore = player2nukescore + 10
  1284. ball[i].dx = -ball[i].dx
  1285. ball[i].x = player2.x - 30
  1286. if ((love.keyboard.isDown(p2control.up)) or sectortouched(1)) then
  1287. select = math.random(1, 5)
  1288. if select == 1 then
  1289. ball[i].dy = -1
  1290. elseif select == 2 then
  1291. ball[i].dy = -1.2
  1292. elseif select == 3 then
  1293. ball[i].dy = -1.5
  1294. elseif select == 4 then
  1295. ball[i].dy = -1.8
  1296. elseif select == 5 then
  1297. ball[i].dy = -2
  1298. end
  1299. elseif (love.keyboard.isDown(p2control.down) or sectortouched(4))then
  1300. select = math.random(1, 5)
  1301. if select == 1 then
  1302. ball[i].dy = 1
  1303. elseif select == 2 then
  1304. ball[i].dy = 1.2
  1305. elseif select == 3 then
  1306. ball[i].dy = 1.5
  1307. elseif select == 4 then
  1308. ball[i].dy = 1.8
  1309. elseif select == 5 then
  1310. ball[i].dy = 2
  1311. end
  1312. else
  1313. if ball[i].dy < 0 then
  1314. select = math.random(1, 5)
  1315. if select == 1 then
  1316. ball[i].dy = -1
  1317. elseif select == 2 then
  1318. ball[i].dy = -1.2
  1319. elseif select == 3 then
  1320. ball[i].dy = -1.5
  1321. elseif select == 4 then
  1322. ball[i].dy = -1.8
  1323. elseif select == 5 then
  1324. ball[i].dy = -2
  1325. end
  1326. else
  1327. select = math.random(1, 5)
  1328. if select == 1 then
  1329. ball[i].dy = 1
  1330. elseif select == 2 then
  1331. ball[i].dy = 1.2
  1332. elseif select == 3 then
  1333. ball[i].dy = 1.5
  1334. elseif select == 4 then
  1335. ball[i].dy = 1.8
  1336. elseif select == 5 then
  1337. ball[i].dy = 2
  1338. end
  1339. end
  1340. end
  1341. end
  1342. hitIdentifier()
  1343. if ball[i].y <= 0 then
  1344. soundtype = love.math.random(1, 5)
  1345. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1346. sounds["wallhit"]:play()
  1347. ball[i].y = 0
  1348. ball[i].dy = -ball[i].dy
  1349. end
  1350. -- -4 to account for the ball's size
  1351. if ball[i].y >= VIRTUAL_HEIGHT - 40 then
  1352. soundtype = love.math.random(1, 5)
  1353. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1354. sounds["wallhit"]:play()
  1355. ball[i].y = VIRTUAL_HEIGHT - 40
  1356. ball[i].dy = -ball[i].dy
  1357. end
  1358. --love.window.setTitle('Trying to update the ball')
  1359. if timeIsSlow then
  1360. if ballSpeed > originalSpeed / 3 then
  1361. paddle_SPEED = 300
  1362. ballSpeed = ballSpeed / (1 + (dt * 2))
  1363. background_scroll_speed = ballSpeed / 20
  1364. end
  1365. player1nukescore = player1nukescore - (dt * 50)
  1366. if player1nukescore < 1 or ball[1].dx > 0 then
  1367. timeIsSlow = false
  1368. player1reverbav = false
  1369. ballSpeed = originalSpeed
  1370. background_scroll_speed = ballSpeed / 20
  1371. sounds["time"]:stop()
  1372. paddle_SPEED = originalPaddle
  1373. end
  1374. end
  1375. if timeIsSlow2 then
  1376. if ballSpeed > originalSpeed / 3 then
  1377. ballSpeed = ballSpeed / (1 + (dt * 2))
  1378. background_scroll_speed = ballSpeed / 20
  1379. end
  1380. player2nukescore = player2nukescore - (dt * 50)
  1381. if player2nukescore < 1 or ball[1].dx < 0 then
  1382. paddle_SPEED = 300
  1383. timeIsSlow2 = false
  1384. player2reverbav = false
  1385. ballSpeed = originalSpeed
  1386. background_scroll_speed = ballSpeed / 20
  1387. sounds["time"]:stop()
  1388. paddle_SPEED = originalPaddle
  1389. end
  1390. end
  1391. ball[i]:update(dt)
  1392. end
  1393. end
  1394. goalManager()
  1395. powerAvailability()
  1396. player1:update(dt)
  1397. player2:update(dt)
  1398. end
  1399. function animateConnection()
  1400. if GetIPType(IP) ~= 1 then
  1401. love.graphics.printf("WRONG SYNTAX", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center")
  1402. else
  1403. counter = counter + 1 / love.timer.getFPS()
  1404. if counter < 0.8 then
  1405. love.graphics.printf("TRYING TO CONNECT.", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center")
  1406. elseif counter < 1.6 then
  1407. love.graphics.printf("TRYING TO CONNECT..", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center")
  1408. elseif counter < 2.4 then
  1409. love.graphics.printf("TRYING TO CONNECT...", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center")
  1410. else
  1411. love.graphics.printf("NO CONNECTION!", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center")
  1412. end
  1413. end
  1414. end
  1415. function GetIPType(ip)
  1416. -- must pass in a string value
  1417. if ip == nil or type(ip) ~= "string" then
  1418. return 0
  1419. end
  1420. -- check for format 1.11.111.111 for ipv4
  1421. local chunks = {ip:match("(%d+)%.(%d+)%.(%d+)%.(%d+)")}
  1422. if (#chunks == 4) then
  1423. for _,v in pairs(chunks) do
  1424. if (tonumber(v) < 0 or tonumber(v) > 255) then
  1425. return 0
  1426. end
  1427. end
  1428. return 1
  1429. else
  1430. return 0
  1431. end
  1432. -- check for ipv6 format, should be 8 'chunks' of numbers/letters
  1433. local _, chunks = ip:gsub("[%a%d]+%:?", "")
  1434. if chunks == 8 then
  1435. return 2
  1436. end
  1437. -- if we get here, assume we've been given a random string
  1438. return 3
  1439. end
  1440. function menuDemo(dt)
  1441. paddle_SPEED = 200
  1442. ballSpeed = 200
  1443. background_scroll_speed = ballSpeed / 20
  1444. if ball[1].dx > 0 then
  1445. AI(player2, maxBalls, 1300)
  1446. player1.goal = 360
  1447. elseif ball[1].dx < 0 then
  1448. AI(player1, maxBalls, 1300)
  1449. player2.goal = 360
  1450. end
  1451. --print(neededTarget, neededTarget1)
  1452. --print("menu demo active")
  1453. ball[1]:update(dt)
  1454. player1:update(dt)
  1455. player2:update(dt)
  1456. if ball[1].x < player1.x+15 then
  1457. player1.y = ball[1].y-player1.height
  1458. end
  1459. if ball[1].x > player2.x-15 then
  1460. player2.y = ball[1].y-player2.height
  1461. end
  1462. if (MAP_TYPE == 2) then
  1463. for i, wall in ipairs(walls) do
  1464. if
  1465. (ball[1].y > wall.wally and ball[1].y < wall.wally + wall.wallheight and
  1466. ball[1].x > wall.wallx - ballSpeed / 200 and
  1467. ball[1].x < wall.wallx + 10 + ballSpeed / 200)
  1468. then
  1469. controllerSer()
  1470. soundtype = love.math.random(1, 5)
  1471. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1472. sounds["wallhit"]:play()
  1473. if (ball[1].dx > 0) then
  1474. ball[1].x = ball[1].x - 1
  1475. else
  1476. ball[1].x = ball[1].x + 1
  1477. end
  1478. ball[1].dx = -ball[1].dx
  1479. elseif
  1480. (ball[1].y > wall.wally - 15 and ball[1].y < wall.wally + wall.wallheight + 10 and
  1481. ball[1].x > wall.wallx and
  1482. ball[1].x < wall.wallx + 10)
  1483. then
  1484. controllerSer()
  1485. soundtype = love.math.random(1, 5)
  1486. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1487. sounds["wallhit"]:play()
  1488. if (ball[1].dy > 0) then
  1489. ball[1].y = ball[1].y - 1
  1490. else
  1491. ball[1].y = ball[1].y + 1
  1492. end
  1493. ball[1].dy = -ball[1].dy
  1494. end
  1495. end
  1496. end
  1497. if ball[1].x >= player2.x-7 then
  1498. sounds["beep"]:setPitch(ballSpeed / 250)
  1499. sounds["beep"]:play()
  1500. select = math.random(1, 2)
  1501. if ball[1].dy < 0 then
  1502. select = math.random(1, 5)
  1503. if select == 1 then
  1504. ball[1].dy = -1
  1505. elseif select == 2 then
  1506. ball[1].dy = -1.2
  1507. elseif select == 3 then
  1508. ball[1].dy = -1.5
  1509. elseif select == 4 then
  1510. ball[1].dy = -1.8
  1511. elseif select == 5 then
  1512. ball[1].dy = -2
  1513. end
  1514. else
  1515. select = math.random(1, 5)
  1516. if select == 1 then
  1517. ball[1].dy = 1
  1518. elseif select == 2 then
  1519. ball[1].dy = 1.2
  1520. elseif select == 3 then
  1521. ball[1].dy = 1.5
  1522. elseif select == 4 then
  1523. ball[1].dy = 1.8
  1524. elseif select == 5 then
  1525. ball[1].dy = 2
  1526. end
  1527. end
  1528. ball[1].x = player2.x-8
  1529. ball[1].dx = -ball[1].dx
  1530. end
  1531. if ball[1].x <= player1.x+7 then
  1532. sounds["beep"]:setPitch(ballSpeed / 250)
  1533. sounds["beep"]:play()
  1534. select = math.random(1, 2)
  1535. if ball[1].dy < 0 then
  1536. select = math.random(1, 5)
  1537. if select == 1 then
  1538. ball[1].dy = -1
  1539. elseif select == 2 then
  1540. ball[1].dy = -1.2
  1541. elseif select == 3 then
  1542. ball[1].dy = -1.5
  1543. elseif select == 4 then
  1544. ball[1].dy = -1.8
  1545. elseif select == 5 then
  1546. ball[1].dy = -2
  1547. end
  1548. else
  1549. select = math.random(1, 5)
  1550. if select == 1 then
  1551. ball[1].dy = 1
  1552. elseif select == 2 then
  1553. ball[1].dy = 1.2
  1554. elseif select == 3 then
  1555. ball[1].dy = 1.5
  1556. elseif select == 4 then
  1557. ball[1].dy = 1.8
  1558. elseif select == 5 then
  1559. ball[1].dy = 2
  1560. end
  1561. end
  1562. ball[1].x = player1.x+8
  1563. ball[1].dx = -ball[1].dx
  1564. end
  1565. if ball[1].y <= 0 then
  1566. soundtype = love.math.random(1, 5)
  1567. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1568. sounds["wallhit"]:play()
  1569. ball[1].y = 0
  1570. ball[1].dy = -ball[1].dy
  1571. end
  1572. -- -4 to account for the ball's size
  1573. if ball[1].y >= VIRTUAL_HEIGHT - 40 then
  1574. soundtype = love.math.random(1, 5)
  1575. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1576. sounds["wallhit"]:play()
  1577. ball[1].y = VIRTUAL_HEIGHT - 40
  1578. ball[1].dy = -ball[1].dy
  1579. end
  1580. end
  1581. function effectControl()
  1582. if player1score > 0.8 * ptw or player2score > 0.8 * ptw then
  1583. for i = 1, maxBalls do
  1584. if math.abs(ball[i].x - VIRTUAL_WIDTH/2) < 10 and #explosions < 1 then
  1585. table.insert(explosions, explosion(love.math.random(100, VIRTUAL_WIDTH-100), love.math.random(player1.y, player2.y), 100, {player1.y/2.81/255,player2.y/2.81/255,ball[1].y/2.81/255,0.4}))
  1586. end
  1587. end
  1588. end
  1589. for i, explosion in ipairs(explosions) do
  1590. if explosion.killed then
  1591. table.remove(explosions, i)
  1592. --print("buried the body")
  1593. end
  1594. end
  1595. end
  1596. --[[
  1597. THE SHIP FUNCTIONALITY HAS BEEN SCRAPPED AND WONT! BE COMING BACK.
  1598. function shipManager(dt)
  1599. ship_timer = ship_timer + dt
  1600. if ship_timer > ship_goal then
  1601. print("summoning ship")
  1602. ship_timer = 0
  1603. ship_goal = love.math.random(2,20)
  1604. table.insert(ships, ship())
  1605. end
  1606. for k, ship in pairs(ships) do
  1607. ship:update(dt)
  1608. if ship.y < -ship.height and ship.direction == 0 then
  1609. table.remove(ships, k)
  1610. elseif ship.y > VIRTUAL_HEIGHT + ship.height and ship.direction == 1 then
  1611. table.remove(ships, k)
  1612. end
  1613. end
  1614. end
  1615. ]]