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.

3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
3 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. level4 = Class{}
  2. local levelLoaded = false
  3. local M = {}
  4. function level4.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. guibutts = {}
  11. thrusterMax = 100
  12. firstShip.fuel = 100
  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(-300, 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(-200, 400, 50, 0.3, asteroidImage, "nodelete"))
  35. table.insert(planets, planet(-200, 200, 50, 0.3, asteroidImage, "nodelete"))
  36. end
  37. function level4.reset()
  38. firstShip:reset()
  39. for k in pairs(planets) do
  40. if planets[k].deletable then
  41. planets[k] = nil
  42. end
  43. end
  44. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  45. shipsleft = 1
  46. firstShip.fuel = 100
  47. shipIsHit = false
  48. planetsleft = 3
  49. end
  50. function level4.GUIControl()
  51. if (love.keyboard.isDown('a') and VCAM.x > -WINDOW_WIDTH/2) then
  52. VCAM.x = VCAM.x - 10
  53. end
  54. if (love.keyboard.isDown('d') and VCAM.x < WINDOW_WIDTH) then
  55. VCAM.x = VCAM.x + 10
  56. end
  57. end
  58. function level4.hint()
  59. GUIDraw("left")
  60. love.graphics.setFont(tinyfont)
  61. if (VCAM.x > -WINDOW_WIDTH/2) then
  62. if love.keyboard.isDown('a') then
  63. love.graphics.setColor(1,0,0,1)
  64. end
  65. love.graphics.print("←[A]",10,50)
  66. love.graphics.setColor(1,1,1,1)
  67. end
  68. if (VCAM.x < WINDOW_WIDTH) then
  69. if love.keyboard.isDown('a') then
  70. love.graphics.setColor(1,0,0,1)
  71. end
  72. love.graphics.print("[D]→",100,50)
  73. love.graphics.setColor(1,1,1,1)
  74. end
  75. end
  76. function level4.goBack()
  77. levelgeneral.goBack()
  78. end
  79. return level4