Gra/maploader.lua
Leszek Winnicki 1a041ce6bb :)
2017-04-22 20:27:46 +02:00

33 lines
641 B
Lua

t={}
t.tiles={}
t.type={}
t.type[1]=love.graphics.newImage("tile1.png")
t.type[2]=love.graphics.newImage("tile2.png")
function t:new(typ, x, y)
tile={}
tile.x=x
tile.y=y
tile.w=32
tile.h=32
tile.type=t.type[typ]
table.insert(t.tiles, tile)
end
function t:clear()
for k in pairs (t.tiles) do
t.tiles[k] = nil
end
end
function loadmap(map)
t:clear()
e:clear()
for q,y in pairs(map) do
for c,x in pairs(y) do
if x~=0 and type(x)=="number" then
t:new(x, (c*32)-32, (q*32)-32)
elseif x=="e" then
e:new(0,0,(c*32)-32,(q*32)-32,3)
print(tostring(q..c))
end
end
end
end