選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

154 行
5.3 KiB

  1. level7 = Class{}
  2. local levelLoaded = false
  3. local M = {}
  4. function love.wheelmoved(x, y)
  5. if gameStatus == "play" then
  6. if y > 0 and camera.scale < 1 then
  7. camera.scale = camera.scale + 0.1
  8. elseif y < 0 and camera.scale > 0.5 then
  9. camera.scale = camera.scale - 0.1
  10. end
  11. end
  12. end
  13. function level7.load()
  14. shipsleft = 1
  15. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  16. planetsleft = 3
  17. gameStatus = "setup"
  18. playbutts = {}
  19. thrusterMax = 75
  20. firstShip.fuel = 75
  21. guibutts = {}
  22. VCAM.x, VCAM.y = WINDOW_WIDTH/2, WINDOW_HEIGHT/2
  23. explosions = {}
  24. shipIsHit = false
  25. guimenu = mainMenu()
  26. reachedGoal = false
  27. lvlbase = base(1400, WINDOW_HEIGHT/2)
  28. levelLoaded = true
  29. attackTimer = 5
  30. table.insert(playbutts, menu:addButton("Return to setup", function()
  31. gameStatus = "setup"
  32. levelgeneral.reset()
  33. end ))
  34. table.insert(guibutts, menu:addButton("Release brake!", function ()
  35. if shipsleft == 0 then
  36. selectedItem = "none"
  37. gameStatus = "play"
  38. end
  39. end
  40. ))
  41. table.insert(guibutts, menu:addButton("To menu", function ()
  42. levelgeneral.goBack()
  43. end))
  44. table.insert(cannons, enemy(10000, 100, false, 3, 5))
  45. table.insert(cannons, enemy(10000, 700, false, 3, 4))
  46. table.insert(planets, planet(1000, -100, 50, 0.3, asteroidImage, "nodelete"))
  47. table.insert(planets, planet(1000, 0, 50, 0.3, asteroidImage, "nodelete"))
  48. table.insert(planets, planet(1000, 100, 50, 0.3, asteroidImage, "nodelete"))
  49. table.insert(planets, planet(1000, 200, 50, 0.3, asteroidImage, "nodelete"))
  50. table.insert(planets, planet(1000, 300, 50, 0.3, asteroidImage, "nodelete"))
  51. table.insert(planets, planet(1000, 400, 50, 0.3, asteroidImage, "nodelete"))
  52. table.insert(planets, planet(1000, 500, 50, 0.3, asteroidImage, "nodelete"))
  53. table.insert(planets, planet(1000, 600, 50, 0.3, asteroidImage, "nodelete"))
  54. table.insert(planets, planet(1000, 700, 50, 0.3, asteroidImage, "nodelete"))
  55. table.insert(planets, planet(1000, 800, 50, 0.3, asteroidImage, "nodelete"))
  56. end
  57. function level7.hint()
  58. GUIDraw("left")
  59. love.graphics.setFont(tinyfont)
  60. if (VCAM.x > WINDOW_WIDTH/2) then
  61. if love.keyboard.isDown('a') then
  62. love.graphics.setColor(1,0,0,1)
  63. end
  64. love.graphics.print("←[A]",10,50)
  65. end
  66. love.graphics.setColor(1,1,1,1)
  67. if (VCAM.x < WINDOW_WIDTH*2) then
  68. if love.keyboard.isDown('d') then
  69. love.graphics.setColor(1,0,0,1)
  70. end
  71. love.graphics.print("[D]→",100,50)
  72. end
  73. love.graphics.setColor(1,1,1,1)
  74. end
  75. function level7.reset()
  76. firstShip:reset()
  77. camera.scale = 1
  78. for i in ipairs(planets) do
  79. if not planets[i].deletable then
  80. table.remove(planets, i)
  81. end
  82. end
  83. table.insert(planets, planet(1000, -100, 50, 0.3, asteroidImage, "nodelete"))
  84. table.insert(planets, planet(1000, 0, 50, 0.3, asteroidImage, "nodelete"))
  85. table.insert(planets, planet(1000, 100, 50, 0.3, asteroidImage, "nodelete"))
  86. table.insert(planets, planet(1000, 200, 50, 0.3, asteroidImage, "nodelete"))
  87. table.insert(planets, planet(1000, 300, 50, 0.3, asteroidImage, "nodelete"))
  88. table.insert(planets, planet(1000, 400, 50, 0.3, asteroidImage, "nodelete"))
  89. table.insert(planets, planet(1000, 500, 50, 0.3, asteroidImage, "nodelete"))
  90. table.insert(planets, planet(1000, 600, 50, 0.3, asteroidImage, "nodelete"))
  91. table.insert(planets, planet(1000, 700, 50, 0.3, asteroidImage, "nodelete"))
  92. table.insert(planets, planet(1000, 800, 50, 0.3, asteroidImage, "nodelete"))
  93. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  94. shipsleft = 1
  95. projectiles = {}
  96. for i in ipairs(cannons) do
  97. cannons[i].x = 100000
  98. cannons[i].destX = 100000
  99. cannons[i].appeared = false
  100. end
  101. cannons[1].appeartimer = 5
  102. cannons[2].appeartimer = 4
  103. firstShip.fuel = 75
  104. shipIsHit = false
  105. attackTimer = 5
  106. end
  107. function level7.bonusUpdate(dt)
  108. if not reachedGoal then
  109. for i in ipairs(cannons) do
  110. cannons[i]:time(dt)
  111. cannons[i].x = cannons[i].x - (math.abs(cannons[i].destX-cannons[i].x)/5)
  112. if cannons[i].appeartimer <= 0 then
  113. cannons[i].destX = 1200
  114. cannons[i]:update(dt)
  115. if not cannons[i].appeared then
  116. sounds["appear"]:stop()
  117. sounds["appear"]:play()
  118. table.insert(explosions, explosion(1500, cannons[i].y, 100, {1,1,1,1}, 1))
  119. cannons[i].appeared = true
  120. end
  121. end
  122. end
  123. for i in ipairs(projectiles) do
  124. projectiles[i]:update(dt)
  125. end
  126. for i in ipairs(projectiles) do
  127. if projectiles[i].killed then
  128. table.remove(projectiles, i)
  129. --print("killing")
  130. end
  131. end
  132. end
  133. end
  134. function level7.GUIControl()
  135. if (love.keyboard.isDown('a') and VCAM.x > WINDOW_WIDTH/2) then
  136. VCAM.x = VCAM.x - 10
  137. end
  138. if (love.keyboard.isDown('d')) then
  139. VCAM.x = VCAM.x + 10
  140. end
  141. end
  142. function level7.goBack()
  143. levelgeneral.goBack()
  144. end
  145. return level7