Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

selectlv.lua 3.3 KiB

há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
há 3 anos
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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