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

main.lua 41 KiB

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