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

baseGame.lua 49 KiB

4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316
  1. function basegame(dt)
  2. if gameMode == "reversegame" then
  3. reversegame(dt)
  4. end
  5. if player1nukescore > 300 then
  6. player1nukescore = 300
  7. end
  8. if player2nukescore > 300 then
  9. player2nukescore = 300
  10. end
  11. speedControl()
  12. balancer()
  13. if t < shakeDuration then
  14. t = t + dt
  15. end
  16. --print("T = " .. tostring(t))
  17. serveBot()
  18. if gameState == 'play' then
  19. if (AGAINST_AI == 1) then
  20. AI(player2, maxBalls, AI_LEVEL)
  21. end
  22. if (love.keyboard.isDown(p1control.up)) then
  23. player1.dy = (paddle_SPEED + p1bonus) * -1
  24. elseif (love.keyboard.isDown(p1control.down)) then
  25. player1.dy = paddle_SPEED + p1bonus
  26. else
  27. player1.dy = 0
  28. end
  29. if (AGAINST_AI == 0) then
  30. if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.up)) ) then
  31. player2.dy = (paddle_SPEED + p2bonus) * -1
  32. elseif ((globalState ~= "nettest" and love.keyboard.isDown(p2control.down))) then
  33. player2.dy = paddle_SPEED + p2bonus
  34. elseif (globalState ~= "nettest") then
  35. player2.dy = 0
  36. end
  37. end
  38. --print(areanuclear .. striken .. player1score .. player2score)
  39. for i = 1, maxBalls do
  40. if rules("p1hit", i) then
  41. if (areanuclear == 0 and striken == 1 and (player1score > ptw-2 or player2score > ptw-2)) then
  42. --print("Calling animation")
  43. print("AREA NUCLEAR?" .. areanuclear)
  44. superanimator("tensehit", 1)
  45. end
  46. if gameMode == "practice" then
  47. player1score = player1score + 1
  48. end
  49. t = 0
  50. if (ballSpeed > 200) then
  51. shakeMagnitude = ballSpeed / 200
  52. else
  53. shakeMagnitude = 0
  54. end
  55. shakeDuration = 1
  56. randomtext = love.math.random(1, #textphrases)
  57. TEXT = textphrases[randomtext]
  58. soundtype = love.math.random(1, 1.2)
  59. if (player1striken == 1) then
  60. TEXT = "PLAYER 1 STRIKES"
  61. ballSpeed = ballSpeed + player1nukescore
  62. potentialnuke1 = 0
  63. player1striken = 0
  64. player1nukescore = 0
  65. potentialstrike1 = 0
  66. striken = 1
  67. if areanuclear == 0 then
  68. sounds["striking"]:setPitch(ballSpeed / 250)
  69. sounds["striking"]:play()
  70. else
  71. sounds["nuclearhit"]:setPitch(1)
  72. sounds["nuclearhit"]:play()
  73. end
  74. print("AREA NUCLEAR?" .. areanuclear)
  75. if areanuclear == 0 then
  76. superanimator("tensehit", 1)
  77. end
  78. else
  79. if areanuclear == 0 then
  80. sounds["beep"]:setPitch(ballSpeed / 250)
  81. sounds["beep"]:play()
  82. else
  83. sounds["nuclearhit"]:setPitch(1)
  84. sounds["nuclearhit"]:play()
  85. end
  86. end
  87. if (striken == 1) then
  88. player1nukescore = player1nukescore * 1.5
  89. if (synctype == 0) then
  90. paddle_SPEED = paddle_SPEED * 1.10
  91. elseif (synctype == 1) then
  92. paddle_SPEED = ballSpeed
  93. end
  94. if (synctype == 0) then
  95. AI_SPEED = AI_SPEED * 1.10
  96. end
  97. if (synctype == 1) then
  98. AI_SPEED = ballSpeed * 1.1 / 10
  99. end
  100. ballSpeed = ballSpeed * 1.10
  101. end
  102. player1nukescore = player1nukescore + 10
  103. ball[i].dx = -ball[i].dx
  104. ball[i].x = player1.x + 30
  105. if (love.keyboard.isDown(p1control.up)) then
  106. select = math.random(1, 5)
  107. if select == 1 then
  108. ball[i].dy = -1
  109. elseif select == 2 then
  110. ball[i].dy = -1.2
  111. elseif select == 3 then
  112. ball[i].dy = -1.5
  113. elseif select == 4 then
  114. ball[i].dy = -1.8
  115. elseif select == 5 then
  116. ball[i].dy = -2
  117. end
  118. elseif love.keyboard.isDown(p1control.down) then
  119. select = math.random(1, 5)
  120. if select == 1 then
  121. ball[i].dy = 1
  122. elseif select == 2 then
  123. ball[i].dy = 1.2
  124. elseif select == 3 then
  125. ball[i].dy = 1.5
  126. elseif select == 4 then
  127. ball[i].dy = 1.8
  128. elseif select == 5 then
  129. ball[i].dy = 2
  130. end
  131. else
  132. if ball[i].dy < 0 then
  133. select = math.random(1, 5)
  134. if select == 1 then
  135. ball[i].dy = -1
  136. elseif select == 2 then
  137. ball[i].dy = -1.2
  138. elseif select == 3 then
  139. ball[i].dy = -1.5
  140. elseif select == 4 then
  141. ball[i].dy = -1.8
  142. elseif select == 5 then
  143. ball[i].dy = -2
  144. end
  145. else
  146. select = math.random(1, 5)
  147. if select == 1 then
  148. ball[i].dy = 1
  149. elseif select == 2 then
  150. ball[i].dy = 1.2
  151. elseif select == 3 then
  152. ball[i].dy = 1.5
  153. elseif select == 4 then
  154. ball[i].dy = 1.8
  155. elseif select == 5 then
  156. ball[i].dy = 2
  157. end
  158. end
  159. end
  160. end
  161. if rules("p2hit", i) then
  162. --ameState = 'quickanim'
  163. t = 0
  164. shakeDuration = 1
  165. if
  166. (areanuclear == 0 and
  167. (striken == 1 and (player1score > ptw-2 or player2score > ptw-2)))
  168. then
  169. print("AREA NUCLEAR?" .. areanuclear)
  170. superanimator("tensehit", 2)
  171. end
  172. if (ballSpeed > 200) then
  173. shakeMagnitude = ballSpeed / 200
  174. else
  175. shakeMagnitude = 0
  176. end
  177. randomtext = love.math.random(1, #textphrases)
  178. TEXT = textphrases[randomtext]
  179. soundtype = love.math.random(1, 1.2)
  180. if (player2striken == 1) then
  181. TEXT = "PLAYER 2 STRIKES"
  182. ballSpeed = ballSpeed + player2nukescore
  183. striken = 1
  184. player2striken = 0
  185. potentialnuke2 = 0
  186. player2nukescore = 0
  187. potentialstrike2 = 0
  188. print("AREA NUCLEAR?" .. areanuclear)
  189. if areanuclear == 0 then
  190. superanimator("tensehit", 2)
  191. end
  192. if areanuclear == 0 then
  193. sounds["striking"]:setPitch(ballSpeed / 250)
  194. sounds["striking"]:play()
  195. else
  196. sounds["nuclearhit"]:setPitch(1)
  197. sounds["nuclearhit"]:play()
  198. end
  199. elseif (striken == 1) then
  200. player2nukescore = player2nukescore * 1.5
  201. if (synctype == 0) then
  202. paddle_SPEED = paddle_SPEED * 1.10
  203. end
  204. if (synctype == 1) then
  205. paddle_SPEED = ballSpeed
  206. end
  207. if (synctype == 0) then
  208. AI_SPEED = AI_SPEED * 1.10
  209. end
  210. if (synctype == 1) then
  211. AI_SPEED = ballSpeed * 1.1 / 10
  212. end
  213. ballSpeed = ballSpeed * 1.10
  214. if areanuclear == 0 then
  215. sounds["beep"]:setPitch(ballSpeed / 250)
  216. sounds["beep"]:play()
  217. else
  218. sounds["nuclearhit"]:setPitch(1)
  219. sounds["nuclearhit"]:play()
  220. end
  221. else
  222. if areanuclear == 0 then
  223. sounds["beep"]:setPitch(ballSpeed / 250)
  224. sounds["beep"]:play()
  225. else
  226. sounds["nuclearhit"]:setPitch(1)
  227. sounds["nuclearhit"]:play()
  228. end
  229. end
  230. player2nukescore = player2nukescore + 10
  231. ball[i].dx = -ball[i].dx
  232. ball[i].x = player2.x - 30
  233. if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.up) ) or AI_SPEED < 0 or lastSentKeyClient == p2control.up) then
  234. select = math.random(1, 5)
  235. if select == 1 then
  236. ball[i].dy = -1
  237. elseif select == 2 then
  238. ball[i].dy = -1.2
  239. elseif select == 3 then
  240. ball[i].dy = -1.5
  241. elseif select == 4 then
  242. ball[i].dy = -1.8
  243. elseif select == 5 then
  244. ball[i].dy = -2
  245. end
  246. elseif (globalState ~= "nettest" and love.keyboard.isDown(p2control.down)) or AI_SPEED > 0 or lastSentKeyClient == p2control.down then
  247. select = math.random(1, 5)
  248. if select == 1 then
  249. ball[i].dy = 1
  250. elseif select == 2 then
  251. ball[i].dy = 1.2
  252. elseif select == 3 then
  253. ball[i].dy = 1.5
  254. elseif select == 4 then
  255. ball[i].dy = 1.8
  256. elseif select == 5 then
  257. ball[i].dy = 2
  258. end
  259. else
  260. if ball[i].dy < 0 then
  261. select = math.random(1, 5)
  262. if select == 1 then
  263. ball[i].dy = -1
  264. elseif select == 2 then
  265. ball[i].dy = -1.2
  266. elseif select == 3 then
  267. ball[i].dy = -1.5
  268. elseif select == 4 then
  269. ball[i].dy = -1.8
  270. elseif select == 5 then
  271. ball[i].dy = -2
  272. end
  273. else
  274. select = math.random(1, 5)
  275. if select == 1 then
  276. ball[i].dy = 1
  277. elseif select == 2 then
  278. ball[i].dy = 1.2
  279. elseif select == 3 then
  280. ball[i].dy = 1.5
  281. elseif select == 4 then
  282. ball[i].dy = 1.8
  283. elseif select == 5 then
  284. ball[i].dy = 2
  285. end
  286. end
  287. end
  288. end
  289. hitIdentifier()
  290. if ball[i].y <= 0 then
  291. soundtype = love.math.random(1, 5)
  292. sounds["wallhit"]:setPitch(ballSpeed / 250)
  293. sounds["wallhit"]:play()
  294. ball[i].y = 0
  295. ball[i].dy = -ball[i].dy
  296. end
  297. -- -4 to account for the ball's size
  298. if ball[i].y >= VIRTUAL_HEIGHT - 40 then
  299. soundtype = love.math.random(1, 5)
  300. sounds["wallhit"]:setPitch(ballSpeed / 250)
  301. sounds["wallhit"]:play()
  302. ball[i].y = VIRTUAL_HEIGHT - 40
  303. ball[i].dy = -ball[i].dy
  304. end
  305. --love.window.setTitle('Trying to update the ball')
  306. if timeIsSlow then
  307. if ballSpeed > originalSpeed / 3 then
  308. paddle_SPEED = 30
  309. ballSpeed = ballSpeed / (1 + (dt * 2))
  310. end
  311. player1nukescore = player1nukescore - (dt * 50)
  312. if player1nukescore < 1 or ball[1].dx > 0 then
  313. timeIsSlow = false
  314. player1reverbav = false
  315. ballSpeed = originalSpeed
  316. sounds["time"]:stop()
  317. paddle_SPEED = originalPaddle
  318. end
  319. end
  320. if timeIsSlow2 then
  321. if ballSpeed > originalSpeed / 3 then
  322. ballSpeed = ballSpeed / (1 + (dt * 2))
  323. end
  324. player2nukescore = player2nukescore - (dt * 50)
  325. if player2nukescore < 1 or ball[1].dx < 0 then
  326. paddle_SPEED = 30
  327. timeIsSlow2 = false
  328. player2reverbav = false
  329. ballSpeed = originalSpeed
  330. sounds["time"]:stop()
  331. paddle_SPEED = originalPaddle
  332. end
  333. end
  334. ball[i]:update(dt)
  335. end
  336. end
  337. goalManager()
  338. powerAvailability()
  339. player1:update(dt)
  340. player2:update(dt)
  341. end
  342. function debugCheck(dt)
  343. if (gameState == "menu") then
  344. updateTEXT = "0.7.7 Chalkboard Update"
  345. end
  346. dangerChecker()
  347. elapsed = elapsed + dt
  348. rotation = math.sin(elapsed * 2.5) * 0.7
  349. if gameState == "assign" then
  350. controlChanger()
  351. end
  352. editor()
  353. mapChanger()
  354. end
  355. function goalManager()
  356. for i = 1, maxBalls do
  357. if (rules("p1miss", i)) then
  358. ball[i].disabled = true
  359. ball[i].x = 2000
  360. if ballsAlive() == false then
  361. if (nuckemodactive == 0) then
  362. areanuclear = 0
  363. nuclearanimation = 3
  364. end
  365. striken = 0
  366. player1striken = 0
  367. player2striken = 0
  368. ballSpeed = ballSet
  369. if (synctype == 0) then
  370. paddle_SPEED = ballSet
  371. end
  372. if (synctype == 1) then
  373. paddle_SPEED = ballSpeed
  374. end
  375. AI_SPEED = difficultyl / 10
  376. for i = 1, maxBalls do
  377. ball[i]:reset(i, 2)
  378. end
  379. if (player2score == ptw and gameMode ~= "practice") then
  380. for i = 1, maxBalls do
  381. ball[i]:reset(i)
  382. end
  383. sounds["win"]:play()
  384. gameState = "done"
  385. TEXT = "Player 2 Won!"
  386. else
  387. if globalState ~= "clienttest" or (globalState == "clienttest" and gameState == "1serve") then
  388. gameState = "1serve"
  389. serveBot()
  390. ball[i]:reset(i, 1)
  391. end
  392. end
  393. end
  394. player2score = player2score + 1
  395. end
  396. if (rules("p2miss", i)) then
  397. ball[i].disabled = true
  398. ball[i].x = 2000
  399. if ballsAlive() == false then
  400. if (nuckemodactive == 0) then
  401. areanuclear = 0
  402. nuclearanimation = 3
  403. end
  404. striken = 0
  405. player1striken = 0
  406. player2striken = 0
  407. ballSpeed = ballSet
  408. if (synctype == 0) then
  409. paddle_SPEED = ballSet
  410. AI_SPEED = ballSet
  411. end
  412. if (synctype == 1) then
  413. paddle_SPEED = ballSpeed
  414. AI_SPEED = ballSpeed
  415. end
  416. AI_SPEED = difficultyl
  417. if (player1score == ptw) then
  418. ball[i]:reset(i)
  419. sounds["win"]:play()
  420. gameState = "done"
  421. TEXT = "Player 1 Won!"
  422. else
  423. if globalState ~= "nettest" or (globalState == "nettest" and gameState == "2serve") then
  424. gameState = "2serve"
  425. serveBot()
  426. ball[i]:reset(i, 2)
  427. end
  428. end
  429. end
  430. sounds["score"]:play()
  431. player1score = player1score + 1
  432. end
  433. end
  434. end
  435. function powerAvailability()
  436. if (player1nukescore >= 20 and player1nukescore < 140) then
  437. potentialstrike1 = 1
  438. if (((globalState ~= "clienttest" and love.keyboard.isDown(p1control.super)) or (globalState == "clienttest" and lastSentKeyP1 == p1control.super)) ) then
  439. player1striken = 1
  440. player1reverbav = 0
  441. end
  442. end
  443. if (player1nukescore >= 140) and timeIsSlow2 == false and timeIsSlow == false and (maxBalls > 1 or (ball[1].dx < 0 and ball[1].x < VIRTUAL_WIDTH/2))then
  444. player1reverbav = 1
  445. if ((globalState == "clienttest" and lastSentKeyP1 == p1control.counter) or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.counter))) then
  446. powerControl(1, "special")
  447. end
  448. end
  449. if (player1nukescore >= 200) then
  450. potentialnuke1 = 1
  451. if ((globalState == "clienttest" and lastSentKeyP1 == p1control.super)or (globalState ~= "clienttest" and love.keyboard.isDown(p1control.super))) then
  452. sounds["nuke"]:play()
  453. if areanuclear == 1 then
  454. maxspeed = maxspeed + 50
  455. end
  456. areanuclear = 1
  457. potentialstrike1 = 0
  458. striken = 0
  459. ballSpeed = ballSpeed * 2
  460. if (synctype == 0) then
  461. paddle_SPEED = paddle_SPEED * 2
  462. end
  463. if (synctype == 1) then
  464. paddle_SPEED = ballSpeed
  465. end
  466. if (synctype == 0) then
  467. AI_SPEED = AI_SPEED * 2.2
  468. end
  469. if (synctype == 1) then
  470. AI_SPEED = ballSpeed * 1.1 / 10
  471. end
  472. player1nukescore = 0
  473. player1reverbav = 0
  474. potentialnuke1 = 0
  475. end
  476. end
  477. if (player2nukescore >= 20 and player2nukescore <= 140) then
  478. potentialstrike2 = 1
  479. if (AGAINST_AI == 0) then
  480. if ((globalState ~= "nettest" and love.keyboard.isDown(p2control.super)) or lastSentKeyClient == p2control.super ) then
  481. player2striken = 1
  482. player2reverbav = 0
  483. end
  484. end
  485. end
  486. if (player2nukescore >= 140) and timeIsSlow == false and timeIsSlow2 == false and (maxBalls > 1 or (ball[1].dx > 0 and ball[1].x < VIRTUAL_WIDTH/2)) then
  487. player2reverbav = 1
  488. if (globalState ~= "nettest" and love.keyboard.isDown(p2control.counter)) or lastSentKeyClient == p2control.counter then
  489. sounds["time"]:play()
  490. player2reverbav = false
  491. timeIsSlow2 = true
  492. originalPaddle = paddle_SPEED
  493. originalSpeed = ballSpeed
  494. player2reverbav = 0
  495. potentialnuke2 = 0
  496. potentialstrike2 = 0
  497. end
  498. end
  499. if (player2nukescore >= 200) then
  500. potentialnuke2 = 1
  501. if (((globalState ~= "nettest" and love.keyboard.isDown(p2control.super)) or lastSentKeyClient == p2control.super)) and AGAINST_AI == 0 then
  502. sounds["nuke"]:play()
  503. if areanuclear == 1 then
  504. maxspeed = maxspeed + 50
  505. end
  506. potentialstrike2 = 0
  507. areanuclear = 1
  508. player2reverbav = 0
  509. ballSpeed = ballSpeed * 2
  510. if (synctype == 0) then
  511. paddle_SPEED = paddle_SPEED * 2
  512. end
  513. if (synctype == 1) then
  514. paddle_SPEED = ballSpeed
  515. end
  516. if (synctype == 0) then
  517. AI_SPEED = AI_SPEED * 2.2
  518. end
  519. if (synctype == 1) then
  520. AI_SPEED = ballSpeed * 1.1 / 10
  521. end
  522. player2nukescore = 0
  523. potentialnuke2 = 0
  524. end
  525. end
  526. end
  527. function editor()
  528. if (gameState == "editor") then
  529. if debug then
  530. --print("Editor is active!")
  531. end
  532. local mx, my = love.mouse.getPosition()
  533. mx = mx * DIFFERENCE_X
  534. my = my * DIFFERENCE_Y
  535. if (love.mouse.isDown(2)) then
  536. wallbreaker(mx, my)
  537. end
  538. if (love.mouse.isDown(3)) then
  539. table.insert(walls, newWall(mx, my, 10, wall1width))
  540. end
  541. end
  542. end
  543. function nuclearDraw()
  544. love.graphics.setColor(1, 1, 1, 1)
  545. for i = 1, maxBalls do
  546. love.graphics.circle("fill", ball[i].x, ball[i].y, explosionRange * 100, 100)
  547. end
  548. player1.RED, player1.GREEN, player1.BLUE, player2.RED, player2.GREEN, player2.BLUE =
  549. nuclearanimation / 3,
  550. nuclearanimation / 3,
  551. nuclearanimation / 3,
  552. nuclearanimation / 3,
  553. nuclearanimation / 3,
  554. nuclearanimation / 3
  555. for i = 1, maxBalls do
  556. love.graphics.setColor(nuclearanimation / 3, nuclearanimation / 3, nuclearanimation / 3, 1)
  557. ball[i]:render("controlled")
  558. end
  559. player1:render()
  560. player2:render()
  561. end
  562. function normalDraw()
  563. if (areanuclear == 1) then
  564. love.graphics.clear(1, 1, 1, 1)
  565. else
  566. love.graphics.clear(40 / 255, 40 / 255, 40 / 255, 1)
  567. end
  568. staticanimator()
  569. if MAP_TYPE == 1 then
  570. love.graphics.setColor(1, 0, 0.20, 1)
  571. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, 0, 10, VIRTUAL_HEIGHT * 0.3)
  572. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, VIRTUAL_HEIGHT * 0.7, 10, VIRTUAL_HEIGHT * 0.3)
  573. love.graphics.setColor(1, 1, 1, 1)
  574. end
  575. if MAP_TYPE == 2 then
  576. for i, wall in ipairs(walls) do
  577. love.graphics.setColor(1, 1, 1, 1)
  578. love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
  579. end
  580. end
  581. pongDraw()
  582. love.graphics.setFont(smallfont)
  583. for i = 1, maxBalls do
  584. if areanuclear == 1 then
  585. --love.window.setTitle('rendering black')
  586. ball[i]:render("black")
  587. else
  588. --love.window.setTitle('rendering white')
  589. ball[i]:render(" ")
  590. end
  591. end
  592. end
  593. function pongDraw()
  594. --print("Drawing classic pong")
  595. love.graphics.setColor(1, 1, 1, 1)
  596. love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
  597. love.graphics.setFont(smallfont)
  598. love.graphics.setFont(scorefont)
  599. if (areanuclear == 1) then
  600. love.graphics.setColor(0, 0, 0, 1)
  601. end
  602. love.graphics.print(tostring(math.floor(player1score)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 12)
  603. love.graphics.print(tostring(math.floor(player2score)), VIRTUAL_WIDTH / 2 + 400, VIRTUAL_HEIGHT / 12)
  604. love.graphics.setColor(1, 1, 1, 1)
  605. displayPoints()
  606. player1:render()
  607. player2:render()
  608. end
  609. function practiceDraw()
  610. player1:render()
  611. love.graphics.rectangle("fill", VIRTUAL_WIDTH-10, 0, 10, VIRTUAL_HEIGHT)
  612. love.graphics.setColor(1, 1, 1, 1)
  613. love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
  614. love.graphics.setFont(smallfont)
  615. love.graphics.setFont(scorefont)
  616. love.graphics.print(tostring(math.floor(player1score)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 12)
  617. end
  618. function menuDraw()
  619. love.graphics.setColor(1, 1, 1, 1)
  620. love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center")
  621. love.graphics.setFont(smallfont)
  622. love.graphics.printf(updateTEXT, 0, VIRTUAL_HEIGHT * 0.95, VIRTUAL_WIDTH, "left")
  623. if MAP_TYPE == 1 then
  624. love.graphics.setColor(1, 0, 0.20, 1)
  625. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, 0, 10, VIRTUAL_HEIGHT * 0.3)
  626. love.graphics.rectangle("fill", VIRTUAL_WIDTH * 0.5, VIRTUAL_HEIGHT * 0.7, 10, VIRTUAL_HEIGHT * 0.3)
  627. love.graphics.setColor(1, 1, 1, 1)
  628. end
  629. if MAP_TYPE == 2 then
  630. for i, wall in ipairs(walls) do
  631. love.graphics.setColor(1, 1, 1, 1)
  632. love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
  633. end
  634. end
  635. if gameState == "windowsettings" then
  636. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, settings, sounds, "right")
  637. love.keyboard.mouseisReleased = false
  638. end
  639. if gameState == "editor" then
  640. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, editorpicks, sounds, "right")
  641. love.keyboard.mouseisReleased = false
  642. end
  643. if gameState == "speedSettings" then
  644. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, speedParameters, sounds, "middle")
  645. love.keyboard.mouseisReleased = false
  646. end
  647. if gameState == "controlSettings" then
  648. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, controlSettings, sounds, "control")
  649. love.keyboard.mouseisReleased = false
  650. end
  651. if gameState == "gameMode" then
  652. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, modeSelectorButtons, sounds, "middle")
  653. love.keyboard.mouseisReleased = false
  654. end
  655. if gameState == "chooseIP" then
  656. IPselect = {}
  657. table.insert(
  658. IPselect,
  659. newButton(
  660. "LANHost",
  661. function()
  662. globalState = "selfhost"
  663. AGAINST_AI = 0
  664. gameState = "1serve"
  665. ball[1]:reset(1, 1)
  666. end
  667. )
  668. )
  669. table.insert(
  670. IPselect,
  671. newButton(
  672. "Check Server",
  673. function()
  674. IP = IPnew
  675. end
  676. )
  677. )
  678. if status == "offline" then
  679. love.graphics.printf("UNABLE TO CONNECT", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  680. elseif status == "nettest" then
  681. table.insert(
  682. IPselect,
  683. newButton(
  684. "Connect as Host",
  685. function()
  686. globalState = "nettest"
  687. AGAINST_AI = 0
  688. gameState = "1serve"
  689. ball[1]:reset(1, 1)
  690. end
  691. )
  692. )
  693. elseif status == "clienttest" then
  694. table.insert(
  695. IPselect,
  696. newButton(
  697. "Connect as Guest",
  698. function()
  699. globalState = "clienttest"
  700. AGAINST_AI = 0
  701. gameState = "1serve"
  702. ball[1]:reset(1, 1)
  703. end
  704. )
  705. )
  706. elseif status == "full" then
  707. love.graphics.printf("SERVER FULL", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
  708. end
  709. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, IPselect, sounds, "middle")
  710. love.graphics.printf(IPnew, 0, VIRTUAL_HEIGHT / 4, VIRTUAL_WIDTH, "center")
  711. love.keyboard.mouseisReleased = false
  712. end
  713. if gameState == "menu" then
  714. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds, "middle")
  715. love.keyboard.mouseisReleased = false
  716. end
  717. if gameState == "difficulty" then
  718. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, difbuttons, sounds, "middle")
  719. love.keyboard.mouseisReleased = false
  720. end
  721. if gameState == "multiMode" then
  722. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, playerCountButtons, sounds, "playercount")
  723. love.keyboard.mouseisReleased = false
  724. end
  725. if gameState == "prdiff" then
  726. mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, pracdiff, sounds, "playercount")
  727. love.keyboard.mouseisReleased = false
  728. end
  729. if gameState == 'start' then
  730. love.graphics.push()
  731. love.graphics.translate(VIRTUAL_WIDTH * 0.4, VIRTUAL_HEIGHT * 0.5)
  732. love.graphics.rotate(rotation)
  733. love.graphics.setFont(smallfont)
  734. love.graphics.print("Press Enter to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8)
  735. love.graphics.setColor(255, 255, 255, 255)
  736. love.graphics.pop()
  737. end
  738. end
  739. function baseDraw()
  740. love.graphics.clear(40 / 255, 40 / 255, 40 / 255, 1)
  741. if shakeDuration > t then
  742. local dx = love.math.random(-shakeMagnitude, shakeMagnitude)
  743. local dy = love.math.random(-shakeMagnitude, shakeMagnitude)
  744. love.graphics.translate(dx, dy)
  745. end
  746. if globalState == 'menu' then
  747. --print("Drawing menuDraw")
  748. if gameState == 'animation' then
  749. --print("Drawing animation")
  750. intro()
  751. end
  752. if gameState ~= 'animation' then
  753. --print("Drawing notanimtaion")
  754. love.graphics.setFont(scorefont)
  755. menuDraw()
  756. end
  757. end
  758. if globalState == 'base' or globalState == 'reverse' or globalState == 'nettest' or globalState == 'clienttest' then
  759. love.graphics.setFont(smallfont)
  760. if gameState == 'nuclearExplosion' then
  761. nuclearDraw()
  762. end
  763. if gameState == 'play' or gameState == '1serve' or gameState == '2serve' or gameState == 'done' then
  764. print("Drawing normally")
  765. normalDraw()
  766. end
  767. end
  768. end
  769. function renderEditor()
  770. if not blockinput then
  771. love.graphics.setColor(1, 0, 0, 1)
  772. love.graphics.rectangle("fill", mx, my, 10, wall1width)
  773. love.graphics.setColor(1, 1, 1, 1)
  774. end
  775. for i, wall in ipairs(walls) do
  776. love.graphics.setColor(1, 1, 1, 1)
  777. love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
  778. end
  779. end
  780. function intro()
  781. love.graphics.setColor(255, 255, 255, light / 255)
  782. love.graphics.draw(image, 0, 0)
  783. end
  784. function displayPoints()
  785. love.graphics.setFont(smallfont)
  786. if areanuclear == 1 then
  787. love.graphics.setColor(0,0,0,1)
  788. end
  789. if (potentialstrike1 == 1 and potentialnuke1 == 0 and player1reverbav == 0) then --FLAG: AVAILABLE SUPER
  790. if (player1striken == 0) then
  791. love.graphics.print(
  792. tostring(math.floor(player1nukescore) .. "[" .. p1control.super .. "]"),
  793. VIRTUAL_WIDTH / 2 - 500,
  794. VIRTUAL_HEIGHT / 60
  795. )
  796. else
  797. love.graphics.print(tostring("READY"), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60)
  798. end
  799. elseif (player1reverbav == 1 and potentialnuke1 == 0 ) then
  800. love.graphics.print(
  801. tostring(
  802. math.floor(player1nukescore) .. "[" .. p1control.super .. "]" .. " [" .. p1control.counter .. "]"
  803. ),
  804. VIRTUAL_WIDTH / 2 - 500,
  805. VIRTUAL_HEIGHT / 60
  806. )
  807. elseif (potentialnuke1 == 1) then
  808. love.graphics.setColor(255, 0, 0, 255)
  809. love.graphics.print(
  810. tostring(
  811. math.floor(player1nukescore) .. "[" .. p1control.super .. "]" .. " [" .. p1control.counter .. "]"
  812. ),
  813. VIRTUAL_WIDTH / 2 - 500,
  814. VIRTUAL_HEIGHT / 60
  815. )
  816. love.graphics.setColor(255, 255, 255, 255)
  817. elseif (potentialnuke1 == 1) then
  818. love.graphics.setColor(255, 0, 0, 255)
  819. love.graphics.print(
  820. tostring(
  821. math.floor(player1nukescore) .. "[" .. p1control.super .. "]"
  822. ),
  823. VIRTUAL_WIDTH / 2 - 500,
  824. VIRTUAL_HEIGHT / 60
  825. )
  826. love.graphics.setColor(255, 255, 255, 255)
  827. else
  828. love.graphics.print(tostring(math.floor(player1nukescore)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60)
  829. end
  830. if (potentialstrike2 == 1 and player2reverbav == 0) then
  831. if (player2striken == 0) then
  832. love.graphics.print(
  833. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "]"),
  834. VIRTUAL_WIDTH / 2 + 430,
  835. VIRTUAL_HEIGHT / 60
  836. )
  837. else
  838. love.graphics.print(tostring("READY"), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60)
  839. end
  840. elseif (potentialnuke2 == 1) then
  841. love.graphics.setColor(255, 0, 0, 255)
  842. love.graphics.print(
  843. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "] [" .. p2control.counter .. "]"),
  844. VIRTUAL_WIDTH / 2 + 400,
  845. VIRTUAL_HEIGHT / 60
  846. )
  847. love.graphics.setColor(255, 255, 255, 255)
  848. elseif (potentialnuke2 == 1 and maxBalls > 1) then
  849. love.graphics.setColor(255, 0, 0, 255)
  850. love.graphics.print(
  851. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "]"),
  852. VIRTUAL_WIDTH / 2 + 430,
  853. VIRTUAL_HEIGHT / 60
  854. )
  855. love.graphics.setColor(255, 255, 255, 255)
  856. elseif (player2reverbav == 1 and potentialnuke2 == 0 ) then
  857. love.graphics.print(
  858. tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "] [" .. p2control.counter .. "]"),
  859. VIRTUAL_WIDTH / 2 + 400,
  860. VIRTUAL_HEIGHT / 60
  861. )
  862. else
  863. love.graphics.print(tostring(math.floor(player2nukescore)), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60)
  864. end
  865. end
  866. function hitIdentifier()
  867. if (gameMode == "practice") then
  868. MAP_TYPE = 0
  869. if ball[i].x > VIRTUAL_WIDTH * 0.99 then
  870. soundtype = love.math.random(1, 5)
  871. sounds["wallhit"]:setPitch(ballSpeed / 250)
  872. sounds["wallhit"]:play()
  873. if (ball[i].dx > 0) then
  874. ball[i].x = ball[i].x - 20
  875. else
  876. ball[i].x = ball[i].x + 20
  877. end
  878. ball[i].dx = -ball[i].dx
  879. end
  880. end
  881. if (MAP_TYPE == 1) then
  882. if
  883. ball[i].y < VIRTUAL_HEIGHT * 0.3 and ball[i].x > VIRTUAL_WIDTH * 0.5 and
  884. ball[i].x < VIRTUAL_WIDTH * 0.5 + 5
  885. then
  886. soundtype = love.math.random(1, 5)
  887. sounds["wallhit"]:setPitch(ballSpeed / 250)
  888. sounds["wallhit"]:play()
  889. if (ball[i].dx > 0) then
  890. ball[i].x = ball[i].x - 20
  891. else
  892. ball[i].x = ball[i].x + 20
  893. end
  894. ball[i].dx = -ball[i].dx
  895. end
  896. if
  897. ball[i].y > VIRTUAL_HEIGHT * 0.7 and ball[i].x > VIRTUAL_WIDTH * 0.5 and
  898. ball[i].x < VIRTUAL_WIDTH * 0.5 + 5
  899. then
  900. soundtype = love.math.random(1, 5)
  901. sounds["wallhit"]:setPitch(ballSpeed / 250)
  902. sounds["wallhit"]:play()
  903. if (ball[i].dx > 0) then
  904. ball[i].x = ball[i].x - 20
  905. else
  906. ball[i].x = ball[i].x + 20
  907. end
  908. ball[i].dx = -ball[i].dx
  909. end
  910. end
  911. if (MAP_TYPE == 2) then
  912. for i, wall in ipairs(walls) do
  913. if
  914. (ball[1].y > wall.wally and ball[1].y < wall.wally + wall.wallheight and
  915. ball[1].x > wall.wallx - ballSpeed / 200 and
  916. ball[1].x < wall.wallx + 10 + ballSpeed / 200)
  917. then
  918. controllerSer()
  919. soundtype = love.math.random(1, 5)
  920. sounds["wallhit"]:setPitch(ballSpeed / 250)
  921. sounds["wallhit"]:play()
  922. if (ball[1].dx > 0) then
  923. ball[1].x = ball[1].x - 1
  924. else
  925. ball[1].x = ball[1].x + 1
  926. end
  927. ball[1].dx = -ball[1].dx
  928. elseif
  929. (ball[1].y > wall.wally - 15 and ball[1].y < wall.wally + wall.wallheight + 10 and
  930. ball[1].x > wall.wallx and
  931. ball[1].x < wall.wallx + 10)
  932. then
  933. controllerSer()
  934. soundtype = love.math.random(1, 5)
  935. sounds["wallhit"]:setPitch(ballSpeed / 250)
  936. sounds["wallhit"]:play()
  937. if (ball[1].dy > 0) then
  938. ball[1].y = ball[1].y - 1
  939. else
  940. ball[1].y = ball[1].y + 1
  941. end
  942. ball[1].dy = -ball[1].dy
  943. end
  944. end
  945. end
  946. end
  947. function rules(query, i)
  948. if query == "p1hit" then
  949. if gameMode == "normal" then
  950. return ball[i]:collides(player1)
  951. elseif gameMode == "reversegame" then
  952. return ball[i].x < 0 and ball[i].disabled == false
  953. end
  954. end
  955. if query == "p2hit" then
  956. if gameMode == "normal" then
  957. return ball[i]:collides(player2)
  958. elseif gameMode == "reversegame" then
  959. return ball[i].x > VIRTUAL_WIDTH-10 and ball[i].disabled == false
  960. end
  961. end
  962. if query == "p1miss" then
  963. if gameMode == "reversegame" then
  964. return ball[i]:collides(player1)
  965. elseif gameMode == "normal" then
  966. return ball[i].x < 0 and ball[i].disabled == false
  967. end
  968. end
  969. if query == "p2miss" then
  970. if gameMode == "reversegame" then
  971. return ball[i]:collides(player2)
  972. elseif gameMode == "normal" then
  973. return ball[i].x > VIRTUAL_WIDTH-10 and ball[i].disabled == false
  974. end
  975. end
  976. end
  977. function clientsBaseGame(dt)
  978. if gameMode == "reverse" then
  979. reversegame(dt)
  980. end
  981. if player1nukescore > 300 then
  982. player1nukescore = 300
  983. end
  984. if player2nukescore > 300 then
  985. player2nukescore = 300
  986. end
  987. speedControl()
  988. balancer()
  989. if t < shakeDuration then
  990. t = t + dt
  991. end
  992. if (lastSentKeyP1 == p1control.up) then
  993. player1.dy = (paddle_SPEED + p2bonus) * -1
  994. print("moving player1 up")
  995. elseif (lastSentKeyP1 == p1control.down) then
  996. player1.dy = paddle_SPEED + p2bonus
  997. print("moving player1 down")
  998. else
  999. player1.dy = 0
  1000. -- print("stopping player")
  1001. end
  1002. if ((love.keyboard.isDown(p2control.up))) then
  1003. player2.dy = (paddle_SPEED + p2bonus) * -1
  1004. elseif ((love.keyboard.isDown(p2control.down))) then
  1005. player2.dy = paddle_SPEED + p2bonus
  1006. else
  1007. player2.dy = 0
  1008. end
  1009. --print("T = " .. tostring(t))
  1010. serveBot()
  1011. if gameState == 'play' then
  1012. if (AGAINST_AI == 1) then
  1013. AI(player2, maxBalls, AI_LEVEL)
  1014. end
  1015. --print(areanuclear .. striken .. player1score .. player2score)
  1016. for i = 1, maxBalls do
  1017. if rules("p1hit", i) then
  1018. if (areanuclear == 0 and striken == 1 and (player1score > ptw-2 or player2score > ptw-2)) then
  1019. --print("Calling animation")
  1020. superanimator("tensehit", 1)
  1021. print("AREA NUCLEAR?" .. areanuclear)
  1022. end
  1023. if gameMode == "practice" then
  1024. player1score = player1score + 1
  1025. end
  1026. t = 0
  1027. if (ballSpeed > 200) then
  1028. shakeMagnitude = ballSpeed / 200
  1029. else
  1030. shakeMagnitude = 0
  1031. end
  1032. shakeDuration = 1
  1033. randomtext = love.math.random(1, #textphrases)
  1034. TEXT = textphrases[randomtext]
  1035. soundtype = love.math.random(1, 1.2)
  1036. if (player1striken == 1) then
  1037. TEXT = "PLAYER 1 STRIKES"
  1038. ballSpeed = ballSpeed + player1nukescore
  1039. potentialnuke1 = 0
  1040. player1striken = 0
  1041. player1nukescore = 0
  1042. potentialstrike1 = 0
  1043. striken = 1
  1044. if areanuclear == 0 then
  1045. sounds["striking"]:setPitch(ballSpeed / 250)
  1046. sounds["striking"]:play()
  1047. else
  1048. sounds["nuclearhit"]:setPitch(1)
  1049. sounds["nuclearhit"]:play()
  1050. end
  1051. if areanuclear == 0 then
  1052. superanimator("tensehit", 1)
  1053. end
  1054. else
  1055. if areanuclear == 0 then
  1056. sounds["beep"]:setPitch(ballSpeed / 250)
  1057. sounds["beep"]:play()
  1058. else
  1059. sounds["nuclearhit"]:setPitch(1)
  1060. sounds["nuclearhit"]:play()
  1061. end
  1062. end
  1063. if (striken == 1) then
  1064. player1nukescore = player1nukescore * 1.5
  1065. if (synctype == 0) then
  1066. paddle_SPEED = paddle_SPEED * 1.10
  1067. elseif (synctype == 1) then
  1068. paddle_SPEED = ballSpeed
  1069. end
  1070. if (synctype == 0) then
  1071. AI_SPEED = AI_SPEED * 1.10
  1072. end
  1073. if (synctype == 1) then
  1074. AI_SPEED = ballSpeed * 1.1 / 10
  1075. end
  1076. ballSpeed = ballSpeed * 1.10
  1077. end
  1078. player1nukescore = player1nukescore + 10
  1079. ball[i].dx = -ball[i].dx
  1080. ball[i].x = player1.x + 30
  1081. end
  1082. if rules("p2hit", i) then
  1083. --ameState = 'quickanim'
  1084. t = 0
  1085. shakeDuration = 1
  1086. if
  1087. (areanuclear == 0 and
  1088. (striken == 1 and (player1score > ptw-2 or player2score > ptw-2)))
  1089. then
  1090. print("AREA NUCLEAR?" .. areanuclear)
  1091. superanimator("tensehit", 2)
  1092. end
  1093. if (ballSpeed > 200) then
  1094. shakeMagnitude = ballSpeed / 200
  1095. else
  1096. shakeMagnitude = 0
  1097. end
  1098. randomtext = love.math.random(1, #textphrases)
  1099. TEXT = textphrases[randomtext]
  1100. soundtype = love.math.random(1, 1.2)
  1101. if (player2striken == 1) then
  1102. TEXT = "PLAYER 2 STRIKES"
  1103. ballSpeed = ballSpeed + player2nukescore
  1104. striken = 1
  1105. player2striken = 0
  1106. potentialnuke2 = 0
  1107. player2nukescore = 0
  1108. potentialstrike2 = 0
  1109. print("AREA NUCLEAR?" .. areanuclear)
  1110. if areanuclear == 0 then
  1111. superanimator("tensehit", 2)
  1112. end
  1113. if areanuclear == 0 then
  1114. sounds["striking"]:setPitch(ballSpeed / 250)
  1115. sounds["striking"]:play()
  1116. else
  1117. sounds["nuclearhit"]:setPitch(1)
  1118. sounds["nuclearhit"]:play()
  1119. end
  1120. elseif (striken == 1) then
  1121. player2nukescore = player2nukescore * 1.5
  1122. if (synctype == 0) then
  1123. paddle_SPEED = paddle_SPEED * 1.10
  1124. end
  1125. if (synctype == 1) then
  1126. paddle_SPEED = ballSpeed
  1127. end
  1128. if (synctype == 0) then
  1129. AI_SPEED = AI_SPEED * 1.10
  1130. end
  1131. if (synctype == 1) then
  1132. AI_SPEED = ballSpeed * 1.1 / 10
  1133. end
  1134. ballSpeed = ballSpeed * 1.10
  1135. if areanuclear == 0 then
  1136. sounds["beep"]:setPitch(ballSpeed / 250)
  1137. sounds["beep"]:play()
  1138. else
  1139. sounds["nuclearhit"]:setPitch(1)
  1140. sounds["nuclearhit"]:play()
  1141. end
  1142. else
  1143. if areanuclear == 0 then
  1144. sounds["beep"]:setPitch(ballSpeed / 250)
  1145. sounds["beep"]:play()
  1146. else
  1147. sounds["nuclearhit"]:setPitch(1)
  1148. sounds["nuclearhit"]:play()
  1149. end
  1150. end
  1151. player2nukescore = player2nukescore + 10
  1152. ball[i].dx = -ball[i].dx
  1153. ball[i].x = player2.x - 30
  1154. if ((love.keyboard.isDown(p2control.up))) then
  1155. select = math.random(1, 5)
  1156. if select == 1 then
  1157. ball[i].dy = -1
  1158. elseif select == 2 then
  1159. ball[i].dy = -1.2
  1160. elseif select == 3 then
  1161. ball[i].dy = -1.5
  1162. elseif select == 4 then
  1163. ball[i].dy = -1.8
  1164. elseif select == 5 then
  1165. ball[i].dy = -2
  1166. end
  1167. elseif (love.keyboard.isDown(p2control.down))then
  1168. select = math.random(1, 5)
  1169. if select == 1 then
  1170. ball[i].dy = 1
  1171. elseif select == 2 then
  1172. ball[i].dy = 1.2
  1173. elseif select == 3 then
  1174. ball[i].dy = 1.5
  1175. elseif select == 4 then
  1176. ball[i].dy = 1.8
  1177. elseif select == 5 then
  1178. ball[i].dy = 2
  1179. end
  1180. else
  1181. if ball[i].dy < 0 then
  1182. select = math.random(1, 5)
  1183. if select == 1 then
  1184. ball[i].dy = -1
  1185. elseif select == 2 then
  1186. ball[i].dy = -1.2
  1187. elseif select == 3 then
  1188. ball[i].dy = -1.5
  1189. elseif select == 4 then
  1190. ball[i].dy = -1.8
  1191. elseif select == 5 then
  1192. ball[i].dy = -2
  1193. end
  1194. else
  1195. select = math.random(1, 5)
  1196. if select == 1 then
  1197. ball[i].dy = 1
  1198. elseif select == 2 then
  1199. ball[i].dy = 1.2
  1200. elseif select == 3 then
  1201. ball[i].dy = 1.5
  1202. elseif select == 4 then
  1203. ball[i].dy = 1.8
  1204. elseif select == 5 then
  1205. ball[i].dy = 2
  1206. end
  1207. end
  1208. end
  1209. end
  1210. hitIdentifier()
  1211. if ball[i].y <= 0 then
  1212. soundtype = love.math.random(1, 5)
  1213. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1214. sounds["wallhit"]:play()
  1215. ball[i].y = 0
  1216. ball[i].dy = -ball[i].dy
  1217. end
  1218. -- -4 to account for the ball's size
  1219. if ball[i].y >= VIRTUAL_HEIGHT - 40 then
  1220. soundtype = love.math.random(1, 5)
  1221. sounds["wallhit"]:setPitch(ballSpeed / 250)
  1222. sounds["wallhit"]:play()
  1223. ball[i].y = VIRTUAL_HEIGHT - 40
  1224. ball[i].dy = -ball[i].dy
  1225. end
  1226. --love.window.setTitle('Trying to update the ball')
  1227. if timeIsSlow then
  1228. if ballSpeed > originalSpeed / 3 then
  1229. paddle_SPEED = 30
  1230. ballSpeed = ballSpeed / (1 + (dt * 2))
  1231. end
  1232. player1nukescore = player1nukescore - (dt * 50)
  1233. if player1nukescore < 1 or ball[1].dx > 0 then
  1234. timeIsSlow = false
  1235. player1reverbav = false
  1236. ballSpeed = originalSpeed
  1237. sounds["time"]:stop()
  1238. paddle_SPEED = originalPaddle
  1239. end
  1240. end
  1241. if timeIsSlow2 then
  1242. if ballSpeed > originalSpeed / 3 then
  1243. ballSpeed = ballSpeed / (1 + (dt * 2))
  1244. end
  1245. player2nukescore = player2nukescore - (dt * 50)
  1246. if player2nukescore < 1 or ball[1].dx < 0 then
  1247. paddle_SPEED = 30
  1248. timeIsSlow2 = false
  1249. player2reverbav = false
  1250. ballSpeed = originalSpeed
  1251. sounds["time"]:stop()
  1252. paddle_SPEED = originalPaddle
  1253. end
  1254. end
  1255. ball[i]:update(dt)
  1256. end
  1257. end
  1258. goalManager()
  1259. powerAvailability()
  1260. player1:update(dt)
  1261. player2:update(dt)
  1262. end