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.

584 lines
21 KiB

  1. function basegame(dt)
  2. if player1nukescore > 300 then
  3. player1nukescore = 300
  4. end
  5. if player2nukescore > 300 then
  6. player2nukescore = 300
  7. end
  8. speedControl()
  9. balancer()
  10. musicController('norm', 1)
  11. if t < shakeDuration then
  12. t = t + dt
  13. end
  14. if gameState == 'play' then
  15. if (AGAINST_AI == 1) then
  16. for i = 1, maxBalls do
  17. if (ball[i].y - player2.y >= 50 and player2.x - ball[i].x < AI_LEVEL) then
  18. player2.dy = AI_SPEED
  19. elseif (player2.y - ball[i].y >= -20 and player2.x - ball[i].x < AI_LEVEL) then
  20. player2.dy = -AI_SPEED
  21. else
  22. player2.dy = 0
  23. end
  24. if
  25. difficultyl == 350 and player2reverbav == true and VIRTUAL_WIDTH - ball[i].x < 90 and
  26. math.abs(ball[i].y - player2.y) > 150
  27. then
  28. sounds["time"]:play()
  29. player2reverbav = false
  30. timeIsSlow2 = true
  31. originalPaddle = paddle_SPEED
  32. originalSpeed = ballSpeed
  33. player2reverbav = 0
  34. potentialnuke2 = 0
  35. potentialstrike2 = 0
  36. end
  37. if (player2nukescore > AI_STRIKEMOD and striken == 0) then
  38. player2striken = 1
  39. elseif (player2nukescore > AI_NUKEMOD and striken == 1) then
  40. if (areanuclear == 1) then
  41. maxspeed = maxspeed + 50
  42. end
  43. sounds["nuke"]:play()
  44. potentialstrike2 = 0
  45. areanuclear = 1
  46. ballSpeed = ballSpeed * 2
  47. if (synctype == 0) then
  48. paddle_SPEED = paddle_SPEED * 2
  49. end
  50. if (synctype == 1) then
  51. paddle_SPEED = ballSpeed / 10
  52. end
  53. if (synctype == 0) then
  54. AI_SPEED = AI_SPEED * 2.2
  55. end
  56. if (synctype == 1) then
  57. AI_SPEED = ballSpeed * 1.1 / 10
  58. end
  59. player2nukescore = 0
  60. player2reverbav = 0
  61. potentialnuke2 = 0
  62. end
  63. end
  64. end
  65. if (love.keyboard.isDown(p1control.up)) then
  66. player1.dy = (paddle_SPEED + p1bonus) * -1
  67. elseif (love.keyboard.isDown(p1control.down)) then
  68. player1.dy = paddle_SPEED + p1bonus
  69. else
  70. player1.dy = 0
  71. end
  72. if (AGAINST_AI == 0) then
  73. if (love.keyboard.isDown(p2control.up)) then
  74. player2.dy = (paddle_SPEED + p2bonus) * -1
  75. elseif (love.keyboard.isDown(p2control.down)) then
  76. player2.dy = paddle_SPEED + p2bonus
  77. else
  78. player2.dy = 0
  79. end
  80. end
  81. for i = 1, maxBalls do
  82. if ball[i]:collides(player1) then
  83. if (areanuclear == 0 and ((player1striken or player2striken) and (player1score > 9 or player2score > 9))) then
  84. print("Calling animation")
  85. superanimator("tensehit", 1)
  86. end
  87. if gameMode == "practice" then
  88. player1score = player1score + 1
  89. end
  90. t = 0
  91. if (ballSpeed > 200) then
  92. shakeMagnitude = ballSpeed / 200
  93. else
  94. shakeMagnitude = 0
  95. end
  96. shakeDuration = 1
  97. randomtext = love.math.random(1, #textphrases)
  98. TEXT = textphrases[randomtext]
  99. soundtype = love.math.random(1, 1.2)
  100. if (player1striken == 1) then
  101. TEXT = "PLAYER 1 STRIKES"
  102. ballSpeed = ballSpeed + player1nukescore
  103. potentialnuke1 = 0
  104. player1striken = 0
  105. player1nukescore = 0
  106. potentialstrike1 = 0
  107. striken = 1
  108. if areanuclear == 0 then
  109. sounds["striking"]:setPitch(ballSpeed / 250)
  110. sounds["striking"]:play()
  111. else
  112. sounds["nuclearhit"]:setPitch(1)
  113. sounds["nuclearhit"]:play()
  114. end
  115. else
  116. if areanuclear == 0 then
  117. sounds["beep"]:setPitch(ballSpeed / 250)
  118. sounds["beep"]:play()
  119. else
  120. sounds["nuclearhit"]:setPitch(1)
  121. sounds["nuclearhit"]:play()
  122. end
  123. end
  124. if (striken == 1) then
  125. player1nukescore = player1nukescore * 1.2
  126. if (synctype == 0) then
  127. paddle_SPEED = paddle_SPEED * 1.10
  128. elseif (synctype == 1) then
  129. paddle_SPEED = ballSpeed / 10
  130. end
  131. if (synctype == 0) then
  132. AI_SPEED = AI_SPEED * 1.10
  133. end
  134. if (synctype == 1) then
  135. AI_SPEED = ballSpeed * 1.1 / 10
  136. end
  137. ballSpeed = ballSpeed * 1.10
  138. end
  139. player1nukescore = player1nukescore + 10
  140. ball[i].dx = -ball[i].dx
  141. ball[i].x = player1.x + 30
  142. if (love.keyboard.isDown(p1control.up)) then
  143. select = math.random(1, 5)
  144. if select == 1 then
  145. ball[i].dy = -1
  146. elseif select == 2 then
  147. ball[i].dy = -1.2
  148. elseif select == 3 then
  149. ball[i].dy = -1.5
  150. elseif select == 4 then
  151. ball[i].dy = -1.8
  152. elseif select == 5 then
  153. ball[i].dy = -2
  154. end
  155. elseif love.keyboard.isDown(p1control.down) then
  156. select = math.random(1, 5)
  157. if select == 1 then
  158. ball[i].dy = 1
  159. elseif select == 2 then
  160. ball[i].dy = 1.2
  161. elseif select == 3 then
  162. ball[i].dy = 1.5
  163. elseif select == 4 then
  164. ball[i].dy = 1.8
  165. elseif select == 5 then
  166. ball[i].dy = 2
  167. end
  168. else
  169. if ball[i].dy < 0 then
  170. select = math.random(1, 5)
  171. if select == 1 then
  172. ball[i].dy = -1
  173. elseif select == 2 then
  174. ball[i].dy = -1.2
  175. elseif select == 3 then
  176. ball[i].dy = -1.5
  177. elseif select == 4 then
  178. ball[i].dy = -1.8
  179. elseif select == 5 then
  180. ball[i].dy = -2
  181. end
  182. else
  183. select = math.random(1, 5)
  184. if select == 1 then
  185. ball[i].dy = 1
  186. elseif select == 2 then
  187. ball[i].dy = 1.2
  188. elseif select == 3 then
  189. ball[i].dy = 1.5
  190. elseif select == 4 then
  191. ball[i].dy = 1.8
  192. elseif select == 5 then
  193. ball[i].dy = 2
  194. end
  195. end
  196. end
  197. end
  198. if ball[i]:collides(player2) then
  199. --ameState = 'quickanim'
  200. t = 0
  201. shakeDuration = 1
  202. if
  203. (areanuclear == 0 and
  204. ((player1striken or player2striken) and (player1score > 9 or player2score > 9)))
  205. then
  206. superanimator("tensehit", 2)
  207. end
  208. if (ballSpeed > 200) then
  209. shakeMagnitude = ballSpeed / 200
  210. else
  211. shakeMagnitude = 0
  212. end
  213. randomtext = love.math.random(1, #textphrases)
  214. TEXT = textphrases[randomtext]
  215. soundtype = love.math.random(1, 1.2)
  216. if (player2striken == 1) then
  217. TEXT = "PLAYER 2 STRIKES"
  218. ballSpeed = ballSpeed + player2nukescore
  219. striken = 1
  220. player2striken = 0
  221. potentialnuke2 = 0
  222. player2nukescore = 0
  223. potentialstrike2 = 0
  224. if areanuclear == 0 then
  225. sounds["striking"]:setPitch(ballSpeed / 250)
  226. sounds["striking"]:play()
  227. else
  228. sounds["nuclearhit"]:setPitch(1)
  229. sounds["nuclearhit"]:play()
  230. end
  231. elseif (striken == 1) then
  232. player2nukescore = player2nukescore * 1.5
  233. if (synctype == 0) then
  234. paddle_SPEED = paddle_SPEED * 1.10
  235. end
  236. if (synctype == 1) then
  237. paddle_SPEED = ballSpeed / 10
  238. end
  239. if (synctype == 0) then
  240. AI_SPEED = AI_SPEED * 1.10
  241. end
  242. if (synctype == 1) then
  243. AI_SPEED = ballSpeed * 1.1 / 10
  244. end
  245. ballSpeed = ballSpeed * 1.10
  246. if areanuclear == 0 then
  247. sounds["beep"]:setPitch(ballSpeed / 250)
  248. sounds["beep"]:play()
  249. else
  250. sounds["nuclearhit"]:setPitch(1)
  251. sounds["nuclearhit"]:play()
  252. end
  253. else
  254. if areanuclear == 0 then
  255. sounds["beep"]:setPitch(ballSpeed / 250)
  256. sounds["beep"]:play()
  257. else
  258. sounds["nuclearhit"]:setPitch(1)
  259. sounds["nuclearhit"]:play()
  260. end
  261. end
  262. player2nukescore = player2nukescore + 10
  263. ball[i].dx = -ball[i].dx
  264. ball[i].x = player2.x - 30
  265. if (love.keyboard.isDown(p2control.up) or AI_SPEED < 0) then
  266. select = math.random(1, 5)
  267. if select == 1 then
  268. ball[i].dy = -1
  269. elseif select == 2 then
  270. ball[i].dy = -1.2
  271. elseif select == 3 then
  272. ball[i].dy = -1.5
  273. elseif select == 4 then
  274. ball[i].dy = -1.8
  275. elseif select == 5 then
  276. ball[i].dy = -2
  277. end
  278. elseif love.keyboard.isDown(p2control.down) or AI_SPEED > 0 then
  279. select = math.random(1, 5)
  280. if select == 1 then
  281. ball[i].dy = 1
  282. elseif select == 2 then
  283. ball[i].dy = 1.2
  284. elseif select == 3 then
  285. ball[i].dy = 1.5
  286. elseif select == 4 then
  287. ball[i].dy = 1.8
  288. elseif select == 5 then
  289. ball[i].dy = 2
  290. end
  291. else
  292. if ball[i].dy < 0 then
  293. select = math.random(1, 5)
  294. if select == 1 then
  295. ball[i].dy = -1
  296. elseif select == 2 then
  297. ball[i].dy = -1.2
  298. elseif select == 3 then
  299. ball[i].dy = -1.5
  300. elseif select == 4 then
  301. ball[i].dy = -1.8
  302. elseif select == 5 then
  303. ball[i].dy = -2
  304. end
  305. else
  306. select = math.random(1, 5)
  307. if select == 1 then
  308. ball[i].dy = 1
  309. elseif select == 2 then
  310. ball[i].dy = 1.2
  311. elseif select == 3 then
  312. ball[i].dy = 1.5
  313. elseif select == 4 then
  314. ball[i].dy = 1.8
  315. elseif select == 5 then
  316. ball[i].dy = 2
  317. end
  318. end
  319. end
  320. end
  321. if ball[i].y <= 0 then
  322. soundtype = love.math.random(1, 5)
  323. sounds["wallhit"]:setPitch(ballSpeed / 250)
  324. sounds["wallhit"]:play()
  325. ball[i].y = 0
  326. ball[i].dy = -ball[i].dy
  327. end
  328. -- -4 to account for the ball's size
  329. if ball[i].y >= VIRTUAL_HEIGHT - 40 then
  330. soundtype = love.math.random(1, 5)
  331. sounds["wallhit"]:setPitch(ballSpeed / 250)
  332. sounds["wallhit"]:play()
  333. ball[i].y = VIRTUAL_HEIGHT - 40
  334. ball[i].dy = -ball[i].dy
  335. end
  336. --love.window.setTitle('Trying to update the ball')
  337. if timeIsSlow then
  338. if ballSpeed > originalSpeed / 3 then
  339. paddle_SPEED = 30
  340. ballSpeed = ballSpeed / (1 + (dt * 2))
  341. end
  342. player1nukescore = player1nukescore - (dt * 50)
  343. if player1nukescore < 1 or ball[1].dx > 0 then
  344. timeIsSlow = false
  345. player1reverbav = false
  346. ballSpeed = originalSpeed
  347. sounds["time"]:stop()
  348. paddle_SPEED = originalPaddle
  349. end
  350. end
  351. if timeIsSlow2 then
  352. if ballSpeed > originalSpeed / 3 then
  353. ballSpeed = ballSpeed / (1 + (dt * 2))
  354. end
  355. player2nukescore = player2nukescore - (dt * 50)
  356. if player2nukescore < 1 or ball[1].dx < 0 then
  357. paddle_SPEED = 30
  358. timeIsSlow2 = false
  359. player2reverbav = false
  360. ballSpeed = originalSpeed
  361. sounds["time"]:stop()
  362. paddle_SPEED = originalPaddle
  363. end
  364. end
  365. ball[i]:update(dt)
  366. end
  367. end
  368. goalManager()
  369. powerAvailability()
  370. player1:update(dt)
  371. player2:update(dt)
  372. end
  373. function menumode(dt)
  374. if (gameState == "menu") then
  375. updateTEXT = "0.7.1 Chalkboard Update"
  376. end
  377. dangerChecker()
  378. elapsed = elapsed + dt
  379. rotation = math.sin(elapsed * 2.5) * 0.7
  380. if gameState == "assign" then
  381. controlChanger()
  382. end
  383. editor()
  384. mapChanger()
  385. end
  386. function goalManager()
  387. for i = 1, maxBalls do
  388. if (ball[i].x < 0 - ballSpeed * 0.5) then
  389. if (gameMode ~= "practice") then
  390. sounds["score"]:play()
  391. end
  392. if (nuckemodactive == 0) then
  393. areanuclear = 0
  394. nuclearanimation = 3
  395. end
  396. striken = 0
  397. player1striken = 0
  398. player2striken = 0
  399. ballSpeed = ballSet
  400. if (synctype == 0) then
  401. paddle_SPEED = ballSet / 10
  402. end
  403. if (synctype == 1) then
  404. paddle_SPEED = ballSpeed / 10
  405. end
  406. AI_SPEED = difficultyl / 10
  407. player2score = player2score + 1
  408. if (player2score == ptw and gameMode ~= "practice") then
  409. for i = 1, maxBalls do
  410. ball[i]:reset(i)
  411. end
  412. sounds["win"]:play()
  413. gameState = "done"
  414. TEXT = "Player 2 Won!"
  415. else
  416. gameState = "1serve"
  417. serveBot()
  418. for i = 1, maxBalls do
  419. ball[i]:reset(i)
  420. end
  421. end
  422. end
  423. if (ball[i].x > VIRTUAL_WIDTH + ballSpeed * 0.5) then
  424. sounds["score"]:play()
  425. if (nuckemodactive == 0) then
  426. areanuclear = 0
  427. nuclearanimation = 3
  428. end
  429. striken = 0
  430. player1striken = 0
  431. player2striken = 0
  432. ballSpeed = ballSet
  433. if (synctype == 0) then
  434. paddle_SPEED = ballSet / 10
  435. AI_SPEED = ballSet / 10
  436. end
  437. if (synctype == 1) then
  438. paddle_SPEED = ballSpeed / 10
  439. AI_SPEED = ballSpeed / 10
  440. end
  441. AI_SPEED = difficultyl / 10
  442. player1score = player1score + 1
  443. if (player1score == ptw) then
  444. ball[i]:reset(i)
  445. sounds["win"]:play()
  446. gameState = "done"
  447. TEXT = "Player 1 Won!"
  448. else
  449. gameState = "2serve"
  450. serveBot()
  451. ball[i]:reset(i)
  452. end
  453. end
  454. end
  455. end
  456. function powerAvailability()
  457. if (player1nukescore >= 20 and player1nukescore < 140) then
  458. potentialstrike1 = 1
  459. if (love.keyboard.isDown(p1control.super)) then
  460. player1striken = 1
  461. player1reverbav = 0
  462. end
  463. end
  464. if (player1nukescore >= 140) and timeIsSlow2 == false and timeIsSlow == false and maxBalls == 1 and ball[1].x < VIRTUAL_WIDTH / 2 then
  465. player1reverbav = 1
  466. if love.keyboard.isDown(p1control.counter) then
  467. powerControl(1, "special")
  468. end
  469. end
  470. if (player1nukescore >= 200) then
  471. potentialnuke1 = 1
  472. if (love.keyboard.isDown(p1control.super)) then
  473. sounds["nuke"]:play()
  474. if areanuclear == 1 then
  475. maxspeed = maxspeed + 50
  476. end
  477. areanuclear = 1
  478. potentialstrike1 = 0
  479. striken = 0
  480. ballSpeed = ballSpeed * 2
  481. if (synctype == 0) then
  482. paddle_SPEED = paddle_SPEED * 2
  483. end
  484. if (synctype == 1) then
  485. paddle_SPEED = ballSpeed / 10
  486. end
  487. if (synctype == 0) then
  488. AI_SPEED = AI_SPEED * 2.2
  489. end
  490. if (synctype == 1) then
  491. AI_SPEED = ballSpeed * 1.1 / 10
  492. end
  493. player1nukescore = 0
  494. player1reverbav = 0
  495. potentialnuke1 = 0
  496. end
  497. end
  498. if (player2nukescore >= 20 and player2nukescore <= 140) then
  499. potentialstrike2 = 1
  500. if (AGAINST_AI == 0) then
  501. if (love.keyboard.isDown(p2control.super)) then
  502. player2striken = 1
  503. player2reverbav = 0
  504. end
  505. end
  506. end
  507. if (player2nukescore >= 140) and timeIsSlow == false and timeIsSlow2 == false and maxBalls == 1 and ball[1].x > VIRTUAL_WIDTH / 2 then
  508. player2reverbav = 1
  509. if love.keyboard.isDown(p2control.counter) then
  510. sounds["time"]:play()
  511. player2reverbav = false
  512. timeIsSlow2 = true
  513. originalPaddle = paddle_SPEED
  514. originalSpeed = ballSpeed
  515. player2reverbav = 0
  516. potentialnuke2 = 0
  517. potentialstrike2 = 0
  518. end
  519. end
  520. if (player2nukescore >= 200) then
  521. potentialnuke2 = 1
  522. if (love.keyboard.isDown(p2control.super) and AGAINST_AI == 0) then
  523. sounds["nuke"]:play()
  524. if areanuclear == 1 then
  525. maxspeed = maxspeed + 50
  526. end
  527. potentialstrike2 = 0
  528. areanuclear = 1
  529. player2reverbav = 0
  530. ballSpeed = ballSpeed * 2
  531. if (synctype == 0) then
  532. paddle_SPEED = paddle_SPEED * 2
  533. end
  534. if (synctype == 1) then
  535. paddle_SPEED = ballSpeed / 10
  536. end
  537. if (synctype == 0) then
  538. AI_SPEED = AI_SPEED * 2.2
  539. end
  540. if (synctype == 1) then
  541. AI_SPEED = ballSpeed * 1.1 / 10
  542. end
  543. player2nukescore = 0
  544. potentialnuke2 = 0
  545. end
  546. end
  547. end
  548. function editor()
  549. if (gameState == "editor") then
  550. local mx, my = love.mouse.getPosition()
  551. mx = mx * DIFFERENCE_X
  552. my = my * DIFFERENCE_Y
  553. if not blockinput then
  554. love.graphics.setColor(1, 0, 0, 1)
  555. love.graphics.rectangle("fill", mx, my, 10, wall1width)
  556. love.graphics.setColor(1, 1, 1, 1)
  557. end
  558. if (love.mouse.isDown(2)) then
  559. wallbreaker(mx, my)
  560. end
  561. if (love.mouse.isDown(3)) then
  562. table.insert(walls, newWall(mx, my, 10, wall1width))
  563. end
  564. for i, wall in ipairs(walls) do
  565. love.graphics.setColor(1, 1, 1, 1)
  566. love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight)
  567. end
  568. end
  569. end