A pong clone, but with a twist!
Você não pode selecionar mais de 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.

1723 linhas
61 KiB

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