A pong clone, but with a twist!
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

1693 lignes
60 KiB

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