You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. menu = Class{}
  2. menuMode = "main"
  3. local M = {}
  4. menuLoaded = false
  5. function menu.update(dt)
  6. if not menuLoaded then
  7. firstShip.x = -100
  8. menuLoaded = true
  9. planets = {}
  10. table.insert(planets, planet(love.math.random(100, WINDOW_WIDTH-100), love.math.random(100, WINDOW_HEIGHT-100), 90000000, 0.3, love.graphics.newImage("entities/planet/planet.png")))
  11. if (planets[1].y < WINDOW_HEIGHT/2) then
  12. firstShip.y = planets[1].y + love.math.random(300, 500)
  13. else
  14. firstShip.y = planets[1].y - love.math.random(300, 500)
  15. end
  16. end
  17. for i in ipairs(planets) do
  18. planets[i]:update(dt)
  19. end
  20. if animationSecsLeft > 0 then
  21. animationSecsLeft = animationSecsLeft - dt
  22. end
  23. firstShip:update(dt)
  24. if shipIsHit then
  25. shipIsHit = false
  26. firstShip:reset()
  27. firstShip.x = -100
  28. if (planets[1].y < WINDOW_HEIGHT/2) then
  29. firstShip.y = love.math.random(WINDOW_HEIGHT/2, WINDOW_HEIGHT)
  30. else
  31. firstShip.y = love.math.random(0, WINDOW_HEIGHT/2)
  32. end
  33. --print("ship is hit")
  34. end
  35. if menuMode == "settings" then
  36. local mx, my = love.mouse.getPosition()
  37. local vmx, vmy = camera:getMousePosition()
  38. local vmx = vmx * DIFFERENCE_X
  39. local vmy = vmy * DIFFERENCE_Y
  40. local mx = mx * DIFFERENCE_X
  41. local my = my * DIFFERENCE_Y
  42. volumeSlider:update(mx, my)
  43. end
  44. end
  45. function menu.draw(dt)
  46. firstShip:draw()
  47. for i in ipairs(planets) do
  48. planets[i]:draw(dt)
  49. end
  50. if animationSecsLeft > 0 then
  51. love.graphics.setColor(1,1,1,1-1/(animationSecsLeft+0.000001))
  52. love.graphics.draw(logo, 0,0)
  53. else
  54. love.graphics.setFont(titlefont)
  55. love.graphics.printf("NuclearGravity", 0, 20, WINDOW_WIDTH, "center")
  56. if menuMode == "main" then
  57. menu:butt(buttons, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, 40, WINDOW_WIDTH/3)
  58. elseif menuMode == "settings" then
  59. menu:butt(mainsettings, WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH/2, WINDOW_HEIGHT/2, 40, WINDOW_WIDTH/3)
  60. love.graphics.setColor(254, 67, 101)
  61. love.graphics.setFont(tinyfont)
  62. love.graphics.printf("Sound volume:", 0, WINDOW_HEIGHT/2-140, WINDOW_WIDTH, "center")
  63. -- draw slider, set color and line style before calling
  64. volumeSlider:draw()
  65. else
  66. print("[EE]No menu found! " .. menu.mode)
  67. end
  68. love.keyboard.mouseisReleased = false
  69. end
  70. end
  71. return menu