From 8048210bac3a133d902b5138a545372947a57cb7 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 16 Aug 2019 22:37:43 +0200 Subject: [PATCH] feat(game): initial "battle completed screen --- .../scenes/battlesystem/assets.lua | 1 + .../scenes/battlesystem/init.lua | 12 +++++- .../scenes/battlesystem/screens/victory.lua | 43 +++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 sonic-radiance.love/scenes/battlesystem/screens/victory.lua diff --git a/sonic-radiance.love/scenes/battlesystem/assets.lua b/sonic-radiance.love/scenes/battlesystem/assets.lua index 6190692..62db59f 100644 --- a/sonic-radiance.love/scenes/battlesystem/assets.lua +++ b/sonic-radiance.love/scenes/battlesystem/assets.lua @@ -24,6 +24,7 @@ return { {"m_power", "assets/gui/emblem_power_mask.png"}, {"hudturn", "assets/gui/strings/hudturn.png"}, + {"battlecompleted", "assets/gui/strings/battle_completed.png" } }, ["fonts"] = { {"small", "assets/gui/fonts/PixelOperator.ttf", 16}, diff --git a/sonic-radiance.love/scenes/battlesystem/init.lua b/sonic-radiance.love/scenes/battlesystem/init.lua index 5fdc3b9..708f21d 100644 --- a/sonic-radiance.love/scenes/battlesystem/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/init.lua @@ -5,6 +5,8 @@ local BattleSystem = Scene:extend() local World = require "scenes.battlesystem.world" local MenuSystem = require "scenes.battlesystem.menu" +local VictoryScreen = require "scenes.battlesystem.screens.victory" + function BattleSystem:new() BattleSystem.super.new(self) @@ -15,6 +17,8 @@ function BattleSystem:new() self:register() self:startBattle() + + self.screen = nil end function BattleSystem:initManagers() @@ -28,15 +32,21 @@ function BattleSystem:startBattle() end function BattleSystem:finishBattle() - + self.screen = VictoryScreen(self) end function BattleSystem:update(dt) self.world:update(dt) + if (self.screen ~= nil) then + self.screen:update(dt) + end end function BattleSystem:draw() self.world:draw() + if (self.screen ~= nil) then + self.screen:draw() + end end function BattleSystem:exit() diff --git a/sonic-radiance.love/scenes/battlesystem/screens/victory.lua b/sonic-radiance.love/scenes/battlesystem/screens/victory.lua new file mode 100644 index 0000000..6c3410b --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/screens/victory.lua @@ -0,0 +1,43 @@ +local VictoryScreen = Object:extend() + +local TweenManager = require "game.modules.tweenmanager" + +local BATTLECOMPLETE_START = 2 +local BATTLECOMPLETE_STOP = 4 + +function VictoryScreen:new(scene) + self.scene = scene + self.assets = scene.assets + + self.tweens = TweenManager(self) + + self.vignetteOpacity = 0 + self.labelOpacity = 0 + + local _, height = core.screen:getDimensions() + self.labelY = height/2 + + self.tweens:newTween(0, 0.6, {vignetteOpacity=0.75}, 'inExpo') + self.tweens:newTween(0, 0.6, {labelOpacity=1}, 'inExpo') + self.tweens:newTween(0.9, 0.4, {labelY=32}, 'inExpo') + +end + +function VictoryScreen:update(dt) + self.tweens:update(dt) +end + +function VictoryScreen:draw() + love.graphics.setColor(0, 0, 0, self.vignetteOpacity) + + local width, height = core.screen:getDimensions() + love.graphics.rectangle("fill", 0, 0, width, height) + love.graphics.setColor(1, 1, 1, self.labelOpacity) + + + local w, h = self.assets.images["battlecompleted"]:getDimensions() + self.assets.images["battlecompleted"]:draw(width/2, self.labelY, 0, 1, 1, w/2, h/2) + utils.graphics.resetColor() +end + +return VictoryScreen