diff --git a/gamecore/init.lua b/gamecore/init.lua index 0ceac21..b172785 100644 --- a/gamecore/init.lua +++ b/gamecore/init.lua @@ -49,14 +49,14 @@ require(cwd .. "callbacks") -- Initialize and configure the core object function CoreSystem:new(DEBUGMODE) + self.modules = modules + self.debug = DebugSystem(self, DEBUGMODE) self.options = Options(self) self.input = Input(self) self.screen = Screen(self) self.scenemanager = SceneManager(self) self.lang = Lang(self) - - self.modules = modules end function CoreSystem:registerGameSystem(gamesystem) @@ -94,6 +94,7 @@ end function CoreSystem:update(dt) self.debug:update(dt) self.input:update(dt) + self.screen:update(dt) if (self.game ~= nil) then self.game:update(dt) @@ -107,6 +108,7 @@ end function CoreSystem:draw() self.scenemanager:draw() + self.screen:drawFade() end -- EXIT FUNCTIONS diff --git a/gamecore/screen.lua b/gamecore/screen.lua index 0cb4c6d..7a39c22 100644 --- a/gamecore/screen.lua +++ b/gamecore/screen.lua @@ -39,6 +39,10 @@ function ScreenManager:new(controller) CScreen.setColor(0, 0, 0, 1) love.graphics.setDefaultFilter( "nearest", "nearest", 1 ) + + self.timers = self.controller.modules.Timers(self) + + self.transitionValue = 0 end function ScreenManager:applySettings() @@ -93,6 +97,34 @@ function ScreenManager:resetScissor() love.graphics.setScissor( ) end +-- UPDATE FUNCTIONS +-- Update the screen + +function ScreenManager:update(dt) + self.timers:update(dt) +end + +-- TRANSITION FUNCTIONS +-- Handle transitions + +function ScreenManager:fadeIn(duration, easing) + local duration = duration or 1 + local easing = easing or "inExpo" + self.timers:newTween(0, duration, {transitionValue = 1}, easing) +end + +function ScreenManager:fadeOut(duration, easing) + local duration = duration or 1 + local easing = easing or "outExpo" + self.timers:newTween(0, duration, {transitionValue = 0}, easing) +end + +function ScreenManager:drawFade() + local w, h = self:getDimensions() + love.graphics.setColor(0, 0, 0, self.transitionValue) + love.graphics.rectangle("fill", 0, 0, w, h) + utils.graphics.resetColor() +end -- DRAW FUNCTIONS -- Apply draw functions to the scene