[SDL] I want to find the position of the mouse...

Patricia Curtis patricia.curtis at gmail.com
Tue Jun 5 10:08:58 PDT 2007


typedef struct
{
 SDL_Rect Src;
 int   HotSpotOffsetX;
 int   HotSpotOffsetY;
}MouseCursor;

#define HAND_CURSOR 0
#define WAIT_CURSOR 1

int Curso; // what cursor to display
MouseCursor   Cursors[MAXCURSORS];

// on init i do this

 Cursors[HAND_CURSOR].Src.x    = 0; // pos on bitmap
 Cursors[HAND_CURSOR].Src.y    = 0; // y pos on bitmap
 Cursors[HAND_CURSOR].Src.w   = 38; // width of cursor imahe
 Cursors[HAND_CURSOR].Src.h   = 43; // height of cursor image
 Cursors[HAND_CURSOR].HotSpotOffsetX  = 30; // hotspot x
 Cursors[HAND_CURSOR].HotSpotOffsetY  = 5; // hotspot y


// then at the end of the draw loop i do this
 CopyRect(&Cursors[Cursor].Src,&Src);  // copys SDL_Rect to another SDL_Rect
(not rocket science)
 Dest.x = MouseX-Cursors[Cursor].HotSpotOffsetX;
 Dest.y = MouseY-Cursors[Cursor].HotSpotOffsetY;
 Dest.w = Src.w;
 Dest.h = Src.h;
 SDL_BlitSurface(gCursors, &Src, gScreen, &Dest);



I hope this helps

Trish x
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070606/60a2eb8c/attachment.htm 


More information about the SDL mailing list