25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

151 satır
5.2 KiB

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