Mail Archives: djgpp/1998/05/03/03:20:37
Excerpts from netnews.comp.os.msdos.djgpp: 2-May-98 Hotspots and mouse.
by "Gillepileptic"@not-very
> I hope someone can help me with Allegro: I'm hoping to set up hotspots on a
> static screen (no animation at this stage) Pretty basic stuff, just point
> and click to call a function.
> I've already got the bitmap routines sorted, and I'll figure out the mouse
> stuff from the docs.
> I'd just like to know what's the most flexible and productive way of
> checking whether a mouse has clicked a 'hotspot'? My program probably only
> needs "...if(((x>100) && (x<120)) &&... " etc, but this seems pretty
> hackish.
Thats exactly how you do it :)
Its quite easy. The most important thing to remember is
to store
int x=mouse_x;
int y=mouse_y;
int b=mouse_b;
whenever you want to check a certain click.
Then do all your checking from these integers.
If you continually poll the mouse variables
you let yourself up to get weird unreproducable bugs.
Ie if mouse_x is in range(x>20 and x<40)
do some stuff and then
do something based on mouse_x. It is wrong to
assume that mouse_x will still be in the range of 20,40
- Raw text -