A pong clone, but with a twist!
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.lua 38 KiB

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