system = {}
system.frameNumber = 0


---------------------------------
-- Runs the main-loop of the game
---------------------------------
function system.run()
   system.frameNumber = 0
   local timer = pge.timer.create()
   
   load()
   
   while (system.isRunning()) do
      system.frameNumber = system.frameNumber + 1
      timer:update()
      dt = timer:getdelta()

      controls.update()
      update(dt)
      
      activeResource = nil
      pge.gfx.startdrawing()
      pge.gfx.clearscreen()
      draw()
      pge.gfx.enddrawing()
      pge.gfx.swapbuffers(false)
   end
end


----------------------------------
-- Stops the main-loop of the game
----------------------------------
function system.exit()
   pge.exit()
end


------------------------------------------
-- Checks whether the main-loop is running
------------------------------------------
function system.isRunning()
   return pge.running()
end


---------------------------------------
-- Gets the number of the current-frame
---------------------------------------
function system.getFrame()
   return system.frameNumber
end
