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.

115 lines
2.9 KiB

  1. gameState = "menu"
  2. animationSecsLeft = 3
  3. require 'src/dependencies'
  4. math.randomseed(os.time())
  5. local discordRPC = require("src/discordRPC")
  6. local appId = "889428447972175933"
  7. --VARIABLES
  8. RESOLUTION_SET = 0
  9. isFullscreen = 0
  10. DIFFERENCE_X = 1
  11. DIFFERENCE_Y = 1
  12. WINDOW_WIDTH = 1280
  13. WINDOW_HEIGHT = 720
  14. OFFSET_X = 0
  15. OFFSET_Y = 0
  16. cameraControl = false
  17. currentLevel = 0
  18. saveData = {
  19. levelsBeaten = 0,
  20. score = 0
  21. }
  22. mainsettings = {}
  23. planets = {}
  24. buttons = {}
  25. cannons = {}
  26. projectiles = {}
  27. menu = mainMenu()
  28. function love.wheelmoved(x, y)
  29. if gameStatus == "play" and cameraControl then
  30. if y > 0 and camera.scale < 1 then
  31. camera.scale = camera.scale + 0.1
  32. elseif y < 0 and camera.scale > 0.5 then
  33. camera.scale = camera.scale - 0.1
  34. end
  35. end
  36. end
  37. function love.keyreleased(key)
  38. if key == "escape" and gameStatus == "play" then
  39. if pauseStatus then
  40. pauseStatus = false
  41. pauseState = "main"
  42. else pauseStatus = true
  43. end
  44. end
  45. end
  46. function love.load()
  47. love.graphics.setLineWidth(4)
  48. pauseMake()
  49. testwalls = love.filesystem.load("save")
  50. if testwalls ~= nil then
  51. saveData = love.filesystem.load("save")()
  52. --print("Save file found")
  53. else
  54. --print("No save file found!")
  55. end
  56. if saveData.score == nil then
  57. saveData.score = 0
  58. end
  59. discordRPC.initialize(appId, true)
  60. local now = os.time(os.date("*t"))
  61. presence = {
  62. state = "Having a good time",
  63. details = "Main Menu",
  64. largeImageKey = "gravitynew",
  65. largeImageText = "Gravity",
  66. }
  67. nextPresenceUpdate = 0
  68. tick.framerate = 60
  69. camera = Camera()
  70. BG = love.graphics.newImage("entities/background.jpg")
  71. logo = love.graphics.newImage("src/logo.png")
  72. simpleScale.setWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT)
  73. firstShip = ship(-500, -500, "entities/ship/smol_white_01.png")
  74. VCAM = VCAM(WINDOW_WIDTH/2, WINDOW_HEIGHT/2)
  75. tinyfont = love.graphics.newFont("src/font.ttf", 15)
  76. smallfont = love.graphics.newFont("src/font.ttf", 25)
  77. titlefont = love.graphics.newFont("src/font.ttf", 50)
  78. myscreen = fullScreener(RESOLUTION_SET, isFullscreen, DIFFERENCE_X, DIFFERENCE_Y, OFFSET_X, OFFSET_Y)
  79. --table.insert(planets, planet(100, WINDOW_HEIGHT/2-100, 1010000000, 1))
  80. buttonClutter()
  81. --planet2 = planet(1000, 300, 1000000000, 20)
  82. end
  83. function love.update(dt)
  84. stateUpdate(dt)
  85. if nextPresenceUpdate < love.timer.getTime() then
  86. discordRPC.updatePresence(presence)
  87. nextPresenceUpdate = love.timer.getTime() + 2.0
  88. end
  89. discordRPC.runCallbacks()
  90. love.window.setTitle("Nuclear Gravity")
  91. end
  92. function love.draw()
  93. simpleScale.set()
  94. love.graphics.clear(30 / 255,30 / 255,30 / 255,1)
  95. stateDraw()
  96. simpleScale.unSet()
  97. end
  98. function love.mousereleased(x, y, button)
  99. love.keyboard.mouseisReleased = true
  100. end
  101. function objReset()
  102. firstShip:reset()
  103. planets = {}
  104. end