From 58cd72ac45ed78fdf160d33c641259ff4bb0b16f Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 7 Aug 2020 11:17:10 +0200 Subject: [PATCH] feat: add basic game over scene --- .../assets/gui/strings/game.png | Bin 0 -> 1478 bytes .../assets/gui/strings/over.png | Bin 0 -> 1748 bytes .../scenes/battlesystem/assets.lua | 6 +- .../scenes/battlesystem/controllers/init.lua | 9 ++ .../scenes/battlesystem/init.lua | 5 + .../scenes/battlesystem/screens/gameover.lua | 110 ++++++++++++++++++ 6 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 sonic-radiance.love/assets/gui/strings/game.png create mode 100644 sonic-radiance.love/assets/gui/strings/over.png create mode 100644 sonic-radiance.love/scenes/battlesystem/screens/gameover.lua diff --git a/sonic-radiance.love/assets/gui/strings/game.png b/sonic-radiance.love/assets/gui/strings/game.png new file mode 100644 index 0000000000000000000000000000000000000000..28bbd4218be4ea18ef822b801136f3a9a975a17a GIT binary patch literal 1478 zcmV;%1v&bOP)EX>4Tx04R}tkv&MmKpe$iQ%j3f9PA(>lA$_T5EXIMDionYs1;guFuC*#ni!H4 z7e~Rh;NZt%)xpJCR|i)?5c~jfa&%I3krMxx6k5c1aNLh~_a1le0HIN3n$%ovd`>)S(glehxvqHp#<}FOz%yfJHZw;YBNj^?taLCdn;P*Xaa`4O$`^7T ztDLtuYtq2V^-JVZ$W;L& z$2>NmL3aJ%fAG6ot2i<4B}J1!=*4k9hJo-d(5ySo_p#$NPk`VvaHY5X8x3Iklk|F9 ziyr~K+rY(jTT}Lc%N?Nq$&gLim4Y;dVi9;hqi@OseYZgOs@GdeSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{00W*$L_t(&-tAgDOY=||eiCm;uu`o>H}USEqO_x~Meza( zog5t;LF;*Yrf^Hw7HxlUsIFz^MOEe z&YSm~^CWrB`@Vz{MG+K50f2}if+&hq`kbODOV^g3NKp}-Nwn1jr%5hKg6#xa+AuaY zhHy9xp68KDr67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okky1F`nth>7# zGMT_V#X=$mz7EM-P zUr(LaYPCv*Nf8eXG1%?)Py2(xAdZfX1ai4tj@sH%Ag@uJw7eK@2=H{ns<9S}x$Hs&A_jge{CX)%x&CT(JIMH}}dlT)W z`MnU9mX^Ttyg;r}snF5U5g{uoDiY{DJUqZ)Fr@tIzP!A|A18hn%w{t@9uKuI{DkWD zda5rzKR-{~;F=JU91;QG^z@V}uc@i|_}tpsO4YI1Y$+$Jva%8d1qA{*$8pIc(PFVs zxL5=0?V?P zo}Nz2tIYE}R#sNxdpakA)zww_d_F-Il%1W8-riogTrTA0<^33c=<#^4u&{v9(b43c z#Loz6Yiom6tEI-KQgL0Xke8Q-wzf7jHZ~@gL@`3Ds;WeT?46yR^elPFWN2t;z{JEv z@~$%gY;A3!udk0$Za+obuL;7>;3&*bZugdW{2ZAQGJuiB+!3* zdlN5({V7~tUQ)vfrBW%7I~gSP%~}CX)$24U#@lrBcCe zw^OS)Vugcf?CtGAtJO;CaU2Ju(HNJb7b^fqm(+ARU2;f_&IzTmidgbW05BK~7#kat zJh_*bmx65IGcXK;rluxIz3-@##$14i&I!K)nhmeli>s?E$+1qS6F(6VB)VL#KNeiO z-R_vK{f{Sca&i)WzdxZN}X1_lOjczB3FAP|!Q zLI|Foo?x|FF)}iO+1XjD-s0jSg2AAuovW)W(f?&q36^E4)uWb{mfyY^|K5N|7%6)f q=Wl}S*Og`dQSsrPnCQ3Gr0_qI1{ 0) then self:nextAction() + else + self:looseBattle() end end end diff --git a/sonic-radiance.love/scenes/battlesystem/init.lua b/sonic-radiance.love/scenes/battlesystem/init.lua index 081b514..ce3980b 100644 --- a/sonic-radiance.love/scenes/battlesystem/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/init.lua @@ -7,6 +7,7 @@ local MenuSystem = require "scenes.battlesystem.menu" local Turns = require "scenes.battlesystem.controllers" local VictoryScreen = require "scenes.battlesystem.screens.victory" +local GameOverScreen = require "scenes.battlesystem.screens.gameover" function BattleSystem:new(battleData) BattleSystem.super.new(self) @@ -46,6 +47,10 @@ function BattleSystem:finishBattle() self.screen = VictoryScreen(self) end +function BattleSystem:looseBattle() + self.screen = GameOverScreen(self) +end + function BattleSystem:haveMenus() for k,v in pairs(self.menusystem.menus) do return true diff --git a/sonic-radiance.love/scenes/battlesystem/screens/gameover.lua b/sonic-radiance.love/scenes/battlesystem/screens/gameover.lua new file mode 100644 index 0000000..0b01b39 --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/screens/gameover.lua @@ -0,0 +1,110 @@ +local VictoryScreen = Object:extend() + +local TweenManager = require "game.modules.tweenmanager" + +local BATTLECOMPLETE_START = 2 +local BATTLECOMPLETE_STOP = 4 + +local gui = require "game.modules.gui" + +local charutils = require "game.utils.characters" + +local tw, th = 128, 32 + +function VictoryScreen:new(scene) + self.scene = scene + self.assets = scene.assets + self.turnSystem = scene.turns + + self:setVariables() + + self.continueBox = gui.newTextBox("assets/gui/dialogbox.png", tw, th) + + self.tweens = TweenManager(self) + self:prepareAnimation() +end + +function VictoryScreen:setVariables() + -- Vignette Opacity + self.vignetteOpacity = 0 + + -- Battle FInished Label + self.labelOpacity = 0 + local width, height = core.screen:getDimensions() + self.labelX = width/2 + + -- Infobox + self.tbSize = 0.6 + self.tbOpacity = 0 + + self.continue = false + self.continueValue = -1 +end + +function VictoryScreen:prepareAnimation() + -- Vignette + self.tweens:newTween(0, 0.6, {vignetteOpacity=0.75}, 'inExpo') + + -- Label + self.tweens:newTween(0, 0.6, {labelOpacity=1}, 'inExpo') + self.tweens:newTween(0.9, 0.4, {labelX=4}, 'inExpo') + + -- Infobox + self.tweens:newTween(1.4, 0.4, {tbSize=1, tbOpacity=1}, 'inExpo') + + self.tweens:newSwitch(1.8, {"continue"}) +end + +function VictoryScreen:update(dt) + self.tweens:update(dt) + + if (self.continue) then + local keys = self.scene:getKeys(1) + if (keys["left"].isPressed) then + self.continueValue = -1 + end + if (keys["right"].isPressed) then + self.continueValue = 1 + end + if (keys["A"].isPressed) then + --placeholder, pour l'instant on retourne juste au menu + scenes.debug.menu() + end + end + +end + +function VictoryScreen:draw() + local width, height = core.screen:getDimensions() + self:drawVignette(width, height) + self:drawLabel(width/2, height/4, self.labelX, self.labelOpacity) + + self:drawContinueBox(width/2, height/2 + 32, self.continueValue, self.tbSize, self.tbOpacity) +end + +function VictoryScreen:drawVignette(width, height) + love.graphics.setColor(0, 0, 0, self.vignetteOpacity) + + love.graphics.rectangle("fill", 0, 0, width, height) +end + +function VictoryScreen:drawLabel(x, y, x2, opacity) + love.graphics.setColor(1, 1, 1, opacity) + + local w, h = self.assets.images["game"]:getDimensions() + self.assets.images["game"]:draw(x - x2, y, 0, 1, 1, w, h/2) + self.assets.images["over"]:draw(x + x2, y, 0, 1, 1, 0, h/2) +end + +function VictoryScreen:drawContinueBox(x, y, continueValue, size, opacity) + love.graphics.setColor(1, 1, 1, opacity) + love.graphics.draw(self.continueBox, x, y, 0, size, size, tw/2, th/2) + local text = "continue" + if (continueValue == 1) then + text = "quit" + end + self.assets.images["arrow"]:draw(x - continueValue*64, y, math.rad(-90) * continueValue, continueValue, 1, 13, 13) + self.assets.fonts["SA2font"]:print(text, x, y-13, "center") +end + +return VictoryScreen