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.

1558 lines
46 KiB

  1. --CALLING OTHER LUA FILES
  2. require "src/dependencies"
  3. io.stdout:setvbuf("no")
  4. --CANCELLED ATTEMPETED SHADING (NOT WORKING)
  5. local shader_code =
  6. [[
  7. vec4 effect(vec4 color, Image image, vec2 uvs, vec2 screen_coords) {
  8. vec4 pixel = Texel(image,uvs);
  9. return pixel * color;
  10. }
  11. ]]
  12. debug = true
  13. --GLOBAL VARIABLES
  14. globalState = "menu"
  15. timeIsSlow = false
  16. timeIsSlow2 = false
  17. originalSpeed = 200
  18. explosionRange = 0
  19. blockinput = false
  20. wall1width = 30
  21. nuclearanimation = 3
  22. easternum = 0
  23. ball_DIR = 0
  24. RED = 255
  25. hitNum = {}
  26. hitNum[1] = 0
  27. hitNum[2] = 0
  28. hitNum[3] = 0
  29. hitNum[4] = 0
  30. p1bonus = 0
  31. p2bonus = 0
  32. hitNum[5] = 0
  33. hitNum[6] = 0
  34. GREEN = 255
  35. BLUE = 255
  36. updateTEXT = "Chalkboard Update"
  37. maxBalls = 1
  38. playerCount = 1
  39. player1reverbav = 0
  40. playertext = "1v1"
  41. player2reverbav = 0
  42. elapsed = 0
  43. rotation = 0
  44. TEXT = "Nuclear Pong"
  45. currentKey = " "
  46. ptw = 10
  47. --CHECKING IF CONTROLS ARE TAKEN
  48. danger = "none"
  49. danger2 = "none"
  50. nuckemodactive = 0
  51. maxspeed = 700
  52. DIFFERENCE_X = 1
  53. DIFFERENCE_Y = 1
  54. paddle_SPEED = 20
  55. textamount = 15
  56. AI_STRIKEMOD = 1000
  57. resolutionWin = 0
  58. AGAINST_AI = 0
  59. RESOLUTION_SET = 0
  60. AI_NUKEMOD = 1000
  61. animstart = true
  62. AI_SPEED = 30
  63. craz = 0
  64. AI_LEVEL = 500
  65. isFullscreen = 0
  66. prtext = "Easy"
  67. MAP_TYPE = 2
  68. difficultyl = 300
  69. req = "pp"
  70. ballSet = 200
  71. p1control = {up = "a", down = "z", super = "s", counter = "x"}
  72. p2control = {up = ";", down = ".", super = "l", counter = ","}
  73. synctext = "Independent"
  74. synctype = 0
  75. function newButton(text, fn)
  76. return {
  77. text = text,
  78. fn = fn,
  79. now = false,
  80. last = false
  81. }
  82. end
  83. function love.keyboard.mouseWasReleased()
  84. return love.keyboard.mouseisReleased
  85. end
  86. function autoSave(dt)
  87. autoTimer = autoTimer + dt
  88. end
  89. function balancer()
  90. if (player2score == 9 or player1score == 9) then
  91. shakeDuration = 10
  92. if debug then
  93. print("Shaking set to match almost over")
  94. end
  95. end
  96. if (player1score < player2score) then
  97. p1bonus = (player2score - player1score) * 5
  98. else
  99. p1bonus = 0
  100. end
  101. if (player2score < player1score) then
  102. p2bonus = (player1score - player2score) * 5
  103. else
  104. p2bonus = 0
  105. end
  106. end
  107. function newWall(wallx, wally, wallwidth, wallheight)
  108. return {
  109. wallx = wallx,
  110. wally = wally,
  111. walwidth = wallwidth,
  112. wallheight = wallheight
  113. }
  114. end
  115. speedParameters = {}
  116. buttons = {}
  117. difbuttons = {}
  118. settings = {}
  119. walls = {}
  120. editorpicks = {}
  121. controlSettings = {}
  122. modeSelectorButtons = {}
  123. pracdiff = {}
  124. playerCountButtons = {}
  125. function controlChanger()
  126. if (gameState == "assign") then
  127. love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
  128. love.graphics.printf("SELECT BUTTON", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  129. end
  130. end
  131. function love.load()
  132. simpleScale.setWindow(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT)
  133. configfile = io.open("config.lua", "r")
  134. configsave = io.open("config.lua", "w")
  135. shader = love.graphics.newShader(shader_code)
  136. time_1 = 0
  137. print("Debug active")
  138. --load
  139. testwalls = love.filesystem.load("save.lua")()
  140. if testwalls ~= nil then
  141. walls = love.filesystem.load("save.lua")()
  142. end
  143. light = 0
  144. image = love.graphics.newImage("Madi.png")
  145. table.insert(
  146. editorpicks,
  147. newButton(
  148. "C",
  149. function()
  150. for k in pairs(walls) do
  151. walls[k] = nil
  152. end
  153. end
  154. )
  155. )
  156. table.insert(
  157. editorpicks,
  158. newButton(
  159. "S",
  160. function()
  161. love.filesystem.write("save.lua", serialize(walls))
  162. end
  163. )
  164. )
  165. table.insert(
  166. editorpicks,
  167. newButton(
  168. "L",
  169. function()
  170. walls = love.filesystem.load("save.lua")()
  171. end
  172. )
  173. )
  174. table.insert(
  175. buttons,
  176. newButton(
  177. "Singleplayer",
  178. function()
  179. gameState = "gameMode"
  180. end
  181. )
  182. )
  183. table.insert(
  184. buttons,
  185. newButton(
  186. "Multiplayer",
  187. function()
  188. gameState = "multiMode"
  189. end
  190. )
  191. )
  192. table.insert(
  193. buttons,
  194. newButton(
  195. "Settings",
  196. function()
  197. AGAINST_AI = 0
  198. gameState = "windowsettings"
  199. end
  200. )
  201. )
  202. table.insert(
  203. buttons,
  204. newButton(
  205. "Exit",
  206. function()
  207. love.event.quit(0)
  208. end
  209. )
  210. )
  211. table.insert(
  212. difbuttons,
  213. newButton(
  214. "Easy",
  215. function()
  216. hardmanager("easy")
  217. end
  218. )
  219. )
  220. table.insert(
  221. difbuttons,
  222. newButton(
  223. "Normal",
  224. function()
  225. hardmanager("normal")
  226. end
  227. )
  228. )
  229. table.insert(
  230. difbuttons,
  231. newButton(
  232. "Hard",
  233. function()
  234. hardmanager("hard")
  235. end
  236. )
  237. )
  238. table.insert(
  239. settings,
  240. newButton(
  241. "Change Map",
  242. function()
  243. MAP_TYPE = MAP_TYPE + 1
  244. end
  245. )
  246. )
  247. table.insert(
  248. settings,
  249. newButton(
  250. "Toggle Fullscreen",
  251. function()
  252. myscreen:toggle(VIRTUAL_HEIGHT, VIRTUAL_WIDTH)
  253. DIFFERENCE_X = myscreen.c
  254. DIFFERENCE_Y = myscreen.d
  255. end
  256. )
  257. )
  258. table.insert(
  259. settings,
  260. newButton(
  261. "Editor",
  262. function()
  263. gameState = "editor"
  264. end
  265. )
  266. )
  267. table.insert(
  268. settings,
  269. newButton(
  270. "Speed Settings",
  271. function()
  272. gameState = "speedSettings"
  273. end
  274. )
  275. )
  276. table.insert(
  277. settings,
  278. newButton(
  279. "Control Settings",
  280. function()
  281. gameState = "controlSettings"
  282. end
  283. )
  284. )
  285. table.insert(
  286. settings,
  287. newButton(
  288. "Back to Menu",
  289. function()
  290. gameState = "menu"
  291. end
  292. )
  293. )
  294. table.insert(
  295. speedParameters,
  296. newButton(
  297. "Back to Menu",
  298. function()
  299. gameState = "windowsettings"
  300. end
  301. )
  302. )
  303. --table.insert(speedParameters, newButton("Ball Speed: ", function() speedSetter('ball') end))
  304. table.insert(
  305. playerCountButtons,
  306. newButton(
  307. "Ball Speed: ",
  308. function()
  309. speedSetter("ball")
  310. end
  311. )
  312. )
  313. --table.insert(speedParameters, newButton("snc", function() speedSetter('snc') end))
  314. table.insert(
  315. playerCountButtons,
  316. newButton(
  317. "snc",
  318. function()
  319. speedSetter("snc")
  320. end
  321. )
  322. )
  323. table.insert(
  324. speedParameters,
  325. newButton(
  326. "NUCLEAR MODE",
  327. function()
  328. speedSetter("nuclearmod")
  329. end
  330. )
  331. )
  332. table.insert(
  333. controlSettings,
  334. newButton(
  335. "1up",
  336. function()
  337. gameState = "assign"
  338. req = "p1up"
  339. end
  340. )
  341. )
  342. table.insert(
  343. controlSettings,
  344. newButton(
  345. "1down",
  346. function()
  347. gameState = "assign"
  348. req = "p1down"
  349. end
  350. )
  351. )
  352. table.insert(
  353. controlSettings,
  354. newButton(
  355. "1special",
  356. function()
  357. gameState = "assign"
  358. req = "p1super"
  359. end
  360. )
  361. )
  362. table.insert(
  363. controlSettings,
  364. newButton(
  365. "1ct",
  366. function()
  367. gameState = "assign"
  368. req = "p1ct"
  369. end
  370. )
  371. )
  372. table.insert(
  373. controlSettings,
  374. newButton(
  375. "2up",
  376. function()
  377. gameState = "assign"
  378. req = "p2up"
  379. end
  380. )
  381. )
  382. table.insert(
  383. controlSettings,
  384. newButton(
  385. "2down",
  386. function()
  387. gameState = "assign"
  388. req = "p2down"
  389. end
  390. )
  391. )
  392. table.insert(
  393. controlSettings,
  394. newButton(
  395. "2special",
  396. function()
  397. gameState = "assign"
  398. req = "p2super"
  399. end
  400. )
  401. )
  402. table.insert(
  403. controlSettings,
  404. newButton(
  405. "2ct",
  406. function()
  407. gameState = "assign"
  408. req = "p2ct"
  409. end
  410. )
  411. )
  412. table.insert(
  413. controlSettings,
  414. newButton(
  415. "Default",
  416. function()
  417. p1control = {up = "a", down = "z", super = "s", counter = "x"}
  418. p2control = {up = ";", down = ".", super = "l", counter = ","}
  419. end
  420. )
  421. )
  422. table.insert(
  423. controlSettings,
  424. newButton(
  425. "Return",
  426. function()
  427. gameState = "windowsettings"
  428. end
  429. )
  430. )
  431. table.insert(
  432. modeSelectorButtons,
  433. newButton(
  434. "Nuclear Pong",
  435. function()
  436. gameState = "difficulty"
  437. end
  438. )
  439. )
  440. table.insert(
  441. modeSelectorButtons,
  442. newButton(
  443. "Nuclear Practice",
  444. function()
  445. gameState = "prdiff"
  446. end
  447. )
  448. )
  449. table.insert(
  450. modeSelectorButtons,
  451. newButton(
  452. "Main Menu",
  453. function()
  454. gameState = "menu"
  455. end
  456. )
  457. )
  458. table.insert(
  459. pracdiff,
  460. newButton(
  461. "Silverblade",
  462. function()
  463. speedSetter("practice")
  464. end
  465. )
  466. )
  467. table.insert(
  468. pracdiff,
  469. newButton(
  470. "Return",
  471. function()
  472. speedSetter("reset")
  473. gameState = "gameMode"
  474. end
  475. )
  476. )
  477. table.insert(
  478. pracdiff,
  479. newButton(
  480. "Go!",
  481. function()
  482. gameMode = "practice"
  483. hardmanager("practice")
  484. end
  485. )
  486. )
  487. --table.insert(playerCountButtons, newButton("1v1", function() speedSetter('pc') end))
  488. table.insert(
  489. playerCountButtons,
  490. newButton(
  491. "ballCount",
  492. function()
  493. speedSetter("ballz")
  494. end
  495. )
  496. )
  497. table.insert(
  498. playerCountButtons,
  499. newButton(
  500. "Return",
  501. function()
  502. speedSetter("reset")
  503. gameState = "menu"
  504. end
  505. )
  506. )
  507. table.insert(
  508. playerCountButtons,
  509. newButton(
  510. "ptw",
  511. function()
  512. speedSetter("ptw")
  513. end
  514. )
  515. )
  516. table.insert(
  517. playerCountButtons,
  518. newButton(
  519. "Play",
  520. function()
  521. AGAINST_AI = 0
  522. gameState = "1serve"
  523. end
  524. )
  525. )
  526. --table.insert(speedParameters, newButton("Ball Speed: ", function() speedSetter() end))
  527. love.window.setTitle("NUCLEAR PONG")
  528. textphrases = {
  529. "Amazing",
  530. "Superb",
  531. "Absolutely beautiful!",
  532. "Awesome",
  533. "Look at That!",
  534. "Great",
  535. "Nice",
  536. "Boom!",
  537. "Dangerous!",
  538. "Astonishing!",
  539. "u/ebernerd saved me",
  540. "Absolutely Wonderful!",
  541. "Exsquisite",
  542. "Delicate",
  543. "Pow!",
  544. "Great Hit",
  545. "all hail nazarbayev"
  546. }
  547. sounds = {
  548. ["updateMusic"] = love.audio.newSource("audio/theme1.mp3", "static"),
  549. ["gayTheme"] = love.audio.newSource("audio/theme2.mp3", "static"),
  550. ["gayTheme2"] = love.audio.newSource("audio/theme3.mp3", "static"),
  551. ["gayTheme3"] = love.audio.newSource("audio/theme4.mp3", "static"),
  552. ["beep"] = love.audio.newSource("audio/hit1.mp3", "static"),
  553. ["wallhit"] = love.audio.newSource("audio/hit2.wav", "static"),
  554. ["win"] = love.audio.newSource("win.wav", "static"),
  555. ["score"] = love.audio.newSource("audio/score.wav", "static"),
  556. ["nuke"] = love.audio.newSource("audio/bomb.wav", "static"),
  557. ["striking"] = love.audio.newSource("audio/superhit.wav", "static"),
  558. ["nuclearhit"] = love.audio.newSource("audio/hit1.mp3", "static"),
  559. ["time"] = love.audio.newSource("audio/time.wav", "static")
  560. }
  561. love.graphics.setDefaultFilter("nearest", "nearest")
  562. --comic sans lmao
  563. math.randomseed(os.time())
  564. smallfont = love.graphics.newFont("font.ttf", 25)
  565. scorefont = love.graphics.newFont("font.ttf", 60)
  566. love.graphics.setFont(smallfont)
  567. --push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
  568. -- fullscreen = isFullscreen,
  569. -- resizable = true,
  570. -- vsync = true,
  571. --})
  572. player1score = 0
  573. player2score = 0
  574. areanuclear = 0
  575. player1nukescore = 0
  576. player2nukescore = 0
  577. striken = 0
  578. soundtype = 1
  579. soundturn = 1
  580. potentialstrike1 = 0
  581. potentialstrike2 = 0
  582. potentialnuke1 = 0
  583. potentialnuke2 = 0
  584. player1striken = 0
  585. player2striken = 0
  586. randomtext = 0
  587. selecting = 0
  588. number = 0
  589. elec = 1
  590. INDIC = {
  591. "",
  592. "",
  593. "",
  594. ""
  595. }
  596. --playe1nuke
  597. player1 = paddle(0, 30, 10, 100, 1)
  598. player2 = paddle(VIRTUAL_WIDTH * 0.99, VIRTUAL_HEIGHT * 0.88, 10, 100, 2)
  599. player3 = paddle(5000, 5000, 10, 100)
  600. player4 = paddle(5000, 5000, 10, 100)
  601. ball = {}
  602. ball[1] = eball(VIRTUAL_WIDTH / 2, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  603. ball[2] = eball(VIRTUAL_WIDTH / 1.9, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  604. ball[3] = eball(VIRTUAL_WIDTH / 1.8, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  605. ball[4] = eball(VIRTUAL_WIDTH / 2.2, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  606. ball[5] = eball(VIRTUAL_WIDTH / 2.1, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  607. myscreen = fullScreener(RESOLUTION_SET, isFullscreen, DIFFERENCE_X, DIFFERENCE_Y)
  608. mymenu = mainMenu()
  609. ballSpeed = 200
  610. ballDX = math.random(2) == 1 and 100 or -100
  611. ballDY = math.random(-50, 50)
  612. gameState = "animation"
  613. end
  614. t = 0
  615. shakeDuration = 0
  616. shakeMagnitude = 1
  617. function startShake(duration, magnitude)
  618. t, shakeDuration, shakeMagnitude = 0, duration or 1, magnitude or 5
  619. end
  620. function displayFPS()
  621. love.window.setTitle(love.timer.getFPS())
  622. if love.keyboard.isDown("space") then
  623. player1nukescore = 200
  624. end
  625. end
  626. function speedControl()
  627. if (ballSpeed > maxspeed and gameState == "play") then
  628. ballSpeed = maxspeed
  629. end
  630. end
  631. function love.update(dt)
  632. staticanimatorcounter(dt)
  633. if debug then
  634. displayFPS()
  635. end
  636. if globalState == "base" then
  637. basegame(dt)
  638. end
  639. if globalState == "menu" then
  640. menumode(dt)
  641. end
  642. end
  643. function wallbreaker(x, y)
  644. if (gameState == "editor") then
  645. for i, wall in ipairs(walls) do
  646. if math.abs(wall.wallx - x) < 10 and math.abs(wall.wally - y) < 10 then
  647. table.remove(walls, i)
  648. end
  649. end
  650. end
  651. end
  652. function hardmanager(diff)
  653. selecting = 1
  654. if (diff == "easy") then
  655. INDIC[1] = ">"
  656. AGAINST_AI = 1
  657. AI_SPEED = ballSet / 10
  658. AI_STRIKEMOD = 100
  659. AI_NUKEMOD = 1000
  660. difficultyl = 200
  661. selecting = 0
  662. gameState = "1serve"
  663. globalState = "base"
  664. end
  665. if (diff == "normal") then
  666. INDIC[2] = ">"
  667. AI_SPEED = ballSet / 10
  668. AI_LEVEL = 500
  669. AI_NUKEMOD = 250
  670. AI_STRIKEMOD = 60
  671. AGAINST_AI = 1
  672. difficultyl = 300
  673. selecting = 0
  674. gameState = "1serve"
  675. globalState = "base"
  676. end
  677. if (diff == "hard") then
  678. INDIC[3] = ">"
  679. AI_SPEED = ballSpeed * 1.1 + 50
  680. AI_SPEED = AI_SPEED / 10
  681. AI_LEVEL = 700
  682. AI_NUKEMOD = 200
  683. AI_STRIKEMOD = 20
  684. selecting = 0
  685. difficultyl = 350
  686. AGAINST_AI = 1
  687. gameState = "1serve"
  688. globalState = "base"
  689. end
  690. if (diff == "practice") then
  691. INDIC[3] = ">"
  692. AI_SPEED = ballSpeed * 500 + 50
  693. AI_SPEED = AI_SPEED / 10
  694. AI_LEVEL = 700
  695. AI_NUKEMOD = 9000000000
  696. AI_STRIKEMOD = 90000000
  697. selecting = 0
  698. difficultyl = 350
  699. AGAINST_AI = 1
  700. gameState = "base"
  701. end
  702. end
  703. function dangerChecker() --CHECK IF CONTROLS ARE DUPLICATING
  704. if (p1control.up == p1control.down) then
  705. danger = "1up"
  706. danger2 = "1down"
  707. elseif (p1control.up == p1control.super) then
  708. danger = "1up"
  709. danger2 = "1special"
  710. elseif (p1control.up == p1control.counter) then
  711. danger = "1up"
  712. danger2 = "1ct"
  713. elseif (p1control.down == p1control.super) then
  714. danger = "1down"
  715. danger2 = "1special"
  716. elseif (p1control.down == p1control.counter) then
  717. danger = "1ct"
  718. danger2 = "1down"
  719. elseif (p1control.super == p1control.counter) then
  720. danger = "1special"
  721. danger2 = "1ct"
  722. elseif (p2control.down == p2control.up) then
  723. danger = "2down"
  724. danger2 = "2up"
  725. elseif (p2control.down == p2control.super) then
  726. danger = "2down"
  727. danger2 = "2special"
  728. elseif (p2control.down == p2control.counter) then
  729. danger = "2down"
  730. danger2 = "2ct"
  731. elseif (p2control.up == p2control.super) then
  732. danger = "2up"
  733. danger2 = "2special"
  734. elseif (p2control.up == p2control.counter) then
  735. danger = "2ct"
  736. danger2 = "2up"
  737. elseif (p2control.super == p2control.counter) then
  738. danger = "2special"
  739. danger2 = "2ct"
  740. else
  741. danger = "none"
  742. danger2 = "none"
  743. end
  744. end
  745. function love.keypressed(key)
  746. if gameState == "assign" then
  747. if (req == "p1up") then
  748. p1control.up = key
  749. currentKey = key
  750. --love.window.setTitle(key)
  751. gameState = "controlSettings"
  752. end
  753. if (req == "p2up") then
  754. p2control.up = key
  755. currentKey = key
  756. --love.window.setTitle(key)
  757. gameState = "controlSettings"
  758. end
  759. if (req == "p1down") then
  760. p1control.down = key
  761. currentKey = key
  762. --love.window.setTitle(key)
  763. gameState = "controlSettings"
  764. end
  765. if (req == "p2down") then
  766. p2control.down = key
  767. currentKey = key
  768. -- love.window.setTitle(key)
  769. gameState = "controlSettings"
  770. end
  771. if (req == "p1super") then
  772. p1control.super = key
  773. currentKey = key
  774. -- love.window.setTitle(key)
  775. gameState = "controlSettings"
  776. end
  777. if (req == "p2super") then
  778. p2control.super = key
  779. currentKey = key
  780. -- love.window.setTitle(key)
  781. gameState = "controlSettings"
  782. end
  783. if (req == "p1ct") then
  784. p1control.counter = key
  785. currentKey = key
  786. -- love.window.setTitle(key)
  787. gameState = "controlSettings"
  788. end
  789. if (req == "p2ct") then
  790. p2control.counter = key
  791. currentKey = key
  792. --love.window.setTitle(key)
  793. gameState = "controlSettings"
  794. end
  795. end
  796. if key == "escape" then
  797. TEXT = "Escape Key"
  798. love.event.quit()
  799. elseif key == "enter" or key == "return" then
  800. if gameState == "start" then
  801. resettinggenius()
  802. gameState = "menu"
  803. globalState = "menu"
  804. hardmanager()
  805. elseif (gameState == "done") then
  806. if (player1score > player2score) then
  807. gameState = "2serve"
  808. potentialnuke1 = 0
  809. potentialnuke2 = 0
  810. striken = 0
  811. if (nuckemodactive == 0) then
  812. areanuclear = 0
  813. nuclearanimation = 3
  814. end
  815. potentialstrike1 = 0
  816. potentialstrike2 = 0
  817. player1nukescore = 0
  818. player2nukescore = 0
  819. else
  820. gameState = "1serve"
  821. resettinggenius()
  822. for i = 1, maxBalls do
  823. ball[i]:reset(i)
  824. end
  825. end
  826. else
  827. gameState = "menu"
  828. globalState = "menu"
  829. if (love.math.random(0, 10) == 1) then
  830. TEXT = "Nuclear Ching Chong"
  831. else
  832. TEXT = "Nuclear Pong"
  833. end
  834. resettinggenius()
  835. for i = 1, maxBalls do
  836. ball[i]:reset(i)
  837. end
  838. end
  839. end
  840. end
  841. function love.keyreleased(key)
  842. currentKey = " "
  843. end
  844. function speedSetter(requesttype)
  845. if (requesttype == "ball") then
  846. if (ballSet > 550) then
  847. ballSet = 0
  848. paddle_SPEED = 0
  849. else
  850. ballSet = ballSet + 50
  851. paddle_SPEED = paddle_SPEED + 5
  852. end
  853. ballSpeed = ballSet
  854. end
  855. if (requesttype == "snc") then
  856. synctype = synctype + 1
  857. if (synctype > 1) then
  858. synctype = 0
  859. end
  860. if synctype == 0 then
  861. synctext = "Independent"
  862. end
  863. if synctype == 1 then
  864. synctext = "Synchronised"
  865. end
  866. end
  867. if (requesttype == "nuclearmod") then
  868. nuckemodactive = nuckemodactive + 1
  869. if (nuckemodactive > 1) then
  870. nuckemodactive = 0
  871. end
  872. if (nuckemodactive == 0) then
  873. areanuclear = 0
  874. nuclearanimation = 3
  875. ballSet = 200
  876. TEXT = "Nuclear Pong"
  877. synctype = 0
  878. maxspeed = 700
  879. synctext = "Independent"
  880. paddle_SPEED = ballSet / 10
  881. AI_SPEED = ballSet / 10
  882. end
  883. if (nuckemodactive == 1) then
  884. areanuclear = 1
  885. ballSet = 2000
  886. maxspeed = 2000
  887. paddle_SPEED = ballSet / 10
  888. AI_SPEED = ballSet / 10
  889. synctext = "death is imminent"
  890. end
  891. ballSpeed = ballSet
  892. end
  893. if (requesttype == "practice") then
  894. if (ballSpeed > 999) then
  895. ballSpeed = 200
  896. ballSet = 200
  897. end
  898. if (ballSpeed > 799) then
  899. prtext = "Insane"
  900. maxBalls = 5
  901. elseif ballSpeed > 599 then
  902. prtext = "Hard"
  903. maxBalls = 4
  904. elseif ballSpeed > 399 then
  905. prtext = "Normal"
  906. maxBalls = 3
  907. elseif ballSpeed > 199 then
  908. prtext = "Easy"
  909. maxBalls = 3
  910. end
  911. ballSpeed = ballSpeed + 200
  912. ballSet = ballSet + 200
  913. end
  914. if (requesttype == "reset") then
  915. ballSpeed = 200
  916. ballSet = 200
  917. synctype = 0
  918. prtext = "Easy"
  919. maxBalls = 1
  920. end
  921. if (requesttype == "pc") then
  922. if (playerCount == 2) then
  923. playerCount = 1
  924. playertext = "1v1"
  925. elseif (playerCount == 1) then
  926. playerCount = playerCount + 1
  927. player3.x = player1.x + VIRTUAL_WIDTH / 2
  928. player3.y = player3.y
  929. playertext = "2v2"
  930. end
  931. end
  932. if (requesttype == "ballz") then
  933. if (maxBalls > 1) then
  934. --love.window.setTitle("more than 4")
  935. maxBalls = 1
  936. else
  937. maxBalls = maxBalls + 1
  938. end
  939. end
  940. if requesttype == "ptw" then
  941. if ptw == 10 then
  942. ptw = 1
  943. else
  944. ptw = ptw + 1
  945. end
  946. end
  947. end
  948. function gameModeChanger()
  949. if (gameState == "gameMode") then
  950. local button_width = VIRTUAL_WIDTH * (1 / 3)
  951. local BUTTON_HEIGHT = 50
  952. local margin = 20
  953. local hot = false
  954. local cursor_y = 0
  955. local total_height = (BUTTON_HEIGHT + margin) * #buttons
  956. for i, button in ipairs(modeSelectorButtons) do
  957. button.last = button.now
  958. local bx = (VIRTUAL_WIDTH * 0.5) - (button_width * 0.5)
  959. local by = (VIRTUAL_HEIGHT * 0.5) - (total_height * 0.5) + cursor_y
  960. local color = {255, 255, 255, 255}
  961. local mx, my = love.mouse.getPosition()
  962. mx = mx * DIFFERENCE_X
  963. my = my * DIFFERENCE_Y
  964. hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
  965. if (hot == i) then
  966. color = {10, 10, 0, 255}
  967. end
  968. button.now = love.mouse.isDown(1)
  969. if button.now and not button.last and hot == i then
  970. love.graphics.setColor(0, 0, 0, 1)
  971. love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
  972. sounds["wallhit"]:play()
  973. button.fn()
  974. end
  975. love.graphics.setColor(unpack(color))
  976. love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT)
  977. love.graphics.setColor(0, 0, 0, 255)
  978. local textW = smallfont:getWidth(button.text)
  979. local textH = smallfont:getHeight(button.text)
  980. love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  981. love.graphics.setColor(255, 255, 255, 255)
  982. cursor_y = cursor_y + (BUTTON_HEIGHT + margin)
  983. end
  984. end
  985. if (gameState == "multiMode") then
  986. local button_width = VIRTUAL_WIDTH * (1 / 3)
  987. local BUTTON_HEIGHT = 50
  988. local margin = 20
  989. local hot = false
  990. local cursor_y = 0
  991. local total_height = (BUTTON_HEIGHT + margin) * #buttons
  992. for i, button in ipairs(playerCountButtons) do
  993. button.last = button.now
  994. local bx = (VIRTUAL_WIDTH * 0.5) - (button_width * 0.5)
  995. local by = (VIRTUAL_HEIGHT * 0.3) - (total_height * 0.5) + cursor_y
  996. if (button.text == "Play") then
  997. by = by + by / 1.8
  998. end
  999. local color = {255, 255, 255, 255}
  1000. local mx, my = love.mouse.getPosition()
  1001. mx = mx * DIFFERENCE_X
  1002. my = my * DIFFERENCE_Y
  1003. hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
  1004. if (hot == i) then
  1005. if (button.text == "Play") then
  1006. color = {0 / 255, 255 / 255, 0 / 255, 255}
  1007. else
  1008. color = {10, 10, 0, 255}
  1009. end
  1010. end
  1011. button.now = love.mouse.isDown(1)
  1012. if button.now and not button.last and hot == i then
  1013. love.graphics.setColor(0, 0, 0, 1)
  1014. love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
  1015. sounds["wallhit"]:play()
  1016. if button.text == "Ball Speed: " and nuckemodactive == 1 then
  1017. else
  1018. button.fn()
  1019. end
  1020. end
  1021. love.graphics.setColor(unpack(color))
  1022. love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT)
  1023. love.graphics.setColor(0, 0, 0, 255)
  1024. local textW = smallfont:getWidth(button.text)
  1025. local textH = smallfont:getHeight(button.text)
  1026. if (button.text == "1v1") then
  1027. love.graphics.print(playertext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1028. elseif button.text == "snc" then
  1029. if (nuckemodactive == 1) then
  1030. love.graphics.setColor(1, 0, 0, 1)
  1031. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1032. love.graphics.setColor(1, 1, 1, 1)
  1033. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1034. love.graphics.setColor(0, 0, 0, 1)
  1035. else
  1036. --
  1037. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.45 - textW * 0.5, by + textH * 0.5)
  1038. end
  1039. elseif (button.text == "ballCount") then
  1040. love.graphics.print(
  1041. "Ball Count: " .. maxBalls,
  1042. smallfont,
  1043. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1044. by + textH * 0.5
  1045. )
  1046. elseif (button.text == "Ball Speed: ") then
  1047. if (nuckemodactive == 1) then
  1048. love.graphics.setColor(1, 0, 0, 1)
  1049. love.graphics.print(
  1050. "shaitan machina",
  1051. smallfont,
  1052. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1053. by + textH * 0.5
  1054. )
  1055. love.graphics.setColor(1, 1, 1, 1)
  1056. love.graphics.print(
  1057. "shaitan machina",
  1058. smallfont,
  1059. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1060. by + textH * 0.5
  1061. )
  1062. love.graphics.setColor(0, 0, 0, 1)
  1063. else
  1064. love.graphics.print(
  1065. button.text .. ballSet,
  1066. smallfont,
  1067. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1068. by + textH * 0.5
  1069. )
  1070. end
  1071. elseif button.text == "ptw" then
  1072. love.graphics.print(
  1073. "Points to Win: " .. ptw,
  1074. smallfont,
  1075. VIRTUAL_WIDTH * 0.5 - textW * 1.5,
  1076. by + textH * 0.5
  1077. )
  1078. else
  1079. love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1080. end
  1081. love.graphics.setColor(255, 255, 255, 255)
  1082. cursor_y = cursor_y + (BUTTON_HEIGHT + margin)
  1083. end
  1084. end
  1085. end
  1086. function love.draw()
  1087. simpleScale.set()
  1088. --LEGACY CODE (INGORE)
  1089. --resolutionChanger()
  1090. --love.graphics.scale( 1.5, 1.5 )
  1091. -- love.graphics.translate( (WINDOW_WIDTH*1.5 - WINDOW_WIDTH), WINDOW_HEIGHT*1.5 - WINDOW_HEIGHT )
  1092. -- push:apply('start')
  1093. --resolutionButtons()
  1094. if gameState == "nuclearExplosion" then --AWFUL WAY TO DO NUCLEAR EXPLOSIONS
  1095. love.graphics.setColor(1, 1, 1, 1)
  1096. love.graphics.circle("fill", ball[1].x, ball[1].y, explosionRange * 100, 100)
  1097. player1.RED, player1.GREEN, player1.BLUE, player2.RED, player2.GREEN, player2.BLUE =
  1098. nuclearanimation / 3,
  1099. nuclearanimation / 3,
  1100. nuclearanimation / 3,
  1101. nuclearanimation / 3,
  1102. nuclearanimation / 3,
  1103. nuclearanimation / 3
  1104. for i = 1, maxBalls do
  1105. love.graphics.setColor(nuclearanimation / 3, nuclearanimation / 3, nuclearanimation / 3, 1)
  1106. ball[i]:render("controlled")
  1107. end
  1108. player1:render()
  1109. player2:render()
  1110. elseif gameState == "animation" then
  1111. callAnimator() --This calls a fucking 100 year old animator. I dont even remember what it does. This has nothing to do with the new one
  1112. else
  1113. if t < shakeDuration then
  1114. local dx = love.math.random(-shakeMagnitude, shakeMagnitude)
  1115. local dy = love.math.random(-shakeMagnitude, shakeMagnitude)
  1116. love.graphics.translate(dx, dy)
  1117. end
  1118. if (areanuclear == 1) then
  1119. love.graphics.setShader(shader)
  1120. love.graphics.clear(1, 1, 1, 1)
  1121. else
  1122. love.graphics.setShader()
  1123. love.graphics.clear(40 / 255, 40 / 255, 40 / 255, 1) --BACKGROUND COLOR
  1124. end
  1125. staticanimator()
  1126. if (gameMode == "practice") then
  1127. love.graphics.rectangle("fill", VIRTUAL_WIDTH, 0, 10, VIRTUAL_HEIGHT)
  1128. end
  1129. if (MAP_TYPE == 1) then
  1130. love.graphics.setColor(1, 0, 0.20, 1)
  1131. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, 0, 10, VIRTUAL_HEIGHT * 0.3)
  1132. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, VIRTUAL_HEIGHT * 0.7, 10, VIRTUAL_HEIGHT * 0.3)
  1133. love.graphics.setColor(1, 1, 1, 1)
  1134. end
  1135. love.graphics.setFont(scorefont)
  1136. if gameState == "play" or gameState == "1serve" or gameState == "2serve" then
  1137. love.graphics.setFont(smallfont)
  1138. end
  1139. love.graphics.setColor(1, 1, 1, 1)
  1140. love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
  1141. love.graphics.setFont(smallfont)
  1142. love.graphics.printf(updateTEXT, 0, VIRTUAL_HEIGHT * 0.95, VIRTUAL_WIDTH, "left")
  1143. love.graphics.setFont(scorefont)
  1144. love.graphics.print(tostring(math.floor(player1score)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 12)
  1145. if (gameMode ~= "practice") then
  1146. love.graphics.print(tostring(math.floor(player2score)), VIRTUAL_WIDTH / 2 + 400, VIRTUAL_HEIGHT / 12)
  1147. end
  1148. love.graphics.setFont(smallfont)
  1149. if (potentialstrike1 == 1 and potentialnuke1 == 0 and player1reverbav == 0) then
  1150. if (player1striken == 0) then
  1151. love.graphics.print(
  1152. tostring(math.floor(player1nukescore) .. "[" .. p1control.super .. "]"),
  1153. VIRTUAL_WIDTH / 2 - 500,
  1154. VIRTUAL_HEIGHT / 60
  1155. )
  1156. else
  1157. love.graphics.print(tostring("READY"), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60)
  1158. end
  1159. elseif (player1reverbav == 1 and potentialnuke1 == 0) then
  1160. love.graphics.print(
  1161. tostring(
  1162. math.floor(player1nukescore) .. "[" .. p1control.super .. "]" .. " [" .. p1control.counter .. "]"
  1163. ),
  1164. VIRTUAL_WIDTH / 2 - 500,
  1165. VIRTUAL_HEIGHT / 60
  1166. )
  1167. elseif (potentialnuke1 == 1) then
  1168. love.graphics.setColor(255, 0, 0, 255)
  1169. love.graphics.print(
  1170. tostring(
  1171. math.floor(player1nukescore) .. "[" .. p1control.super .. "]" .. " [" .. p1control.counter .. "]"
  1172. ),
  1173. VIRTUAL_WIDTH / 2 - 500,
  1174. VIRTUAL_HEIGHT / 60
  1175. )
  1176. love.graphics.setColor(255, 255, 255, 255)
  1177. else
  1178. love.graphics.print(tostring(math.floor(player1nukescore)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60)
  1179. end
  1180. if (potentialstrike2 == 1 and player2reverbav == 0) then
  1181. if (player2striken == 0 and gameMode ~= "practice") then
  1182. love.graphics.print(
  1183. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "]"),
  1184. VIRTUAL_WIDTH / 2 + 430,
  1185. VIRTUAL_HEIGHT / 60
  1186. )
  1187. elseif (gameMode ~= "practice") then
  1188. love.graphics.print(tostring("READY"), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60)
  1189. end
  1190. elseif (potentialnuke2 == 1 and gameMode ~= "practice") then
  1191. love.graphics.setColor(255, 0, 0, 255)
  1192. love.graphics.print(
  1193. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "]"),
  1194. VIRTUAL_WIDTH / 2 + 430,
  1195. VIRTUAL_HEIGHT / 60
  1196. )
  1197. love.graphics.setColor(255, 255, 255, 255)
  1198. elseif (player2reverbav == 1 and potentialnuke2 == 0) then
  1199. love.graphics.print(
  1200. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "] [" .. p2control.counter .. "]"),
  1201. VIRTUAL_WIDTH / 2 + 430,
  1202. VIRTUAL_HEIGHT / 60
  1203. )
  1204. elseif (gameMode ~= "practice") then
  1205. love.graphics.print(tostring(math.floor(player2nukescore)), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60)
  1206. end
  1207. if (MAP_TYPE == 2) then
  1208. for i, wall in ipairs(walls) do
  1209. love.graphics.setColor(1, 1, 1, 1)
  1210. love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
  1211. end
  1212. end
  1213. if gameState ~= "assign" then
  1214. player1:render()
  1215. player3:render()
  1216. if gameMode ~= "practice" then
  1217. player2:render()
  1218. player4:render()
  1219. end
  1220. for i = 1, maxBalls do
  1221. if areanuclear == 1 then
  1222. --love.window.setTitle('rendering black')
  1223. ball[i]:render("black")
  1224. else
  1225. --love.window.setTitle('rendering white')
  1226. ball[i]:render(" ")
  1227. end
  1228. end
  1229. if gameState == "windowsettings" then
  1230. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, settings, sounds, "right")
  1231. love.keyboard.mouseisReleased = false
  1232. end
  1233. if gameState == "editor" then
  1234. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, editorpicks, sounds, "right")
  1235. love.keyboard.mouseisReleased = false
  1236. end
  1237. if gameState == "speedSettings" then
  1238. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, speedParameters, sounds, "middle")
  1239. love.keyboard.mouseisReleased = false
  1240. end
  1241. if gameState == "controlSettings" then
  1242. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, controlSettings, sounds, "control")
  1243. love.keyboard.mouseisReleased = false
  1244. end
  1245. if gameState == "gameMode" then
  1246. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, modeSelectorButtons, sounds, "middle")
  1247. love.keyboard.mouseisReleased = false
  1248. end
  1249. if gameState == "menu" then
  1250. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds, "middle")
  1251. love.keyboard.mouseisReleased = false
  1252. end
  1253. if gameState == "difficulty" then
  1254. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, difbuttons, sounds, "middle")
  1255. love.keyboard.mouseisReleased = false
  1256. end
  1257. if gameState == "multiMode" then
  1258. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, playerCountButtons, sounds, "playercount")
  1259. love.keyboard.mouseisReleased = false
  1260. end
  1261. if gameState == "prdiff" then
  1262. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, pracdiff, sounds, "playercount")
  1263. love.keyboard.mouseisReleased = false
  1264. end
  1265. end
  1266. if (gameState == "start") then
  1267. love.graphics.push()
  1268. love.graphics.translate(VIRTUAL_WIDTH * 0.4, VIRTUAL_HEIGHT * 0.5)
  1269. love.graphics.rotate(rotation)
  1270. love.graphics.setFont(smallfont)
  1271. love.graphics.print("Press Enter to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8)
  1272. love.graphics.setColor(255, 255, 255, 255)
  1273. love.graphics.pop()
  1274. end
  1275. end
  1276. simpleScale.unSet()
  1277. end
  1278. --Check if controls are duplicating
  1279. function controllerSer()
  1280. for i = 1, maxBalls do
  1281. if (ball[i].dy == 0) then
  1282. hitNum[i] = hitNum[i] + 1
  1283. if hitNum[i] >= 10 then
  1284. ball[i].dy = 1
  1285. hitNum[i] = 0
  1286. end
  1287. else
  1288. hitNum[i] = 0
  1289. end
  1290. end
  1291. end
  1292. function palleteController() --!!!!LEGACY CODE, MIGRATED TO Paddle.lua!!!!
  1293. if (areanuclear == 0) then
  1294. player1.RED = 1
  1295. player1.GREEN = 1
  1296. player1.BLUE = 1
  1297. end
  1298. if (areanuclear == 0) then
  1299. player2.RED = 1
  1300. player2.GREEN = 1
  1301. player2.BLUE = 1
  1302. end
  1303. if (areanuclear == 1) then
  1304. player1.RED = 0
  1305. player1.GREEN = 0
  1306. player1.BLUE = 0
  1307. end
  1308. if (areanuclear == 1) then
  1309. player2.RED = 0
  1310. player2.GREEN = 0
  1311. player2.BLUE = 0
  1312. end
  1313. end
  1314. function love.wheelmoved(x, y)
  1315. if (y < 0 and wall1width > 0) then
  1316. wall1width = wall1width - 5
  1317. elseif y > 0 and wall1width < 900 then
  1318. wall1width = wall1width + 5
  1319. end
  1320. end
  1321. function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SERVES
  1322. if (gameState == "1serve") then
  1323. updateTEXT = ""
  1324. if (gameMode ~= "practice") then
  1325. TEXT = "PLAYER 1, serve!(q)"
  1326. end
  1327. if (love.keyboard.isDown("q") or gameMode == "practice") then
  1328. TEXT = "Lets Begin!"
  1329. ball_DIR = 1
  1330. for i = 1, maxBalls do
  1331. ball[i]:reset(i)
  1332. end
  1333. gameState = "play"
  1334. globalState = "base"
  1335. end
  1336. end
  1337. if (gameState == "2serve") then
  1338. TEXT = "PLAYER 2, serve!(p)"
  1339. if (AGAINST_AI == 1) then
  1340. TEXT = ""
  1341. ball_DIR = -1
  1342. for i = 1, maxBalls do
  1343. ball[i]:reset(i)
  1344. end
  1345. gameState = "play"
  1346. globalState = "base"
  1347. end
  1348. if (love.keyboard.isDown("p") and AGAINST_AI == 0) then
  1349. TEXT = "Lets Begin"
  1350. ball_DIR = -1
  1351. for i = 1, maxBalls do
  1352. ball[i]:reset(i)
  1353. end
  1354. --love.window.setTitle("An atttttttt")
  1355. gameState = "play"
  1356. globalState = "base"
  1357. end
  1358. end
  1359. end
  1360. function mapChanger()
  1361. for i = 1, maxBalls do
  1362. if (gameState == "editor") then
  1363. MAP_TYPE = 2
  1364. end
  1365. if (MAP_TYPE > 2) then
  1366. MAP_TYPE = 0
  1367. end
  1368. if (gameMode == "practice") then
  1369. MAP_TYPE = 0
  1370. if ball[i].x > VIRTUAL_WIDTH * 0.99 then
  1371. soundtype = love.math.random(1, 5)
  1372. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1373. sounds["wallhit"]:play()
  1374. if (ball[i].dx > 0) then
  1375. ball[i].x = ball[i].x - 20
  1376. else
  1377. ball[i].x = ball[i].x + 20
  1378. end
  1379. ball[i].dx = -ball[i].dx
  1380. end
  1381. end
  1382. if (MAP_TYPE == 1) then
  1383. if
  1384. ball[i].y < VIRTUAL_HEIGHT * 0.3 and ball[i].x > VIRTUAL_WIDTH * 0.5 and
  1385. ball[i].x < VIRTUAL_WIDTH * 0.5 + 5
  1386. then
  1387. soundtype = love.math.random(1, 5)
  1388. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1389. sounds["wallhit"]:play()
  1390. if (ball[i].dx > 0) then
  1391. ball[i].x = ball[i].x - 20
  1392. else
  1393. ball[i].x = ball[i].x + 20
  1394. end
  1395. ball[i].dx = -ball[i].dx
  1396. end
  1397. if
  1398. ball[i].y > VIRTUAL_HEIGHT * 0.7 and ball[i].x > VIRTUAL_WIDTH * 0.5 and
  1399. ball[i].x < VIRTUAL_WIDTH * 0.5 + 5
  1400. then
  1401. soundtype = love.math.random(1, 5)
  1402. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1403. sounds["wallhit"]:play()
  1404. if (ball[i].dx > 0) then
  1405. ball[i].x = ball[i].x - 20
  1406. else
  1407. ball[i].x = ball[i].x + 20
  1408. end
  1409. ball[i].dx = -ball[i].dx
  1410. end
  1411. end
  1412. if (MAP_TYPE == 2) then
  1413. for i, wall in ipairs(walls) do
  1414. if
  1415. (ball[1].y > wall.wally and ball[1].y < wall.wally + wall.wallheight and
  1416. ball[1].x > wall.wallx - ballSpeed / 200 and
  1417. ball[1].x < wall.wallx + 10 + ballSpeed / 200)
  1418. then
  1419. controllerSer()
  1420. soundtype = love.math.random(1, 5)
  1421. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1422. sounds["wallhit"]:play()
  1423. if (ball[1].dx > 0) then
  1424. ball[1].x = ball[1].x - 1
  1425. else
  1426. ball[1].x = ball[1].x + 1
  1427. end
  1428. ball[1].dx = -ball[1].dx
  1429. elseif
  1430. (ball[1].y > wall.wally - 15 and ball[1].y < wall.wally + wall.wallheight + 10 and
  1431. ball[1].x > wall.wallx and
  1432. ball[1].x < wall.wallx + 10)
  1433. then
  1434. controllerSer()
  1435. soundtype = love.math.random(1, 5)
  1436. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1437. sounds["wallhit"]:play()
  1438. if (ball[1].dy > 0) then
  1439. ball[1].y = ball[1].y - 1
  1440. else
  1441. ball[1].y = ball[1].y + 1
  1442. end
  1443. ball[1].dy = -ball[1].dy
  1444. end
  1445. end
  1446. end
  1447. end
  1448. end
  1449. function resolutionChanger()
  1450. if (RESOLUTION_SET > 1) then
  1451. RESOLUTION_SET = 0
  1452. end
  1453. if (RESOLUTION_SET == 0) then
  1454. if (isFullscreen == 1) then
  1455. DIFFERENCE_X = 1
  1456. DIFFERENCE_Y = 1
  1457. simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = false})
  1458. isFullscreen = 0
  1459. end
  1460. end
  1461. if (RESOLUTION_SET == 1) then
  1462. if (isFullscreen == 0) then
  1463. simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = true})
  1464. local newWidth = love.graphics.getWidth()
  1465. local newHeight = love.graphics.getHeight()
  1466. DIFFERENCE_X = VIRTUAL_WIDTH / newWidth
  1467. DIFFERENCE_Y = VIRTUAL_HEIGHT / newHeight
  1468. isFullscreen = 1
  1469. end
  1470. end
  1471. end
  1472. function resettinggenius()
  1473. maxBalls = 1
  1474. for i = 1, maxBalls do
  1475. ball[i]:reset(i)
  1476. end
  1477. paddle_SPEED = 20
  1478. nuclearanimation = 3
  1479. timeIsSlow = false
  1480. timeIsSlow2 = false
  1481. originalSpeed = 200
  1482. gameState = "menu"
  1483. globalState = "menu"
  1484. gameMode = "notpracticd"
  1485. ballSet = 200
  1486. ballSpeed = ballSet
  1487. player2.GREEN = 255
  1488. player2.BLUE = 255
  1489. player1.GREEN = 255
  1490. player1.BLUE = 255
  1491. player1score = 0
  1492. player2score = 0
  1493. potentialnuke1 = 0
  1494. potentialnuke2 = 0
  1495. striken = 0
  1496. areanuclear = 0
  1497. potentialstrike1 = 0
  1498. potentialstrike2 = 0
  1499. player1nukescore = 0
  1500. player2nukescore = 0
  1501. player1reverbav = 0
  1502. player2reverbav = 0
  1503. selecting = 0
  1504. AGAINST_AI = 0
  1505. end
  1506. function callAnimator()
  1507. love.graphics.setColor(255, 255, 255, light / 255)
  1508. love.graphics.draw(image, 0, 0)
  1509. end
  1510. function love.mousereleased(x, y, button)
  1511. love.keyboard.mouseisReleased = true
  1512. if (gameState == "editor") then
  1513. if (#walls < 1000 and button == 1 and blockinput ~= true) then
  1514. table.insert(walls, newWall(x * DIFFERENCE_X, y * DIFFERENCE_Y, 10, wall1width))
  1515. end
  1516. end
  1517. end