Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

level2.lua 1.9 KiB

3 anni fa
3 anni fa
3 anni fa
3 anni fa
3 anni fa
3 anni fa
3 anni fa
3 anni fa
3 anni fa
3 anni fa
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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, planetImage, "nodelete"))
  35. end
  36. function level2.reset()
  37. firstShip:reset()
  38. for k in pairs(planets) do
  39. planets[k] = nil
  40. end
  41. firstShip.fuel = 50
  42. local planetImage = love.graphics.newImage("entities/planet/planet" .. math.random(1, 18) .. ".png")
  43. table.insert(planets, planet(700, 500, 50, 0.3, planetImage))
  44. shipsleft = 1
  45. shipIsHit = false
  46. planetsleft = 3
  47. end
  48. function level2.hint()
  49. GUIDraw("left")
  50. love.graphics.setFont(tinyfont)
  51. if (VCAM.x > WINDOW_WIDTH/2) then
  52. love.graphics.print("←[A]",10,50)
  53. end
  54. if (VCAM.x < WINDOW_WIDTH*2) then
  55. love.graphics.print("[D]→",100,50)
  56. end
  57. end
  58. function level2.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')) then
  63. VCAM.x = VCAM.x + 10
  64. end
  65. end
  66. function level2.goBack()
  67. levelgeneral.goBack()
  68. end
  69. return level2