A pong clone, but with a twist!
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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