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 0000000..28bbd42 Binary files /dev/null and b/sonic-radiance.love/assets/gui/strings/game.png differ diff --git a/sonic-radiance.love/assets/gui/strings/over.png b/sonic-radiance.love/assets/gui/strings/over.png new file mode 100644 index 0000000..6ef2d9e Binary files /dev/null and b/sonic-radiance.love/assets/gui/strings/over.png differ diff --git a/sonic-radiance.love/scenes/battlesystem/assets.lua b/sonic-radiance.love/scenes/battlesystem/assets.lua index 5437363..7191589 100644 --- a/sonic-radiance.love/scenes/battlesystem/assets.lua +++ b/sonic-radiance.love/scenes/battlesystem/assets.lua @@ -32,7 +32,11 @@ return { {"hudturn", "assets/gui/strings/hudturn.png"}, {"battlecompleted", "assets/gui/strings/battle_completed.png" }, - {"egghead", "assets/gui/egghead.png"} + {"egghead", "assets/gui/egghead.png"}, + + {"game", "assets/gui/strings/game.png"}, + {"over", "assets/gui/strings/over.png"}, + {"arrow", "assets/gui/arrow.png"}, }, ["fonts"] = { {"small", "assets/gui/fonts/PixelOperator.ttf", 16}, diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/init.lua b/sonic-radiance.love/scenes/battlesystem/controllers/init.lua index 78987ed..fc3cc02 100644 --- a/sonic-radiance.love/scenes/battlesystem/controllers/init.lua +++ b/sonic-radiance.love/scenes/battlesystem/controllers/init.lua @@ -42,6 +42,13 @@ function TurnController:finishBattle() self.scene:finishBattle() end +function TurnController:looseBattle() + self.isActive = false + self.actionlist = {} + self.hud:movePlayerHUD(false) + self.scene:looseBattle() +end + function TurnController:update(dt) self.player:update(dt) self.ennemies:update(dt) @@ -52,6 +59,8 @@ function TurnController:update(dt) else if (self.player:countAlive() > 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