Jul-25-2020, 09:56 PM
When in doubt, print it out!
I added this to your loop:
Your
I added this to your loop:
print(f"{snake.left} == {fruit.left}: {snake.left == fruit.left}")
, and saw the issue almost immediately.Your
rand()
function sets x2
to a random int. In my case, 159. But the snake moves in multiples of 10. So it'll never be at 159. 150 or 160, sure, but never 159.