A pong clone, but with a twist!
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

animator.lua 3.0 KiB

4 년 전
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. local player1anim = false
  2. local player2anim = false
  3. local player1animend = false
  4. local player2animaend = false
  5. local effectRange = {[0] = 0,[1] = 0}
  6. local diseffectRange = {[0] = 0,[1] = 0}
  7. function superanimator(type, param)
  8. if type == 'tensehit' then
  9. if param == 1 then
  10. --print("Animation called!")
  11. player1anim = true
  12. end
  13. if param == 2 then
  14. --print("Animation called!")
  15. player2anim = true
  16. end
  17. end
  18. end
  19. function staticanimatorcounter(dt)
  20. backgroundScroll = (backgroundScroll + background_scroll_speed * dt) % background_looping_point
  21. if (gameState == 'animation') then
  22. time_1 = time_1 + dt
  23. light = 255 - time_1 * 85
  24. if (light < 0) then
  25. time_1 = 0
  26. light = 0
  27. gameState = 'start'
  28. end
  29. end
  30. if areanuclear == 1 then
  31. if nuclearanimation > 0 then
  32. gameState = 'nuclearExplosion'
  33. nuclearanimation = nuclearanimation - dt
  34. explosionRange = explosionRange + dt*24
  35. elseif (gameState ~= 'play') then
  36. gameState = 'play'
  37. explosionRange = 0
  38. end
  39. end
  40. if gameState == "done" then
  41. if explosionRange < 40 then
  42. nuclearanimation = nuclearanimation - dt
  43. explosionRange = explosionRange + dt*24
  44. end
  45. end
  46. if (player1anim) then
  47. --print("Effect range: " .. effectRange[0])
  48. effectRange[0] = effectRange[0] + dt*24
  49. if effectRange[0] > 7500/ballSpeed then
  50. player1animend = true
  51. end
  52. end
  53. if player1animend then
  54. print("DISEffect range: " .. diseffectRange[0])
  55. diseffectRange[0] = diseffectRange[0] + dt*24
  56. if diseffectRange[0] > 50 then
  57. effectRange[0] = 0
  58. diseffectRange[0] = 0
  59. player1anim = false
  60. player1animend = false
  61. end
  62. end
  63. if (player2anim) then
  64. --print("Effect range: " .. effectRange[1])
  65. effectRange[1] = effectRange[1] + dt*24
  66. if effectRange[1] > 7500/ballSpeed then
  67. player2animend = true
  68. end
  69. end
  70. if player2animend then
  71. print("DISEffect range: " .. diseffectRange[1])
  72. diseffectRange[1] = diseffectRange[1] + dt*24
  73. if diseffectRange[1] > 50 then
  74. effectRange[1] = 0
  75. diseffectRange[1] = 0
  76. player2anim = false
  77. player2animend = false
  78. end
  79. end
  80. end
  81. function staticanimator()
  82. if player1anim or player1animend then
  83. love.graphics.setColor(140/255,70/255,70/255,(50-diseffectRange[0])/100)
  84. love.graphics.circle("fill", player1.x, player1.y , effectRange[0]*100, 100)
  85. end
  86. if player2anim or player2animend then
  87. love.graphics.setColor(70/255,70/255,140/255,(50-diseffectRange[1])/100)
  88. love.graphics.circle("fill", player2.x, player2.y , effectRange[1]*100, 100)
  89. end
  90. end
  91. function animateExplosion(x, y, v, color)
  92. love.graphics.setColor(color)
  93. love.graphics.circle("fill", x, y, explosionRange * v, 100)
  94. end