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.

64 satır
1.8 KiB

  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 = 200
  12. firstShip.fuel = 200
  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, planetImage, "nodelete"))
  35. table.insert(planets, planet(-200, 200, 50, 0.3, planetImage, "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 = 200
  47. shipIsHit = false
  48. planetsleft = 3
  49. end
  50. function level4.GUIControl()
  51. if (love.keyboard.isDown('a') and VCAM.x > -WINDOW_WIDTH) then
  52. VCAM.x = VCAM.x - 10
  53. end
  54. if (love.keyboard.isDown('d') and VCAM.x < WINDOW_WIDTH*2) then
  55. VCAM.x = VCAM.x + 10
  56. end
  57. end
  58. function level4.goBack()
  59. levelgeneral.goBack()
  60. end
  61. return level4