You can use pygame.event.wait() That way your program does almost nothing until more events happen. This isn't very good if you have animation though. However if it is a program that just waits around for user input before doing anything it can be a good way to go.
Also if nothing on your screen changes you don't need to do a pygame.display.flip() at all. Just wait until something on your screen changes, and then flip for that frame. Cheers, On 6/20/06, Chuang Wu <[EMAIL PROTECTED]> wrote:
I wonder if there is other way to save CPU resource? On 6/18/06, Chuang Wu <[EMAIL PROTECTED]> wrote: > Thanks, I set the fps to 10. The game still runs correctly with only > 5% CPU resource used =D > > On 6/18/06, Richard Jones <[EMAIL PROTECTED]> wrote: > > On Monday 19 June 2006 10:55, Chuang Wu wrote: > > > The main loop of the game is while(1) function. So I wonder if there's > > > a way to save the CPU resource. > > > > clock = pygame.time.Clock() > > > > while 1: > > dt = clock.tick(FPS) > > do stuff > > > > > > Note that on certain platforms if FPS > 42 then you're going to end up with > > CPU at 100% anyway since system clocks aren't precise enough. Most games are > > fine with an FPS of 30 anyway. > > > > > > Richard > > >
