There are two games (A and B), on the left and right screen sides. The game A responds to mouse clicks, the game B — to left/right keydowns. There is also a server which handles games behaviour:
I run games as two separate subprocesses (using subprocess.Popen I start a.py
and b.py
). Where a.py
and b.py
are simple pygame games that listen my server events inside their game loop.
Is it possible to share event loop between two different pygame windowed apps? Or may be it's better to change focus in some OS-specific way?
Okay, I have got a solution which works like a charm.
Since we have a server for handling some game events, we decided to grab a focus inside one game and share all keyboard events to other games through the server using web sockets.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.