Stop using the unsupported graphics.drawt

This commit is contained in:
Jean-André Santoni 2015-08-22 23:07:11 +02:00
parent 5045238c88
commit d968db3fb1
2 changed files with 31 additions and 11 deletions

View File

@ -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

View File

@ -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