modules/assets: make the tileset use a texture object

This commit is contained in:
Kazhnuz 2019-03-18 17:20:33 +01:00
parent 6f1f7af711
commit 01bda0f70c

View file

@ -27,9 +27,12 @@
]] ]]
local Tileset = Object:extend() local Tileset = Object:extend()
local cwd = (...):gsub('%.tileset$', '') .. "."
local Texture = require(cwd .. "texture")
function Tileset:new(filepath) function Tileset:new(filepath)
self.texture = love.graphics.newImage(filepath .. ".png") self.texture = Texture(filepath .. ".png")
local data = require(filepath) local data = require(filepath)
self.metadata = data.metadata self.metadata = data.metadata
@ -79,11 +82,11 @@ end
function Tileset:drawTile_Grid(i, j, x, y, r, sx, sy, ox, oy, kx, ky) function Tileset:drawTile_Grid(i, j, x, y, r, sx, sy, ox, oy, kx, ky)
local tileID = self:getTileID_Grid(i, j) 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 end
function Tileset:drawTile(id, x, y, r, sx, sy, ox, oy, kx, ky) 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 end
return Tileset return Tileset