A pong clone, but with a twist!
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.

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