From 01bda0f70ce4a55a10662bd0086a4c53a2cf643b Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Mon, 18 Mar 2019 17:20:33 +0100 Subject: [PATCH] modules/assets: make the tileset use a texture object --- gamecore/modules/assets/tileset.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gamecore/modules/assets/tileset.lua b/gamecore/modules/assets/tileset.lua index c86aa44..6cf23f9 100644 --- a/gamecore/modules/assets/tileset.lua +++ b/gamecore/modules/assets/tileset.lua @@ -27,9 +27,12 @@ ]] local Tileset = Object:extend() +local cwd = (...):gsub('%.tileset$', '') .. "." + +local Texture = require(cwd .. "texture") function Tileset:new(filepath) - self.texture = love.graphics.newImage(filepath .. ".png") + self.texture = Texture(filepath .. ".png") local data = require(filepath) self.metadata = data.metadata @@ -79,11 +82,11 @@ end function Tileset:drawTile_Grid(i, j, x, y, r, sx, sy, ox, oy, kx, ky) local tileID = self:getTileID_Grid(i, j) - love.graphics.draw(self.texture, self.quads[tileID], x, y, r, sx, sy, ox, oy, kx, ky) + self.texture:drawQuad(self.quads[tileID], x, y, r, sx, sy, ox, oy, kx, ky) end function Tileset:drawTile(id, x, y, r, sx, sy, ox, oy, kx, ky) - love.graphics.draw(self.texture, 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 return Tileset