A pong clone, but with a twist!
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

main.lua 43 KiB

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