25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

76 satır
2.1 KiB

  1. level2 = Class{}
  2. local levelLoaded = false
  3. local M = {}
  4. function level2.load()
  5. shipsleft = 1
  6. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  7. planetsleft = 3
  8. thrusterMax = 50
  9. firstShip.fuel = 50
  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(1800, 500)
  19. levelLoaded = true
  20. table.insert(playbutts, menu:addButton("Return to setup", function()
  21. gameStatus = "setup"
  22. level2.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. level2.goBack()
  33. end))
  34. table.insert(planets, planet(700, 500, 50, 0.3, asteroidImage, "nodelete"))
  35. end
  36. function level2.reset()
  37. firstShip:reset()
  38. firstShip.fuel = 50
  39. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  40. table.insert(planets, planet(700, 500, 50, 0.3, asteroidImage))
  41. shipsleft = 1
  42. shipIsHit = false
  43. end
  44. function level2.hint()
  45. GUIDraw("left")
  46. love.graphics.setFont(tinyfont)
  47. if (VCAM.x > WINDOW_WIDTH/2) then
  48. if love.keyboard.isDown('a') then
  49. love.graphics.setColor(1,0,0,1)
  50. end
  51. love.graphics.print("←[A]",10,50)
  52. love.graphics.setColor(1,1,1,1)
  53. end
  54. if (VCAM.x < WINDOW_WIDTH*2) then
  55. if love.keyboard.isDown('d') then
  56. love.graphics.setColor(1,0,0,1)
  57. end
  58. love.graphics.print("[D]→",100,50)
  59. love.graphics.setColor(1,1,1,1)
  60. end
  61. end
  62. function level2.GUIControl()
  63. if (love.keyboard.isDown('a') and VCAM.x > WINDOW_WIDTH/2) then
  64. VCAM.x = VCAM.x - 10
  65. end
  66. if (love.keyboard.isDown('d')) then
  67. VCAM.x = VCAM.x + 10
  68. end
  69. end
  70. function level2.goBack()
  71. levelgeneral.goBack()
  72. end
  73. return level2