A pong clone, but with a twist!
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

1429 行
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. staticanimatorcounter(dt)
  682. musicController('norm', 1)
  683. if debug then
  684. displayFPS()
  685. end
  686. if globalState == "base" then
  687. basegame(dt)
  688. end
  689. if globalState == "menu" then
  690. debugCheck(dt)
  691. end
  692. if globalState == "nettest" then
  693. basegame(dt)
  694. nettest(dt)
  695. end
  696. if globalState == "clienttest" then
  697. if confirmation ~= "disconnected" then
  698. if confirmation == "up1" then lastSentKeyP2 = lastSentKeyClient lastSentKeyP1 = lastSentKey else
  699. lastSentKeyP1 = lastSentKeyClient lastSentKeyP2 = lastSentKey end
  700. clientsBaseGame(dt)
  701. end
  702. clienttest(dt)
  703. end
  704. end
  705. serverinit = false
  706. clientinit = false
  707. function nettest(dt)
  708. if serverinit == false then
  709. local socket = require('socket')
  710. udp = socket.udp()
  711. udp:setsockname('localhost', 142)
  712. udp:settimeout(0)
  713. serverinit = true
  714. end
  715. data, msg_or_ip, port_or_nil = udp:receivefrom()
  716. if data then
  717. print(data .. "FROM " .. msg_or_ip)
  718. end
  719. if data then
  720. local p = split(data, '|')
  721. lastSentKeyClient = p[1]
  722. for i = 1, maxBalls do
  723. print (tostring(ball[i].dy))
  724. 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)
  725. print("SENT: " .. lastSentKey)
  726. end
  727. end
  728. end
  729. function clienttest(dt)
  730. if clientinit == false then
  731. local socket = require "socket"
  732. local address, port = "45.76.95.31", 12345
  733. udp = socket.udp()
  734. udp:setpeername(address, port)
  735. udp:settimeout(0)
  736. clientinit = true
  737. end
  738. udp:send(tostring(lastSentKey))
  739. print(lastSentKey)
  740. data = udp:receive()
  741. print(data)
  742. if data then
  743. local p = split(data, '|')
  744. for i = 1, maxBalls do
  745. local die = tonumber(p[2])
  746. print(p[2])
  747. print(p[2] + 0)
  748. 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]
  749. end
  750. end
  751. end
  752. function wallbreaker(x, y)
  753. if (gameState == "editor") then
  754. for i, wall in ipairs(walls) do
  755. if math.abs(wall.wallx - x) < 10 and math.abs(wall.wally - y) < 10 then
  756. table.remove(walls, i)
  757. end
  758. end
  759. end
  760. end
  761. function hardmanager(diff)
  762. selecting = 1
  763. if (diff == "easy") then
  764. INDIC[1] = ">"
  765. AGAINST_AI = 1
  766. AI_SPEED = ballSet / 10
  767. AI_STRIKEMOD = 100
  768. AI_NUKEMOD = 1000
  769. AI_LEVEL = 350
  770. difficultyl = 200
  771. selecting = 0
  772. gameState = "1serve"
  773. globalState = "base"
  774. end
  775. if (diff == "normal") then
  776. INDIC[2] = ">"
  777. AI_SPEED = ballSet / 10
  778. AI_LEVEL = 500
  779. AI_NUKEMOD = 250
  780. AI_STRIKEMOD = 60
  781. AGAINST_AI = 1
  782. difficultyl = 300
  783. selecting = 0
  784. gameState = "1serve"
  785. globalState = "base"
  786. end
  787. if (diff == "hard") then
  788. INDIC[3] = ">"
  789. AI_SPEED = ballSpeed * 1.1 + 50
  790. AI_SPEED = AI_SPEED / 10
  791. AI_LEVEL = 700
  792. AI_NUKEMOD = 200
  793. AI_STRIKEMOD = 20
  794. selecting = 0
  795. difficultyl = 350
  796. AGAINST_AI = 1
  797. gameState = "1serve"
  798. globalState = "base"
  799. end
  800. if (diff == "smart") then
  801. INDIC[3] = ">"
  802. AI_SPEED = ballSpeed * 1.1 + 50
  803. AI_SPEED = AI_SPEED / 10
  804. AI_LEVEL = 1500
  805. AI_NUKEMOD = 200
  806. AI_STRIKEMOD = 20
  807. selecting = 0
  808. difficultyl = 350
  809. AGAINST_AI = 1
  810. gameState = "1serve"
  811. globalState = "base"
  812. end
  813. if (diff == "practice") then
  814. INDIC[3] = ">"
  815. AI_SPEED = ballSpeed * 500 + 50
  816. AI_SPEED = AI_SPEED / 10
  817. AI_LEVEL = 700
  818. AI_NUKEMOD = 9000000000
  819. AI_STRIKEMOD = 90000000
  820. selecting = 0
  821. difficultyl = 350
  822. AGAINST_AI = 1
  823. gameState = "base"
  824. end
  825. end
  826. function dangerChecker() --CHECK IF CONTROLS ARE DUPLICATING
  827. if (p1control.up == p1control.down) then
  828. danger = "1up"
  829. danger2 = "1down"
  830. elseif (p1control.up == p1control.super) then
  831. danger = "1up"
  832. danger2 = "1special"
  833. elseif (p1control.up == p1control.counter) then
  834. danger = "1up"
  835. danger2 = "1ct"
  836. elseif (p1control.down == p1control.super) then
  837. danger = "1down"
  838. danger2 = "1special"
  839. elseif (p1control.down == p1control.counter) then
  840. danger = "1ct"
  841. danger2 = "1down"
  842. elseif (p1control.super == p1control.counter) then
  843. danger = "1special"
  844. danger2 = "1ct"
  845. elseif (p2control.down == p2control.up) then
  846. danger = "2down"
  847. danger2 = "2up"
  848. elseif (p2control.down == p2control.super) then
  849. danger = "2down"
  850. danger2 = "2special"
  851. elseif (p2control.down == p2control.counter) then
  852. danger = "2down"
  853. danger2 = "2ct"
  854. elseif (p2control.up == p2control.super) then
  855. danger = "2up"
  856. danger2 = "2special"
  857. elseif (p2control.up == p2control.counter) then
  858. danger = "2ct"
  859. danger2 = "2up"
  860. elseif (p2control.super == p2control.counter) then
  861. danger = "2special"
  862. danger2 = "2ct"
  863. else
  864. danger = "none"
  865. danger2 = "none"
  866. end
  867. end
  868. function love.keypressed(key)
  869. lastSentKey = key
  870. if gameState == "assign" then
  871. if (req == "p1up") then
  872. p1control.up = key
  873. currentKey = key
  874. --love.window.setTitle(key)
  875. gameState = "controlSettings"
  876. end
  877. if (req == "p2up") then
  878. p2control.up = key
  879. currentKey = key
  880. --love.window.setTitle(key)
  881. gameState = "controlSettings"
  882. end
  883. if (req == "p1down") then
  884. p1control.down = key
  885. currentKey = key
  886. --love.window.setTitle(key)
  887. gameState = "controlSettings"
  888. end
  889. if (req == "p2down") then
  890. p2control.down = key
  891. currentKey = key
  892. -- love.window.setTitle(key)
  893. gameState = "controlSettings"
  894. end
  895. if (req == "p1super") then
  896. p1control.super = key
  897. currentKey = key
  898. -- love.window.setTitle(key)
  899. gameState = "controlSettings"
  900. end
  901. if (req == "p2super") then
  902. p2control.super = key
  903. currentKey = key
  904. -- love.window.setTitle(key)
  905. gameState = "controlSettings"
  906. end
  907. if (req == "p1ct") then
  908. p1control.counter = key
  909. currentKey = key
  910. -- love.window.setTitle(key)
  911. gameState = "controlSettings"
  912. end
  913. if (req == "p2ct") then
  914. p2control.counter = key
  915. currentKey = key
  916. --love.window.setTitle(key)
  917. gameState = "controlSettings"
  918. end
  919. end
  920. if key == "escape" then
  921. TEXT = "Escape Key"
  922. love.event.quit()
  923. elseif key == "enter" or key == "return" then
  924. if gameState == "start" then
  925. resettinggenius()
  926. gameState = "menu"
  927. globalState = "menu"
  928. hardmanager()
  929. elseif (gameState == "done") then
  930. if (player1score > player2score) then
  931. gameState = "2serve"
  932. potentialnuke1 = 0
  933. potentialnuke2 = 0
  934. striken = 0
  935. if (nuckemodactive == 0) then
  936. areanuclear = 0
  937. nuclearanimation = 3
  938. end
  939. potentialstrike1 = 0
  940. potentialstrike2 = 0
  941. player1nukescore = 0
  942. player2nukescore = 0
  943. else
  944. gameState = "1serve"
  945. resettinggenius()
  946. for i = 1, maxBalls do
  947. ball[i]:reset(i)
  948. end
  949. end
  950. else
  951. gameState = "menu"
  952. globalState = "menu"
  953. if (love.math.random(0, 10) == 1) then
  954. TEXT = "Nuclear Ching Chong"
  955. else
  956. TEXT = "Nuclear Pong"
  957. end
  958. resettinggenius()
  959. for i = 1, maxBalls do
  960. ball[i]:reset(i)
  961. end
  962. end
  963. end
  964. end
  965. function love.keyreleased(key)
  966. currentKey = " "
  967. if lastSentKey == key then
  968. lastSentKey = "g"
  969. end
  970. end
  971. function speedSetter(requesttype)
  972. if (requesttype == "ball") then
  973. if (ballSet > 550) then
  974. ballSet = 0
  975. paddle_SPEED = 0
  976. else
  977. ballSet = ballSet + 50
  978. paddle_SPEED = paddle_SPEED + 5
  979. end
  980. ballSpeed = ballSet
  981. end
  982. if (requesttype == "snc") then
  983. synctype = synctype + 1
  984. if (synctype > 1) then
  985. synctype = 0
  986. end
  987. if synctype == 0 then
  988. synctext = "Independent"
  989. end
  990. if synctype == 1 then
  991. synctext = "Synchronised"
  992. end
  993. end
  994. if (requesttype == "nuclearmod") then
  995. nuckemodactive = nuckemodactive + 1
  996. if (nuckemodactive > 1) then
  997. nuckemodactive = 0
  998. end
  999. if (nuckemodactive == 0) then
  1000. areanuclear = 0
  1001. nuclearanimation = 3
  1002. ballSet = 200
  1003. TEXT = "Nuclear Pong"
  1004. synctype = 0
  1005. maxspeed = 700
  1006. synctext = "Independent"
  1007. paddle_SPEED = ballSet / 10
  1008. AI_SPEED = ballSet / 10
  1009. end
  1010. if (nuckemodactive == 1) then
  1011. areanuclear = 1
  1012. ballSet = 2000
  1013. maxspeed = 2000
  1014. paddle_SPEED = ballSet / 10
  1015. AI_SPEED = ballSet / 10
  1016. synctext = "death is imminent"
  1017. end
  1018. ballSpeed = ballSet
  1019. end
  1020. if (requesttype == "practice") then
  1021. if (ballSpeed > 999) then
  1022. ballSpeed = 200
  1023. ballSet = 200
  1024. end
  1025. if (ballSpeed > 799) then
  1026. prtext = "Insane"
  1027. maxBalls = 5
  1028. elseif ballSpeed > 599 then
  1029. prtext = "Hard"
  1030. maxBalls = 4
  1031. elseif ballSpeed > 399 then
  1032. prtext = "Normal"
  1033. maxBalls = 3
  1034. elseif ballSpeed > 199 then
  1035. prtext = "Easy"
  1036. maxBalls = 3
  1037. end
  1038. ballSpeed = ballSpeed + 200
  1039. ballSet = ballSet + 200
  1040. end
  1041. if (requesttype == "reset") then
  1042. ballSpeed = 200
  1043. ballSet = 200
  1044. synctype = 0
  1045. prtext = "Easy"
  1046. maxBalls = 1
  1047. end
  1048. if (requesttype == "pc") then
  1049. if (playerCount == 2) then
  1050. playerCount = 1
  1051. playertext = "1v1"
  1052. elseif (playerCount == 1) then
  1053. playerCount = playerCount + 1
  1054. player3.x = player1.x + VIRTUAL_WIDTH / 2
  1055. player3.y = player3.y
  1056. playertext = "2v2"
  1057. end
  1058. end
  1059. if (requesttype == "ballz") then
  1060. if (maxBalls > 1) then
  1061. --love.window.setTitle("more than 4")
  1062. maxBalls = 1
  1063. else
  1064. maxBalls = maxBalls + 1
  1065. end
  1066. end
  1067. if requesttype == "ptw" then
  1068. if ptw == 10 then
  1069. ptw = 1
  1070. else
  1071. ptw = ptw + 1
  1072. end
  1073. end
  1074. end
  1075. function gameModeChanger()
  1076. if (gameState == "gameMode") then
  1077. local button_width = VIRTUAL_WIDTH * (1 / 3)
  1078. local BUTTON_HEIGHT = 50
  1079. local margin = 20
  1080. local hot = false
  1081. local cursor_y = 0
  1082. local total_height = (BUTTON_HEIGHT + margin) * #buttons
  1083. for i, button in ipairs(modeSelectorButtons) do
  1084. button.last = button.now
  1085. local bx = (VIRTUAL_WIDTH * 0.5) - (button_width * 0.5)
  1086. local by = (VIRTUAL_HEIGHT * 0.5) - (total_height * 0.5) + cursor_y
  1087. local color = {255, 255, 255, 255}
  1088. local mx, my = love.mouse.getPosition()
  1089. mx = mx * DIFFERENCE_X
  1090. my = my * DIFFERENCE_Y
  1091. hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
  1092. if (hot == i) then
  1093. color = {10, 10, 0, 255}
  1094. end
  1095. button.now = love.mouse.isDown(1)
  1096. if button.now and not button.last and hot == i then
  1097. love.graphics.setColor(0, 0, 0, 1)
  1098. love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
  1099. sounds["wallhit"]:play()
  1100. button.fn()
  1101. end
  1102. love.graphics.setColor(unpack(color))
  1103. love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT)
  1104. love.graphics.setColor(0, 0, 0, 255)
  1105. local textW = smallfont:getWidth(button.text)
  1106. local textH = smallfont:getHeight(button.text)
  1107. love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1108. love.graphics.setColor(255, 255, 255, 255)
  1109. cursor_y = cursor_y + (BUTTON_HEIGHT + margin)
  1110. end
  1111. end
  1112. if (gameState == "multiMode") then
  1113. local button_width = VIRTUAL_WIDTH * (1 / 3)
  1114. local BUTTON_HEIGHT = 50
  1115. local margin = 20
  1116. local hot = false
  1117. local cursor_y = 0
  1118. local total_height = (BUTTON_HEIGHT + margin) * #buttons
  1119. for i, button in ipairs(playerCountButtons) do
  1120. button.last = button.now
  1121. local bx = (VIRTUAL_WIDTH * 0.5) - (button_width * 0.5)
  1122. local by = (VIRTUAL_HEIGHT * 0.3) - (total_height * 0.5) + cursor_y
  1123. if (button.text == "Play") then
  1124. by = by + by / 1.8
  1125. end
  1126. local color = {255, 255, 255, 255}
  1127. local mx, my = love.mouse.getPosition()
  1128. mx = mx * DIFFERENCE_X
  1129. my = my * DIFFERENCE_Y
  1130. hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
  1131. if (hot == i) then
  1132. if (button.text == "Play") then
  1133. color = {0 / 255, 255 / 255, 0 / 255, 255}
  1134. else
  1135. color = {10, 10, 0, 255}
  1136. end
  1137. end
  1138. button.now = love.mouse.isDown(1)
  1139. if button.now and not button.last and hot == i then
  1140. love.graphics.setColor(0, 0, 0, 1)
  1141. love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
  1142. sounds["wallhit"]:play()
  1143. if button.text == "Ball Speed: " and nuckemodactive == 1 then
  1144. else
  1145. button.fn()
  1146. end
  1147. end
  1148. love.graphics.setColor(unpack(color))
  1149. love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT)
  1150. love.graphics.setColor(0, 0, 0, 255)
  1151. local textW = smallfont:getWidth(button.text)
  1152. local textH = smallfont:getHeight(button.text)
  1153. if (button.text == "1v1") then
  1154. love.graphics.print(playertext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1155. elseif button.text == "snc" then
  1156. if (nuckemodactive == 1) then
  1157. love.graphics.setColor(1, 0, 0, 1)
  1158. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1159. love.graphics.setColor(1, 1, 1, 1)
  1160. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1161. love.graphics.setColor(0, 0, 0, 1)
  1162. else
  1163. --
  1164. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.45 - textW * 0.5, by + textH * 0.5)
  1165. end
  1166. elseif (button.text == "ballCount") then
  1167. love.graphics.print(
  1168. "Ball Count: " .. maxBalls,
  1169. smallfont,
  1170. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1171. by + textH * 0.5
  1172. )
  1173. elseif (button.text == "Ball Speed: ") then
  1174. if (nuckemodactive == 1) then
  1175. love.graphics.setColor(1, 0, 0, 1)
  1176. love.graphics.print(
  1177. "shaitan machina",
  1178. smallfont,
  1179. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1180. by + textH * 0.5
  1181. )
  1182. love.graphics.setColor(1, 1, 1, 1)
  1183. love.graphics.print(
  1184. "shaitan machina",
  1185. smallfont,
  1186. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1187. by + textH * 0.5
  1188. )
  1189. love.graphics.setColor(0, 0, 0, 1)
  1190. else
  1191. love.graphics.print(
  1192. button.text .. ballSet,
  1193. smallfont,
  1194. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1195. by + textH * 0.5
  1196. )
  1197. end
  1198. elseif button.text == "ptw" then
  1199. love.graphics.print(
  1200. "Points to Win: " .. ptw,
  1201. smallfont,
  1202. VIRTUAL_WIDTH * 0.5 - textW * 1.5,
  1203. by + textH * 0.5
  1204. )
  1205. else
  1206. love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1207. end
  1208. love.graphics.setColor(255, 255, 255, 255)
  1209. cursor_y = cursor_y + (BUTTON_HEIGHT + margin)
  1210. end
  1211. end
  1212. end
  1213. function love.draw()
  1214. simpleScale.set()
  1215. baseDraw()
  1216. simpleScale.unSet()
  1217. end
  1218. --Check if controls are duplicating
  1219. function controllerSer()
  1220. for i = 1, maxBalls do
  1221. if (ball[i].dy == 0) then
  1222. hitNum[i] = hitNum[i] + 1
  1223. if hitNum[i] >= 10 then
  1224. ball[i].dy = 1
  1225. hitNum[i] = 0
  1226. end
  1227. else
  1228. hitNum[i] = 0
  1229. end
  1230. end
  1231. end
  1232. function palleteController() --!!!!LEGACY CODE, MIGRATED TO Paddle.lua!!!!
  1233. if (areanuclear == 0) then
  1234. player1.RED = 1
  1235. player1.GREEN = 1
  1236. player1.BLUE = 1
  1237. end
  1238. if (areanuclear == 0) then
  1239. player2.RED = 1
  1240. player2.GREEN = 1
  1241. player2.BLUE = 1
  1242. end
  1243. if (areanuclear == 1) then
  1244. player1.RED = 0
  1245. player1.GREEN = 0
  1246. player1.BLUE = 0
  1247. end
  1248. if (areanuclear == 1) then
  1249. player2.RED = 0
  1250. player2.GREEN = 0
  1251. player2.BLUE = 0
  1252. end
  1253. end
  1254. function love.wheelmoved(x, y)
  1255. if (y < 0 and wall1width > 0) then
  1256. wall1width = wall1width - 5
  1257. elseif y > 0 and wall1width < 900 then
  1258. wall1width = wall1width + 5
  1259. end
  1260. end
  1261. function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SERVES
  1262. --print("servebot called")
  1263. if (gameState == "1serve") then
  1264. updateTEXT = ""
  1265. if (gameMode ~= "practice") then
  1266. TEXT = "PLAYER 1, serve!(q)"
  1267. end
  1268. 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
  1269. TEXT = "Lets Begin!"
  1270. ball_DIR = 1
  1271. for i = 1, maxBalls do
  1272. ball[i]:reset(i)
  1273. end
  1274. gameState = "play"
  1275. end
  1276. end
  1277. if (gameState == "2serve") then
  1278. TEXT = "PLAYER 2, serve!(p)"
  1279. if (AGAINST_AI == 1) then
  1280. TEXT = ""
  1281. ball_DIR = -1
  1282. for i = 1, maxBalls do
  1283. ball[i]:reset(i)
  1284. end
  1285. gameState = "play"
  1286. end
  1287. if (((confirmation == "up1" and lastSentKeyP2 == "p") or ((globalState ~= "clienttest" or confirmation == "up2") and love.keyboard.isDown("p")))and AGAINST_AI == 0) then
  1288. TEXT = "Lets Begin"
  1289. ball_DIR = -1
  1290. for i = 1, maxBalls do
  1291. ball[i]:reset(i)
  1292. end
  1293. --love.window.setTitle("An atttttttt")
  1294. gameState = "play"
  1295. end
  1296. end
  1297. end
  1298. function mapChanger()
  1299. if (gameState == "editor") then
  1300. MAP_TYPE = 2
  1301. end
  1302. if (MAP_TYPE > 2) then
  1303. MAP_TYPE = 0
  1304. end
  1305. end
  1306. function resolutionChanger()
  1307. if (RESOLUTION_SET > 1) then
  1308. RESOLUTION_SET = 0
  1309. end
  1310. if (RESOLUTION_SET == 0) then
  1311. if (isFullscreen == 1) then
  1312. DIFFERENCE_X = 1
  1313. DIFFERENCE_Y = 1
  1314. simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = false})
  1315. isFullscreen = 0
  1316. end
  1317. end
  1318. if (RESOLUTION_SET == 1) then
  1319. if (isFullscreen == 0) then
  1320. simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = true})
  1321. local newWidth = love.graphics.getWidth()
  1322. local newHeight = love.graphics.getHeight()
  1323. DIFFERENCE_X = VIRTUAL_WIDTH / newWidth
  1324. DIFFERENCE_Y = VIRTUAL_HEIGHT / newHeight
  1325. isFullscreen = 1
  1326. end
  1327. end
  1328. end
  1329. function resettinggenius()
  1330. maxBalls = 1
  1331. for i = 1, maxBalls do
  1332. ball[i]:reset(i)
  1333. end
  1334. paddle_SPEED = 20
  1335. nuclearanimation = 3
  1336. timeIsSlow = false
  1337. timeIsSlow2 = false
  1338. originalSpeed = 200
  1339. gameState = "menu"
  1340. globalState = "menu"
  1341. gameMode = "normal"
  1342. player1.height = 100
  1343. player2.height = 100
  1344. ballSet = 200
  1345. ballSpeed = ballSet
  1346. player2.GREEN = 255
  1347. player2.BLUE = 255
  1348. player1.GREEN = 255
  1349. player1.BLUE = 255
  1350. player1score = 0
  1351. player2score = 0
  1352. potentialnuke1 = 0
  1353. potentialnuke2 = 0
  1354. striken = 0
  1355. areanuclear = 0
  1356. potentialstrike1 = 0
  1357. potentialstrike2 = 0
  1358. player1nukescore = 0
  1359. player2nukescore = 0
  1360. player1reverbav = 0
  1361. player2reverbav = 0
  1362. selecting = 0
  1363. AGAINST_AI = 0
  1364. end
  1365. function love.mousereleased(x, y, button)
  1366. love.keyboard.mouseisReleased = true
  1367. if (gameState == "editor") then
  1368. if (#walls < 1000 and button == 1 and blockinput ~= true) then
  1369. table.insert(walls, newWall(x * DIFFERENCE_X, y * DIFFERENCE_Y, 10, wall1width))
  1370. end
  1371. end
  1372. end
  1373. function ballsAlive()
  1374. for i = 1, maxBalls do
  1375. if ball[i].disabled == false then
  1376. print("Ball " .. i .. " is not disabled")
  1377. return true
  1378. end
  1379. end
  1380. return false
  1381. end
  1382. function split(s, delimiter)
  1383. result = {}
  1384. for match in (s..delimiter):gmatch("(.-)"..delimiter) do
  1385. table.insert(result, match)
  1386. end
  1387. return result
  1388. end