Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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