From 2e608f7fac6fa1960c92b616a0616a2aac66204a Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Mon, 18 Mar 2019 17:23:12 +0100 Subject: [PATCH] modules/assets: make tileset support mask drawing --- examples/test_scene2/init.lua | 4 +++- gamecore/modules/assets/tileset.lua | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/test_scene2/init.lua b/examples/test_scene2/init.lua index e4ca4a1..588d5ac 100644 --- a/examples/test_scene2/init.lua +++ b/examples/test_scene2/init.lua @@ -59,11 +59,13 @@ function TestScene:draw() if self.estImpair then 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) else love.graphics.setColor(0, 1, 0, 1) self.assets.images["debris"]:drawMask(16, 32) + self.assets.tileset["weapon"]:drawTileMask(3, 32, 32) + utils.graphics.resetColor() end end diff --git a/gamecore/modules/assets/tileset.lua b/gamecore/modules/assets/tileset.lua index 6cf23f9..40ae249 100644 --- a/gamecore/modules/assets/tileset.lua +++ b/gamecore/modules/assets/tileset.lua @@ -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) 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