A pong clone, but with a twist!
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

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