Mail Archives: djgpp/1998/06/10/22:46:52
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?
>
> Here's way I do:
>
> do
> {
> for (int x = 0; x = 40; x++)
> {
> for (int y = 0; y = 40; y++)
> {
> if (mouse_x == x && mouse_y = y)
> outtext(screen,font,"Bla",1,1,COLOR);
> }
> }
> } while (keypressed() != 0);
>
> Sorry for my coding habits... Nicolas Blais
Try:
if (mouse_x >= 0 && mouse_x <= 40)
if (mouse_y >= 0 && mouse_y <= 40)
outtext(...);
I think that works, I haven't been programming much lately though so my
brain may have gone gooey.
- Raw text -