modules/assets: make tileset support mask drawing

This commit is contained in:
Kazhnuz 2019-03-18 17:23:12 +01:00
parent 01bda0f70c
commit 2e608f7fac
2 changed files with 13 additions and 1 deletions

View file

@ -59,11 +59,13 @@ function TestScene:draw()
if self.estImpair then if self.estImpair then
self.assets.images["debris"]:draw(16, 32) self.assets.images["debris"]:draw(16, 32)
self.assets.tileset["weapon"]:drawTile(1, 32, 32) self.assets.tileset["weapon"]:drawTile(3, 32, 32)
self.assets.sprites["poof"]:drawAnimation(64, 32) self.assets.sprites["poof"]:drawAnimation(64, 32)
else else
love.graphics.setColor(0, 1, 0, 1) love.graphics.setColor(0, 1, 0, 1)
self.assets.images["debris"]:drawMask(16, 32) self.assets.images["debris"]:drawMask(16, 32)
self.assets.tileset["weapon"]:drawTileMask(3, 32, 32)
utils.graphics.resetColor() utils.graphics.resetColor()
end end
end end

View file

@ -89,4 +89,14 @@ function Tileset:drawTile(id, x, y, r, sx, sy, ox, oy, kx, ky)
self.texture:drawQuad(self.quads[id], x, y, r, sx, sy, ox, oy, kx, ky) self.texture:drawQuad(self.quads[id], x, y, r, sx, sy, ox, oy, kx, ky)
end end
function Tileset:drawTileMask_Grid(i, j, x, y, r, sx, sy, ox, oy, kx, ky)
local tileID = self:getTileID_Grid(i, j)
self.texture:drawMaskQuad(self.quads[tileID], x, y, r, sx, sy, ox, oy, kx, ky)
end
function Tileset:drawTileMask(id, x, y, r, sx, sy, ox, oy, kx, ky)
self.texture:drawMaskQuad(self.quads[id], x, y, r, sx, sy, ox, oy, kx, ky)
end
return Tileset return Tileset