Compare commits

...

2 Commits

Author SHA1 Message Date
e4e1e59e8b - [NEW][EDITOR] Copy tile
-[NEW][EDITOR] Flood fill
2023-01-28 09:02:27 +01:00
65c3fb8c70 - [FIX] Bug that prevented saving 2023-01-28 08:52:42 +01:00
2 changed files with 16 additions and 1 deletions

View File

@@ -18,6 +18,15 @@ editor={
}, function()editor.paused=false end)
end,
floodfill=function(x,y,tile)
local t=mget(x,y)
mset(x,y,tile)
if x<mapa.w-1 and mget(x+1,y)==t then editor.floodfill(x+1,y,tile) end
if x>0 and mget(x-1,y)==t then editor.floodfill(x-1,y,tile) end
if y<mapa.h-1 and mget(x,y+1)==t then editor.floodfill(x,y+1,tile) end
if y>0 and mget(x,y-1)==t then editor.floodfill(x,y-1,tile) end
end,
update=function()
cls()
camera(editor.cam.x, editor.cam.y)
@@ -38,6 +47,12 @@ editor={
if btnp(KEY_LEFT) then editor.cam.x=editor.cam.x-8 end
if btnp(KEY_UP) then editor.cam.y=editor.cam.y-8 end
if btnp(KEY_DOWN) then editor.cam.y=editor.cam.y+8 end
if btnp(KEY_F) then
editor.floodfill(tx,ty,editor.selected_tile)
end
if btnp(KEY_RETURN) then
editor.selected_tile=mget(tx,ty)
end
if btnp(KEY_ESCAPE) then
editor.paused=true
editor.show_menu()

View File

@@ -39,8 +39,8 @@ mapa={
save = function(filename)
mapa.name=filename
file = io.open("data/"..filename, "w")
if file then
file = io.open("data/"..filename, "w")
io.output(file)
io.write(mapa.w.."\n")
io.write(mapa.h.."\n")