feat: add leader change to overworld

Fix #18
This commit is contained in:
Kazhnuz 2020-08-03 08:59:04 +02:00
parent 693150029c
commit 4bb4c14198
4 changed files with 16 additions and 2 deletions

View file

@ -14,4 +14,6 @@ return {
canBreakCraft = false, canBreakCraft = false,
icon = 3, icon = 3,
charset = "perso",
charId = 3,
} }

View file

@ -14,4 +14,6 @@ return {
canBreakCraft = false, canBreakCraft = false,
icon = 2, icon = 2,
charset = "perso",
charId = 2,
} }

View file

@ -143,6 +143,10 @@ function CharacterManager:getActiveCharacter()
return self.team[self.active] return self.team[self.active]
end end
function CharacterManager:getActiveCharacterData()
return self.list[self.team[self.active]]
end
-- DEBUG FUNCTIONS -- DEBUG FUNCTIONS
function CharacterManager:printCharacter(id) function CharacterManager:printCharacter(id)

View file

@ -5,6 +5,7 @@ local Player = Parent:extend()
function Player:new(world, x, y, id) function Player:new(world, x, y, id)
Player.super.new(self, world, "player", x, y, 16, 16, true) Player.super.new(self, world, "player", x, y, 16, 16, true)
self.charset:addTexture("perso") self.charset:addTexture("perso")
self.active = game.characters:getActiveCharacterData()
end end
function Player:isMoving() function Player:isMoving()
@ -30,13 +31,18 @@ function Player:updateStart(dt)
self.xsp = 120 self.xsp = 120
self.charDir = "right" self.charDir = "right"
end end
if self.keys["select"].isPressed then
game.characters:setActiveCharacter()
self.active = game.characters:getActiveCharacterData()
end
end end
function Player:draw() function Player:draw()
if (self:isMoving()) then 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 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
end end