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.

83 satır
2.4 KiB

  1. level5 = Class{}
  2. local levelLoaded = false
  3. local M = {}
  4. function level5.load()
  5. shipsleft = 1
  6. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  7. planetsleft = 10
  8. gameStatus = "setup"
  9. playbutts = {}
  10. guibutts = {}
  11. thrusterMax = 100
  12. firstShip.fuel = 100
  13. VCAM.x, VCAM.y = 0, WINDOW_HEIGHT/2
  14. explosions = {}
  15. shipIsHit = false
  16. guimenu = mainMenu()
  17. reachedGoal = false
  18. lvlbase = base(50, 2000)
  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(0, 2000, 50, 0.3, asteroidImage, "nodelete"))
  35. table.insert(planets, planet(100, 2000, 50, 0.3, asteroidImage, "nodelete"))
  36. table.insert(planets, planet(50, 1700, 50, 0.3, asteroidImage, "nodelete"))
  37. end
  38. function level5.reset()
  39. firstShip:reset()
  40. for k in pairs(planets) do
  41. if planets[k].deletable then
  42. planets[k] = nil
  43. end
  44. end
  45. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  46. shipsleft = 1
  47. firstShip.fuel = 100
  48. shipIsHit = false
  49. planetsleft = 10
  50. end
  51. function level5.GUIControl()
  52. if (love.keyboard.isDown('w') and VCAM.y > -WINDOW_WIDTH) then
  53. VCAM.y = VCAM.y - 10
  54. end
  55. if (love.keyboard.isDown('s') and VCAM.y < WINDOW_WIDTH*2) then
  56. VCAM.y = VCAM.y + 10
  57. end
  58. end
  59. function level5.hint()
  60. GUIDraw("up")
  61. love.graphics.setFont(tinyfont)
  62. if (VCAM.y > -WINDOW_WIDTH) then
  63. if love.keyboard.isDown('w') then
  64. love.graphics.setColor(1,0,0,1)
  65. end
  66. love.graphics.print("↑[W]",50,10)
  67. love.graphics.setColor(1,1,1,1)
  68. end
  69. if (VCAM.y < WINDOW_WIDTH*2) then
  70. if love.keyboard.isDown('s') then
  71. love.graphics.setColor(1,0,0,1)
  72. end
  73. love.graphics.print("↓[S]",50,100)
  74. love.graphics.setColor(1,1,1,1)
  75. end
  76. end
  77. function level5.goBack()
  78. levelgeneral.goBack()
  79. end
  80. return level5