feat(charset): add mirroring and 'large anim'

This commit is contained in:
Kazhnuz 2021-04-10 13:04:45 +02:00
parent 2ede81dc8d
commit 6569cb0dd7

View file

@ -79,25 +79,43 @@ end
-- DRAW FUNCTIONS -- DRAW FUNCTIONS
-- Draw the charset in various situations -- 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 drawable = self:getTexture(charsetName)
local quad = self:getQuad(frame, charID, direction) 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 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) local frame = self:getCurrentFrame(isFast)
self:draw(charsetName, charID, direction, frame, x, y) self:draw(charsetName, charID, direction, frame, x, y, isMirrored)
end end
function Charset:drawStanding(charsetName, charID, direction, x, y) function Charset:drawStanding(charsetName, charID, direction, x, y, isMirrored)
self:draw(charsetName, charID, direction, FRAME_STANDING, x, y) self:draw(charsetName, charID, direction, FRAME_STANDING, x, y, isMirrored)
end 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 frame = frame or FRAME_STANDING
local dir = self:getCurrentFrame(isFast) 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 end
return Charset return Charset