A pong clone, but with a twist!
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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