I am coding a simulation of a fire in a forest. The code is mostly done and the result can be seen below. To start the fire, you have to input the coordinates of the first tree that will burn, so that it can spread around.
However, python will ask you again and again about these coordinates if a tree is not found in the designated area. Hence, I am looking to create a function that would help me to choose the first tree by clicking on it in a tkinter window and not lose time finding a tree.
You will find below the part of the code that asks about the coordinates. If needed, I can post the whole code.
Thanks.
def take_input():
while 1:
print("The coordinates to start the fire are :")
debut =int(input("x= "))
debutbis=int(input("y= "))
xx=T[debut]
yy=T[debut][debutbis]
if yy == 0:
print("Error, no tree found.")
elif debut < 0 or debut >= len(T) or debutbis < 0 or debutbis >= len(T[0]):
print("Error")
else:
break
app.after(200, burn_forest, debut, debutbis)