Collision detection

Hi!

Is there someone out there that can give me some ideas or some code that helps me with collision detection? I’ve looked at using a color scan method and am not sure about it. Is there something that SDL allows that would make collision detection easier?

I am not too picky. I’m currently trying to move a bitmap across the screen that has a image of a path. I would like to detect collision between the bmp and the edge of the path to prevent the bmp from leaving the path. I’m currently trying to get this example code to work, but having difficulties:

int Color_Scan(int x1, int y1, int x2, int y2,
UCHAR scan_color, UCHAR *scan_buffer, int scan_lpitch)
{
// this function implements a crude collision technique
// based on scanning for a specific color within a rectangle

// clip rectangle

// x coords first
if (x1 >= SCREEN_WIDTH)
x1=SCREEN_WIDTH-1;
else
if (x1 < 0)
x1=0;

if (x2 >= SCREEN_WIDTH)
x2=SCREEN_WIDTH-1;
else
if (x2 < 0)
x2=0;

// now y-coords
if (y1 >= SCREEN_HEIGHT)
y1=SCREEN_HEIGHT-1;
else
if (y1 < 0)
y1=0;

if (y2 >= SCREEN_HEIGHT)
y2=SCREEN_HEIGHT-1;
else
if (y2 < 0)
y2=0;

// scan the region
scan_buffer +=y1*scan_lpitch;

for (int scan_y=y1; scan_y<=y2; scan_y++)
{
for (int scan_x=x1; scan_x<=x2; scan_x++)
{
if (scan_buffer[scan_x] == scan_color)
return(1);
} // end for x

// move down a line
scan_buffer+=scan_lpitch;

} // end for y

By the way, thanks! I solved my colorkey prob!

Richard---------------------------------
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards?

It’s not really clear to me what this scan buffer stuff is exactly, but you are on the right track it looks like, I think.

In one of my games, I do pixel level collision detection between 2 sprites on the screen. It basically comes down to checking for overlapping non-colorkey pixels. If there is any overlap, a collision has occured. Here’s the code for it, which right now only supports 16 bit color mode, but shouldn’t be too hard to change to different depths.

bool sprite_collision_check(int x1, int y1, Sprite *s1, int x2, int y2, Sprite *s2)
{
bool r = false;
int x, y, w, h, x3, y3, x4, y4;

x3 = x1 + s1->width;
x4 = x2 + s2->width;
if (x1 > x2) {
w = ((x3 > x4) ? x4 : x3) - x1;
x2 = x1 - x2;
x1 = 0;

} else {
w = ((x3 > x4) ? x4 : x3) - x2;
x1 = x2 - x1;
x2 = 0;
}

y3 = y1 + s1->height;
y4 = y2 + s2->height;
if (y1 > y2) {
h = ((y3 > y4) ? y4 : y3) - y1;
y2 = y1 - y2;
y1 = 0;

} else {
h = ((y3 > y4) ? y4 : y3) - y2;
y1 = y2 - y1;
y2 = 0;
}

// check bounding box overlap first
if ((w < 1) || (h < 1))
return false;

if (SDL_MUSTLOCK(s1->bitmap))
while (SDL_LockSurface(s1->bitmap) < 0);

if (SDL_MUSTLOCK(s2->bitmap))
while (SDL_LockSurface(s2->bitmap) < 0);

if (screen_bpp == 8) {

} else { // screen_bpp == 16
int pitch1, pitch2;
Uint16 *ptr1, *ptr2;

pitch1 = s1->bitmap->pitch >> 1;
pitch2 = s2->bitmap->pitch >> 1;
ptr1 = (Uint16 *) s1->bitmap->pixels + y1 * pitch1 + x1;
ptr2 = (Uint16 *) s2->bitmap->pixels + y2 * pitch2 + x2;
pitch1 -= w;
pitch2 -= w;

for (y=0; y<h; y++) {
for (x=0; x<w; x++) {
if (*ptr1++ && *ptr2) {
r = true;
y = h;
break;
}

ptr2++;

}

ptr1 += pitch1;
ptr2 += pitch2;
}
}

if (SDL_MUSTLOCK(s1->bitmap))
SDL_UnlockSurface(s1->bitmap);

if (SDL_MUSTLOCK(s2->bitmap))
SDL_UnlockSurface(s2->bitmap);

return r;
}

-Jason----- Original Message -----
From: Richard Perrine
To: SDLgroup
Sent: Friday, March 22, 2002 9:49 AM
Subject: [SDL] collision detection

Hi!

Is there someone out there that can give me some ideas or some code that helps me with collision detection? I’ve looked at using a color scan method and am not sure about it. Is there something that SDL allows that would make collision detection easier?

I am not too picky. I’m currently trying to move a bitmap across the screen that has a image of a path. I would like to detect collision between the bmp and the edge of the path to prevent the bmp from leaving the path. I’m currently trying to get this example code to work, but having difficulties:

int Color_Scan(int x1, int y1, int x2, int y2,
UCHAR scan_color, UCHAR *scan_buffer, int scan_lpitch)
{
// this function implements a crude collision technique
// based on scanning for a specific color within a rectangle

// clip rectangle

// x coords first
if (x1 >= SCREEN_WIDTH)
x1=SCREEN_WIDTH-1;
else
if (x1 < 0)
x1=0;

if (x2 >= SCREEN_WIDTH)
x2=SCREEN_WIDTH-1;
else
if (x2 < 0)
x2=0;

// now y-coords
if (y1 >= SCREEN_HEIGHT)
y1=SCREEN_HEIGHT-1;
else
if (y1 < 0)
y1=0;

if (y2 >= SCREEN_HEIGHT)
y2=SCREEN_HEIGHT-1;
else
if (y2 < 0)
y2=0;

// scan the region
scan_buffer +=y1*scan_lpitch;

for (int scan_y=y1; scan_y<=y2; scan_y++)
{
for (int scan_x=x1; scan_x<=x2; scan_x++)
{
if (scan_buffer[scan_x] == scan_color)
return(1);
} // end for x

  // move down a line
  scan_buffer+=scan_lpitch;

  } // end for y

By the way, thanks! I solved my colorkey prob!

Richard


Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards?

|
| Is there someone out there that can give me some ideas or some code
| that helps me with collision detection? I’ve looked at using a color
| scan method and am not sure about it. Is there something that SDL allows
| that would make collision detection easier?

How would you do this so you can detect a car going around a track
(checking when the car goes off the edge of the track)?

Would I draw round the edges of the track in a ‘magic’ colour and test
for that, or is there another way? I could split the track up into
rectangles for the parts you’re allowed to drive on, but that wouldn’t
work with corners and wiggly bits of track, would it?On Fri, Mar 22, 2002 at 06:49:53AM -0800, Richard Perrine wrote:


Quoting one is plagiarism. Quoting many is research.
6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)

I’d have to know more about your specific game design to really say. But
I’m guessing a track mask would probably work best. It would basically be
an identical image as the track, only would have black or white to represent
’on track’ or ‘off track’. You then check collisions against this instead.
Since you have only black and white, you could pack this down into bits,
cutting the memory requirements by 8, 16 or 32 (depending on your color
depth).

-Jason> ----- Original Message -----

From: james@piku.org.uk (James)
To:
Sent: Friday, March 22, 2002 11:09 AM
Subject: Re: [SDL] collision detection

On Fri, Mar 22, 2002 at 06:49:53AM -0800, Richard Perrine wrote:
|
| Is there someone out there that can give me some ideas or some code
| that helps me with collision detection? I’ve looked at using a color
| scan method and am not sure about it. Is there something that SDL allows
| that would make collision detection easier?

How would you do this so you can detect a car going around a track
(checking when the car goes off the edge of the track)?

Would I draw round the edges of the track in a ‘magic’ colour and test
for that, or is there another way? I could split the track up into
rectangles for the parts you’re allowed to drive on, but that wouldn’t
work with corners and wiggly bits of track, would it?


Quoting one is plagiarism. Quoting many is research.
6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I’ve seen a site with Java applets demonstrating various “AI” algorithms
in real time. Objects walking around, following a track, avoiding
obstacles, chasing each other etc…

Unfortunately, I’ve lost the URL, and I can’t seem to find the site. :frowning:

Anyway, I have a few suggestions:

* Separate control and interface. That is, don't use the
  actual graphics in your navigation/collision code, but
  rather use separate "mask" images, which you convert
  into whatever format works best for your algo. Creating
  levels as image + mask should be trivial with GIMP,
  PhotoShop, PaintShop Pro and similar programs.
  (Layers...)

* You'll most probably need to detect more than just
  collisions, if objects are supposed to "bounce" off
  edges in anything like a realistic way. One simple
  way that might work is to check a few pixels around
  each corner of the vehicle, to get a rough idea about
  the angle of the obstacle, and then just make the car
  bounce and/or spin in one direction or the other,
  depending on that angle.

* As an alternative to bouncing or crashing against edges,
  how about "gravel zones"? You could check each wheel
  separately, and feed into a simple simulation of how
  the off-axis forces affects the vehicle. (Braking
  with gravel under the left two wheels will make the
  car spin to the right, etc...)

* Don't forget to scale things according to the velocity!
  (Actually, the energy.) It looks kind of silly when
  you're hardly moving, and then, as you hit some object,
  *boing* - and you're flying in the other direction
  at 10 times the speed! :-) (Seen that a few times, so
  I guess it's not obvious to everyone...)

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Friday 22 March 2002 17:09, James wrote:

On Fri, Mar 22, 2002 at 06:49:53AM -0800, Richard Perrine wrote:
| Is there someone out there that can give me some ideas or some code
| that helps me with collision detection? I’ve looked at using a color
| scan method and am not sure about it. Is there something that SDL
| allows that would make collision detection easier?

How would you do this so you can detect a car going around a track
(checking when the car goes off the edge of the track)?

Would I draw round the edges of the track in a ‘magic’ colour and test
for that, or is there another way? I could split the track up into
rectangles for the parts you’re allowed to drive on, but that wouldn’t
work with corners and wiggly bits of track, would it?

| I’d have to know more about your specific game design to really say. But
| I’m guessing a track mask would probably work best. It would basically be
| an identical image as the track, only would have black or white to represent
| ‘on track’ or ‘off track’. You then check collisions against this instead.
| Since you have only black and white, you could pack this down into bits,
| cutting the memory requirements by 8, 16 or 32 (depending on your color
| depth).

I like that idea. It’s simple. And I could modify it to have black,
white, grey(?) to represent “on” “off” and “bridge” pieces. I assume
I’d make a mask for my cars as well, and use that to check collisions,
etc.On Fri, Mar 22, 2002 at 11:27:26AM -0500, Jason Hoffoss wrote:


I will not trade pants with others
6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)

