diff --git a/sonic-radiance.love/game/modules/subgames/hud.lua b/sonic-radiance.love/game/modules/subgames/hud.lua new file mode 100644 index 0000000..ce9f9c3 --- /dev/null +++ b/sonic-radiance.love/game/modules/subgames/hud.lua @@ -0,0 +1,62 @@ +local GuiScreen = require "birb.modules.gui.screen" +local OWScreen = GuiScreen:extend() + +local Composite = require "birb.modules.gui.elements.composite" +local Counter = require "birb.modules.gui.elements.counter" +local Asset = require "birb.modules.gui.elements.assets" + +local Emblems = require "scenes.overworld.gui.hudelements.emblems" + +local show = { + -- {"rings", "movement", 0, 0.3, 16, 16, "inOutQuart"}, + -- {"time", "movement", 0, 0.3, 408, 250, "inOutQuart"}, + {"teamEmblems", "movement", 0, 0.3, 368, 24, "inOutQuart"}, + -- {"lifebars", "movement", 0, 0.3, 8, 168, "inOutQuart"}, +} + +local hide = { + -- {"rings", "movement", 0, 0.3, -16, -16, "inOutQuart"}, + -- {"time", "movement", 0, 0.3, 408, 250, "inOutQuart"}, + {"teamEmblems", "movement", 0, 0.3, 500, 24, "inOutQuart"}, + -- {"lifebars", "movement", 0, 0.3, -124, 168, "inOutQuart"}, +} + +local showMenu = { + -- {"rings", "movement", 0, 0.5, 8, 8, "inOutQuart"}, + -- {"time", "movement", 0, 0.5, 408, 221, "inOutQuart"}, + {"teamEmblems", "movement", 0, 0.3, 500, 24, "inOutQuart"}, + -- {"lifebars", "movement", 0, 0.3, -124, 168, "inOutQuart"}, +} + +local hideMenu = { + -- {"rings", "movement", 0, 0.5, 16, 16, "inOutQuart"}, + -- {"time", "movement", 0, 0.5, 408, 250, "inOutQuart"}, + {"teamEmblems", "movement", 0, 0.3, 368, 24, "inOutQuart"}, + -- {"lifebars", "movement", 0, 0.3, 8, 168, "inOutQuart"} +} + +function OWScreen:new() + OWScreen.super.new(self, "hud") + self:addTransform("show", show) + self:addTransform("hide", hide) + self:addTransform("pause", showMenu) + self:addTransform("unpause", hideMenu) + self:show() +end + +function OWScreen:createElements() + local list = { + -- {Composite("rings", -16, -16, { + -- {Asset("guiRing", "images", "guiRing", -1, -1), 0, 0}, + -- {Counter("turnCnt", "hudnbrs", game.loot, "rings", 3, -1, -1), 14, 1} + -- }), 0, -100}, + -- {TimeElement("hudnbrs", 408, 250, "right"), 0, -100}, + Emblems(500, 24), + -- Lifebars(-124, 168), + -- Interactions() + } + + return list +end + +return OWScreen diff --git a/sonic-radiance.love/game/modules/subgames/init.lua b/sonic-radiance.love/game/modules/subgames/init.lua index f1c1942..eb1192b 100644 --- a/sonic-radiance.love/game/modules/subgames/init.lua +++ b/sonic-radiance.love/game/modules/subgames/init.lua @@ -3,6 +3,7 @@ local PlayStyle = Scene:extend() local TweenManager = require "birb.classes.time" local PauseScreen = require("game.modules.subgames.pause") +local HUD = require("game.modules.subgames.hud") local TestWorld = require("game.modules.subgames.world.parent") function PlayStyle:new(supportedLevels, missionfile) @@ -17,6 +18,7 @@ function PlayStyle:new(supportedLevels, missionfile) self.tweens = TweenManager(self) PauseScreen() + HUD() self.haveStarted = false self.canPause = true diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/player/actions.lua b/sonic-radiance.love/game/modules/subgames/world/actors/player/actions.lua index 37a0422..80c82af 100644 --- a/sonic-radiance.love/game/modules/subgames/world/actors/player/actions.lua +++ b/sonic-radiance.love/game/modules/subgames/world/actors/player/actions.lua @@ -10,4 +10,13 @@ function PlayerActions:doActions() end end +function PlayerActions:actionSwitch() + if self.keys["L1"].isPressed and (self.action == "normal") and (self.onGround) then + self:switchActiveCharacter() + end + if self.keys["R1"].isPressed and (self.action == "normal") and (self.onGround) then + self:switchActiveCharacter(-1) + end +end + return PlayerActions \ No newline at end of file diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/player/init.lua b/sonic-radiance.love/game/modules/subgames/world/actors/player/init.lua index 0d10cb8..9a067c0 100644 --- a/sonic-radiance.love/game/modules/subgames/world/actors/player/init.lua +++ b/sonic-radiance.love/game/modules/subgames/world/actors/player/init.lua @@ -2,15 +2,19 @@ local cwd = (...):gsub('%.player$', '') .. "." local Parent = require(cwd .. "parent") local Player = Parent:extend() +local TweenManager = require "birb.classes.time" + local Actions = require "game.modules.subgames.world.actors.player.actions" local Movements = require "game.modules.subgames.world.actors.player.movements" local Score = require "game.modules.subgames.world.actors.player.score" local Sprites = require "game.modules.subgames.world.actors.player.sprites" +local Team = require "scenes.overworld.actors.player.team" Player:implement(Actions) Player:implement(Movements) Player:implement(Score) Player:implement(Sprites) +Player:implement(Team) function Player:new(world, x, y, z, id) Player.super.new(self, world, "player", x, y, 0, 16, 12, 24, true) @@ -18,19 +22,35 @@ function Player:new(world, x, y, z, id) self:initCharactersSprites() self:initScore() self:initActions() + self:initTeam() + + self.tweens = TweenManager(self) end function Player:updateStart(dt) self:basicMovements() self:doActions() + self:actionSwitch() end +function Player:update(dt) + Player.super.update(self, dt) + self.tweens:update(dt) +end + + function Player:collisionResponse(collision) if collision.other.type == "collectible" then collision.other.owner:getPicked(self) end end +function Player:timerResponse(response) + if (response == "changeCharacter") then + self:endCharacterSwitchAnimation() + end +end + function Player:animationEnded(name) end diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/player/sprites.lua b/sonic-radiance.love/game/modules/subgames/world/actors/player/sprites.lua index 36efdb0..cd751d5 100644 --- a/sonic-radiance.love/game/modules/subgames/world/actors/player/sprites.lua +++ b/sonic-radiance.love/game/modules/subgames/world/actors/player/sprites.lua @@ -1,9 +1,11 @@ local SpritedPlayer = Object:extend() function SpritedPlayer:initCharactersSprites() - self.charName = game.characters:getActiveCharacter() - self.assets:addSprite(self.charName, "datas/gamedata/characters/" .. self.charName .. "/sprites") - self:setSprite(self.charName, true, 8, 10) + for id, name in ipairs(game.characters.team) do + self.assets:addSprite(name, "datas/gamedata/characters/" .. name .. "/sprites") + end + self.direction = 1 + self:updateCurrentCharset() end function SpritedPlayer:setAnimation() @@ -38,4 +40,10 @@ function SpritedPlayer:setDirection(direction) end end +function SpritedPlayer:updateCurrentCharset() + self.charName = game.characters:getActiveCharacter() + self:setSprite(self.charName, true, 8, 10) + self.sprite:setScallingX(self.direction) +end + return SpritedPlayer