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

Re: [pygame] Question about mouse motion



Ok Thanks for different answers...

Le mardi 29 novembre 2005 Ã 22:20 -0800, Peter Shinners a Ãcrit :
> On Wed, 2005-11-30 at 02:06 +0100, Julien Peeters wrote:
> > I wonder what is the best way to implement this algorithm:
> >         while true:
> >                 if mouse click:
> >                         return get rect which mouse is on
> 
> If nothing in your window is animating, you'll want to use the
> pygame.event.wait() function. This will put your program to sleep (0%
> cpu time) until the user does something.
> 
> 
> 
> while True:
>     event = pygame.event.wait()
>     if event.type == pygame.MOUSEBUTTONDOWN:
>         position = event.pos
>         for thing in allGraphicThings:
>             if thing.getRect().collidepoint(position):
>                 print "You Pressed:", thing
> 
> 
>