1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
void CoordClick(int *xx, int *yy)
{ int go=1;
SDL_Event event;
event.button.x=0;
event.button.y=0;
while(go)
{
SDL_WaitEvent(&event);
if(event.type==SDL_MOUSEBUTTONUP)
{
*xx = event.button.x;
*yy = event.button.y;
go=0;
}
}
}
int main(int argc, char *argv[])
{
int *xx=NULL;
int *yy=NULL;
SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE);
SDL_Surface *ecran = NULL;
ecran = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE);
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 17, 206, 112));
SDL_Flip(ecran);
CoordClick(xx,yy);
printf("x = %d y = %d",*xx,*yy);
SDL_Quit();
return EXIT_SUCCESS;
} |
Partager