A pong clone, but with a twist!
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

main2.lua 60 KiB

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