#Flood Fill Method bug
1 messages · Page 1 of 1 (latest)
Here is the full relevant code:
extends Area2D
var openList = [];
var closedList = [];
func initSelf():
z_index =2000;
var startList = get_overlapping_areas();
openList.append_array(startList);
func stepForward():
var currentTile = openList[0];
global_position = currentTile.global_position
currentTile.get_child(0).color = Color(0,1,0);
closedList.append(currentTile);
openList.remove_at(0);
var surroundingTiles = get_overlapping_areas();
print("Surrounding Tiles: "+str(surroundingTiles));
for value in surroundingTiles:
if !closedList.has(value):
if !openList.has(value):
openList.append(value);
print("Open list: "+str(openList));
var state = "init";
func _physics_process(_delta):
await get_tree().physics_frame
if state=="init":
initSelf();
state = "null";
if openList.size() > 0:
stepForward();
print(closedList.size()) //DEBUG
else:
print(get_parent().get_child(0).get_children().size()); //DEBUG
print(closedList.size() == get_parent().get_child(0).get_children().size()); //DEBUG
queue_free();