25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.0 KiB

  1. level1 = Class{}
  2. local levelLoaded = false
  3. local M = {}
  4. function level1.load()
  5. shipsleft = 1
  6. thrusterMax = 25
  7. firstShip.fuel = 25
  8. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  9. planetsleft = 3
  10. gameStatus = "setup"
  11. playbutts = {}
  12. guibutts = {}
  13. VCAM.x, VCAM.y = WINDOW_WIDTH/2, WINDOW_HEIGHT/2
  14. explosions = {}
  15. shipIsHit = false
  16. guimenu = mainMenu()
  17. reachedGoal = false
  18. lvlbase = base(900, 200)
  19. levelLoaded = true
  20. table.insert(playbutts, menu:addButton("Return to setup", function()
  21. gameStatus = "setup"
  22. level1.reset()
  23. end ))
  24. table.insert(guibutts, menu:addButton("Release brake!", function ()
  25. if shipsleft == 0 then
  26. selectedItem = "none"
  27. gameStatus = "play"
  28. end
  29. end
  30. ))
  31. table.insert(guibutts, menu:addButton("To menu", function ()
  32. level.goBack()
  33. end))
  34. table.insert(planets, planet(700, 200, 50, 0.3, planetImage, "nodelete"))
  35. end
  36. function level1.hint()
  37. GUIDraw("left")
  38. love.graphics.setFont(tinyfont)
  39. if (VCAM.x > WINDOW_WIDTH/2) then
  40. love.graphics.print("←[A]",10,50)
  41. end
  42. if (VCAM.x < WINDOW_WIDTH*2) then
  43. love.graphics.print("[D]→",100,50)
  44. end
  45. end
  46. function level1.reset()
  47. firstShip:reset()
  48. for k in pairs(planets) do
  49. planets[k] = nil
  50. end
  51. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  52. table.insert(planets, planet(700, 200, 50, 0.3, planetImage))
  53. shipsleft = 1
  54. shipIsHit = false
  55. firstShip.fuel = 25
  56. planetsleft = 3
  57. end
  58. function level1.GUIControl()
  59. if (love.keyboard.isDown('a') and VCAM.x > WINDOW_WIDTH/2) then
  60. VCAM.x = VCAM.x - 10
  61. end
  62. if (love.keyboard.isDown('d') and VCAM.x < WINDOW_WIDTH*2) then
  63. VCAM.x = VCAM.x + 10
  64. end
  65. end
  66. function level1.goBack()
  67. levelgeneral.goBack()
  68. end
  69. return level1