[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] CPU 100%



I wonder if there is other way to save CPU resource?

On 6/18/06, Chuang Wu <chuangwoo@xxxxxxxxx> 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 <richardjones@xxxxxxxxxxxxxxxx> 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
>