From 11e40da8af6e893b4f6b3151f205656a0b9b9c78 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Mon, 3 Aug 2020 09:44:25 +0200 Subject: [PATCH] improvement: use the new mini emblem on minigames Fix #21 --- .../game/modules/gui/assets.lua | 31 +++++++++++++++++++ .../game/modules/world/actors/player.lua | 14 ++++----- .../scenes/test_scene/init.lua | 1 + .../scenes/test_scene2/init.lua | 1 + 4 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 sonic-radiance.love/game/modules/gui/assets.lua diff --git a/sonic-radiance.love/game/modules/gui/assets.lua b/sonic-radiance.love/game/modules/gui/assets.lua new file mode 100644 index 0000000..a31e17b --- /dev/null +++ b/sonic-radiance.love/game/modules/gui/assets.lua @@ -0,0 +1,31 @@ +return { + ["sprites"] = { + {"cursorground", "assets/gui/cursor/ground"} + }, + ["textures"] = { + {"menucursor", "assets/gui/cursor-menulist.png"}, + {"statusbar", "assets/gui/status_bar.png"}, + {"cursorpeak", "assets/gui/cursor/peak.png"}, + + {"e_speedster", "assets/gui/emblem_speedster.png"}, + {"e_technic", "assets/gui/emblem_technic.png"}, + {"e_power", "assets/gui/emblem_power.png"}, + + {"m_speedster", "assets/gui/emblem_speedster_mask.png"}, + {"m_technic", "assets/gui/emblem_technic_mask.png"}, + {"m_power", "assets/gui/emblem_power_mask.png"}, + }, + ["fonts"] = { + {"small", "assets/gui/fonts/PixelOperator.ttf", 16} + }, + ["imagefonts"] = { + {"hudnbrs", "assets/gui/fonts/hudnumbers"}, + {"hudnbrs_small", "assets/gui/fonts/hudsmallnumbers"}, + }, + ["sfx"] = { + {"mBack", "assets/sfx/menus/back.wav"}, + {"mBeep", "assets/sfx/menus/beep.wav"}, + {"mSelect", "assets/sfx/menus/select.wav"}, + {"mError", "assets/sfx/menus/error.wav"}, + } +} diff --git a/sonic-radiance.love/game/modules/world/actors/player.lua b/sonic-radiance.love/game/modules/world/actors/player.lua index c361ba9..7cebabb 100644 --- a/sonic-radiance.love/game/modules/world/actors/player.lua +++ b/sonic-radiance.love/game/modules/world/actors/player.lua @@ -2,18 +2,19 @@ local cwd = (...):gsub('%.player$', '') .. "." local Parent = require(cwd .. "parent") local Player = Parent:extend() +local Emblem = require "game.modules.gui.emblem" + function Player:new(world, x, y, z, id) Player.super.new(self, world, "player", x, y, 0, 16, 12, 24, true) self:setGravity(480*2) self.charName = game.characters:getActiveCharacter() - self.assets:addSprite("player", "datas/gamedata/characters/" .. self.charName .. "/sprites") - self:setSprite("player", 8, 10) + self.assets:addSprite(self.charName, "datas/gamedata/characters/" .. self.charName .. "/sprites") + self:setSprite(self.charName, 8, 10) self:cloneSprite() self.guiborder = game.gui.newBorder(424, 20, 6) - self.emblem = love.graphics.newImage("assets/gui/emblem_speedster.png") - self.status = love.graphics.newImage("assets/gui/status_bar.png") + self.emblem = Emblem(game.characters:getActiveCharacterData(), self.scene) self.action = "normal" end @@ -93,9 +94,8 @@ function Player:draw() end function Player:drawHUD(id) - love.graphics.draw(self.guiborder, 424, 20, 0, -1, -1) - love.graphics.draw(self.emblem, 8, 8, 0) - love.graphics.draw(self.status, 24, 16, 0) + love.graphics.draw(self.guiborder, 0, 20, 0, 1, -1) + self.emblem:draw(424 - 40, 12) end return Player diff --git a/sonic-radiance.love/scenes/test_scene/init.lua b/sonic-radiance.love/scenes/test_scene/init.lua index a8e37a4..bc276e5 100644 --- a/sonic-radiance.love/scenes/test_scene/init.lua +++ b/sonic-radiance.love/scenes/test_scene/init.lua @@ -29,6 +29,7 @@ local World = require "game.modules.world" function MovePlayer:new(map) MovePlayer.super.new(self) + self.assets:batchImport("game.modules.gui.assets") self.assets:batchImport("scenes.test_scene.assets") World(self, "battle", map) diff --git a/sonic-radiance.love/scenes/test_scene2/init.lua b/sonic-radiance.love/scenes/test_scene2/init.lua index 0550982..6898b3f 100644 --- a/sonic-radiance.love/scenes/test_scene2/init.lua +++ b/sonic-radiance.love/scenes/test_scene2/init.lua @@ -31,6 +31,7 @@ function MovePlayer:new(playerNumber, cameraMode) local cameraMode = cameraMode or "split" MovePlayer.super.new(self) + self.assets:batchImport("game.modules.gui.assets") self.assets:batchImport("scenes.test_scene.assets") World(self, "shoot", "forest")