I picked up Game Programming Gems, and it had a chapter in it about
’Navigation Meshes’. Maybe something like that could help you with your
problem? Maybe you could find something similar on the net, without having
to shell out $70 (!) for the book.> ----- Original Message -----

From: james@piku.org.uk (James)
To:
Sent: Friday, March 22, 2002 11:09 AM
Subject: Re: [SDL] collision detection

On Fri, Mar 22, 2002 at 06:49:53AM -0800, Richard Perrine wrote:
|
| Is there someone out there that can give me some ideas or some code
| that helps me with collision detection? I’ve looked at using a color
| scan method and am not sure about it. Is there something that SDL allows
| that would make collision detection easier?

How would you do this so you can detect a car going around a track
(checking when the car goes off the edge of the track)?

Would I draw round the edges of the track in a ‘magic’ colour and test
for that, or is there another way? I could split the track up into
rectangles for the parts you’re allowed to drive on, but that wouldn’t
work with corners and wiggly bits of track, would it?


Quoting one is plagiarism. Quoting many is research.
6AD6 865A BF6E 76BB 1FC2 | www.piku.org.uk/public-key.asc
E4C4 DEEA 7D08 D511 E149 | www.piku.org.uk wnzrf at cvxh.bet.hx (rot13’d)


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

| I’d have to know more about your specific game design to really say.
But
| I’m guessing a track mask would probably work best. It would basically
be
| an identical image as the track, only would have black or white to
represent
| ‘on track’ or ‘off track’. You then check collisions against this
instead.
| Since you have only black and white, you could pack this down into bits,
| cutting the memory requirements by 8, 16 or 32 (depending on your color
| depth).

