Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

74 rader
2.1 KiB

  1. level3 = Class{}
  2. local levelLoaded = false
  3. local M = {}
  4. function level3.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. reachedGoal = false
  18. lvlbase = base(900, 300)
  19. levelLoaded = true
  20. table.insert(playbutts, menu:addButton("Return to setup", function()
  21. gameStatus = "setup"
  22. levelgeneral.reset()
  23. end ))
  24. table.insert(guibutts, menu:addButton("Release brake!", function ()
  25. if shipsleft == 0 then
  26. selectedItem = "none"
  27. gameStatus = "play"
  28. end
  29. end
  30. ))
  31. table.insert(guibutts, menu:addButton("To menu", function ()
  32. levelgeneral.goBack()
  33. end))
  34. table.insert(planets, planet(900, 400, 50, 0.3, planetImage, "nodelete"))
  35. table.insert(planets, planet(700, 300, 50, 0.3, planetImage, "nodelete"))
  36. table.insert(planets, planet(900, 200, 50, 0.3, planetImage, "nodelete"))
  37. end
  38. function level3.hint()
  39. GUIDraw("left")
  40. love.graphics.setFont(tinyfont)
  41. if (VCAM.x > WINDOW_WIDTH/2) then
  42. love.graphics.print("←[A]",10,50)
  43. end
  44. if (VCAM.x < WINDOW_WIDTH*2) then
  45. love.graphics.print("[D]→",100,50)
  46. end
  47. end
  48. function level3.reset()
  49. firstShip:reset()
  50. for k in pairs(planets) do
  51. if planets[k].deletable then
  52. planets[k] = nil
  53. end
  54. end
  55. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  56. shipsleft = 1
  57. firstShip.fuel = 75
  58. shipIsHit = false
  59. planetsleft = 3
  60. end
  61. function level3.GUIControl()
  62. if (love.keyboard.isDown('a') and VCAM.x > WINDOW_WIDTH/2) then
  63. VCAM.x = VCAM.x - 10
  64. end
  65. if (love.keyboard.isDown('d')) then
  66. VCAM.x = VCAM.x + 10
  67. end
  68. end
  69. function level3.goBack()
  70. levelgeneral.goBack()
  71. end
  72. return level3