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

Re: [pygame] How to make a (fast) smooth movement on 30 frames



Hi,

On 6/22/06, Richard Jones <richardjones@xxxxxxxxxxxxxxxx> wrote:
On Thursday 22 June 2006 18:29, Sami Hangaslammi wrote:
> Even if you only have two static sprites, I'm presuming you are
> re-painting the whole screen. For software surfaces, this is done
> entirely by the CPU.

Yes, but that's not the reason. See below.


Also, and this is an FAQ I guess, if you're asking clock.tick() for a frame
rate of > 40 or so then tick() will busy-loop to get the timing right.

Yeah, that's it. Thanks. I thought the reason was my ugly update-handling but the cpu usage of 100% occures even when I draw nothing to the screen:

import pygame
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((800,600))
clock = pygame.time.Clock()

while 1:
   for event in pygame.event.get():
       if event.type == KEYDOWN:
           if event.key == K_ESCAPE:
               sys.exit()

   clock.tick(60)

Causes ~98% cpu usage.


Richard

Thanks to all of you. :-)