Skip to content

Commit

Permalink
Added support to Transitions
Browse files Browse the repository at this point in the history
Updated the MooJohn lib to correct use
  • Loading branch information
Jictyvoo committed Feb 8, 2019
1 parent 458d004 commit 9f4fcfe
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/controllers/GameDirector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/libs/MoonJohn
Submodule MoonJohn updated 4 files
+51 −10 MoonJohn.lua
+16 −0 README.md
+24 −0 Transitions.lua
+7 −0 init.lua
4 changes: 2 additions & 2 deletions src/main.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local MoonJohn = require "libs.MoonJohn.MoonJohn"
local GameDirector = require "controllers.GameDirector"
local ScaleDimension = require "util.ScaleDimension"

Expand All @@ -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())
Expand Down
15 changes: 13 additions & 2 deletions src/scenes/InGameScene.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 9f4fcfe

Please sign in to comment.