Skip to main content

Timeline for Ping Pong game in pygame

Current License: CC BY-SA 3.0

11 events
when toggle format what by license comment
Sep 18, 2017 at 19:21 comment added Tauling That's very interesting - let's hope the bug will be fix in the next release. (Btw: i have no experience with cProfile so far)
Sep 11, 2017 at 22:12 comment added skrx It seems to be a bug in pygame. Check out the comments here.
Sep 11, 2017 at 21:11 comment added skrx Do you know how to profile a program with the help of cProfile?
Sep 11, 2017 at 20:48 comment added Tauling The CPU usage did not change noticeable compared to the original version. I am executing the game using python3.5 on a linux mint directly through the CLI (pygame should be the current version). Nonetheless i gained a lot from your answer! The separation which is portrayed in your link looks very good. (BTW, sorry for my late response.)
Sep 1, 2017 at 12:14 comment added skrx Regarding the review, I forgot to mention that I only rerender the score surfaces when one player scores now (but that's also just a minimal optimization). And I'd actually use a Game class with separate handle_events, run_logic and draw methods instead of the main function. There's an example in Program Arcade Games.
Sep 1, 2017 at 12:03 comment added skrx I'm still wondering why you have this CPU problem. Does my example also cause 100% CPU usage? BTW, which Python and pygame version and operating system do you use? And how do you run the game?
Sep 1, 2017 at 9:33 vote accept Tauling
Sep 1, 2017 at 9:33 comment added Tauling Thanks a lot for the detailed code review. You (@skrx) brought out some important aspects to my attention. I issued the post mainly because i thought the event handling could be a bottleneck and my CPU fan immediately starts running the moment i start the application. I accepted your answer since it helped me a lot and the performance, by all appearances, cannot be further improved.
Aug 31, 2017 at 19:23 comment added skrx I think the changes have hardly any effect on the performance. Both the original and the changed version run fine on my machine. The only thing that affected the performance in a negative way was the continuous creation of SysFont objects in the main loop, but that was only a minor problem.
Aug 31, 2017 at 19:03 comment added srattigan It would be nice to know if this improved the performance as well. Would using a Sprite Group give some improvement, aside from the other (more marginal?) improvements outlined above?
Aug 31, 2017 at 17:00 history answered skrx CC BY-SA 3.0