diff --git a/src/controllers/GameDirector.lua b/src/controllers/GameDirector.lua index 00efaad..078f0e7 100644 --- a/src/controllers/GameDirector.lua +++ b/src/controllers/GameDirector.lua @@ -14,6 +14,7 @@ local ButtonManager = require "util.ui.ButtonManager" -- Libraries local Sanghost = require "libs.Sanghost.Sanghost" local Pixelurite = require "libs.Pixelurite" +local MoonJohn = require "libs.MoonJohn" local GameDirector = {} @@ -30,7 +31,7 @@ function GameDirector:new() libraries = { Sanghost = Sanghost, ButtonManager = ButtonManager, Button = Button, Pixelurite = Pixelurite, CameraController = CameraController, DataPersistence = DataPersistence, - Wall = Wall, LetterboardTimer = LetterboardTimer + Wall = Wall, LetterboardTimer = LetterboardTimer, MoonJohn = MoonJohn }, fonts = { default = love.graphics.getFont(), diff --git a/src/libs/MoonJohn b/src/libs/MoonJohn index 39f662f..a8c71ca 160000 --- a/src/libs/MoonJohn +++ b/src/libs/MoonJohn @@ -1 +1 @@ -Subproject commit 39f662fd25624406f6b554dba1ab60e0643ec024 +Subproject commit a8c71ca9878dab78e797dc84195c864fc061aebd diff --git a/src/main.lua b/src/main.lua index 87d0530..60b2fce 100644 --- a/src/main.lua +++ b/src/main.lua @@ -1,4 +1,3 @@ -local MoonJohn = require "libs.MoonJohn.MoonJohn" local GameDirector = require "controllers.GameDirector" local ScaleDimension = require "util.ScaleDimension" @@ -9,7 +8,8 @@ function love.load() scaleDimension = ScaleDimension:new() scaleDimension:setGameScreenScale(800, 600) gameDirector = GameDirector:new() - sceneDirector = MoonJohn:new(require "scenes.SplashScreen":new()) + sceneDirector = gameDirector:getLibrary("MoonJohn").MoonJohn:new(require "scenes.SplashScreen":new()) + sceneDirector:setDefaultTransition(function() return gameDirector:getLibrary("MoonJohn").Transitions:FadeOut() end) --Adding Scenes to SceneDirector sceneDirector:addScene("mainMenu", require "scenes.MainMenuScene":new()) sceneDirector:addScene("levelSelection", require "scenes.LevelSelectionScene":new()) diff --git a/src/scenes/InGameScene.lua b/src/scenes/InGameScene.lua index a66189e..b477b23 100644 --- a/src/scenes/InGameScene.lua +++ b/src/scenes/InGameScene.lua @@ -39,7 +39,7 @@ function InGameScene:new(world) return setmetatable(this, InGameScene) end -function InGameScene:changeGamemode() +function InGameScene:randomizeGamemode() self.gamemodeName = self.gamemodes.names[love.math.random(#self.gamemodes.names)] self.currentGamemode = self.gamemodes[self.gamemodeName]:getInstance(self.world) self.currentGamemode:setGamemodesController(self) @@ -48,17 +48,28 @@ function InGameScene:changeGamemode() sceneDirector:switchSubscene("letterboard") end +function InGameScene:changeGamemode() + local update, draw = gameDirector:getLibrary("MoonJohn").Transitions:FadeOut() + sceneDirector:setTransition(update, draw, function() self:randomizeGamemode() end) +end + function InGameScene:increaseScore(amount) self.totalScore = self.totalScore + amount end -function InGameScene:exitGamemode(over) +function InGameScene:GoToMainGamemode() self.currentGamemode = self.DriveTheBus:getInstance(self.world) self.gamemodeName = "DriveTheBus" self.world:changeCallbacks("DriveTheBus") +end + +function InGameScene:exitGamemode(over) if over then sceneDirector:addSubscene("finalScore", require "scenes.subscenes.FinalScore":new(self.totalScore, self.DriveTheBus:getInstance(self.world).totalTime), true) sceneDirector:switchSubscene("finalScore") + else + local update, draw = gameDirector:getLibrary("MoonJohn").Transitions:FadeOut() + sceneDirector:setTransition(update, draw, function() self:GoToMainGamemode() end) end end