I like that idea. It’s simple. And I could modify it to have black,
white, grey(?) to represent “on” “off” and “bridge” pieces. I assume
I’d make a mask for my cars as well, and use that to check collisions,
etc.

You could make masks for the cars as well, but it’s not really necessary,
assuming you have a color key for them. That would represent black in the
mask, and anything that isn’t the color key color would be white. So these
cars would already have a mask built into them, so to speak. But you can
make explicit masks if you wish, if you think it would simplify things or
whatever.

-Jason

----- Original Message -----
From: james@piku.org.uk (James)
To:
Sent: Friday, March 22, 2002 2:06 PM
Subject: Re: [SDL] collision detection
On Fri, Mar 22, 2002 at 11:27:26AM -0500, Jason Hoffoss wrote:

Hi Jason,
Thanks for that collision code.
I also have another problem that you may be able to help me with. I’m trying to create multiple moveable bitmaps on a screen by using rectangles for each bitmap. I’ve created a rectangle surface for each image but still get probs with one image blitting on top of another. I guess I’m having some probs fully understanding the dynamics of the Blit function. This is what I have:
SDL_BlitSurface(pBitmap,NULL,background,NULL);
SDL_BlitSurface(launcher,&rcSsl,background,NULL);
SDL_BlitSurface(background,&rcBkg,pSurface,NULL);
pBitmap, launcher, background are all bmp images. background is being used as the background. pBitmap moves independently up and down the screen and launcher is supposed to moved at the opposite end of the screen using the arrow keys. I have the background and the pBitmap doing what it should, but the launcher image just sits there. Oh, I know that I need to have two separate x,y variables for the moving bitmaps, but when I create the rectangle for the second image, I get an error message indicating that x2, y2 are not acceptable in the Blit function. What do you think?
THanks again.
Richard (No doubt you’ve realized that I’m new to this :>)
Jason Hoffoss wrote: It’s not really clear to me what this scan buffer stuff is exactly, but you are on the right track it looks like, I think. In one of my games, I do pixel level collision detection between 2 sprites on the screen. It basically comes down to checking for overlapping non-colorkey pixels. If there is any overlap, a collision has occured. Here’s the code for it, which right now only supports 16 bit color mode, but shouldn’t be too hard to change to different depths. bool sprite_collision_check(int x1, int y1, Sprite *s1, int x2, int y2, Sprite *s2)
{
bool r = false;
int x, y, w, h, x3, y3, x4, y4; x3 = x1 + s1->width;
x4 = x2 + s2->width;
if (x1 > x2) {
w = ((x3 > x4) ? x4 : x3) - x1;
x2 = x1 - x2;
x1 = 0; } else {
w = ((x3 > x4) ? x4 : x3) - x2;
x1 = x2 - x1;
x2 = 0;
} y3 = y1 + s1->height;
y4 = y2 + s2->height;
if (y1 > y2) {
h = ((y3 > y4) ? y4 : y3) - y1;
y2 = y1 - y2;
y1 = 0; } else {
h = ((y3 > y4) ? y4 : y3) - y2;
y1 = y2 - y1;
y2 = 0;
} // check bounding box overlap first if ((w < 1) || (h < 1))
return false; if (SDL_MUSTLOCK(s1->bitmap))
while (SDL_LockSurface(s1->bitmap) < 0); if (SDL_MUSTLOCK(s2->bitmap))
while (SDL_LockSurface(s2->bitmap) < 0); if (screen_bpp == 8) { } else { // screen_bpp == 16
int pitch1, pitch2;
Uint16 *ptr1, *ptr2; pitch1 = s1->bitmap->pitch >> 1;
pitch2 = s2->bitmap->pitch >> 1;
ptr1 = (Uint16 *) s1->bitmap->pixels + y1 * pitch1 + x1;
ptr2 = (Uint16 *) s2->bitmap->pixels + y2 * pitch2 + x2;
pitch1 -= w;
pitch2 -= w; for (y=0; y<h; y++) {
for (x=0; x<w; x++) {
if (*ptr1++ && *ptr2) {
r = true;
y = h;
break;
} ptr2++;
} ptr1 += pitch1;
ptr2 += pitch2;
}
} if (SDL_MUSTLOCK(s1->bitmap))
SDL_UnlockSurface(s1->bitmap); if (SDL_MUSTLOCK(s2->bitmap))
SDL_UnlockSurface(s2->bitmap); return r;
}
-Jason----- Original Message ----- From: Richard Perrine To: SDLgroup Sent: Friday, March 22, 2002 9:49 AMSubject: [SDL] collision detection

