Ask coding questions

← Back to all posts
Ball Freezing in Simple Pygame Program
Archonic7 (2)

Hi! I’m trying to make a simple test in Pygame where a ball moves towards one large square in the center, and once it reaches the square, it spawns a new ball at a random position. I have it’s set up right now so that it doesn’t move the x or y if the x distance or y distance is closer to the goal than the other corresponding axis’ distance. But for some reason, the ball just freezes sometimes. I have tried debugging it, but the debug says that one of the distances is greater than the other, in which case the ball should move one way, but it just doesn’t. I would really appreciate it if someone helped me!