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.

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