You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

957 lines
35 KiB

  1. function basegame(dt)
  2. if player1nukescore > 300 then
  3. player1nukescore = 300
  4. end
  5. if player2nukescore > 300 then
  6. player2nukescore = 300
  7. end
  8. speedControl()
  9. balancer()
  10. if t < shakeDuration then
  11. t = t + dt
  12. end
  13. print("T = " .. tostring(t))
  14. serveBot()
  15. if gameState == 'play' then
  16. if (AGAINST_AI == 1) then
  17. for i = 1, maxBalls do
  18. if (ball[i].y - player2.y >= 50 and player2.x - ball[i].x < AI_LEVEL) then
  19. player2.dy = AI_SPEED
  20. elseif (player2.y - ball[i].y >= -20 and player2.x - ball[i].x < AI_LEVEL) then
  21. player2.dy = -AI_SPEED
  22. else
  23. player2.dy = 0
  24. end
  25. if
  26. difficultyl == 350 and player2reverbav == true and VIRTUAL_WIDTH - ball[i].x < 90 and
  27. math.abs(ball[i].y - player2.y) > 150
  28. then
  29. sounds["time"]:play()
  30. player2reverbav = false
  31. timeIsSlow2 = true
  32. originalPaddle = paddle_SPEED
  33. originalSpeed = ballSpeed
  34. player2reverbav = 0
  35. potentialnuke2 = 0
  36. potentialstrike2 = 0
  37. end
  38. if (player2nukescore > AI_STRIKEMOD and striken == 0) then
  39. player2striken = 1
  40. elseif (player2nukescore > AI_NUKEMOD and striken == 1) then
  41. if (areanuclear == 1) then
  42. maxspeed = maxspeed + 50
  43. end
  44. sounds["nuke"]:play()
  45. potentialstrike2 = 0
  46. areanuclear = 1
  47. ballSpeed = ballSpeed * 2
  48. if (synctype == 0) then
  49. paddle_SPEED = paddle_SPEED * 2
  50. end
  51. if (synctype == 1) then
  52. paddle_SPEED = ballSpeed / 10
  53. end
  54. if (synctype == 0) then
  55. AI_SPEED = AI_SPEED * 2.2
  56. end
  57. if (synctype == 1) then
  58. AI_SPEED = ballSpeed * 1.1 / 10
  59. end
  60. player2nukescore = 0
  61. player2reverbav = 0
  62. potentialnuke2 = 0
  63. end
  64. end
  65. end
  66. if (love.keyboard.isDown(p1control.up)) then
  67. player1.dy = (paddle_SPEED + p1bonus) * -1
  68. elseif (love.keyboard.isDown(p1control.down)) then
  69. player1.dy = paddle_SPEED + p1bonus
  70. else
  71. player1.dy = 0
  72. end
  73. if (AGAINST_AI == 0) then
  74. if (love.keyboard.isDown(p2control.up)) then
  75. player2.dy = (paddle_SPEED + p2bonus) * -1
  76. elseif (love.keyboard.isDown(p2control.down)) then
  77. player2.dy = paddle_SPEED + p2bonus
  78. else
  79. player2.dy = 0
  80. end
  81. end
  82. print(areanuclear .. striken .. player1score .. player2score)
  83. for i = 1, maxBalls do
  84. if ball[i]:collides(player1) then
  85. if (areanuclear == 0 and striken == 1 and (player1score > ptw-2 or player2score > ptw-2)) then
  86. print("Calling animation")
  87. superanimator("tensehit", 1)
  88. end
  89. if gameMode == "practice" then
  90. player1score = player1score + 1
  91. end
  92. t = 0
  93. if (ballSpeed > 200) then
  94. shakeMagnitude = ballSpeed / 200
  95. else
  96. shakeMagnitude = 0
  97. end
  98. shakeDuration = 1
  99. randomtext = love.math.random(1, #textphrases)
  100. TEXT = textphrases[randomtext]
  101. soundtype = love.math.random(1, 1.2)
  102. if (player1striken == 1) then
  103. TEXT = "PLAYER 1 STRIKES"
  104. ballSpeed = ballSpeed + player1nukescore
  105. potentialnuke1 = 0
  106. player1striken = 0
  107. player1nukescore = 0
  108. potentialstrike1 = 0
  109. striken = 1
  110. if areanuclear == 0 then
  111. sounds["striking"]:setPitch(ballSpeed / 250)
  112. sounds["striking"]:play()
  113. else
  114. sounds["nuclearhit"]:setPitch(1)
  115. sounds["nuclearhit"]:play()
  116. end
  117. superanimator("tensehit", 1)
  118. else
  119. if areanuclear == 0 then
  120. sounds["beep"]:setPitch(ballSpeed / 250)
  121. sounds["beep"]:play()
  122. else
  123. sounds["nuclearhit"]:setPitch(1)
  124. sounds["nuclearhit"]:play()
  125. end
  126. end
  127. if (striken == 1) then
  128. player1nukescore = player1nukescore * 1.2
  129. if (synctype == 0) then
  130. paddle_SPEED = paddle_SPEED * 1.10
  131. elseif (synctype == 1) then
  132. paddle_SPEED = ballSpeed / 10
  133. end
  134. if (synctype == 0) then
  135. AI_SPEED = AI_SPEED * 1.10
  136. end
  137. if (synctype == 1) then
  138. AI_SPEED = ballSpeed * 1.1 / 10
  139. end
  140. ballSpeed = ballSpeed * 1.10
  141. end
  142. player1nukescore = player1nukescore + 10
  143. ball[i].dx = -ball[i].dx
  144. ball[i].x = player1.x + 30
  145. if (love.keyboard.isDown(p1control.up)) then
  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. elseif love.keyboard.isDown(p1control.down) then
  159. select = math.random(1, 5)
  160. if select == 1 then
  161. ball[i].dy = 1
  162. elseif select == 2 then
  163. ball[i].dy = 1.2
  164. elseif select == 3 then
  165. ball[i].dy = 1.5
  166. elseif select == 4 then
  167. ball[i].dy = 1.8
  168. elseif select == 5 then
  169. ball[i].dy = 2
  170. end
  171. else
  172. if ball[i].dy < 0 then
  173. select = math.random(1, 5)
  174. if select == 1 then
  175. ball[i].dy = -1
  176. elseif select == 2 then
  177. ball[i].dy = -1.2
  178. elseif select == 3 then
  179. ball[i].dy = -1.5
  180. elseif select == 4 then
  181. ball[i].dy = -1.8
  182. elseif select == 5 then
  183. ball[i].dy = -2
  184. end
  185. else
  186. select = math.random(1, 5)
  187. if select == 1 then
  188. ball[i].dy = 1
  189. elseif select == 2 then
  190. ball[i].dy = 1.2
  191. elseif select == 3 then
  192. ball[i].dy = 1.5
  193. elseif select == 4 then
  194. ball[i].dy = 1.8
  195. elseif select == 5 then
  196. ball[i].dy = 2
  197. end
  198. end
  199. end
  200. end
  201. if ball[i]:collides(player2) then
  202. --ameState = 'quickanim'
  203. t = 0
  204. shakeDuration = 1
  205. if
  206. (areanuclear == 0 and
  207. (striken == 1 and (player1score > ptw-2 or player2score > ptw-2)))
  208. then
  209. superanimator("tensehit", 2)
  210. end
  211. if (ballSpeed > 200) then
  212. shakeMagnitude = ballSpeed / 200
  213. else
  214. shakeMagnitude = 0
  215. end
  216. randomtext = love.math.random(1, #textphrases)
  217. TEXT = textphrases[randomtext]
  218. soundtype = love.math.random(1, 1.2)
  219. if (player2striken == 1) then
  220. TEXT = "PLAYER 2 STRIKES"
  221. ballSpeed = ballSpeed + player2nukescore
  222. striken = 1
  223. player2striken = 0
  224. potentialnuke2 = 0
  225. player2nukescore = 0
  226. potentialstrike2 = 0
  227. superanimator("tensehit", 2)
  228. if areanuclear == 0 then
  229. sounds["striking"]:setPitch(ballSpeed / 250)
  230. sounds["striking"]:play()
  231. else
  232. sounds["nuclearhit"]:setPitch(1)
  233. sounds["nuclearhit"]:play()
  234. end
  235. elseif (striken == 1) then
  236. player2nukescore = player2nukescore * 1.5
  237. if (synctype == 0) then
  238. paddle_SPEED = paddle_SPEED * 1.10
  239. end
  240. if (synctype == 1) then
  241. paddle_SPEED = ballSpeed / 10
  242. end
  243. if (synctype == 0) then
  244. AI_SPEED = AI_SPEED * 1.10
  245. end
  246. if (synctype == 1) then
  247. AI_SPEED = ballSpeed * 1.1 / 10
  248. end
  249. ballSpeed = ballSpeed * 1.10
  250. if areanuclear == 0 then
  251. sounds["beep"]:setPitch(ballSpeed / 250)
  252. sounds["beep"]:play()
  253. else
  254. sounds["nuclearhit"]:setPitch(1)
  255. sounds["nuclearhit"]:play()
  256. end
  257. else
  258. if areanuclear == 0 then
  259. sounds["beep"]:setPitch(ballSpeed / 250)
  260. sounds["beep"]:play()
  261. else
  262. sounds["nuclearhit"]:setPitch(1)
  263. sounds["nuclearhit"]:play()
  264. end
  265. end
  266. player2nukescore = player2nukescore + 10
  267. ball[i].dx = -ball[i].dx
  268. ball[i].x = player2.x - 30
  269. if (love.keyboard.isDown(p2control.up) or AI_SPEED < 0) then
  270. select = math.random(1, 5)
  271. if select == 1 then
  272. ball[i].dy = -1
  273. elseif select == 2 then
  274. ball[i].dy = -1.2
  275. elseif select == 3 then
  276. ball[i].dy = -1.5
  277. elseif select == 4 then
  278. ball[i].dy = -1.8
  279. elseif select == 5 then
  280. ball[i].dy = -2
  281. end
  282. elseif love.keyboard.isDown(p2control.down) or AI_SPEED > 0 then
  283. select = math.random(1, 5)
  284. if select == 1 then
  285. ball[i].dy = 1
  286. elseif select == 2 then
  287. ball[i].dy = 1.2
  288. elseif select == 3 then
  289. ball[i].dy = 1.5
  290. elseif select == 4 then
  291. ball[i].dy = 1.8
  292. elseif select == 5 then
  293. ball[i].dy = 2
  294. end
  295. else
  296. if ball[i].dy < 0 then
  297. select = math.random(1, 5)
  298. if select == 1 then
  299. ball[i].dy = -1
  300. elseif select == 2 then
  301. ball[i].dy = -1.2
  302. elseif select == 3 then
  303. ball[i].dy = -1.5
  304. elseif select == 4 then
  305. ball[i].dy = -1.8
  306. elseif select == 5 then
  307. ball[i].dy = -2
  308. end
  309. else
  310. select = math.random(1, 5)
  311. if select == 1 then
  312. ball[i].dy = 1
  313. elseif select == 2 then
  314. ball[i].dy = 1.2
  315. elseif select == 3 then
  316. ball[i].dy = 1.5
  317. elseif select == 4 then
  318. ball[i].dy = 1.8
  319. elseif select == 5 then
  320. ball[i].dy = 2
  321. end
  322. end
  323. end
  324. end
  325. hitIdentifier()
  326. if ball[i].y <= 0 then
  327. soundtype = love.math.random(1, 5)
  328. sounds["wallhit"]:setPitch(ballSpeed / 250)
  329. sounds["wallhit"]:play()
  330. ball[i].y = 0
  331. ball[i].dy = -ball[i].dy
  332. end
  333. -- -4 to account for the ball's size
  334. if ball[i].y >= VIRTUAL_HEIGHT - 40 then
  335. soundtype = love.math.random(1, 5)
  336. sounds["wallhit"]:setPitch(ballSpeed / 250)
  337. sounds["wallhit"]:play()
  338. ball[i].y = VIRTUAL_HEIGHT - 40
  339. ball[i].dy = -ball[i].dy
  340. end
  341. --love.window.setTitle('Trying to update the ball')
  342. if timeIsSlow then
  343. if ballSpeed > originalSpeed / 3 then
  344. paddle_SPEED = 30
  345. ballSpeed = ballSpeed / (1 + (dt * 2))
  346. end
  347. player1nukescore = player1nukescore - (dt * 50)
  348. if player1nukescore < 1 or ball[1].dx > 0 then
  349. timeIsSlow = false
  350. player1reverbav = false
  351. ballSpeed = originalSpeed
  352. sounds["time"]:stop()
  353. paddle_SPEED = originalPaddle
  354. end
  355. end
  356. if timeIsSlow2 then
  357. if ballSpeed > originalSpeed / 3 then
  358. ballSpeed = ballSpeed / (1 + (dt * 2))
  359. end
  360. player2nukescore = player2nukescore - (dt * 50)
  361. if player2nukescore < 1 or ball[1].dx < 0 then
  362. paddle_SPEED = 30
  363. timeIsSlow2 = false
  364. player2reverbav = false
  365. ballSpeed = originalSpeed
  366. sounds["time"]:stop()
  367. paddle_SPEED = originalPaddle
  368. end
  369. end
  370. ball[i]:update(dt)
  371. end
  372. end
  373. goalManager()
  374. powerAvailability()
  375. player1:update(dt)
  376. player2:update(dt)
  377. end
  378. function debugCheck(dt)
  379. if (gameState == "menu") then
  380. updateTEXT = "0.7.2 Chalkboard Update"
  381. end
  382. dangerChecker()
  383. elapsed = elapsed + dt
  384. rotation = math.sin(elapsed * 2.5) * 0.7
  385. if gameState == "assign" then
  386. controlChanger()
  387. end
  388. editor()
  389. mapChanger()
  390. end
  391. function goalManager()
  392. for i = 1, maxBalls do
  393. if (ball[i].x < 0 - ballSpeed * 0.5) then
  394. if (gameMode ~= "practice") then
  395. sounds["score"]:play()
  396. end
  397. if (nuckemodactive == 0) then
  398. areanuclear = 0
  399. nuclearanimation = 3
  400. end
  401. striken = 0
  402. player1striken = 0
  403. player2striken = 0
  404. ballSpeed = ballSet
  405. if (synctype == 0) then
  406. paddle_SPEED = ballSet / 10
  407. end
  408. if (synctype == 1) then
  409. paddle_SPEED = ballSpeed / 10
  410. end
  411. AI_SPEED = difficultyl / 10
  412. player2score = player2score + 1
  413. if (player2score == ptw and gameMode ~= "practice") then
  414. for i = 1, maxBalls do
  415. ball[i]:reset(i)
  416. end
  417. sounds["win"]:play()
  418. gameState = "done"
  419. TEXT = "Player 2 Won!"
  420. else
  421. gameState = "1serve"
  422. serveBot()
  423. for i = 1, maxBalls do
  424. ball[i]:reset(i)
  425. end
  426. end
  427. end
  428. if (ball[i].x > VIRTUAL_WIDTH + ballSpeed * 0.5) then
  429. sounds["score"]:play()
  430. if (nuckemodactive == 0) then
  431. areanuclear = 0
  432. nuclearanimation = 3
  433. end
  434. striken = 0
  435. player1striken = 0
  436. player2striken = 0
  437. ballSpeed = ballSet
  438. if (synctype == 0) then
  439. paddle_SPEED = ballSet / 10
  440. AI_SPEED = ballSet / 10
  441. end
  442. if (synctype == 1) then
  443. paddle_SPEED = ballSpeed / 10
  444. AI_SPEED = ballSpeed / 10
  445. end
  446. AI_SPEED = difficultyl / 10
  447. player1score = player1score + 1
  448. if (player1score == ptw) then
  449. ball[i]:reset(i)
  450. sounds["win"]:play()
  451. gameState = "done"
  452. TEXT = "Player 1 Won!"
  453. else
  454. gameState = "2serve"
  455. serveBot()
  456. ball[i]:reset(i)
  457. end
  458. end
  459. end
  460. end
  461. function powerAvailability()
  462. if (player1nukescore >= 20 and player1nukescore < 140) then
  463. potentialstrike1 = 1
  464. if (love.keyboard.isDown(p1control.super)) then
  465. player1striken = 1
  466. player1reverbav = 0
  467. end
  468. end
  469. if (player1nukescore >= 140) and timeIsSlow2 == false and timeIsSlow == false and maxBalls == 1 and ball[1].x < VIRTUAL_WIDTH / 2 and ball[1].dx < 0 then
  470. player1reverbav = 1
  471. if love.keyboard.isDown(p1control.counter) then
  472. powerControl(1, "special")
  473. end
  474. end
  475. if (player1nukescore >= 200) then
  476. potentialnuke1 = 1
  477. if (love.keyboard.isDown(p1control.super)) then
  478. sounds["nuke"]:play()
  479. if areanuclear == 1 then
  480. maxspeed = maxspeed + 50
  481. end
  482. areanuclear = 1
  483. potentialstrike1 = 0
  484. striken = 0
  485. ballSpeed = ballSpeed * 2
  486. if (synctype == 0) then
  487. paddle_SPEED = paddle_SPEED * 2
  488. end
  489. if (synctype == 1) then
  490. paddle_SPEED = ballSpeed / 10
  491. end
  492. if (synctype == 0) then
  493. AI_SPEED = AI_SPEED * 2.2
  494. end
  495. if (synctype == 1) then
  496. AI_SPEED = ballSpeed * 1.1 / 10
  497. end
  498. player1nukescore = 0
  499. player1reverbav = 0
  500. potentialnuke1 = 0
  501. end
  502. end
  503. if (player2nukescore >= 20 and player2nukescore <= 140) then
  504. potentialstrike2 = 1
  505. if (AGAINST_AI == 0) then
  506. if (love.keyboard.isDown(p2control.super)) then
  507. player2striken = 1
  508. player2reverbav = 0
  509. end
  510. end
  511. end
  512. if (player2nukescore >= 140) and timeIsSlow == false and timeIsSlow2 == false and maxBalls == 1 and ball[1].x > VIRTUAL_WIDTH / 2 and ball[1].dx > 0 then
  513. player2reverbav = 1
  514. if love.keyboard.isDown(p2control.counter) then
  515. sounds["time"]:play()
  516. player2reverbav = false
  517. timeIsSlow2 = true
  518. originalPaddle = paddle_SPEED
  519. originalSpeed = ballSpeed
  520. player2reverbav = 0
  521. potentialnuke2 = 0
  522. potentialstrike2 = 0
  523. end
  524. end
  525. if (player2nukescore >= 200) then
  526. potentialnuke2 = 1
  527. if (love.keyboard.isDown(p2control.super) and AGAINST_AI == 0) then
  528. sounds["nuke"]:play()
  529. if areanuclear == 1 then
  530. maxspeed = maxspeed + 50
  531. end
  532. potentialstrike2 = 0
  533. areanuclear = 1
  534. player2reverbav = 0
  535. ballSpeed = ballSpeed * 2
  536. if (synctype == 0) then
  537. paddle_SPEED = paddle_SPEED * 2
  538. end
  539. if (synctype == 1) then
  540. paddle_SPEED = ballSpeed / 10
  541. end
  542. if (synctype == 0) then
  543. AI_SPEED = AI_SPEED * 2.2
  544. end
  545. if (synctype == 1) then
  546. AI_SPEED = ballSpeed * 1.1 / 10
  547. end
  548. player2nukescore = 0
  549. potentialnuke2 = 0
  550. end
  551. end
  552. end
  553. function editor()
  554. if (gameState == "editor") then
  555. if debug then
  556. --print("Editor is active!")
  557. end
  558. local mx, my = love.mouse.getPosition()
  559. mx = mx * DIFFERENCE_X
  560. my = my * DIFFERENCE_Y
  561. if (love.mouse.isDown(2)) then
  562. wallbreaker(mx, my)
  563. end
  564. if (love.mouse.isDown(3)) then
  565. table.insert(walls, newWall(mx, my, 10, wall1width))
  566. end
  567. end
  568. end
  569. function nuclearDraw()
  570. love.graphics.setColor(1, 1, 1, 1)
  571. love.graphics.circle("fill", ball[1].x, ball[1].y, explosionRange * 100, 100)
  572. player1.RED, player1.GREEN, player1.BLUE, player2.RED, player2.GREEN, player2.BLUE =
  573. nuclearanimation / 3,
  574. nuclearanimation / 3,
  575. nuclearanimation / 3,
  576. nuclearanimation / 3,
  577. nuclearanimation / 3,
  578. nuclearanimation / 3
  579. for i = 1, maxBalls do
  580. love.graphics.setColor(nuclearanimation / 3, nuclearanimation / 3, nuclearanimation / 3, 1)
  581. ball[i]:render("controlled")
  582. end
  583. player1:render()
  584. player2:render()
  585. end
  586. function normalDraw()
  587. if (areanuclear == 1) then
  588. love.graphics.clear(1, 1, 1, 1)
  589. else
  590. love.graphics.clear(40 / 255, 40 / 255, 40 / 255, 1)
  591. end
  592. staticanimator()
  593. if MAP_TYPE == 1 then
  594. love.graphics.setColor(1, 0, 0.20, 1)
  595. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, 0, 10, VIRTUAL_HEIGHT * 0.3)
  596. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, VIRTUAL_HEIGHT * 0.7, 10, VIRTUAL_HEIGHT * 0.3)
  597. love.graphics.setColor(1, 1, 1, 1)
  598. end
  599. if MAP_TYPE == 2 then
  600. for i, wall in ipairs(walls) do
  601. love.graphics.setColor(1, 1, 1, 1)
  602. love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
  603. end
  604. end
  605. if gameMode == 'practice' then
  606. practiceDraw()
  607. end
  608. if gameMode == 'normal' then
  609. pongDraw()
  610. end
  611. love.graphics.setFont(smallfont)
  612. for i = 1, maxBalls do
  613. if areanuclear == 1 then
  614. --love.window.setTitle('rendering black')
  615. ball[i]:render("black")
  616. else
  617. --love.window.setTitle('rendering white')
  618. ball[i]:render(" ")
  619. end
  620. end
  621. end
  622. function pongDraw()
  623. --print("Drawing classic pong")
  624. love.graphics.setColor(1, 1, 1, 1)
  625. love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
  626. love.graphics.setFont(smallfont)
  627. love.graphics.setFont(scorefont)
  628. if (areanuclear == 1) then
  629. love.graphics.setColor(0, 0, 0, 1)
  630. end
  631. love.graphics.print(tostring(math.floor(player1score)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 12)
  632. love.graphics.print(tostring(math.floor(player2score)), VIRTUAL_WIDTH / 2 + 400, VIRTUAL_HEIGHT / 12)
  633. love.graphics.setColor(1, 1, 1, 1)
  634. displayPoints()
  635. player1:render()
  636. player2:render()
  637. end
  638. function practiceDraw()
  639. player1:render()
  640. love.graphics.rectangle("fill", VIRTUAL_WIDTH-10, 0, 10, VIRTUAL_HEIGHT)
  641. love.graphics.setColor(1, 1, 1, 1)
  642. love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
  643. love.graphics.setFont(smallfont)
  644. love.graphics.setFont(scorefont)
  645. love.graphics.print(tostring(math.floor(player1score)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 12)
  646. end
  647. function menuDraw()
  648. love.graphics.setColor(1, 1, 1, 1)
  649. love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
  650. love.graphics.setFont(smallfont)
  651. love.graphics.printf(updateTEXT, 0, VIRTUAL_HEIGHT * 0.95, VIRTUAL_WIDTH, "left")
  652. if MAP_TYPE == 1 then
  653. love.graphics.setColor(1, 0, 0.20, 1)
  654. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, 0, 10, VIRTUAL_HEIGHT * 0.3)
  655. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, VIRTUAL_HEIGHT * 0.7, 10, VIRTUAL_HEIGHT * 0.3)
  656. love.graphics.setColor(1, 1, 1, 1)
  657. end
  658. if MAP_TYPE == 2 then
  659. for i, wall in ipairs(walls) do
  660. love.graphics.setColor(1, 1, 1, 1)
  661. love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
  662. end
  663. end
  664. if gameState == "windowsettings" then
  665. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, settings, sounds, "right")
  666. love.keyboard.mouseisReleased = false
  667. end
  668. if gameState == "editor" then
  669. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, editorpicks, sounds, "right")
  670. love.keyboard.mouseisReleased = false
  671. end
  672. if gameState == "speedSettings" then
  673. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, speedParameters, sounds, "middle")
  674. love.keyboard.mouseisReleased = false
  675. end
  676. if gameState == "controlSettings" then
  677. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, controlSettings, sounds, "control")
  678. love.keyboard.mouseisReleased = false
  679. end
  680. if gameState == "gameMode" then
  681. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, modeSelectorButtons, sounds, "middle")
  682. love.keyboard.mouseisReleased = false
  683. end
  684. if gameState == "menu" then
  685. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds, "middle")
  686. love.keyboard.mouseisReleased = false
  687. end
  688. if gameState == "difficulty" then
  689. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, difbuttons, sounds, "middle")
  690. love.keyboard.mouseisReleased = false
  691. end
  692. if gameState == "multiMode" then
  693. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, playerCountButtons, sounds, "playercount")
  694. love.keyboard.mouseisReleased = false
  695. end
  696. if gameState == "prdiff" then
  697. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, pracdiff, sounds, "playercount")
  698. love.keyboard.mouseisReleased = false
  699. end
  700. if gameState == 'start' then
  701. love.graphics.push()
  702. love.graphics.translate(VIRTUAL_WIDTH * 0.4, VIRTUAL_HEIGHT * 0.5)
  703. love.graphics.rotate(rotation)
  704. love.graphics.setFont(smallfont)
  705. love.graphics.print("Press Enter to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8)
  706. love.graphics.setColor(255, 255, 255, 255)
  707. love.graphics.pop()
  708. end
  709. end
  710. function baseDraw()
  711. love.graphics.clear(40 / 255, 40 / 255, 40 / 255, 1)
  712. if shakeDuration > t then
  713. local dx = love.math.random(-shakeMagnitude, shakeMagnitude)
  714. local dy = love.math.random(-shakeMagnitude, shakeMagnitude)
  715. love.graphics.translate(dx, dy)
  716. end
  717. if globalState == 'menu' then
  718. print("Drawing menuDraw")
  719. if gameState == 'animation' then
  720. print("Drawing animation")
  721. intro()
  722. end
  723. if gameState ~= 'animation' then
  724. print("Drawing notanimtaion")
  725. love.graphics.setFont(scorefont)
  726. menuDraw()
  727. end
  728. end
  729. if globalState == 'base' then
  730. love.graphics.setFont(smallfont)
  731. if gameState == 'nuclearExplosion' then
  732. nuclearDraw()
  733. end
  734. if gameState == 'play' or gameState == '1serve' or gameState == '2serve' or gameState == 'done' then
  735. print("Drawing normally")
  736. normalDraw()
  737. end
  738. end
  739. end
  740. function renderEditor()
  741. if not blockinput then
  742. love.graphics.setColor(1, 0, 0, 1)
  743. love.graphics.rectangle("fill", mx, my, 10, wall1width)
  744. love.graphics.setColor(1, 1, 1, 1)
  745. end
  746. for i, wall in ipairs(walls) do
  747. love.graphics.setColor(1, 1, 1, 1)
  748. love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
  749. end
  750. end
  751. function intro()
  752. love.graphics.setColor(255, 255, 255, light / 255)
  753. love.graphics.draw(image, 0, 0)
  754. end
  755. function displayPoints()
  756. love.graphics.setFont(smallfont)
  757. if areanuclear == 1 then
  758. love.graphics.setColor(0,0,0,1)
  759. end
  760. if (potentialstrike1 == 1 and potentialnuke1 == 0 and player1reverbav == 0) then --FLAG: AVAILABLE SUPER
  761. if (player1striken == 0) then
  762. love.graphics.print(
  763. tostring(math.floor(player1nukescore) .. "[" .. p1control.super .. "]"),
  764. VIRTUAL_WIDTH / 2 - 500,
  765. VIRTUAL_HEIGHT / 60
  766. )
  767. else
  768. love.graphics.print(tostring("READY"), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60)
  769. end
  770. elseif (player1reverbav == 1 and potentialnuke1 == 0 and maxBalls == 1) then
  771. love.graphics.print(
  772. tostring(
  773. math.floor(player1nukescore) .. "[" .. p1control.super .. "]" .. " [" .. p1control.counter .. "]"
  774. ),
  775. VIRTUAL_WIDTH / 2 - 500,
  776. VIRTUAL_HEIGHT / 60
  777. )
  778. elseif (potentialnuke1 == 1 and maxBalls == 1) then
  779. love.graphics.setColor(255, 0, 0, 255)
  780. love.graphics.print(
  781. tostring(
  782. math.floor(player1nukescore) .. "[" .. p1control.super .. "]" .. " [" .. p1control.counter .. "]"
  783. ),
  784. VIRTUAL_WIDTH / 2 - 500,
  785. VIRTUAL_HEIGHT / 60
  786. )
  787. love.graphics.setColor(255, 255, 255, 255)
  788. elseif (potentialnuke1 == 1) then
  789. love.graphics.setColor(255, 0, 0, 255)
  790. love.graphics.print(
  791. tostring(
  792. math.floor(player1nukescore) .. "[" .. p1control.super .. "]"
  793. ),
  794. VIRTUAL_WIDTH / 2 - 500,
  795. VIRTUAL_HEIGHT / 60
  796. )
  797. love.graphics.setColor(255, 255, 255, 255)
  798. else
  799. love.graphics.print(tostring(math.floor(player1nukescore)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60)
  800. end
  801. if (potentialstrike2 == 1 and player2reverbav == 0) then
  802. if (player2striken == 0) then
  803. love.graphics.print(
  804. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "]"),
  805. VIRTUAL_WIDTH / 2 + 430,
  806. VIRTUAL_HEIGHT / 60
  807. )
  808. else
  809. love.graphics.print(tostring("READY"), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60)
  810. end
  811. elseif (potentialnuke2 == 1 and maxBalls == 1) then
  812. love.graphics.setColor(255, 0, 0, 255)
  813. love.graphics.print(
  814. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "] [" .. p2control.counter .. "]"),
  815. VIRTUAL_WIDTH / 2 + 400,
  816. VIRTUAL_HEIGHT / 60
  817. )
  818. love.graphics.setColor(255, 255, 255, 255)
  819. elseif (potentialnuke2 == 1 and maxBalls > 1) then
  820. love.graphics.setColor(255, 0, 0, 255)
  821. love.graphics.print(
  822. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "]"),
  823. VIRTUAL_WIDTH / 2 + 430,
  824. VIRTUAL_HEIGHT / 60
  825. )
  826. love.graphics.setColor(255, 255, 255, 255)
  827. elseif (player2reverbav == 1 and potentialnuke2 == 0 and maxBalls == 1) then
  828. love.graphics.print(
  829. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "] [" .. p2control.counter .. "]"),
  830. VIRTUAL_WIDTH / 2 + 400,
  831. VIRTUAL_HEIGHT / 60
  832. )
  833. else
  834. love.graphics.print(tostring(math.floor(player2nukescore)), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60)
  835. end
  836. end
  837. function hitIdentifier()
  838. if (gameMode == "practice") then
  839. MAP_TYPE = 0
  840. if ball[i].x > VIRTUAL_WIDTH * 0.99 then
  841. soundtype = love.math.random(1, 5)
  842. sounds["wallhit"]:setPitch(ballSpeed / 250)
  843. sounds["wallhit"]:play()
  844. if (ball[i].dx > 0) then
  845. ball[i].x = ball[i].x - 20
  846. else
  847. ball[i].x = ball[i].x + 20
  848. end
  849. ball[i].dx = -ball[i].dx
  850. end
  851. end
  852. if (MAP_TYPE == 1) then
  853. if
  854. ball[i].y < VIRTUAL_HEIGHT * 0.3 and ball[i].x > VIRTUAL_WIDTH * 0.5 and
  855. ball[i].x < VIRTUAL_WIDTH * 0.5 + 5
  856. then
  857. soundtype = love.math.random(1, 5)
  858. sounds["wallhit"]:setPitch(ballSpeed / 250)
  859. sounds["wallhit"]:play()
  860. if (ball[i].dx > 0) then
  861. ball[i].x = ball[i].x - 20
  862. else
  863. ball[i].x = ball[i].x + 20
  864. end
  865. ball[i].dx = -ball[i].dx
  866. end
  867. if
  868. ball[i].y > VIRTUAL_HEIGHT * 0.7 and ball[i].x > VIRTUAL_WIDTH * 0.5 and
  869. ball[i].x < VIRTUAL_WIDTH * 0.5 + 5
  870. then
  871. soundtype = love.math.random(1, 5)
  872. sounds["wallhit"]:setPitch(ballSpeed / 250)
  873. sounds["wallhit"]:play()
  874. if (ball[i].dx > 0) then
  875. ball[i].x = ball[i].x - 20
  876. else
  877. ball[i].x = ball[i].x + 20
  878. end
  879. ball[i].dx = -ball[i].dx
  880. end
  881. end
  882. if (MAP_TYPE == 2) then
  883. for i, wall in ipairs(walls) do
  884. if
  885. (ball[1].y > wall.wally and ball[1].y < wall.wally + wall.wallheight and
  886. ball[1].x > wall.wallx - ballSpeed / 200 and
  887. ball[1].x < wall.wallx + 10 + ballSpeed / 200)
  888. then
  889. controllerSer()
  890. soundtype = love.math.random(1, 5)
  891. sounds["wallhit"]:setPitch(ballSpeed / 250)
  892. sounds["wallhit"]:play()
  893. if (ball[1].dx > 0) then
  894. ball[1].x = ball[1].x - 1
  895. else
  896. ball[1].x = ball[1].x + 1
  897. end
  898. ball[1].dx = -ball[1].dx
  899. elseif
  900. (ball[1].y > wall.wally - 15 and ball[1].y < wall.wally + wall.wallheight + 10 and
  901. ball[1].x > wall.wallx and
  902. ball[1].x < wall.wallx + 10)
  903. then
  904. controllerSer()
  905. soundtype = love.math.random(1, 5)
  906. sounds["wallhit"]:setPitch(ballSpeed / 250)
  907. sounds["wallhit"]:play()
  908. if (ball[1].dy > 0) then
  909. ball[1].y = ball[1].y - 1
  910. else
  911. ball[1].y = ball[1].y + 1
  912. end
  913. ball[1].dy = -ball[1].dy
  914. end
  915. end
  916. end
  917. end