A pong clone, but with a twist!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.lua 45 KiB

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