選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

70 行
2.0 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("Go Back", function ()
  34. gameState = "menu"
  35. end ))
  36. local M = {}
  37. function selectlv.update(dt)
  38. if not menuLoaded then
  39. firstShip.x = -100
  40. firstShip.speed = 10
  41. firstShip.y = love.math.random(0, WINDOW_HEIGHT)
  42. menuLoaded = true
  43. 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")))
  44. end
  45. for i in ipairs(planets) do
  46. planets[i]:update(dt)
  47. end
  48. firstShip:update(dt)
  49. if shipIsHit then
  50. shipIsHit = false
  51. firstShip:reset()
  52. firstShip.x = -100
  53. firstShip.speed = 10
  54. firstShip.y = love.math.random(0, WINDOW_HEIGHT)
  55. --print("ship is hit")
  56. end
  57. end
  58. function selectlv.draw(dt)
  59. firstShip:draw()
  60. for i in ipairs(planets) do
  61. planets[i]:draw(dt)
  62. end
  63. menu:butt(levels, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, 40, WINDOW_WIDTH/3, "beatenGreen")
  64. end
  65. return selectlv