From: gah AT jet DOT es (Grzegorz Adam Hankiewicz) Newsgroups: comp.os.msdos.djgpp Subject: Re: Area of square problem, different. Date: Fri, 12 Jun 1998 12:49:24 GMT Organization: Gogosoftware Lines: 47 Message-ID: <35811fae.6174643@news.jet.es> References: <35806450 DOT B3F694CD AT netrover DOT com> NNTP-Posting-Host: infot162.jet.es To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk So you are here again ... :-) On Thu, 11 Jun 1998 19:12:17 -0400, Nicolas Blais 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. Ok. let's think for a moment what your program is trying to do. Now you are checking quickly both the area and the mouse button. Think how many times a second could be run this loop. I would say more than hundreds of times a second... and that's the number of "Yeps" you get on the screen. After printing the text, you may want to "wait" for the user to release the button :-) It could be done like this: if (mouse_b == 1) { show_mouse(NULL); textout(blah... blah ...blah...); // Here comes the change... while( mouse_b == 1) ; show_mouse(screen); } Notice that you can place the "wait" after or before show_mouse(screen). If you choose the later, you will be able to 'see' the mouse pointer while the user is still pressing the mouse button. >Also, sometimes,it just doesn't print the "Yep". Can this be fixed? The x and y parameters you pass to textout are random() % 800 and random() % 600. Remember that these point the top left pixel of the first character, which is "Y". Now imagine that random() % 800 returns a value of 797. You would be able then to see only 3 pixels of the "Y", while the rest of the string is clipped out. The same goes to the height, if random() % 600 is bigger than 595 or so, you probably won't notice the string that is being printed out. In this case you simple need to reduce by some amount the values you are getting. Say random() % 770 for the x value and random() % 590 for the y value of textout. This is not a very elegant solution, but will work :-) - Grzegorz Adam Hankiewicz - gah AT jet DOT es - http://web.jet.es/gregorio/ - Gogosoftware - http://welcome.to/gogosoftware/