From f7f1a772f7f1dab551d564a700c810c1bb87d67e Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 20 Mar 2021 17:10:09 +0100 Subject: [PATCH] feat: add message engine on overworld --- sonic-radiance.love/scenes/overworld/init.lua | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sonic-radiance.love/scenes/overworld/init.lua b/sonic-radiance.love/scenes/overworld/init.lua index 49ec8c1..f13099f 100644 --- a/sonic-radiance.love/scenes/overworld/init.lua +++ b/sonic-radiance.love/scenes/overworld/init.lua @@ -32,6 +32,8 @@ local screens = require "scenes.overworld.screens" local gui = require "game.modules.gui" local TweenManager = require "game.modules.tweenmanager" +local PLAYER_MESSAGE = 240 - 32 + function MovePlayer:new() MovePlayer.super.new(self) self.charsetManager = CharsetManager(self) @@ -56,6 +58,15 @@ function MovePlayer:new() self.emblemPosition = 368 self.ringBorder = 16 self.timeBorder = -10 + self.message = "Test de message" + self.messageOpacity = 0 +end + +function MovePlayer:showMessage(message) + self.message = message + self.messageOpacity = 1 + self.tweens:newTween(0, 0.2, {messageOpacity = 1}, 'inOutCubic') + self.tweens:newTween(1, 0.2, {messageOpacity = 0}, 'inOutCubic') end function MovePlayer:registerScreen(screen) @@ -141,6 +152,15 @@ function MovePlayer:draw() if (self.currentScreen ~= nil) then self.currentScreen:drawForeground() end + + love.graphics.setColor(0,0,0, 0.5 * self.messageOpacity) + love.graphics.rectangle("fill", 0, PLAYER_MESSAGE, 424, 16) + if (self.messageOpacity > 0) then + self.assets.fonts["small"]:setColor(1,1,1, self.messageOpacity) + self.assets.fonts["small"]:draw(self.message, 424/2, PLAYER_MESSAGE - 1, -1, "center") + self.assets.fonts["small"]:setColor(1,1,1, 1) + end + utils.graphics.resetColor() end return MovePlayer