Source: GameDev.Net LLC BlogAll I want to do is click and drag a spriteelse if (event.type == SDL_MOUSEBUTTONDOWN||SDL_MOUSEMOTION) {
if (event.button.button == SDL_BUTTON_LEFT) {
int mouseX, mouseY;
SDL_GetMouseState(&mouseX, &mouseY);
cout << mouseX << " " << mouseY << endl;
if (mouseX > 522 && mouseX < 567 && mouseY>394 && mouseY < 439)
{
SDL_Rect rect_two;
rect_two.x = 567;
rect_two.y = 394;
SDL_BlitSurface(gHelloWorld_one, NULL, gScreenSurface, &rect_two);
SDL_UpdateWindowSurface((gWindow));
}
}
Read full article »
Followers on Owler
4