Mail Archives: djgpp/1998/06/13/19:01:32
[This followup was posted to comp.os.msdos.djgpp and a copy was sent to
the cited author.]
In comp.os.msdos.djgpp, article <35808F82 DOT 538C6AB8 AT netrover DOT com>, Nicolas
Blais (eletech AT netrover DOT com) wrote:
> The bit of code below seams to work partially or actually more than I
> expect, because when I click on the rectangle, it gives me millions
> (seriously) of the "Yep" string, but I only want one. Also, sometimes,
> it just doesn't print the "Yep" at all, and I have to hold the mouse
> button until the million "Yep"s show! Can this be fixed?
Well, I think the reason it is saying 'Yep' a million times is that that
is what the program does. If you make it so the text is always printed in
the same place, you will only see one 'Yep'. If you want the text to be
in a random position, as it is at the moment, but only one 'Yep', you can
use a flag, i.e.
showing_yep = FALSE;
do
{
if(((mouse_x >= min_x) && (mouse_x <= max_x))
&& ((mouse_y >= min_y ) && (mouse_y <= max_y)))
{
if ( (mouse_b & 1) && (!showing_yep) )
{
showing_yep = TRUE;
show_mouse(NULL);
textout(screen,font,"Yep",
random() % 800,random() % 600,RGB(0,255,0));
show_mouse(screen);
}
}
} while (!keypressed());
- Raw text -