Last active
January 22, 2018 20:31
-
-
Save Bradshaw/a3744d7e40e90fb4e7df to your computer and use it in GitHub Desktop.
The magic of ellipsis in Lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local old_draw = love.graphics.draw | |
local monkey_draw = function(im, ...) | |
if fudge.current and type(im)=="string" then | |
--Get associate and draw it | |
local fud = fudge.current:getPiece(im) | |
old_draw(fud.img, fud.quad, ...) | |
elseif type(im)=="table" and im.img and im.quad then | |
old_draw(im.img, im.quad, ...) | |
elseif type(im)=="table" and im.batch then | |
old_draw(im.batch) | |
else | |
old_draw(im, ...) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Call like -> a:draw(subimage, x, y, angle, scalex, scaley, ox, oy) | |
function Animation:draw(subimage, ...) | |
if subimage then | |
subimage = math.min(self.n_frames, math.floor(subimage)) | |
else | |
subimage = 1 | |
end | |
love.graphics.draw(self.img, self.quads[subimage], ...) -- Lua is magic n.n | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment