A pong clone, but with a twist!
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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