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

vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608
  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. end
  805. else
  806. lastSentKeyClient = p[1]
  807. player2.y = tonumber(p[4])
  808. end
  809. end
  810. until not data
  811. if not datawaspassed then
  812. datawaspassedtimer = datawaspassedtimer + 1
  813. if datawaspassedtimer > 5 then
  814. confirmation = "D"
  815. datawaspassedtimer = 0
  816. end
  817. else
  818. datawaspassedtimer = 0
  819. end
  820. end
  821. function clienttest(dt)
  822. if clientinit == false then
  823. local socket = require "socket"
  824. local address, port = IP, 12345
  825. udp = socket.udp()
  826. udp:setpeername(address, port)
  827. udp:settimeout(0)
  828. udp:send(tostring(lastSentKey) ..'|' .. player2.y .. "|CLIENT")
  829. clientinit = true
  830. end
  831. ts = ts + dt
  832. if ts > updaterate then
  833. udp:send(tostring(lastSentKey) ..
  834. '|' .. tostring(ball[1].dy) ..
  835. '|' .. tostring(player1.y) ..
  836. '|' .. tostring(player2.y) ..
  837. '|' .. tostring(player1score) ..
  838. '|' .. tostring(player2score) ..
  839. '|' .. tostring(player1nukescore) ..
  840. '|' .. tostring(player2nukescore) ..
  841. '|' .. tostring(ball[1].x) ..
  842. '|' .. tostring(ball[1].y) ..
  843. '|' .. gameState ..
  844. '|' .. tostring(ball[1].dx) ..
  845. '|' .. tostring(ballSpeed) ..
  846. '|' .. tostring(paddle_SPEED) ..
  847. "|CLIENT")
  848. ts = 0
  849. end
  850. local data
  851. local datanumtest = 0
  852. local datawaspassed = false
  853. repeat
  854. datanumtest = datanumtest + 1
  855. print("LATENCY: " .. tostring(datanumtest))
  856. data = udp:receive()
  857. if data then
  858. print("RECEIVED DATA: " .. data)
  859. datawaspassed = true
  860. print("SENT TO SERVER:" .. lastSentKey)
  861. confirmation = "N"
  862. local p = split(data, '|')
  863. if p[15] then
  864. if p[15] ~= "HOST" then
  865. confirmation = "U"
  866. end
  867. if tonumber(p[16]) > 90 then
  868. confirmation = "L"
  869. end
  870. for i = 1, maxBalls do
  871. local die = tonumber(p[2])
  872. if (ball[i].x <= VIRTUAL_WIDTH/2) then
  873. if tonumber(p[9]) <= VIRTUAL_WIDTH/2 then
  874. 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])
  875. end
  876. else
  877. lastSentKeyClient = p[1]
  878. player1.y = tonumber(p[4])
  879. end
  880. end
  881. else
  882. confirmation = "U"
  883. end
  884. end
  885. print("GOT: " .. lastSentKeyClient)
  886. until not data
  887. if not datawaspassed then
  888. datawaspassedtimer = datawaspassedtimer + 1
  889. if datawaspassedtimer > 5 then
  890. confirmation = "D"
  891. datawaspassedtimer = 0
  892. end
  893. else
  894. datawaspassedtimer = 0
  895. end
  896. end
  897. function wallbreaker(x, y)
  898. if (gameState == "editor") then
  899. for i, wall in ipairs(walls) do
  900. if math.abs(wall.wallx - x) < 10 and math.abs(wall.wally - y) < 10 then
  901. table.remove(walls, i)
  902. end
  903. end
  904. end
  905. end
  906. function hardmanager(diff)
  907. selecting = 1
  908. if (diff == "easy") then
  909. INDIC[1] = ">"
  910. AGAINST_AI = 1
  911. AI_SPEED = ballSet / 10
  912. AI_STRIKEMOD = 100
  913. AI_NUKEMOD = 1000
  914. AI_LEVEL = 350
  915. difficultyl = 200
  916. selecting = 0
  917. gameState = "1serve"
  918. globalState = "base"
  919. end
  920. if (diff == "normal") then
  921. INDIC[2] = ">"
  922. AI_SPEED = ballSet / 10
  923. AI_LEVEL = 500
  924. AI_NUKEMOD = 250
  925. AI_STRIKEMOD = 60
  926. AGAINST_AI = 1
  927. difficultyl = 300
  928. selecting = 0
  929. gameState = "1serve"
  930. globalState = "base"
  931. end
  932. if (diff == "hard") then
  933. INDIC[3] = ">"
  934. AI_SPEED = ballSpeed * 1.1 + 50
  935. AI_SPEED = AI_SPEED / 10
  936. AI_LEVEL = 700
  937. AI_NUKEMOD = 200
  938. AI_STRIKEMOD = 20
  939. selecting = 0
  940. difficultyl = 350
  941. AGAINST_AI = 1
  942. gameState = "1serve"
  943. globalState = "base"
  944. end
  945. if (diff == "smart") then
  946. INDIC[3] = ">"
  947. AI_SPEED = ballSpeed * 1.1 + 50
  948. AI_SPEED = AI_SPEED / 10
  949. AI_LEVEL = 1500
  950. AI_NUKEMOD = 200
  951. AI_STRIKEMOD = 20
  952. selecting = 0
  953. difficultyl = 350
  954. AGAINST_AI = 1
  955. gameState = "1serve"
  956. globalState = "base"
  957. end
  958. if (diff == "practice") then
  959. INDIC[3] = ">"
  960. AI_SPEED = ballSpeed * 500 + 50
  961. AI_SPEED = AI_SPEED / 10
  962. AI_LEVEL = 700
  963. AI_NUKEMOD = 9000000000
  964. AI_STRIKEMOD = 90000000
  965. selecting = 0
  966. difficultyl = 350
  967. AGAINST_AI = 1
  968. gameState = "base"
  969. end
  970. end
  971. function dangerChecker() --CHECK IF CONTROLS ARE DUPLICATING
  972. if (p1control.up == p1control.down) then
  973. danger = "1up"
  974. danger2 = "1down"
  975. elseif (p1control.up == p1control.super) then
  976. danger = "1up"
  977. danger2 = "1special"
  978. elseif (p1control.up == p1control.counter) then
  979. danger = "1up"
  980. danger2 = "1ct"
  981. elseif (p1control.down == p1control.super) then
  982. danger = "1down"
  983. danger2 = "1special"
  984. elseif (p1control.down == p1control.counter) then
  985. danger = "1ct"
  986. danger2 = "1down"
  987. elseif (p1control.super == p1control.counter) then
  988. danger = "1special"
  989. danger2 = "1ct"
  990. elseif (p2control.down == p2control.up) then
  991. danger = "2down"
  992. danger2 = "2up"
  993. elseif (p2control.down == p2control.super) then
  994. danger = "2down"
  995. danger2 = "2special"
  996. elseif (p2control.down == p2control.counter) then
  997. danger = "2down"
  998. danger2 = "2ct"
  999. elseif (p2control.up == p2control.super) then
  1000. danger = "2up"
  1001. danger2 = "2special"
  1002. elseif (p2control.up == p2control.counter) then
  1003. danger = "2ct"
  1004. danger2 = "2up"
  1005. elseif (p2control.super == p2control.counter) then
  1006. danger = "2special"
  1007. danger2 = "2ct"
  1008. else
  1009. danger = "none"
  1010. danger2 = "none"
  1011. end
  1012. end
  1013. function love.keypressed(key)
  1014. lastSentKey = key
  1015. if gameState == "chooseIP" then
  1016. if key == "backspace" then
  1017. -- get the byte offset to the last UTF-8 character in the string.
  1018. local byteoffset = utf8.offset(IP, -1)
  1019. if byteoffset then
  1020. -- remove the last UTF-8 character.
  1021. -- string.sub operates on bytes rather than UTF-8 characters, so we couldn't do string.sub(text, 1, -2).
  1022. IP = string.sub(IP, 1, byteoffset - 1)
  1023. end
  1024. end
  1025. end
  1026. if gameState == "assign" then
  1027. if (req == "p1up") then
  1028. p1control.up = key
  1029. currentKey = key
  1030. --love.window.setTitle(key)
  1031. gameState = "controlSettings"
  1032. end
  1033. if (req == "p2up") then
  1034. p2control.up = key
  1035. currentKey = key
  1036. --love.window.setTitle(key)
  1037. gameState = "controlSettings"
  1038. end
  1039. if (req == "p1down") then
  1040. p1control.down = key
  1041. currentKey = key
  1042. --love.window.setTitle(key)
  1043. gameState = "controlSettings"
  1044. end
  1045. if (req == "p2down") then
  1046. p2control.down = key
  1047. currentKey = key
  1048. -- love.window.setTitle(key)
  1049. gameState = "controlSettings"
  1050. end
  1051. if (req == "p1super") then
  1052. p1control.super = key
  1053. currentKey = key
  1054. -- love.window.setTitle(key)
  1055. gameState = "controlSettings"
  1056. end
  1057. if (req == "p2super") then
  1058. p2control.super = key
  1059. currentKey = key
  1060. -- love.window.setTitle(key)
  1061. gameState = "controlSettings"
  1062. end
  1063. if (req == "p1ct") then
  1064. p1control.counter = key
  1065. currentKey = key
  1066. -- love.window.setTitle(key)
  1067. gameState = "controlSettings"
  1068. end
  1069. if (req == "p2ct") then
  1070. p2control.counter = key
  1071. currentKey = key
  1072. --love.window.setTitle(key)
  1073. gameState = "controlSettings"
  1074. end
  1075. end
  1076. if key == "escape" then
  1077. TEXT = "Escape Key"
  1078. love.event.quit()
  1079. elseif key == "enter" or key == "return" then
  1080. if gameState == "start" then
  1081. resettinggenius()
  1082. gameState = "menu"
  1083. globalState = "menu"
  1084. hardmanager()
  1085. elseif (gameState == "done") then
  1086. if (player1score > player2score) then
  1087. gameState = "2serve"
  1088. potentialnuke1 = 0
  1089. potentialnuke2 = 0
  1090. striken = 0
  1091. if (nuckemodactive == 0) then
  1092. areanuclear = 0
  1093. nuclearanimation = 3
  1094. end
  1095. potentialstrike1 = 0
  1096. potentialstrike2 = 0
  1097. player1nukescore = 0
  1098. player2nukescore = 0
  1099. else
  1100. gameState = "1serve"
  1101. resettinggenius()
  1102. for i = 1, maxBalls do
  1103. ball[i]:reset(i, 1)
  1104. end
  1105. end
  1106. else
  1107. gameState = "menu"
  1108. globalState = "menu"
  1109. if (love.math.random(0, 10) == 1) then
  1110. TEXT = "Nuclear Ching Chong"
  1111. else
  1112. TEXT = "Nuclear Pong"
  1113. end
  1114. resettinggenius()
  1115. for i = 1, maxBalls do
  1116. ball[i]:reset(i)
  1117. end
  1118. end
  1119. end
  1120. end
  1121. function love.keyreleased(key)
  1122. currentKey = " "
  1123. if lastSentKey == key then
  1124. lastSentKey = "g"
  1125. end
  1126. end
  1127. function speedSetter(requesttype)
  1128. if (requesttype == "ball") then
  1129. if (ballSet > 550) then
  1130. ballSet = 0
  1131. paddle_SPEED = 0
  1132. else
  1133. ballSet = ballSet + 50
  1134. paddle_SPEED = paddle_SPEED + 5
  1135. end
  1136. ballSpeed = ballSet
  1137. end
  1138. if (requesttype == "snc") then
  1139. synctype = synctype + 1
  1140. if (synctype > 1) then
  1141. synctype = 0
  1142. end
  1143. if synctype == 0 then
  1144. synctext = "Independent"
  1145. end
  1146. if synctype == 1 then
  1147. synctext = "Synchronised"
  1148. end
  1149. end
  1150. if (requesttype == "nuclearmod") then
  1151. nuckemodactive = nuckemodactive + 1
  1152. if (nuckemodactive > 1) then
  1153. nuckemodactive = 0
  1154. end
  1155. if (nuckemodactive == 0) then
  1156. areanuclear = 0
  1157. nuclearanimation = 3
  1158. ballSet = 200
  1159. TEXT = "Nuclear Pong"
  1160. synctype = 0
  1161. maxspeed = 700
  1162. synctext = "Independent"
  1163. paddle_SPEED = ballSet / 10
  1164. AI_SPEED = ballSet / 10
  1165. end
  1166. if (nuckemodactive == 1) then
  1167. areanuclear = 1
  1168. ballSet = 2000
  1169. maxspeed = 2000
  1170. paddle_SPEED = ballSet / 10
  1171. AI_SPEED = ballSet / 10
  1172. synctext = "death is imminent"
  1173. end
  1174. ballSpeed = ballSet
  1175. end
  1176. if (requesttype == "practice") then
  1177. if (ballSpeed > 999) then
  1178. ballSpeed = 200
  1179. ballSet = 200
  1180. end
  1181. if (ballSpeed > 799) then
  1182. prtext = "Insane"
  1183. maxBalls = 5
  1184. elseif ballSpeed > 599 then
  1185. prtext = "Hard"
  1186. maxBalls = 4
  1187. elseif ballSpeed > 399 then
  1188. prtext = "Normal"
  1189. maxBalls = 3
  1190. elseif ballSpeed > 199 then
  1191. prtext = "Easy"
  1192. maxBalls = 3
  1193. end
  1194. ballSpeed = ballSpeed + 200
  1195. ballSet = ballSet + 200
  1196. end
  1197. if (requesttype == "reset") then
  1198. ballSpeed = 200
  1199. ballSet = 200
  1200. synctype = 0
  1201. prtext = "Easy"
  1202. maxBalls = 1
  1203. end
  1204. if (requesttype == "pc") then
  1205. if (playerCount == 2) then
  1206. playerCount = 1
  1207. playertext = "1v1"
  1208. elseif (playerCount == 1) then
  1209. playerCount = playerCount + 1
  1210. player3.x = player1.x + VIRTUAL_WIDTH / 2
  1211. player3.y = player3.y
  1212. playertext = "2v2"
  1213. end
  1214. end
  1215. if (requesttype == "ballz") then
  1216. if (maxBalls > 1) then
  1217. --love.window.setTitle("more than 4")
  1218. maxBalls = 1
  1219. else
  1220. maxBalls = maxBalls + 1
  1221. end
  1222. end
  1223. if requesttype == "ptw" then
  1224. if ptw == 10 then
  1225. ptw = 1
  1226. else
  1227. ptw = ptw + 1
  1228. end
  1229. end
  1230. end
  1231. function gameModeChanger()
  1232. if (gameState == "gameMode") then
  1233. local button_width = VIRTUAL_WIDTH * (1 / 3)
  1234. local BUTTON_HEIGHT = 50
  1235. local margin = 20
  1236. local hot = false
  1237. local cursor_y = 0
  1238. local total_height = (BUTTON_HEIGHT + margin) * #buttons
  1239. for i, button in ipairs(modeSelectorButtons) do
  1240. button.last = button.now
  1241. local bx = (VIRTUAL_WIDTH * 0.5) - (button_width * 0.5)
  1242. local by = (VIRTUAL_HEIGHT * 0.5) - (total_height * 0.5) + cursor_y
  1243. local color = {255, 255, 255, 255}
  1244. local mx, my = love.mouse.getPosition()
  1245. mx = mx * DIFFERENCE_X
  1246. my = my * DIFFERENCE_Y
  1247. hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
  1248. if (hot == i) then
  1249. color = {10, 10, 0, 255}
  1250. end
  1251. button.now = love.mouse.isDown(1)
  1252. if button.now and not button.last and hot == i then
  1253. love.graphics.setColor(0, 0, 0, 1)
  1254. love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
  1255. sounds["wallhit"]:play()
  1256. button.fn()
  1257. end
  1258. love.graphics.setColor(unpack(color))
  1259. love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT)
  1260. love.graphics.setColor(0, 0, 0, 255)
  1261. local textW = smallfont:getWidth(button.text)
  1262. local textH = smallfont:getHeight(button.text)
  1263. love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1264. love.graphics.setColor(255, 255, 255, 255)
  1265. cursor_y = cursor_y + (BUTTON_HEIGHT + margin)
  1266. end
  1267. end
  1268. if (gameState == "multiMode") then
  1269. local button_width = VIRTUAL_WIDTH * (1 / 3)
  1270. local BUTTON_HEIGHT = 50
  1271. local margin = 20
  1272. local hot = false
  1273. local cursor_y = 0
  1274. local total_height = (BUTTON_HEIGHT + margin) * #buttons
  1275. for i, button in ipairs(playerCountButtons) do
  1276. button.last = button.now
  1277. local bx = (VIRTUAL_WIDTH * 0.5) - (button_width * 0.5)
  1278. local by = (VIRTUAL_HEIGHT * 0.3) - (total_height * 0.5) + cursor_y
  1279. if (button.text == "Play") then
  1280. by = by + by / 1.8
  1281. end
  1282. local color = {255, 255, 255, 255}
  1283. local mx, my = love.mouse.getPosition()
  1284. mx = mx * DIFFERENCE_X
  1285. my = my * DIFFERENCE_Y
  1286. hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
  1287. if (hot == i) then
  1288. if (button.text == "Play") then
  1289. color = {0 / 255, 255 / 255, 0 / 255, 255}
  1290. else
  1291. color = {10, 10, 0, 255}
  1292. end
  1293. end
  1294. button.now = love.mouse.isDown(1)
  1295. if button.now and not button.last and hot == i then
  1296. love.graphics.setColor(0, 0, 0, 1)
  1297. love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
  1298. sounds["wallhit"]:play()
  1299. if button.text == "Ball Speed: " and nuckemodactive == 1 then
  1300. else
  1301. button.fn()
  1302. end
  1303. end
  1304. love.graphics.setColor(unpack(color))
  1305. love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT)
  1306. love.graphics.setColor(0, 0, 0, 255)
  1307. local textW = smallfont:getWidth(button.text)
  1308. local textH = smallfont:getHeight(button.text)
  1309. if (button.text == "1v1") then
  1310. love.graphics.print(playertext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1311. elseif button.text == "snc" then
  1312. if (nuckemodactive == 1) then
  1313. love.graphics.setColor(1, 0, 0, 1)
  1314. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1315. love.graphics.setColor(1, 1, 1, 1)
  1316. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1317. love.graphics.setColor(0, 0, 0, 1)
  1318. else
  1319. --
  1320. love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.45 - textW * 0.5, by + textH * 0.5)
  1321. end
  1322. elseif (button.text == "ballCount") then
  1323. love.graphics.print(
  1324. "Ball Count: " .. maxBalls,
  1325. smallfont,
  1326. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1327. by + textH * 0.5
  1328. )
  1329. elseif (button.text == "Ball Speed: ") then
  1330. if (nuckemodactive == 1) then
  1331. love.graphics.setColor(1, 0, 0, 1)
  1332. love.graphics.print(
  1333. "shaitan machina",
  1334. smallfont,
  1335. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1336. by + textH * 0.5
  1337. )
  1338. love.graphics.setColor(1, 1, 1, 1)
  1339. love.graphics.print(
  1340. "shaitan machina",
  1341. smallfont,
  1342. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1343. by + textH * 0.5
  1344. )
  1345. love.graphics.setColor(0, 0, 0, 1)
  1346. else
  1347. love.graphics.print(
  1348. button.text .. ballSet,
  1349. smallfont,
  1350. VIRTUAL_WIDTH * 0.5 - textW * 0.5,
  1351. by + textH * 0.5
  1352. )
  1353. end
  1354. elseif button.text == "ptw" then
  1355. love.graphics.print(
  1356. "Points to Win: " .. ptw,
  1357. smallfont,
  1358. VIRTUAL_WIDTH * 0.5 - textW * 1.5,
  1359. by + textH * 0.5
  1360. )
  1361. else
  1362. love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
  1363. end
  1364. love.graphics.setColor(255, 255, 255, 255)
  1365. cursor_y = cursor_y + (BUTTON_HEIGHT + margin)
  1366. end
  1367. end
  1368. end
  1369. function love.draw()
  1370. simpleScale.set()
  1371. baseDraw()
  1372. if (globalState == "nettest" or globalState == "clienttest") and confirmation == "D" then
  1373. love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
  1374. love.graphics.printf("WAIT FOR OPPONENT", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  1375. end
  1376. if (globalState == "nettest" or globalState == "clienttest") and confirmation == "U" then
  1377. love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
  1378. love.graphics.printf("LOBBY FULL OR WRONG MODE CHOSEN", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  1379. end
  1380. if (globalState == "nettest" or globalState == "clienttest") and confirmation == "L" then
  1381. love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
  1382. love.graphics.printf("POOR CONNECTION TO SERVER", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  1383. end
  1384. simpleScale.unSet()
  1385. end
  1386. --Check if controls are duplicating
  1387. function controllerSer()
  1388. for i = 1, maxBalls do
  1389. if (ball[i].dy == 0) then
  1390. hitNum[i] = hitNum[i] + 1
  1391. if hitNum[i] >= 10 then
  1392. ball[i].dy = 1
  1393. hitNum[i] = 0
  1394. end
  1395. else
  1396. hitNum[i] = 0
  1397. end
  1398. end
  1399. end
  1400. function palleteController() --!!!!LEGACY CODE, MIGRATED TO Paddle.lua!!!!
  1401. if (areanuclear == 0) then
  1402. player1.RED = 1
  1403. player1.GREEN = 1
  1404. player1.BLUE = 1
  1405. end
  1406. if (areanuclear == 0) then
  1407. player2.RED = 1
  1408. player2.GREEN = 1
  1409. player2.BLUE = 1
  1410. end
  1411. if (areanuclear == 1) then
  1412. player1.RED = 0
  1413. player1.GREEN = 0
  1414. player1.BLUE = 0
  1415. end
  1416. if (areanuclear == 1) then
  1417. player2.RED = 0
  1418. player2.GREEN = 0
  1419. player2.BLUE = 0
  1420. end
  1421. end
  1422. function love.wheelmoved(x, y)
  1423. if (y < 0 and wall1width > 0) then
  1424. wall1width = wall1width - 5
  1425. elseif y > 0 and wall1width < 900 then
  1426. wall1width = wall1width + 5
  1427. end
  1428. end
  1429. function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SERVES
  1430. --print("servebot called")
  1431. if (gameState == "1serve") then
  1432. updateTEXT = ""
  1433. if (gameMode ~= "practice") then
  1434. TEXT = "PLAYER 1, serve!(q)"
  1435. end
  1436. if ((globalState ~= "clienttest" and love.keyboard.isDown("q")) or (globalState == "clienttest" and lastSentKeyP1 == "q")) then
  1437. TEXT = "Lets Begin!"
  1438. ball_DIR = 1
  1439. for i = 1, maxBalls do
  1440. ball[i]:reset(i, 1)
  1441. end
  1442. gameState = "play"
  1443. end
  1444. end
  1445. if (gameState == "2serve") then
  1446. TEXT = "PLAYER 2, serve!(p)"
  1447. if (AGAINST_AI == 1) then
  1448. TEXT = ""
  1449. ball_DIR = -1
  1450. for i = 1, maxBalls do
  1451. ball[i]:reset(i, 2)
  1452. end
  1453. gameState = "play"
  1454. end
  1455. if (((globalState == "nettest" and lastSentKeyClient == "p") or ((globalState ~= "nettest") and love.keyboard.isDown("p")))and AGAINST_AI == 0) then
  1456. TEXT = "Lets Begin"
  1457. ball_DIR = -1
  1458. for i = 1, maxBalls do
  1459. ball[i]:reset(i, 2)
  1460. end
  1461. --love.window.setTitle("An atttttttt")
  1462. gameState = "play"
  1463. end
  1464. end
  1465. end
  1466. function mapChanger()
  1467. if (gameState == "editor") then
  1468. MAP_TYPE = 2
  1469. end
  1470. if (MAP_TYPE > 2) then
  1471. MAP_TYPE = 0
  1472. end
  1473. end
  1474. function resolutionChanger()
  1475. if (RESOLUTION_SET > 1) then
  1476. RESOLUTION_SET = 0
  1477. end
  1478. if (RESOLUTION_SET == 0) then
  1479. if (isFullscreen == 1) then
  1480. DIFFERENCE_X = 1
  1481. DIFFERENCE_Y = 1
  1482. simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = false})
  1483. isFullscreen = 0
  1484. end
  1485. end
  1486. if (RESOLUTION_SET == 1) then
  1487. if (isFullscreen == 0) then
  1488. simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = true})
  1489. local newWidth = love.graphics.getWidth()
  1490. local newHeight = love.graphics.getHeight()
  1491. DIFFERENCE_X = VIRTUAL_WIDTH / newWidth
  1492. DIFFERENCE_Y = VIRTUAL_HEIGHT / newHeight
  1493. isFullscreen = 1
  1494. end
  1495. end
  1496. end
  1497. function resettinggenius()
  1498. maxBalls = 1
  1499. for i = 1, maxBalls do
  1500. ball[i]:reset(i)
  1501. end
  1502. paddle_SPEED = 20
  1503. nuclearanimation = 3
  1504. timeIsSlow = false
  1505. timeIsSlow2 = false
  1506. originalSpeed = 200
  1507. gameState = "menu"
  1508. globalState = "menu"
  1509. gameMode = "normal"
  1510. player1.height = 100
  1511. player2.height = 100
  1512. ballSet = 200
  1513. ballSpeed = ballSet
  1514. player2.GREEN = 255
  1515. player2.BLUE = 255
  1516. player1.GREEN = 255
  1517. player1.BLUE = 255
  1518. player1score = 0
  1519. player2score = 0
  1520. potentialnuke1 = 0
  1521. potentialnuke2 = 0
  1522. striken = 0
  1523. areanuclear = 0
  1524. potentialstrike1 = 0
  1525. potentialstrike2 = 0
  1526. player1nukescore = 0
  1527. player2nukescore = 0
  1528. player1reverbav = 0
  1529. player2reverbav = 0
  1530. selecting = 0
  1531. AGAINST_AI = 0
  1532. end
  1533. function love.mousereleased(x, y, button)
  1534. love.keyboard.mouseisReleased = true
  1535. if (gameState == "editor") then
  1536. if (#walls < 1000 and button == 1 and blockinput ~= true) then
  1537. table.insert(walls, newWall(x * DIFFERENCE_X, y * DIFFERENCE_Y, 10, wall1width))
  1538. end
  1539. end
  1540. end
  1541. function ballsAlive()
  1542. for i = 1, maxBalls do
  1543. if ball[i].disabled == false then
  1544. print("Ball " .. i .. " is not disabled")
  1545. return true
  1546. end
  1547. end
  1548. return false
  1549. end
  1550. function split(s, delimiter)
  1551. result = {}
  1552. for match in (s..delimiter):gmatch("(.-)"..delimiter) do
  1553. table.insert(result, match)
  1554. end
  1555. return result
  1556. end