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

level1.lua 2.4 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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, asteroidImage, "nodelete"))
  35. end
  36. function level1.hint()
  37. GUIDraw("left")
  38. love.graphics.setFont(tinyfont)
  39. love.graphics.setColor(1,1,1,1)
  40. if (VCAM.x > WINDOW_WIDTH/2) then
  41. if love.keyboard.isDown('a') then
  42. love.graphics.setColor(1,0,0,1)
  43. end
  44. love.graphics.print("←[A]",10,50)
  45. love.graphics.setColor(1,1,1,1)
  46. end
  47. if (VCAM.x < WINDOW_WIDTH*2) then
  48. if love.keyboard.isDown('d') then
  49. love.graphics.setColor(1,0,0,1)
  50. end
  51. love.graphics.print("[D]→",100,50)
  52. love.graphics.setColor(1,1,1,1)
  53. end
  54. love.graphics.setColor(1,1,1,1)
  55. end
  56. function level1.reset()
  57. firstShip:reset()
  58. for k in pairs(planets) do
  59. planets[k] = nil
  60. end
  61. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  62. table.insert(planets, planet(700, 200, 50, 0.3, asteroidImage))
  63. shipsleft = 1
  64. shipIsHit = false
  65. firstShip.fuel = 25
  66. planetsleft = 3
  67. end
  68. function level1.GUIControl()
  69. if (love.keyboard.isDown('a') and VCAM.x > WINDOW_WIDTH/2) then
  70. VCAM.x = VCAM.x - 10
  71. end
  72. if (love.keyboard.isDown('d') and VCAM.x < WINDOW_WIDTH*2) then
  73. VCAM.x = VCAM.x + 10
  74. end
  75. end
  76. function level1.goBack()
  77. levelgeneral.goBack()
  78. end
  79. return level1