[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Question about mouse motion
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