From d968db3fb1e7da4f16ab03f558273a4853eb5cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sat, 22 Aug 2015 23:07:11 +0200 Subject: [PATCH] Stop using the unsupported graphics.drawt --- anim.lua | 19 +++++++++++++++---- tiled.lua | 23 ++++++++++++++++------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/anim.lua b/anim.lua index 5ba9068..85a7de8 100644 --- a/anim.lua +++ b/anim.lua @@ -25,10 +25,21 @@ function animation:update(dt) end function animation:draw(x, y) - lutro.graphics.drawt( + local id = math.floor(self.timer / self.period + 1) + local tw = self.width + local th = self.height + local sw = self.image:getWidth() + local sh = self.image:getHeight() + + local q = lutro.graphics.newQuad( + ((id-1)%(sw/tw))*tw, + math.floor((id-1)/(sw/tw))*tw, + tw, th, + sw, sh) + + lutro.graphics.draw( self.image, - x, y, - self.width, self.height, - self.timer / self.period + 1 + q, + x, y ) end diff --git a/tiled.lua b/tiled.lua index cd4b3fc..5f6c3dd 100644 --- a/tiled.lua +++ b/tiled.lua @@ -27,14 +27,23 @@ function tiled_draw_layer(layer) local data = layer.data for j = 1, #data do local id = data[j] - local y = math.floor((j-1) / layer.width) * map.tileheight - local x = ((j-1) % layer.width) * map.tilewidth - local t = tiled_get_tileset(map, id) - if (id > 0) then - lutro.graphics.drawt(t.surface, x, y, - map.tilewidth, map.tileheight, - id - t.firstgid+1) + local y = math.floor((j-1) / layer.width) * map.tileheight + local x = ((j-1) % layer.width) * map.tilewidth + local t = tiled_get_tileset(map, id) + local tw = map.tilewidth + local th = map.tileheight + local sw = t.surface:getWidth() + local sh = t.surface:getHeight() + local tid = id - t.firstgid+1 + + local q = lutro.graphics.newQuad( + ((tid-1)%(sw/tw))*tw, + math.floor((tid-1)/(sw/tw))*tw, + tw, th, + sw, sh) + + lutro.graphics.draw(t.surface, q, x, y) end end end