Hi. I'm new to godot and am currently using 4.2.1. Im basically trying to make a real time flood fill that I can click on an area that is enclosed and it fills the 'selected' region. Using tiles to paint the area. I managed to get it to work on the ready function but in realtime using the delta process function it doesn't display the tiles. The code runs but no tiles are displayed which I can't seem to find why also when I click on an enclosed region the code works but ignores the edges of the tiles and continues to fill until it reaches my set limit. I can seem to figure out why this is occuring since it works perfectly when the function is ran in the ready function at the begining of the scene.
Here is my code: `func flood_fill_alogrithm(cell):
var cells_list = []
set_cell(0,cell,0,Vector2i(0,0),0)
cells_list += get_surrounding_cells(cell)
#remove_list += get_surrounding_cells(cell)
#print(get_cell_tile_data(0,cell,false))
#print(get_cell_source_id(0,start_location+Vector2(1,1),false))
bfs_fill_recursion(cells_list)
#print(cells_list,len(cells_list))
#
#return flood_fill_alogrithm(cell)
func bfs_fill_recursion(cells_list):
print(len(cells_list))
if len(cells_list) == 0 or len(cells_list) >= 1000:
print('finish filling')
pass
else:
for cells in cells_list:
if get_cell_source_id(0,cells,false) == -1:
#print('no tile')
set_cell(0,cells,0,Vector2i(0,0),0)
#print(cells_list)
#queue
cells_list += get_surrounding_cells(cells)
#
#dequeue
cells_list.erase(cells)
elif get_cell_source_id(0,cells,false) ==0:
cells_list.erase(cells)
#print('hit a tile')
elif get_cell_source_id(0,cells,false) != -1 or 0:
cells_list.erase(cells)
#cells_list = duplicate_remover_2(cells_list)
return bfs_fill_recursion(cells_list)`
``
func _process(_delta):
if Input.is_action_just_pressed("mouse left"):
print('mouse clicked')
var mouse_position = get_global_mouse_position()
#emit_signal('paint_fill',mouse_position)
flood_fill_alogrithm(mouse_position)