local path = string.sub(..., 1, string.len(...) - string.len(".core.scene")) local atlas = require(path..'.core.atlas') local helium = require(path..'.dummy') local input = require(path..'.core.input') local scene = { activeScene = nil } scene.__index = scene function scene.new(cached) local self = { atlas = cached and atlas.create() or nil, cached = cached or false, subscriptions = {}, buffer = {} } return setmetatable(self, scene) end local skipframes = 10 function scene.bench() if skipframes == 0 then local startTime = love.timer.getTime() for i = 1, 20 do love.graphics.print(i,-100,-100) end helium.setBench((love.timer.getTime()-startTime)/5) elseif skipframes>0 then skipframes = skipframes - 1 end end function scene:activate() scene.activeScene = self end --Keeps the scene in memory with potentially the atlas function scene:deactivate() scene.activeScene = nil end function scene:reload() self.atlas = self.cached and atlas.create() or nil self.ioSubscriptions = {} self.buffer = {} end --Nukes the scene and it's elements and atlases and subscriptions from memory --To achieve same state as after creation, use reload function scene:unload() self.atlas = nil self.buffer = nil self.ioSubscriptions = nil end function scene:draw() helium.stack.newFrame() if not helium.benchNum then scene.bench() end --We don't want any side effects affecting internal rendering love.graphics.reset() for i, e in ipairs(self.buffer) do e:externalRender() end end function scene:update(dt) for i = 1, #self.buffer do if self.buffer[i]:externalUpdate(i) then table.remove(self.buffer, i) end end end return scene