- Implementat el segon layer
- Implementat resizar el mapa
This commit is contained in:
@@ -15,12 +15,56 @@ editor={
|
||||
menu.show({ {"NEW MAP", editor.new},
|
||||
{"LOAD MAP", function() textbox.show("FILENAME TO LOAD:",editor.load, mapa.name) end},
|
||||
{"SAVE MAP", function() if mapa.name~=nil then editor.save(mapa.name) else textbox.show("FILENAME TO SAVE:",editor.save, mapa.name) end end},
|
||||
-- {"BACK TO EDITOR", function() editor.paused=false end},
|
||||
{mapa.front_layer and "DISABLE FRONT LAYER" or "ENABLE FRONT LAYER", editor.toggle_front_layer},
|
||||
{"RESIZE MAP", editor.resize},
|
||||
{"EXIT", main_init},
|
||||
-- {"ENNER LLOR NEIM", function() textbox.show("PELANDRUSC!") end}
|
||||
}, function()editor.paused=false end)
|
||||
end,
|
||||
|
||||
toggle_front_layer=function()
|
||||
if not mapa.front_layer then
|
||||
mapa.front_layer=newsurf(mapa.w,mapa.h)
|
||||
editor.editing_front_layer=true
|
||||
setmap(mapa.front_layer)
|
||||
for y=0,mapa.h-1 do
|
||||
for x=0,mapa.w-1 do
|
||||
mset(x,y,0)
|
||||
end
|
||||
end
|
||||
else
|
||||
mapa.front_layer=nil
|
||||
end
|
||||
editor.paused=false
|
||||
end,
|
||||
|
||||
resize=function()
|
||||
textbox.show("NEW MAP WIDTH:",function(value)
|
||||
editor.new_w=value
|
||||
textbox.show("NEW MAP HEIGHT:", function(value)
|
||||
editor.new_h=value
|
||||
editor.do_resize()
|
||||
end, tostring(mapa.h))
|
||||
end, tostring(mapa.w))
|
||||
end,
|
||||
|
||||
do_resize=function()
|
||||
local old_surface= mapa.surface
|
||||
mapa.w=tonumber(editor.new_w)
|
||||
mapa.h=tonumber(editor.new_h)
|
||||
mapa.surface=newsurf(mapa.w,mapa.h)
|
||||
for y=0,mapa.h-1 do
|
||||
for x=0,mapa.w-1 do
|
||||
setmap(old_surface)
|
||||
local value=mget(x,y)
|
||||
setmap(mapa.surface)
|
||||
mset(x,y,value)
|
||||
end
|
||||
end
|
||||
freesurf(old_surface)
|
||||
setmap(mapa.surface)
|
||||
editor.paused=false
|
||||
end,
|
||||
|
||||
floodfill=function(x,y,tile)
|
||||
local t=mget(x,y)
|
||||
mset(x,y,tile)
|
||||
@@ -92,8 +136,18 @@ editor={
|
||||
cls()
|
||||
camera(editor.cam.x, editor.cam.y)
|
||||
setsource(tiles)
|
||||
setmap(mapa.surface)
|
||||
map(0,0,0,0,mapa.w, mapa.h)
|
||||
|
||||
if mapa.front_layer then
|
||||
setmap(mapa.front_layer)
|
||||
map(0,0,0,0,mapa.w, mapa.h)
|
||||
end
|
||||
if editor.editing_front_layer then
|
||||
setmap(mapa.front_layer)
|
||||
text("EDITING FRONT LAYER",12,2,10)
|
||||
else
|
||||
setmap(mapa.surface)
|
||||
end
|
||||
local mx,my=mousex()+editor.cam.x,mousey()+editor.cam.y
|
||||
local tx,ty=mx>>3,my>>3
|
||||
local rx,ry=tx<<3,ty<<3
|
||||
@@ -149,6 +203,13 @@ editor={
|
||||
if btnp(KEY_F) then
|
||||
editor.floodfill(tx,ty,editor.brush.tiles[1])
|
||||
end
|
||||
if btnp(KEY_1) then
|
||||
if editor.editing_front_layer then
|
||||
editor.editing_front_layer=nil
|
||||
else
|
||||
editor.editing_front_layer=true
|
||||
end
|
||||
end
|
||||
if btnp(KEY_RETURN) then
|
||||
editor.brush.tiles[1]=mget(tx,ty)
|
||||
end
|
||||
@@ -188,6 +249,7 @@ editor={
|
||||
|
||||
new=function()
|
||||
mapa.new(128,128)
|
||||
editor.editing_front_layer=nil
|
||||
editor.paused=false
|
||||
end,
|
||||
|
||||
@@ -198,6 +260,7 @@ editor={
|
||||
|
||||
load=function(filename)
|
||||
mapa.load(filename)
|
||||
editor.editing_front_layer=nil
|
||||
editor.paused=false
|
||||
end
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ game={
|
||||
restart=function()
|
||||
flags={}
|
||||
objects.list={}
|
||||
actors.main={name="jailer",x=6,y=9,o="r",gfx={x=32,y=0},level="test"}
|
||||
game.init("test")
|
||||
actors.main={name="jailer",x=6,y=9,o="r",gfx={x=32,y=0},level="jail"}
|
||||
game.init("jail")
|
||||
end,
|
||||
|
||||
init=function(levelname,f,objs)
|
||||
@@ -133,9 +133,16 @@ game={
|
||||
end
|
||||
camera(game.cam.x, game.cam.y)
|
||||
setsource(tiles)
|
||||
setmap(mapa.surface)
|
||||
map(0,0,0,0,mapa.w, mapa.h)
|
||||
setsource(sprites)
|
||||
actors.draw()
|
||||
if mapa.front_layer then
|
||||
setsource(tiles)
|
||||
setmap(mapa.front_layer)
|
||||
map(0,0,0,0,mapa.w, mapa.h)
|
||||
end
|
||||
setmap(mapa.surface)
|
||||
camera(0,0)
|
||||
|
||||
if not scene.script and hero and not hero.path and hero.dx+hero.dy==0 then
|
||||
|
||||
39
data/jail.map
Normal file
39
data/jail.map
Normal file
@@ -0,0 +1,39 @@
|
||||
20
|
||||
18
|
||||
2
|
||||
17,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,17,
|
||||
17,16,23,24,23,24,23,24,23,24,23,24,23,24,23,24,23,24,18,17,
|
||||
17,16,39,40,39,40,39,40,39,40,39,40,39,40,39,40,39,40,18,17,
|
||||
17,16,55,56,55,56,55,56,55,56,55,56,55,56,55,56,55,56,18,17,
|
||||
17,16,10,11,12,13,5,2,10,11,12,13,5,2,10,11,12,13,18,17,
|
||||
17,16,87,88,89,90,5,2,87,88,89,90,5,2,87,88,89,90,18,17,
|
||||
17,16,10,11,12,13,5,2,10,11,12,13,5,2,10,11,12,13,18,17,
|
||||
17,16,87,88,89,90,5,2,87,88,89,90,5,2,64,65,66,65,18,17,
|
||||
17,16,10,11,12,13,5,2,10,11,12,13,5,2,80,81,82,81,18,17,
|
||||
17,16,87,88,89,90,5,2,87,88,89,90,5,2,96,97,97,98,18,17,
|
||||
17,16,10,11,12,13,5,2,10,11,12,13,5,2,5,2,5,3,18,17,
|
||||
17,16,87,88,89,90,5,2,87,88,89,90,5,2,5,2,5,2,18,17,
|
||||
17,16,10,11,12,13,5,2,10,11,12,13,5,2,5,2,5,2,18,17,
|
||||
17,16,87,88,89,90,5,2,87,88,89,90,5,2,5,2,5,2,18,17,
|
||||
17,16,5,2,5,2,5,2,5,2,5,2,5,2,14,15,12,13,18,17,
|
||||
17,32,33,33,33,48,5,2,49,33,33,48,5,2,49,33,33,33,34,17,
|
||||
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
||||
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,71,72,71,72,0,0,71,72,71,72,0,0,71,72,71,72,0,0,
|
||||
0,0,67,68,69,70,0,0,67,68,69,70,0,0,67,68,69,70,0,0,
|
||||
0,0,71,72,71,72,0,0,71,72,71,72,0,0,71,72,71,72,0,0,
|
||||
0,0,67,68,69,70,0,0,67,68,69,70,0,0,67,68,69,70,0,0,
|
||||
0,0,71,72,71,72,0,0,71,72,71,72,0,0,0,0,0,0,0,0,
|
||||
0,0,67,68,69,70,0,0,67,68,69,70,0,0,0,0,0,0,0,0,
|
||||
0,0,71,72,71,72,0,0,71,72,71,72,0,0,0,0,0,0,0,0,
|
||||
0,0,67,68,69,70,0,0,67,68,69,70,0,0,0,0,0,0,0,0,
|
||||
0,0,71,72,71,72,0,0,71,72,71,72,0,0,0,0,0,0,0,0,
|
||||
0,0,67,68,69,70,0,0,67,68,69,70,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,71,72,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,83,84,69,70,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
@@ -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,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
128
|
||||
128
|
||||
1
|
||||
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
||||
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
||||
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
|
||||
|
||||
BIN
data/tiles.gif
BIN
data/tiles.gif
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.6 KiB |
Reference in New Issue
Block a user