From 6569cb0dd7e5d27f258301aee50f07d341509306 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 10 Apr 2021 13:04:45 +0200 Subject: [PATCH] feat(charset): add mirroring and 'large anim' --- .../scenes/overworld/charsetmanager.lua | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/sonic-radiance.love/scenes/overworld/charsetmanager.lua b/sonic-radiance.love/scenes/overworld/charsetmanager.lua index ca12011..53a843d 100644 --- a/sonic-radiance.love/scenes/overworld/charsetmanager.lua +++ b/sonic-radiance.love/scenes/overworld/charsetmanager.lua @@ -79,25 +79,43 @@ end -- DRAW FUNCTIONS -- Draw the charset in various situations -function Charset:draw(charsetName, charID, direction, frame, x, y) +function Charset:draw(charsetName, charID, direction, frame, x, y, isMirrored) local drawable = self:getTexture(charsetName) local quad = self:getQuad(frame, charID, direction) - love.graphics.draw(drawable, quad, math.floor(x), math.floor(y), 0, 1, 1, 11, 32) + local sx = 1 + if (isMirrored == false) then + sx = -1 + end + love.graphics.draw(drawable, quad, math.floor(x) + 8, math.floor(y), 0, sx, 1, 19, 32) end -function Charset:drawMoving(charsetName, charID, direction, x, y, isFast) +function Charset:drawMoving(charsetName, charID, direction, x, y, isFast, isMirrored) local frame = self:getCurrentFrame(isFast) - self:draw(charsetName, charID, direction, frame, x, y) + self:draw(charsetName, charID, direction, frame, x, y, isMirrored) end -function Charset:drawStanding(charsetName, charID, direction, x, y) - self:draw(charsetName, charID, direction, FRAME_STANDING, x, y) +function Charset:drawStanding(charsetName, charID, direction, x, y, isMirrored) + self:draw(charsetName, charID, direction, FRAME_STANDING, x, y, isMirrored) end -function Charset:drawTurning(charsetName, charID, x, y, isFast, frame) +function Charset:drawLargeAnim(charsetName, charID, direction, x, y, isFast) + local frame = FRAME_STANDING + local isMirrored = false + for i, dir in ipairs(directionList) do + if (dir == direction) then + frame = animation[i] + end + end + if (direction == "right") then + isMirrored = true + end + self:drawTurning(charsetName, charID, x, y, isFast, frame, isMirrored) +end + +function Charset:drawTurning(charsetName, charID, x, y, isFast, frame, isMirrored) local frame = frame or FRAME_STANDING local dir = self:getCurrentFrame(isFast) - return self:draw(charsetName, charID, directionList[dir], frame, x, y) + return self:draw(charsetName, charID, directionList[dir], frame, x, y, isMirrored) end return Charset