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

level6.lua 3.6 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. level6 = Class{}
  2. local levelLoaded = false
  3. local M = {}
  4. function level6.load()
  5. shipsleft = 1
  6. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  7. planetsleft = 3
  8. gameStatus = "setup"
  9. playbutts = {}
  10. thrusterMax = 0
  11. firstShip.fuel = 0
  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(1600, 400)
  19. levelLoaded = true
  20. attackTimer = 5
  21. table.insert(playbutts, menu:addButton("Return to setup", function()
  22. gameStatus = "setup"
  23. levelgeneral.reset()
  24. end ))
  25. table.insert(guibutts, menu:addButton("Release brake!", function ()
  26. if shipsleft == 0 then
  27. selectedItem = "none"
  28. gameStatus = "play"
  29. end
  30. end
  31. ))
  32. table.insert(guibutts, menu:addButton("To menu", function ()
  33. levelgeneral.goBack()
  34. end))
  35. table.insert(cannons, enemy(10000, 400, false, 3))
  36. table.insert(planets, planet(1600, 250, 50, 0.3, asteroidImage, "nodelete"))
  37. table.insert(planets, planet(1600, 550, 50, 0.3, asteroidImage, "nodelete"))
  38. end
  39. function level6.hint()
  40. GUIDraw("left")
  41. love.graphics.setFont(tinyfont)
  42. if (VCAM.x > WINDOW_WIDTH/2) then
  43. if love.keyboard.isDown('a') then
  44. love.graphics.setColor(1,0,0,1)
  45. end
  46. love.graphics.print("←[A]",10,50)
  47. love.graphics.setColor(1,1,1,1)
  48. end
  49. if (VCAM.x < WINDOW_WIDTH*2) then
  50. if love.keyboard.isDown('d') then
  51. love.graphics.setColor(1,0,0,1)
  52. end
  53. love.graphics.print("[D]→",100,50)
  54. love.graphics.setColor(1,1,1,1)
  55. end
  56. end
  57. function level6.reset()
  58. firstShip:reset()
  59. for i in ipairs(planets) do
  60. if not planets[i].deletable then
  61. table.remove(planets, i)
  62. end
  63. end
  64. table.insert(planets, planet(1600, 250, 50, 0.3, asteroidImage, "nodelete"))
  65. table.insert(planets, planet(1600, 550, 50, 0.3, asteroidImage, "nodelete"))
  66. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  67. shipsleft = 1
  68. projectiles = {}
  69. for i in ipairs(cannons) do
  70. cannons[i].timer = cannons[i].otimer
  71. end
  72. cannons[1].x = 100000
  73. cannons[1].destX = 100000
  74. firstShip.fuel = 0
  75. shipIsHit = false
  76. attackTimer = 5
  77. cannons[1].appeared = false
  78. end
  79. function level6.bonusUpdate(dt)
  80. if not reachedGoal then
  81. if attackTimer >= 0 then
  82. attackTimer = attackTimer - dt
  83. else
  84. cannons[1].destX = 1200
  85. cannons[1]:update(dt)
  86. if not cannons[1].appeared then
  87. sounds["appear"]:stop()
  88. sounds["appear"]:play()
  89. if #explosions == 0 then
  90. table.insert(explosions, explosion(1400, 400, 100, {1,1,1,1}))
  91. explosions[1].type = 1
  92. end
  93. camera:shake(8, 1, 60, 'X')
  94. cannons[1].appeared = true
  95. end
  96. end
  97. for i in ipairs(projectiles) do
  98. projectiles[i]:update(dt)
  99. end
  100. for i in ipairs(projectiles) do
  101. if projectiles[i].killed then
  102. table.remove(projectiles, i)
  103. --print("killing")
  104. end
  105. end
  106. cannons[1].x = cannons[1].x - (math.abs(cannons[1].destX-cannons[1].x)/5)
  107. end
  108. end
  109. function level6.GUIControl()
  110. if (love.keyboard.isDown('a') and VCAM.x > WINDOW_WIDTH/2) then
  111. VCAM.x = VCAM.x - 10
  112. end
  113. if (love.keyboard.isDown('d')) then
  114. VCAM.x = VCAM.x + 10
  115. end
  116. end
  117. function level6.goBack()
  118. levelgeneral.goBack()
  119. end
  120. return level6