Hi!

Is there someone out there that can give me some ideas or some code that helps me with collision detection? I’ve looked at using a color scan method and am not sure about it. Is there something that SDL allows that would make collision detection easier?

I am not too picky. I’m currently trying to move a bitmap across the screen that has a image of a path. I would like to detect collision between the bmp and the edge of the path to prevent the bmp from leaving the path. I’m currently trying to get this example code to work, but having difficulties:

int Color_Scan(int x1, int y1, int x2, int y2,
UCHAR scan_color, UCHAR *scan_buffer, int scan_lpitch)
{
// this function implements a crude collision technique
// based on scanning for a specific color within a rectangle

// clip rectangle

// x coords first
if (x1 >= SCREEN_WIDTH)
x1=SCREEN_WIDTH-1;
else
if (x1 < 0)
x1=0;

if (x2 >= SCREEN_WIDTH)
x2=SCREEN_WIDTH-1;
else
if (x2 < 0)
x2=0;

// now y-coords
if (y1 >= SCREEN_HEIGHT)
y1=SCREEN_HEIGHT-1;
else
if (y1 < 0)
y1=0;

if (y2 >= SCREEN_HEIGHT)
y2=SCREEN_HEIGHT-1;
else
if (y2 < 0)
y2=0;

// scan the region
scan_buffer +=y1*scan_lpitch;

for (int scan_y=y1; scan_y<=y2; scan_y++)
{
for (int scan_x=x1; scan_x<=x2; scan_x++)
{
if (scan_buffer[scan_x] == scan_color)
return(1);
} // end for x

// move down a line
scan_buffer+=scan_lpitch;

} // end for y

By the way, thanks! I solved my colorkey prob!

Richard---------------------------------
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards?


Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards?

Hi Jason,

Thanks for that collision code.

I also have another problem that you may be able to help me with. I’m trying to create multiple moveable bitmaps on a screen by using rectangles for each bitmap. I’ve created a rectangle surface for each image but still get probs with one image blitting on top of another. I guess I’m having some probs fully understanding the dynamics of the Blit function. This is what I have:

SDL_BlitSurface(pBitmap,NULL,background,NULL);
SDL_BlitSurface(launcher,&rcSsl,background,NULL);
SDL_BlitSurface(background,&rcBkg,pSurface,NULL);

pBitmap, launcher, background are all bmp images. background is being used as the background. pBitmap moves independently up and down the screen and launcher is supposed to moved at the opposite end of the screen using the arrow keys. I have the background and the pBitmap doing what it should, but the launcher image just sits there. Oh, I know that I need to have two separate x,y variables for the moving bitmaps, but when I create the rectangle for the second image, I get an error message indicating that x2, y2 are not acceptable in the Blit function. What do you think?

I think you need to show me the code you are using to fill in rcSsl and rcBkg. Seems like you are using NULL a lot here, which seems kind of surprising. Maybe tell me the width and height values of all these surfaces too. And is pSurface your actual screen surface? So you clear out background once a frame or anything?----- Original Message -----
From: Richard Perrine
To: sdl at libsdl.org
Sent: Saturday, March 23, 2002 10:26 AM
Subject: Re: [SDL] collision detection

Here it is Jason. The background bmp (ONE) is 800x600, pBitmap bmp (TWO) is 100x100 and the launcher bmp (bluesphere) is 73x68.
int main(int argc, charargv[])
{
Uint8
keys;
// initialize systems //
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);

// set our at exit function //
atexit(SDL_Quit);
// create a window //
SDL_SurfacepSurface= SDL_SetVideoMode(SCREENWIDTH,SCREENHEIGHT,SCREENBPP,SCREENFLAGS);
// load bitmaps //
SDL_Surface
pBitmap=SDL_LoadBMP(“TWO.bmp”);
SDL_Surfacebackground=SDL_LoadBMP(“ONE.bmp”);
SDL_Surface
launcher=SDL_LoadBMP(“bluesphere.bmp”);

// launcher (Ssl) rectangle //
SDL_Rect rcSsl;
rcSsl.w=launcher->w;
rcSsl.h=launcher->h;
rcSsl.x=0;
rcSsl.y=0;

// source rectangle “TWO” //
SDL_Rect rcSrc,rcDst;
rcSrc.w=pBitmap->w;
rcSrc.h=pBitmap->h;
rcSrc.x=0;
rcSrc.y=0;
rcDst=rcSrc;
// movement rate //
int dx=NULL, dy=5;

// declare event variable //
SDL_Event event;

// message pump //
for(;:wink:
{
// look for an event //
if(SDL_PollEvent(&event))
{
// an event was found //
if(event.type==SDL_QUIT)
break;
if(event.type==SDL_KEYDOWN)
{
if(event.key.keysym.sym==SDLK_ESCAPE)
exit(0);

 }

}
// place (blit) images on screen //
SDL_BlitSurface(pBitmap,&rcSrc,background,&rcDst);
SDL_BlitSurface(launcher,&rcSsl,background,NULL);
SDL_BlitSurface(background,NULL,pSurface,NULL);
// move the TWO up and down //
rcDst.x=700;
rcDst.y +=dy;

// check for TWO at the edge //

if(rcDst.y==0||rcDst.y==SCREENHEIGHT-100)
dy=-dy; // make TWO go in the opposite direction
// when it hits the edge of screen

keys=SDL_GetKeyState(NULL);
if(keys[SDLK_UP]){rcSsl.y =5;} // moves image with arrow keys
if(keys[SDLK_DOWN]){rcSsl.y =5;}

// update the screen //

SDL_UpdateRect(pSurface,0,0,0,0);

} // end of message pump //
// done //

return 0;
}
What do you think is the prob(s)?
Thanks Jason.
Richard
Jason Hoffoss wrote: ----- Original Message ----- From: Richard Perrine To: sdl at libsdl.org Sent: Saturday, March 23, 2002 10:26 AMSubject: Re: [SDL] collision detection

Hi Jason,
Thanks for that collision code.
I also have another problem that you may be able to help me with. I’m trying to create multiple moveable bitmaps on a screen by using rectangles for each bitmap. I’ve created a rectangle surface for each image but still get probs with one image blitting on top of another. I guess I’m having some probs fully understanding the dynamics of the Blit function. This is what I have:
SDL_BlitSurface(pBitmap,NULL,background,NULL);
SDL_BlitSurface(launcher,&rcSsl,background,NULL);
SDL_BlitSurface(background,&rcBkg,pSurface,NULL);
pBitmap, launcher, background are all bmp images. background is being used as the background. pBitmap moves independently up and down the screen and launcher is supposed to moved at the opposite end of the screen using the arrow keys. I have the background and the pBitmap doing what it should, but the launcher image just sits there. Oh, I know that I need to have two separate x,y variables for the moving bitmaps, but when I create the rectangle for the second image, I get an error message indicating that x2, y2 are not acceptable in the Blit function. What do you think?

I think you need to show me the code you are using to fill in rcSsl and rcBkg. Seems like you are using NULL a lot here, which seems kind of surprising. Maybe tell me the width and height values of all these surfaces too. And is pSurface your actual screen surface? So you clear out background once a frame or anything?---------------------------------
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards?