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.

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