Hello,
I’ve been trying to modify existing SDL programs to learn as much as I can. I have currently succeeded in using a program that moves a bmp using the arrow keys and using the mouse. But, whenever the bmp is moved to the right or down, it doesn’t erase the old bmp position. It does when it goes to the left and up. I have provided some code that I suspect is where the prob may be. Can anyone help me on this?
void updateScene(int newx, int newy) {
/* since we’re updating multiple areas,
we store all rectangles in an array */
SDL_Rect rects[2];
SDL_Rect r;
/ this rectangle contains the old cursor image /
r = &(rects[0]);
r->x = x;
r->y = y;
//r->w = cursor->w;
//r->h = cursor->h;
/ overwrite old cursor image with background /
SDL_BlitSurface(background, r, screen, r);
/ this rectangle contains the new cursor image /
r = &(rects[1]);
r->x = newx;
r->y = newy;
//r->w = cursor->w;
//r->h = cursor->h;
/ draw new cursor /
SDL_BlitSurface(cursor, NULL, screen, r);
/ make sure screen is updated /
SDL_UpdateRects(screen, 2, rects);
/ store the new cursor coordinates */
x = newx;
y = newy;
//
SDL_Event event;
while(SDL_WaitEvent(&event)) {
keys=SDL_GetKeyState(NULL);
if(keys[SDLK_UP]){y -=1;}
if(keys[SDLK_DOWN]){y +=1;}
if(keys[SDLK_LEFT]){x -=1;}
if(keys[SDLK_RIGHT]){x +=1;}
drawScene();
//convertImages();
updateScene(x,y);
Also, theres a function called SDL_WarpCursor. I couldn’t find this in the SDL guide. What does it do exactly and why isn’t it in the guide?
Thanks!
Richard---------------------------------
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage