Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

100 Zeilen
3.3 KiB

  1. selectlv = Class{}
  2. levels = {}
  3. table.insert(levels, menu:addButton("Level 1", function ()
  4. menuLoaded = false
  5. objReset()
  6. gameState = "levelgeneral"
  7. currentLevel = 1
  8. end ))
  9. table.insert(levels, menu:addButton("Level 2", function ()
  10. if saveData.levelsBeaten > 0 then
  11. menuLoaded = false
  12. objReset()
  13. gameState = "levelgeneral"
  14. currentLevel = 2
  15. end
  16. end ))
  17. table.insert(levels, menu:addButton("Level 3", function ()
  18. if saveData.levelsBeaten > 1 then
  19. menuLoaded = false
  20. objReset()
  21. gameState = "levelgeneral"
  22. currentLevel = 3
  23. end
  24. end ))
  25. table.insert(levels, menu:addButton("Level 4", function ()
  26. if saveData.levelsBeaten > 2 then
  27. menuLoaded = false
  28. objReset()
  29. gameState = "levelgeneral"
  30. currentLevel = 4
  31. end
  32. end ))
  33. table.insert(levels, menu:addButton("Level 5", function ()
  34. if saveData.levelsBeaten > 3 then
  35. menuLoaded = false
  36. objReset()
  37. gameState = "levelgeneral"
  38. currentLevel = 5
  39. end
  40. end ))
  41. table.insert(levels, menu:addButton("Level 6", function ()
  42. if saveData.levelsBeaten > 4 then
  43. menuLoaded = false
  44. objReset()
  45. gameState = "levelgeneral"
  46. currentLevel = 6
  47. end
  48. end ))
  49. table.insert(levels, menu:addButton("Level 7", function ()
  50. if saveData.levelsBeaten > 5 then
  51. menuLoaded = false
  52. objReset()
  53. gameState = "levelgeneral"
  54. currentLevel = 7
  55. end
  56. end ))
  57. table.insert(levels, menu:addButton("Go Back", function ()
  58. gameState = "menu"
  59. end ))
  60. local M = {}
  61. function selectlv.update(dt)
  62. if not menuLoaded then
  63. firstShip.x = -100
  64. menuLoaded = true
  65. table.insert(planets, planet(love.math.random(100, WINDOW_WIDTH-100), love.math.random(100, WINDOW_HEIGHT-100), 90000000, 0.3, love.graphics.newImage("entities/planet/planet.png")))
  66. if (planets[1].y < WINDOW_HEIGHT/2) then
  67. firstShip.y = love.math.random(WINDOW_HEIGHT/2, WINDOW_HEIGHT)
  68. else
  69. firstShip.y = love.math.random(0, WINDOW_HEIGHT/2)
  70. end
  71. end
  72. for i in ipairs(planets) do
  73. planets[i]:update(dt)
  74. end
  75. firstShip:update(dt)
  76. if shipIsHit then
  77. shipIsHit = false
  78. firstShip:reset()
  79. firstShip.x = -100
  80. if (planets[1].y < WINDOW_HEIGHT/2) then
  81. firstShip.y = love.math.random(WINDOW_HEIGHT/2, WINDOW_HEIGHT)
  82. else
  83. firstShip.y = love.math.random(0, WINDOW_HEIGHT/2)
  84. end
  85. --print("ship is hit")
  86. end
  87. end
  88. function selectlv.draw(dt)
  89. firstShip:draw()
  90. for i in ipairs(planets) do
  91. planets[i]:draw(dt)
  92. end
  93. menu:butt(levels, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, 40, WINDOW_WIDTH/3, "beatenGreen")
  94. love.keyboard.mouseisReleased = false
  95. end
  96. return selectlv