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

selectlv.lua 2.0 KiB

3年前
3年前
3年前
3年前
3年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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.y = love.math.random(0, WINDOW_HEIGHT)
  41. menuLoaded = true
  42. 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")))
  43. end
  44. for i in ipairs(planets) do
  45. planets[i]:update(dt)
  46. end
  47. firstShip:update(dt)
  48. if shipIsHit then
  49. shipIsHit = false
  50. firstShip:reset()
  51. firstShip.x = -100
  52. firstShip.y = love.math.random(0, WINDOW_HEIGHT)
  53. --print("ship is hit")
  54. end
  55. end
  56. function selectlv.draw(dt)
  57. firstShip:draw()
  58. for i in ipairs(planets) do
  59. planets[i]:draw(dt)
  60. end
  61. menu:butt(levels, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, 40, WINDOW_WIDTH/3, "beatenGreen")
  62. love.keyboard.mouseisReleased = false
  63. end
  64. return selectlv