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.

131 line
3.9 KiB

  1. level8 = Class{}
  2. local levelLoaded = false
  3. local M = {}
  4. function level8.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(-100, 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. table.insert(cannons, enemy(10000, firstShip.y+200, false, 3, 0.1,firstShip.x+200))
  31. table.insert(cannons, enemy(10000, firstShip.y+200, false, 3, 0.4,firstShip.x-200))
  32. table.insert(cannons, enemy(10000, firstShip.y-200, false, 3, 0.8,firstShip.x-200))
  33. table.insert(cannons, enemy(10000, firstShip.y-200, false, 3, 1, firstShip.x+200))
  34. table.insert(cannons, enemy(10000, firstShip.y, false, 3, 2, firstShip.x+600))
  35. end
  36. end
  37. ))
  38. table.insert(guibutts, menu:addButton("To menu", function ()
  39. levelgeneral.goBack()
  40. end))
  41. --table.insert(planets, planet(1000, -100, 50, 0.3, asteroidImage, "nodelete"))
  42. end
  43. function level8.hint()
  44. GUIDraw("left")
  45. love.graphics.setFont(tinyfont)
  46. if (VCAM.x > -WINDOW_WIDTH/3) then
  47. if love.keyboard.isDown('a') then
  48. love.graphics.setColor(1,0,0,1)
  49. end
  50. love.graphics.print("←[A]",10,50)
  51. end
  52. love.graphics.setColor(1,1,1,1)
  53. if (VCAM.x < WINDOW_WIDTH*2) then
  54. if love.keyboard.isDown('d') then
  55. love.graphics.setColor(1,0,0,1)
  56. end
  57. love.graphics.print("[D]→",100,50)
  58. end
  59. love.graphics.setColor(1,1,1,1)
  60. end
  61. function level8.reset()
  62. firstShip:reset()
  63. camera.scale = 1
  64. for i in ipairs(planets) do
  65. if not planets[i].deletable then
  66. table.remove(planets, i)
  67. end
  68. end
  69. for i in ipairs(cannons) do
  70. cannons[i].timer = cannons[i].otimer
  71. end
  72. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  73. shipsleft = 1
  74. projectiles = {}
  75. cannons = {}
  76. firstShip.fuel = 75
  77. shipIsHit = false
  78. attackTimer = 5
  79. end
  80. function level8.bonusUpdate(dt)
  81. if not reachedGoal then
  82. for i in ipairs(cannons) do
  83. cannons[i]:time(dt)
  84. cannons[i].x = cannons[i].x - (math.abs(cannons[i].destX-cannons[i].x)/5)
  85. if cannons[i].appeartimer <= 0 then
  86. cannons[i].destX = cannons[i].actualdest
  87. cannons[i]:update(dt)
  88. if not cannons[i].appeared then
  89. sounds["appear"]:stop()
  90. sounds["appear"]:play()
  91. local coolx, cooly = camera:toWorldCoords(1280, 720)
  92. table.insert(explosions, explosion(coolx, cannons[i].y, 100, {1,1,1,1}, 1))
  93. cannons[i].appeared = true
  94. end
  95. end
  96. end
  97. for i in ipairs(projectiles) do
  98. projectiles[i]:update(dt)
  99. end
  100. for i in ipairs(projectiles) do
  101. if projectiles[i].killed then
  102. table.remove(projectiles, i)
  103. --print("killing")
  104. end
  105. end
  106. end
  107. end
  108. function level8.GUIControl()
  109. if (love.keyboard.isDown('a') and VCAM.x > -WINDOW_WIDTH/3) then
  110. VCAM.x = VCAM.x - 10
  111. end
  112. if (love.keyboard.isDown('d') and VCAM.x < WINDOW_WIDTH*2) then
  113. VCAM.x = VCAM.x + 10
  114. end
  115. end
  116. function level8.goBack()
  117. levelgeneral.goBack()
  118. end
  119. return level8