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

Re: [pygame] Weird problem



On 10/13/06, Kai Kuehne <kai.kuehne@xxxxxxxxx> wrote:
> that code is not "waiting" for a key input.
> So the code is "looping while checking for a key input".

Where is the difference?

the difference is in waiting or not waiting

when the program is "waiting", it means it is not doing anything
meaning it isn't using the cpu

when the program is not waiting, it means it is busy doing something,
meaning it is using the cpu

because nothing in your program waits (in particular pygame.event.get
doesn't wait) it means it is always busy. meaning it uses 100% cpu. It
behaves exactly how one should expect it to behave, given how it's
written.

using 100% cpu can make some systems perform poorly and choppy, so
it's perferrable to have something that waits if your prog doesn't.
the pygame.time.wait func luke mentioned will wait. pygame.event.wait
will wait too. Clock.tick waits in newer pygames (I think it only
waited in certain circumstances in older pygames).