I have this piece of code that should get the position of the mouse when a button is clicked, then I check if that click is inside a certain area. However, no matter where I click I still get game over. Am I doing something wrong? (btw if this post is in the wrong place, this is my first post so sorry)
Code:
if (gameEvent.type == SDL_MOUSEBUTTONDOWN)
{
SDL_GetMouseState(&mouseX, &mouseY);
if (mouseX >= buttonX && mouseX <= buttonW && mouseY >= buttonY && mouseY <= buttonH) {
win = true;
click = true;
SDL_Surface *winSurface = SDL_LoadBMP("Images/VictoryScreen.bmp");
SDL_Texture *winTexture = SDL_CreateTextureFromSurface(gamerenderer, winSurface);
SDL_RenderClear(gamerenderer);
SDL_RenderCopy(gamerenderer, winTexture, NULL, NULL);
SDL_RenderPresent(gamerenderer);
}