I recently made a few games with Pygame but I found out that it is quite slow and laggy also there isn't any bug in my game. I tried everything apart from creating multiple threads in my game but I am wondering if creating them could lead to some glitches or trouble in my game.
Asked
Active
Viewed 115 times
0
-
4Pygame is intended for educational purposes only. It is completely CPU bound and does not use the GPU, so it is "slow". All the drawing and event handling must be done in the main thread (the thread in which the display window was created). – Rabbid76 Aug 20 '22 at 07:36
-
3The other reason that new programmers say their programs are slow is because they use inappropriate algorithms. I should know because I used to use bubble sorts when I should have been using quicksort. – quamrana Aug 20 '22 at 08:02
-
threads may run in different moments (system decide which treat has access to CPU) and sometimes it can make problem to synchronize data from different threads. – furas Aug 20 '22 at 14:27
-
You should [profile](https://stackoverflow.com/a/582337/2280890) your program to see where bottlenecks lie. One Common error is loading images multiple times instead of just once. – import random Aug 20 '22 at 16:49
-
Threading can be a tool to improve performance, but it's no magic bullet that will solve things automatically. – klutt Aug 21 '22 at 11:10
1 Answers
0
In theory, it could be used very sparsely and if you really know what you are doing. Threading is really not a beginner concept and threading + pygame is most likely a bad idea, will cause more problems than it solves.
So short answer is "no", don't use threading. If your games are laggy that probably comes from your programming skills. Perhaps you could create a new post with a more specific example, sharing some code of yours, I'm sure the community would give you tons of advise to improve your coding.
You can check out "DaFluffyPotato" on youtube. He is one of the best content creator when it comes to making complexe/advance games with pygame and pygame optimization.

Anto
- 267
- 1
- 11