I have got a problem with my click detection.
Here is the code that manages that:
if click != []:
for i in range(len(stars[0])):
if (((click[0][0] >= (int(stars[0][i]) - 8)) and (click[0][0] <= (int(stars[0][i]) + 8))) and ((click[0][1] >= (int(stars[1][i]) - 8)) and (click[0][1] <= (int(stars[1][i]) + 8)))) and click[1][0] == 1:
stars[2][i] = 2
print("left")
elif (((click[0][0] >= (int(stars[0][i]) - 8)) and (click[0][0] <= (int(stars[0][i]) + 8))) and ((click[0][1] >= (int(stars[1][i]) - 8)) and (click[0][1] <= (int(stars[1][i]) + 8)))) and click[1][2] == 1:
for j in range(len(stars[0])):
if stars[2][j] == 2 and j != i:
setUpStart = []
setUpStart.append(int(stars[0][j]))
setUpStart.append(int(stars[1][j]))
setUpEnd = []
setUpEnd.append(int(stars[0][i]))
setUpEnd.append(int(stars[1][i]))
setUpLine = []
setUpLine.append(setUpStart)
setUpLine.append(setUpEnd)
fleets.append(setUpLine)
stars[2][j] = 1
stars[2][i] = 1
print("right")
else:
stars[2][i] = 1
It should basically allowe me to select a star with a left click and then select another star with right click, whose coordinates are then stored for later. Clicks that do not land on stars, Just deselect any star that happens to be active.
But the problem is, that some stars some times just do nothing when I right click on them even though I have another star selected. I cannot find the reason that is causing it. Can anyone else find it?