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

59 行
1.6 KiB

  1. selectlv = Class{}
  2. levels = {}
  3. table.insert(levels, menu:addButton("Level 1", function ()
  4. menuLoaded = false
  5. objReset()
  6. gameState = "level1"
  7. end ))
  8. table.insert(levels, menu:addButton("Level 2", function ()
  9. if saveData.levelsBeaten > 0 then
  10. menuLoaded = false
  11. objReset()
  12. gameState = "level2"
  13. end
  14. end ))
  15. table.insert(levels, menu:addButton("Level 3", function ()
  16. if saveData.levelsBeaten > 1 then
  17. menuLoaded = false
  18. objReset()
  19. gameState = "level3"
  20. end
  21. end ))
  22. table.insert(levels, menu:addButton("Go Back", function ()
  23. gameState = "menu"
  24. end ))
  25. local M = {}
  26. function selectlv.update(dt)
  27. if not menuLoaded then
  28. firstShip.x = -100
  29. firstShip.speed = 10
  30. firstShip.y = love.math.random(0, WINDOW_HEIGHT)
  31. menuLoaded = true
  32. 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")))
  33. end
  34. for i in ipairs(planets) do
  35. planets[i]:update(dt)
  36. end
  37. firstShip:update(dt)
  38. if shipIsHit then
  39. shipIsHit = false
  40. firstShip:reset()
  41. firstShip.x = -100
  42. firstShip.speed = 10
  43. firstShip.y = love.math.random(0, WINDOW_HEIGHT)
  44. --print("ship is hit")
  45. end
  46. end
  47. function selectlv.draw(dt)
  48. firstShip:draw()
  49. for i in ipairs(planets) do
  50. planets[i]:draw(dt)
  51. end
  52. menu:butt(levels, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, 40, WINDOW_WIDTH/3, "beatenGreen")
  53. end
  54. return selectlv