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

Re: [pygame] Pausing a function



> On Sep 21, 2007, at 11:19 AM, Samuel Mankins wrote:
>
> > Hi.
> > Is there a way to pause one function, but to keep all the others
> > going? I'm building a 2D RPG, and my current animation function
> > uses pygame.time.wait(), which is good, but means I can't have
> > "ambient" animations (Things that move around randomly, like plants
> > waving in the wind), and I can only have on going at a time. Does
> > anyone know a way around this?
> >
> > Thanks!

You will notice that Python does not tell functions to run, and move
on.  It will wait for the function to exit.  Ex:

import sys
def main():
    while 1:
        pass
main()
sys.exit()

...will never exit, because the sytem waits for the function to exit.
It never does.  You probably already know this.  If you *must* have a
fuction that operates independently from the main, use a subprocess.

Ian