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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286
  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 = 2
  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. "Nuclear Practice",
  445. function()
  446. gameState = "prdiff"
  447. end
  448. )
  449. )
  450. table.insert(
  451. modeSelectorButtons,
  452. newButton(
  453. "Main Menu",
  454. function()
  455. gameState = "menu"
  456. end
  457. )
  458. )
  459. table.insert(
  460. pracdiff,
  461. newButton(
  462. "Silverblade",
  463. function()
  464. speedSetter("practice")
  465. end
  466. )
  467. )
  468. table.insert(
  469. pracdiff,
  470. newButton(
  471. "Return",
  472. function()
  473. speedSetter("reset")
  474. gameState = "gameMode"
  475. end
  476. )
  477. )
  478. table.insert(
  479. pracdiff,
  480. newButton(
  481. "Go!",
  482. function()
  483. gameMode = "practice"
  484. hardmanager("practice")
  485. end
  486. )
  487. )
  488. --table.insert(playerCountButtons, newButton("1v1", function() speedSetter('pc') end))
  489. table.insert(
  490. playerCountButtons,
  491. newButton(
  492. "ballCount",
  493. function()
  494. speedSetter("ballz")
  495. end
  496. )
  497. )
  498. table.insert(
  499. playerCountButtons,
  500. newButton(
  501. "Return",
  502. function()
  503. speedSetter("reset")
  504. gameState = "menu"
  505. end
  506. )
  507. )
  508. table.insert(
  509. playerCountButtons,
  510. newButton(
  511. "ptw",
  512. function()
  513. speedSetter("ptw")
  514. end
  515. )
  516. )
  517. table.insert(
  518. playerCountButtons,
  519. newButton(
  520. "Play",
  521. function()
  522. AGAINST_AI = 0
  523. gameState = "1serve"
  524. end
  525. )
  526. )
  527. --table.insert(speedParameters, newButton("Ball Speed: ", function() speedSetter() end))
  528. love.window.setTitle("NUCLEAR PONG")
  529. textphrases = {
  530. "Amazing",
  531. "Superb",
  532. "Absolutely beautiful!",
  533. "Awesome",
  534. "Look at That!",
  535. "Great",
  536. "Nice",
  537. "Boom!",
  538. "Dangerous!",
  539. "Astonishing!",
  540. "u/ebernerd saved me",
  541. "Absolutely Wonderful!",
  542. "Exsquisite",
  543. "Delicate",
  544. "Pow!",
  545. "Great Hit",
  546. "all hail nazarbayev"
  547. }
  548. sounds = {
  549. ["updateMusic"] = love.audio.newSource("audio/theme1.mp3", "static"),
  550. ["gayTheme"] = love.audio.newSource("audio/theme2.mp3", "static"),
  551. ["gayTheme2"] = love.audio.newSource("audio/theme3.mp3", "static"),
  552. ["gayTheme3"] = love.audio.newSource("audio/theme4.mp3", "static"),
  553. ["beep"] = love.audio.newSource("audio/hit1.mp3", "static"),
  554. ["wallhit"] = love.audio.newSource("audio/hit2.wav", "static"),
  555. ["win"] = love.audio.newSource("win.wav", "static"),
  556. ["score"] = love.audio.newSource("audio/score.wav", "static"),
  557. ["nuke"] = love.audio.newSource("audio/bomb.wav", "static"),
  558. ["striking"] = love.audio.newSource("audio/superhit.wav", "static"),
  559. ["nuclearhit"] = love.audio.newSource("audio/hit1.mp3", "static"),
  560. ["time"] = love.audio.newSource("audio/time.wav", "static")
  561. }
  562. love.graphics.setDefaultFilter("nearest", "nearest")
  563. --comic sans lmao
  564. math.randomseed(os.time())
  565. smallfont = love.graphics.newFont("font.ttf", 25)
  566. scorefont = love.graphics.newFont("font.ttf", 60)
  567. love.graphics.setFont(smallfont)
  568. --push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
  569. -- fullscreen = isFullscreen,
  570. -- resizable = true,
  571. -- vsync = true,
  572. --})
  573. player1score = 0
  574. player2score = 0
  575. areanuclear = 0
  576. player1nukescore = 0
  577. player2nukescore = 0
  578. striken = 0
  579. soundtype = 1
  580. soundturn = 1
  581. potentialstrike1 = 0
  582. potentialstrike2 = 0
  583. potentialnuke1 = 0
  584. potentialnuke2 = 0
  585. player1striken = 0
  586. player2striken = 0
  587. randomtext = 0
  588. selecting = 0
  589. number = 0
  590. elec = 1
  591. INDIC = {
  592. "",
  593. "",
  594. "",
  595. ""
  596. }
  597. --playe1nuke
  598. player1 = paddle(0, 30, 10, 100, 1)
  599. player2 = paddle(VIRTUAL_WIDTH * 0.99, VIRTUAL_HEIGHT * 0.88, 10, 100, 2)
  600. player3 = paddle(5000, 5000, 10, 100)
  601. player4 = paddle(5000, 5000, 10, 100)
  602. ball = {}
  603. ball[1] = eball(VIRTUAL_WIDTH / 2, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  604. ball[2] = eball(VIRTUAL_WIDTH / 1.9, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  605. ball[3] = eball(VIRTUAL_WIDTH / 1.8, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  606. ball[4] = eball(VIRTUAL_WIDTH / 2.2, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  607. ball[5] = eball(VIRTUAL_WIDTH / 2.1, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
  608. myscreen = fullScreener(RESOLUTION_SET, isFullscreen, DIFFERENCE_X, DIFFERENCE_Y)
  609. mymenu = mainMenu()
  610. ballSpeed = 200
  611. ballDX = math.random(2) == 1 and 100 or -100
  612. ballDY = math.random(-50, 50)
  613. gameState = "animation"
  614. end
  615. t = 0
  616. shakeDuration = 0
  617. shakeMagnitude = 1
  618. function startShake(duration, magnitude)
  619. t, shakeDuration, shakeMagnitude = 0, duration or 1, magnitude or 5
  620. end
  621. function displayFPS()
  622. --love.window.setTitle(love.timer.getFPS())
  623. love.window.setTitle(gameState .. " " .. gameMode .. " " .. globalState .. " " .. MAP_TYPE)
  624. if love.keyboard.isDown("space") then
  625. player1nukescore = 200
  626. player1score = 9
  627. player2score = 9
  628. end
  629. end
  630. function speedControl()
  631. if (ballSpeed > maxspeed and gameState == "play") then
  632. ballSpeed = maxspeed
  633. end
  634. end
  635. function love.update(dt)
  636. staticanimatorcounter(dt)
  637. if debug then
  638. displayFPS()
  639. end
  640. if globalState == "base" then
  641. basegame(dt)
  642. end
  643. if globalState == "menu" then
  644. debugCheck(dt)
  645. end
  646. end
  647. function wallbreaker(x, y)
  648. if (gameState == "editor") then
  649. for i, wall in ipairs(walls) do
  650. if math.abs(wall.wallx - x) < 10 and math.abs(wall.wally - y) < 10 then
  651. table.remove(walls, i)
  652. end
  653. end
  654. end
  655. end
  656. function hardmanager(diff)
  657. selecting = 1
  658. if (diff == "easy") then
  659. INDIC[1] = ">"
  660. AGAINST_AI = 1
  661. AI_SPEED = ballSet / 10
  662. AI_STRIKEMOD = 100
  663. AI_NUKEMOD = 1000
  664. difficultyl = 200
  665. selecting = 0
  666. gameState = "1serve"
  667. globalState = "base"
  668. end
  669. if (diff == "normal") then
  670. INDIC[2] = ">"
  671. AI_SPEED = ballSet / 10
  672. AI_LEVEL = 500
  673. AI_NUKEMOD = 250
  674. AI_STRIKEMOD = 60
  675. AGAINST_AI = 1
  676. difficultyl = 300
  677. selecting = 0
  678. gameState = "1serve"
  679. globalState = "base"
  680. end
  681. if (diff == "hard") then
  682. INDIC[3] = ">"
  683. AI_SPEED = ballSpeed * 1.1 + 50
  684. AI_SPEED = AI_SPEED / 10
  685. AI_LEVEL = 700
  686. AI_NUKEMOD = 200
  687. AI_STRIKEMOD = 20
  688. selecting = 0
  689. difficultyl = 350
  690. AGAINST_AI = 1
  691. gameState = "1serve"
  692. globalState = "base"
  693. end
  694. if (diff == "practice") then
  695. INDIC[3] = ">"
  696. AI_SPEED = ballSpeed * 500 + 50
  697. AI_SPEED = AI_SPEED / 10
  698. AI_LEVEL = 700
  699. AI_NUKEMOD = 9000000000
  700. AI_STRIKEMOD = 90000000
  701. selecting = 0
  702. difficultyl = 350
  703. AGAINST_AI = 1
  704. gameState = "base"
  705. end
  706. end
  707. function dangerChecker() --CHECK IF CONTROLS ARE DUPLICATING
  708. if (p1control.up == p1control.down) then
  709. danger = "1up"
  710. danger2 = "1down"
  711. elseif (p1control.up == p1control.super) then
  712. danger = "1up"
  713. danger2 = "1special"
  714. elseif (p1control.up == p1control.counter) then
  715. danger = "1up"
  716. danger2 = "1ct"
  717. elseif (p1control.down == p1control.super) then
  718. danger = "1down"
  719. danger2 = "1special"
  720. elseif (p1control.down == p1control.counter) then
  721. danger = "1ct"
  722. danger2 = "1down"
  723. elseif (p1control.super == p1control.counter) then
  724. danger = "1special"
  725. danger2 = "1ct"
  726. elseif (p2control.down == p2control.up) then
  727. danger = "2down"
  728. danger2 = "2up"
  729. elseif (p2control.down == p2control.super) then
  730. danger = "2down"
  731. danger2 = "2special"
  732. elseif (p2control.down == p2control.counter) then
  733. danger = "2down"
  734. danger2 = "2ct"
  735. elseif (p2control.up == p2control.super) then
  736. danger = "2up"
  737. danger2 = "2special"
  738. elseif (p2control.up == p2control.counter) then
  739. danger = "2ct"
  740. danger2 = "2up"
  741. elseif (p2control.super == p2control.counter) then
  742. danger = "2special"
  743. danger2 = "2ct"
  744. else
  745. danger = "none"
  746. danger2 = "none"
  747. end
  748. end
  749. function love.keypressed(key)
  750. if gameState == "assign" then
  751. if (req == "p1up") then
  752. p1control.up = key
  753. currentKey = key
  754. --love.window.setTitle(key)
  755. gameState = "controlSettings"
  756. end
  757. if (req == "p2up") then
  758. p2control.up = key
  759. currentKey = key
  760. --love.window.setTitle(key)
  761. gameState = "controlSettings"
  762. end
  763. if (req == "p1down") then
  764. p1control.down = key
  765. currentKey = key
  766. --love.window.setTitle(key)
  767. gameState = "controlSettings"
  768. end
  769. if (req == "p2down") then
  770. p2control.down = key
  771. currentKey = key
  772. -- love.window.setTitle(key)
  773. gameState = "controlSettings"
  774. end
  775. if (req == "p1super") then
  776. p1control.super = key
  777. currentKey = key
  778. -- love.window.setTitle(key)
  779. gameState = "controlSettings"
  780. end
  781. if (req == "p2super") then
  782. p2control.super = key
  783. currentKey = key
  784. -- love.window.setTitle(key)
  785. gameState = "controlSettings"
  786. end
  787. if (req == "p1ct") then
  788. p1control.counter = key
  789. currentKey = key
  790. -- love.window.setTitle(key)
  791. gameState = "controlSettings"
  792. end
  793. if (req == "p2ct") then
  794. p2control.counter = key
  795. currentKey = key
  796. --love.window.setTitle(key)
  797. gameState = "controlSettings"
  798. end
  799. end
  800. if key == "escape" then
  801. TEXT = "Escape Key"
  802. love.event.quit()
  803. elseif key == "enter" or key == "return" then
  804. if gameState == "start" then
  805. resettinggenius()
  806. gameState = "menu"
  807. globalState = "menu"
  808. hardmanager()
  809. elseif (gameState == "done") then
  810. if (player1score > player2score) then
  811. gameState = "2serve"
  812. potentialnuke1 = 0
  813. potentialnuke2 = 0
  814. striken = 0
  815. if (nuckemodactive == 0) then
  816. areanuclear = 0
  817. nuclearanimation = 3
  818. end
  819. potentialstrike1 = 0
  820. potentialstrike2 = 0
  821. player1nukescore = 0
  822. player2nukescore = 0
  823. else
  824. gameState = "1serve"
  825. resettinggenius()
  826. for i = 1, maxBalls do
  827. ball[i]:reset(i)
  828. end
  829. end
  830. else
  831. gameState = "menu"
  832. globalState = "menu"
  833. if (love.math.random(0, 10) == 1) then
  834. TEXT = "Nuclear Ching Chong"
  835. else
  836. TEXT = "Nuclear Pong"
  837. end
  838. resettinggenius()
  839. for i = 1, maxBalls do
  840. ball[i]:reset(i)
  841. end
  842. end
  843. end
  844. end
  845. function love.keyreleased(key)
  846. currentKey = " "
  847. end
  848. function speedSetter(requesttype)
  849. if (requesttype == "ball") then
  850. if (ballSet > 550) then
  851. ballSet = 0
  852. paddle_SPEED = 0
  853. else
  854. ballSet = ballSet + 50
  855. paddle_SPEED = paddle_SPEED + 5
  856. end
  857. ballSpeed = ballSet
  858. end
  859. if (requesttype == "snc") then
  860. synctype = synctype + 1
  861. if (synctype > 1) then
  862. synctype = 0
  863. end
  864. if synctype == 0 then
  865. synctext = "Independent"
  866. end
  867. if synctype == 1 then
  868. synctext = "Synchronised"
  869. end
  870. end
  871. if (requesttype == "nuclearmod") then
  872. nuckemodactive = nuckemodactive + 1
  873. if (nuckemodactive > 1) then
  874. nuckemodactive = 0
  875. end
  876. if (nuckemodactive == 0) then
  877. areanuclear = 0
  878. nuclearanimation = 3
  879. ballSet = 200
  880. TEXT = "Nuclear Pong"
  881. synctype = 0
  882. maxspeed = 700
  883. synctext = "Independent"
  884. paddle_SPEED = ballSet / 10
  885. AI_SPEED = ballSet / 10
  886. end
  887. if (nuckemodactive == 1) then
  888. areanuclear = 1
  889. ballSet = 2000
  890. maxspeed = 2000
  891. paddle_SPEED = ballSet / 10
  892. AI_SPEED = ballSet / 10
  893. synctext = "death is imminent"
  894. end
  895. ballSpeed = ballSet
  896. end
  897. if (requesttype == "practice") then
  898. if (ballSpeed > 999) then
  899. ballSpeed = 200
  900. ballSet = 200
  901. end
  902. if (ballSpeed > 799) then
  903. prtext = "Insane"
  904. maxBalls = 5
  905. elseif ballSpeed > 599 then
  906. prtext = "Hard"
  907. maxBalls = 4
  908. elseif ballSpeed > 399 then
  909. prtext = "Normal"
  910. maxBalls = 3
  911. elseif ballSpeed > 199 then
  912. prtext = "Easy"
  913. maxBalls = 3
  914. end
  915. ballSpeed = ballSpeed + 200
  916. ballSet = ballSet + 200
  917. end
  918. if (requesttype == "reset") then
  919. ballSpeed = 200
  920. ballSet = 200
  921. synctype = 0
  922. prtext = "Easy"
  923. maxBalls = 1
  924. end
  925. if (requesttype == "pc") then
  926. if (playerCount == 2) then
  927. playerCount = 1
  928. playertext = "1v1"
  929. elseif (playerCount == 1) then
  930. playerCount = playerCount + 1
  931. player3.x = player1.x + VIRTUAL_WIDTH / 2
  932. player3.y = player3.y
  933. playertext = "2v2"
  934. end
  935. end
  936. if (requesttype == "ballz") then
  937. if (maxBalls > 1) then
  938. --love.window.setTitle("more than 4")
  939. maxBalls = 1
  940. else
  941. maxBalls = maxBalls + 1
  942. end
  943. end
  944. if requesttype == "ptw" then
  945. if ptw == 10 then
  946. ptw = 1
  947. else
  948. ptw = ptw + 1
  949. end
  950. end
  951. end
  952. function gameModeChanger()
  953. if (gameState == "gameMode") then
  954. local button_width = VIRTUAL_WIDTH * (1 / 3)
  955. local BUTTON_HEIGHT = 50
  956. local margin = 20
  957. local hot = false
  958. local cursor_y = 0
  959. local total_height = (BUTTON_HEIGHT + margin) * #buttons
  960. for i, button in ipairs(modeSelectorButtons) do
  961. button.last = button.now
  962. local bx = (VIRTUAL_WIDTH * 0.5) - (button_width * 0.5)
  963. local by = (VIRTUAL_HEIGHT * 0.5) - (total_height * 0.5) + cursor_y
  964. local color = {255, 255, 255, 255}
  965. local mx, my = love.mouse.getPosition()
  966. mx = mx * DIFFERENCE_X
  967. my = my * DIFFERENCE_Y
  968. hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
  969. if (hot == i) then
  970. color = {10, 10, 0, 255}
  971. end
  972. button.now = love.mouse.isDown(1)
  973. if button.now and not button.last and hot == i then
  974. love.graphics.setColor(0, 0, 0, 1)
  975. love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
  976. sounds["wallhit"]:play()
  977. button.fn()
  978. end
  979. love.graphics.setColor(unpack(color))
  980. love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT)
  981. love.graphics.setColor(0, 0, 0, 255)
  982. local textW = smallfont:getWidth(button.text)
  983. local textH = smallfont:getHeight(button.text)
  984. love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  985. love.graphics.setColor(255, 255, 255, 255)
  986. cursor_y = cursor_y + (BUTTON_HEIGHT + margin)
  987. end
  988. end
  989. if (gameState == "multiMode") then
  990. local button_width = VIRTUAL_WIDTH * (1 / 3)
  991. local BUTTON_HEIGHT = 50
  992. local margin = 20
  993. local hot = false
  994. local cursor_y = 0
  995. local total_height = (BUTTON_HEIGHT + margin) * #buttons
  996. for i, button in ipairs(playerCountButtons) do
  997. button.last = button.now
  998. local bx = (VIRTUAL_WIDTH * 0.5) - (button_width * 0.5)
  999. local by = (VIRTUAL_HEIGHT * 0.3) - (total_height * 0.5) + cursor_y
  1000. if (button.text == "Play") then
  1001. by = by + by / 1.8
  1002. end
  1003. local color = {255, 255, 255, 255}
  1004. local mx, my = love.mouse.getPosition()
  1005. mx = mx * DIFFERENCE_X
  1006. my = my * DIFFERENCE_Y
  1007. hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
  1008. if (hot == i) then
  1009. if (button.text == "Play") then
  1010. color = {0 / 255, 255 / 255, 0 / 255, 255}
  1011. else
  1012. color = {10, 10, 0, 255}
  1013. end
  1014. end
  1015. button.now = love.mouse.isDown(1)
  1016. if button.now and not button.last and hot == i then
  1017. love.graphics.setColor(0, 0, 0, 1)
  1018. love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
  1019. sounds["wallhit"]:play()
  1020. if button.text == "Ball Speed: " and nuckemodactive == 1 then
  1021. else
  1022. button.fn()
  1023. end
  1024. end
  1025. love.graphics.setColor(unpack(color))
  1026. love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT)
  1027. love.graphics.setColor(0, 0, 0, 255)
  1028. local textW = smallfont:getWidth(button.text)
  1029. local textH = smallfont:getHeight(button.text)
  1030. if (button.text == "1v1") then
  1031. love.graphics.print(playertext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1032. elseif button.text == "snc" then
  1033. if (nuckemodactive == 1) then
  1034. love.graphics.setColor(1, 0, 0, 1)
  1035. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1036. love.graphics.setColor(1, 1, 1, 1)
  1037. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1038. love.graphics.setColor(0, 0, 0, 1)
  1039. else
  1040. --
  1041. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.45 - textW * 0.5, by + textH * 0.5)
  1042. end
  1043. elseif (button.text == "ballCount") then
  1044. love.graphics.print(
  1045. "Ball Count: " .. maxBalls,
  1046. smallfont,
  1047. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1048. by + textH * 0.5
  1049. )
  1050. elseif (button.text == "Ball Speed: ") then
  1051. if (nuckemodactive == 1) then
  1052. love.graphics.setColor(1, 0, 0, 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(1, 1, 1, 1)
  1060. love.graphics.print(
  1061. "shaitan machina",
  1062. smallfont,
  1063. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1064. by + textH * 0.5
  1065. )
  1066. love.graphics.setColor(0, 0, 0, 1)
  1067. else
  1068. love.graphics.print(
  1069. button.text .. ballSet,
  1070. smallfont,
  1071. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1072. by + textH * 0.5
  1073. )
  1074. end
  1075. elseif button.text == "ptw" then
  1076. love.graphics.print(
  1077. "Points to Win: " .. ptw,
  1078. smallfont,
  1079. VIRTUAL_WIDTH * 0.5 - textW * 1.5,
  1080. by + textH * 0.5
  1081. )
  1082. else
  1083. love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1084. end
  1085. love.graphics.setColor(255, 255, 255, 255)
  1086. cursor_y = cursor_y + (BUTTON_HEIGHT + margin)
  1087. end
  1088. end
  1089. end
  1090. function love.draw()
  1091. simpleScale.set()
  1092. baseDraw()
  1093. simpleScale.unSet()
  1094. end
  1095. --Check if controls are duplicating
  1096. function controllerSer()
  1097. for i = 1, maxBalls do
  1098. if (ball[i].dy == 0) then
  1099. hitNum[i] = hitNum[i] + 1
  1100. if hitNum[i] >= 10 then
  1101. ball[i].dy = 1
  1102. hitNum[i] = 0
  1103. end
  1104. else
  1105. hitNum[i] = 0
  1106. end
  1107. end
  1108. end
  1109. function palleteController() --!!!!LEGACY CODE, MIGRATED TO Paddle.lua!!!!
  1110. if (areanuclear == 0) then
  1111. player1.RED = 1
  1112. player1.GREEN = 1
  1113. player1.BLUE = 1
  1114. end
  1115. if (areanuclear == 0) then
  1116. player2.RED = 1
  1117. player2.GREEN = 1
  1118. player2.BLUE = 1
  1119. end
  1120. if (areanuclear == 1) then
  1121. player1.RED = 0
  1122. player1.GREEN = 0
  1123. player1.BLUE = 0
  1124. end
  1125. if (areanuclear == 1) then
  1126. player2.RED = 0
  1127. player2.GREEN = 0
  1128. player2.BLUE = 0
  1129. end
  1130. end
  1131. function love.wheelmoved(x, y)
  1132. if (y < 0 and wall1width > 0) then
  1133. wall1width = wall1width - 5
  1134. elseif y > 0 and wall1width < 900 then
  1135. wall1width = wall1width + 5
  1136. end
  1137. end
  1138. function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SERVES
  1139. print("servebot called")
  1140. if (gameState == "1serve") then
  1141. updateTEXT = ""
  1142. if (gameMode ~= "practice") then
  1143. TEXT = "PLAYER 1, serve!(q)"
  1144. end
  1145. if (love.keyboard.isDown("q") or gameMode == "practice") then
  1146. TEXT = "Lets Begin!"
  1147. ball_DIR = 1
  1148. for i = 1, maxBalls do
  1149. ball[i]:reset(i)
  1150. end
  1151. gameState = "play"
  1152. globalState = "base"
  1153. end
  1154. end
  1155. if (gameState == "2serve") then
  1156. TEXT = "PLAYER 2, serve!(p)"
  1157. if (AGAINST_AI == 1) then
  1158. TEXT = ""
  1159. ball_DIR = -1
  1160. for i = 1, maxBalls do
  1161. ball[i]:reset(i)
  1162. end
  1163. gameState = "play"
  1164. globalState = "base"
  1165. end
  1166. if (love.keyboard.isDown("p") and AGAINST_AI == 0) then
  1167. TEXT = "Lets Begin"
  1168. ball_DIR = -1
  1169. for i = 1, maxBalls do
  1170. ball[i]:reset(i)
  1171. end
  1172. --love.window.setTitle("An atttttttt")
  1173. gameState = "play"
  1174. globalState = "base"
  1175. end
  1176. end
  1177. end
  1178. function mapChanger()
  1179. if (gameState == "editor") then
  1180. MAP_TYPE = 2
  1181. end
  1182. if (MAP_TYPE > 2) then
  1183. MAP_TYPE = 0
  1184. end
  1185. end
  1186. function resolutionChanger()
  1187. if (RESOLUTION_SET > 1) then
  1188. RESOLUTION_SET = 0
  1189. end
  1190. if (RESOLUTION_SET == 0) then
  1191. if (isFullscreen == 1) then
  1192. DIFFERENCE_X = 1
  1193. DIFFERENCE_Y = 1
  1194. simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = false})
  1195. isFullscreen = 0
  1196. end
  1197. end
  1198. if (RESOLUTION_SET == 1) then
  1199. if (isFullscreen == 0) then
  1200. simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = true})
  1201. local newWidth = love.graphics.getWidth()
  1202. local newHeight = love.graphics.getHeight()
  1203. DIFFERENCE_X = VIRTUAL_WIDTH / newWidth
  1204. DIFFERENCE_Y = VIRTUAL_HEIGHT / newHeight
  1205. isFullscreen = 1
  1206. end
  1207. end
  1208. end
  1209. function resettinggenius()
  1210. maxBalls = 1
  1211. for i = 1, maxBalls do
  1212. ball[i]:reset(i)
  1213. end
  1214. paddle_SPEED = 20
  1215. nuclearanimation = 3
  1216. timeIsSlow = false
  1217. timeIsSlow2 = false
  1218. originalSpeed = 200
  1219. gameState = "menu"
  1220. globalState = "menu"
  1221. gameMode = "normal"
  1222. ballSet = 200
  1223. ballSpeed = ballSet
  1224. player2.GREEN = 255
  1225. player2.BLUE = 255
  1226. player1.GREEN = 255
  1227. player1.BLUE = 255
  1228. player1score = 0
  1229. player2score = 0
  1230. potentialnuke1 = 0
  1231. potentialnuke2 = 0
  1232. striken = 0
  1233. areanuclear = 0
  1234. potentialstrike1 = 0
  1235. potentialstrike2 = 0
  1236. player1nukescore = 0
  1237. player2nukescore = 0
  1238. player1reverbav = 0
  1239. player2reverbav = 0
  1240. selecting = 0
  1241. AGAINST_AI = 0
  1242. end
  1243. function love.mousereleased(x, y, button)
  1244. love.keyboard.mouseisReleased = true
  1245. if (gameState == "editor") then
  1246. if (#walls < 1000 and button == 1 and blockinput ~= true) then
  1247. table.insert(walls, newWall(x * DIFFERENCE_X, y * DIFFERENCE_Y, 10, wall1width))
  1248. end
  1249. end
  1250. end