- Implementat el segon layer

- Implementat resizar el mapa
This commit is contained in:
2023-02-02 18:54:40 +01:00
parent 1f4274f278
commit 5091fe267b
6 changed files with 143 additions and 5 deletions

View File

@@ -23,6 +23,8 @@ mapa={
io.input(file)
mapa.w = tonumber(io.read())
mapa.h = tonumber(io.read())
local num_layers=tonumber(io.read())
mapa.new(mapa.w, mapa.h)
mapa.name=filename
for y=0,mapa.h-1 do
@@ -33,6 +35,21 @@ mapa={
x=x+1
end
end
if num_layers==2 then
mapa.front_layer=newsurf(mapa.w,mapa.h)
setmap(mapa.front_layer)
for y=0,mapa.h-1 do
local line = io.read()
local x=0
for m in string.gmatch(line, "%d+") do
mset(x,y,m)
x=x+1
end
end
end
setmap(mapa.surface)
io.close(file)
end
end,
@@ -44,12 +61,23 @@ mapa={
io.output(file)
io.write(mapa.w.."\n")
io.write(mapa.h.."\n")
if mapa.front_layer then io.write("2\n") else io.write("1\n") end
setmap(mapa.surface)
for y=0,mapa.h-1 do
for x=0,mapa.w-1 do
io.write(mget(x,y)..",")
end
io.write("\n")
end
if mapa.front_layer then
setmap(mapa.front_layer)
for y=0,mapa.h-1 do
for x=0,mapa.w-1 do
io.write(mget(x,y)..",")
end
io.write("\n")
end
end
io.close(file)
end
end,