SDL - C - How to check if the mouse pointer is over an image?

1
Hello, I'm starting a learning about the graphical interface SDL in C and I intend to make a menu. In this menu there will be the options and when the user hover over some, it will change color (yellow to green) only I'm having difficulty in this. I already placed the images of the buttons arranged vertically, I wanted to know how to check if the mouse is over some to render it again.

    
asked by anonymous 11.06.2016 / 19:44

1 answer

1

When you pick up the mouse movement event, you can compare the coordinates of the mouse with those of the menu items:

int end_x;
int end_y;
if(e.type == SDL_MOUSEMOTION)
{
    SDL_GetMouseState(&end_x,&end_y);
}

Good luck in studies:)

    
04.09.2016 / 03:10