From: gah AT jet DOT es (Grzegorz Adam Hankiewicz) Newsgroups: comp.os.msdos.djgpp Subject: Re: How to get the Area of a square... Date: Thu, 11 Jun 1998 12:27:34 GMT Organization: Gogosoftware Lines: 29 Message-ID: <357fcbce.1694322@news.jet.es> References: <357F3B82 DOT D761E6FD AT netrover DOT com> NNTP-Posting-Host: infon428.jet.es To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk On Wed, 10 Jun 1998 22:05:55 -0400, Nicolas Blais wrote: >Hi, let's say I have a 40 by 40 pixels square (at 0,0) on the screen. I >use Allegro for my mouse routines and I currently use a do/while loop to >see if the mouse is over this square, but it's very slow and >inefficient. Can someone suggest me a better way with example? Yes. What you are trying to do is check the coordinates of _every_ pixel of the box to see if it's coordinates are the same than the ones of the mouse. However, you only need to know if the pointer is inside, and therefore you only need to check the borders of the box and compare them to the coordinates of the mouse. I would write it like this: while (keypressed() != 0) { if (mouse_x >= 0 && mouse_x <40 && mouse_y >= 0 && mouse_y <40) outtext(screen,font,"Bla",1,1,COLOR); } - Grzegorz Adam Hankiewicz - gah AT jet DOT es - http://web.jet.es/gregorio/ - Gogosoftware - http://welcome.to/gogosoftware/