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

main.lua 41 KiB

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