pythonlover753
pythonlover753

Reputation: 11

pygame window Not responding error (using sockets)

I made an online connect 4 game that uses the following logic:

It works but there is a problem: when player1 takes a while to choose their move and player2 is waiting to receive, player2's pygame window becomes unresponsive since it is stuck in a .recv() call. How can I fix this?

Upvotes: 0

Views: 173

Answers (1)

Ladrillo
Ladrillo

Reputation: 89

You need to use threading and events. This way, the pygame window can refresh while another thread waits for any updates from the server.

As soon as the thread receives the update, an event should handle it to the main thread.

I don't remember much about implementation details (i'm a C# developer), but i used this while waiting for a AI to complete in Python.

Upvotes: 2

Related Questions