Message-Id: <199807022332.AAA15390@sable.ox.ac.uk> Comments: Authenticated sender is From: George Foot To: djgpp AT delorie DOT com Date: Fri, 3 Jul 1998 00:27:43 +0000 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Re: allegro mouse problems Reply-to: george DOT foot AT merton DOT oxford DOT ac DOT uk Precedence: bulk On 2 Jul 98 at 4:43, Roger W. Huggins wrote: > I am trying to get the mouse to work with allegro. I get the mouse to > display and move about the screen okay, but I can't seem to detect when a > mouse button is pressed . I would appreciate it if someone could tell me > what is wrong with the following code: > > show_mouse(NULL); > rectfill(screen,x,y,x1,y1,BLACK); > show_mouse(screen); > do > { > if(mouse_b & 1) > { > textout_centre(screen,font,"Left Button Pressed",10,10,YELLOW); Side note: you should have hidden the mouse before the above line. > //left button pressed > show_mouse(NULL); > rectfill(screen,x,y,x1,y1,BLUE); > show_mouse(screen); > } > }while(!readkey()); You're using the wrong function here -- I think you mean `keypressed'. The `readkey' function reads a character from the buffer, or, if the buffer is empty, waits for it to stop being empty (i.e. waits for a key to be pressed). It blocks, though, so your test on `mouse_b' is only made after keys are pressed. In fact, though, you're looping until `readkey' returns a nonzero number -- but it always returns a nonzero number, so your while loop will terminate after the first pass. Replace `readkey' with `keypressed' and move the `show_mouse(NULL);' line before the `textout_centre' line. -- george DOT foot AT merton DOT oxford DOT ac DOT uk