Advertisement

How do I set up a hot spot for the mouse?

Started by May 20, 2000 10:47 AM
1 comment, last by Kavos 24 years, 7 months ago
I got the numbers and stuff but how do I accually go about telling the mouse "Tell me if your clicked in the area of 20 X and 20 Y to 100 X and 100 Y (for example)"? ~Kavos
I am not sure if I am right here but I figured I may as well offer any help I can provide. What I think you have to do is basically, each game loop, update your mouse position and get the numbers. Than I think you just have to test it if its in that rectangle. You could create a stupid little function that will do this for you. I am not sure if there is already one or not since I suck ass but this is what I did:

BOOL IsInRect ( int x, int y, RECT dst )
{
if ( x < dst.left )
return FALSE;
if ( x > dst.right )
return FALSE;
if ( y > dst.bottom )
return FALSE;
if ( y < dst.top )
return FALSE;
return TRUE;
}

you could combine all of those into one big IF statement but I expanded it for two reasons. The first would be that the group members of my project are just learning (so am I but I know more than they do) and 2, I just don''t care that much

Than you just update your mouse and each time, you pass the X-Y''s into that with a rectangle structure of where you want. If you have a GUI type game like Starcraft, you could do a test for each of the different elements, like the MiniMap RECT, the Unit Info RECT and the main game board. Thats the best I can think of but than again, I am an idiot. If you need anymore help, I will be willing to tell ya whatever I know.

Spanky (they call me the Spankster)
Advertisement
Hey, thanks alot.

~Kavos

This topic is closed to new replies.

Advertisement