- [NEW][EDITOR] Copy tile

-[NEW][EDITOR] Flood fill
This commit is contained in:
2023-01-28 09:02:27 +01:00
parent 65c3fb8c70
commit e4e1e59e8b

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()