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

Re: [pygame] get_rel and events



indent these lines one more block:

   if event.type == pygame.MOUSEBUTTONDOWN:
       print event
   if event.type == pygame.MOUSEBUTTONUP:
       print event

They are not in your loop:  for event in remainingEvents.

So only the last event in that lots gets checked to see if it is a
mouseup/down event.


Chairs.

On Thu, 17 Feb 2005 20:18:09 -0800, Fred Burton <flbl@xxxxxxxxxxxxxx> wrote:
> Marco Marconi wrote:
> 
> >On Fri, 11 Feb 2005 10:04:19 -0800
> >Fred Burton <flbl@xxxxxxxxxxxxxx> wrote:
> >
> >
> >
> >>I'm using get_rel in a pygame + pyOpenGL app (under Win XP) to get mouse
> >>movement (for camera/player control), and the event processing stuff for
> >>clicks in menus.
> >>When it's running slowly, sometimes... er..
> >>
> >>
> >
> >
> >any codes?
> >
> >
> >
> Here's a sample program that exhibits this behaviour...
> 
> Moving the mouse across the window and pressing the button may result in
> the BUTTONDOWN or BUTTONUP events being lost.
> 
> Holding down the mouse button while the mouse is still seems to generate
> a whole bunch of BUTTONDOWN events (until you move the mouse or release
> the button)
> 
> 
> 
> import pygame
> 
> pygame.init()
> 
> screen = pygame.display.set_mode((640,480))
> gamequit = 0
> while gamequit == 0:
>     remainingEvents = pygame.event.get()
>     for event in remainingEvents:
>         if event.type == pygame.QUIT:
>             gamequit = 1
>         if event.type == pygame.KEYDOWN:
>             if event.key == pygame.K_ESCAPE:
>                 gamequit = 1
>     if event.type == pygame.MOUSEBUTTONDOWN:
>         print event
>     if event.type == pygame.MOUSEBUTTONUP:
>         print event
> 
>     (rx,ry) = pygame.mouse.get_rel()
> #    if (rx != 0) and (ry != 0):
> #        print rx,ry
> 
> #    pygame.time.wait(0)
>     pygame.time.wait(40)
>     pygame.display.flip()
> 
> pygame.quit()
> 
>