Gra/maploader.lua
2017-04-22 21:55:28 +02:00

32 lines
613 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((c*32)-32,(q*32)-32,32,32,3)
end
end
end
end