diff --git a/sonic-radiance.love/datas/gamedata/characters/amy/init.lua b/sonic-radiance.love/datas/gamedata/characters/amy/init.lua index be3fc0b..0c2be07 100644 --- a/sonic-radiance.love/datas/gamedata/characters/amy/init.lua +++ b/sonic-radiance.love/datas/gamedata/characters/amy/init.lua @@ -14,4 +14,6 @@ return { canBreakCraft = false, icon = 3, + charset = "perso", + charId = 3, } diff --git a/sonic-radiance.love/datas/gamedata/characters/tails/init.lua b/sonic-radiance.love/datas/gamedata/characters/tails/init.lua index 7c4aac9..68739fa 100644 --- a/sonic-radiance.love/datas/gamedata/characters/tails/init.lua +++ b/sonic-radiance.love/datas/gamedata/characters/tails/init.lua @@ -14,4 +14,6 @@ return { canBreakCraft = false, icon = 2, + charset = "perso", + charId = 2, } diff --git a/sonic-radiance.love/game/characters.lua b/sonic-radiance.love/game/characters.lua index ec91a66..a66829e 100644 --- a/sonic-radiance.love/game/characters.lua +++ b/sonic-radiance.love/game/characters.lua @@ -143,6 +143,10 @@ function CharacterManager:getActiveCharacter() return self.team[self.active] end +function CharacterManager:getActiveCharacterData() + return self.list[self.team[self.active]] +end + -- DEBUG FUNCTIONS function CharacterManager:printCharacter(id) diff --git a/sonic-radiance.love/scenes/overworld/actors/player.lua b/sonic-radiance.love/scenes/overworld/actors/player.lua index 29a9e6d..3f8bbd0 100644 --- a/sonic-radiance.love/scenes/overworld/actors/player.lua +++ b/sonic-radiance.love/scenes/overworld/actors/player.lua @@ -5,6 +5,7 @@ local Player = Parent:extend() function Player:new(world, x, y, id) Player.super.new(self, world, "player", x, y, 16, 16, true) self.charset:addTexture("perso") + self.active = game.characters:getActiveCharacterData() end function Player:isMoving() @@ -30,13 +31,18 @@ function Player:updateStart(dt) self.xsp = 120 self.charDir = "right" end + + if self.keys["select"].isPressed then + game.characters:setActiveCharacter() + self.active = game.characters:getActiveCharacterData() + end end function Player:draw() if (self:isMoving()) then - self.charset:draw("perso", 1, self.charDir, self.x, self.y) + self.charset:draw(self.active.data.charset, self.active.data.charId, self.charDir, self.x, self.y) else - self.charset:drawStanding("perso", 1, self.charDir, self.x, self.y) + self.charset:drawStanding(self.active.data.charset, self.active.data.charId, self.charDir, self.x, self.y) end end