SDL collision.

I have a moving image that i want to not pass into of obstacles so i made a function:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

bool CheckCollision(float Ax,float Ay,float Aw,float Ah,
                    float Bx,float By,float Bw,float Bh)

    {

        if(Ay+Ah<By)
        return false;

        else if(Ay>By+Bh)
        return false;

        else if(Ax+Aw<Bx)
        return false;

        else if(Ax>Bx+Bw)
        return false;


        return true;

    }



And these:

SDL_Surface *heroe=NULL;

int srcX1=0;
int srcY1=0;

int dstX1=5;
int dstY1=840;

int width1=32;
int height1=32;




SDL_Rect heroe_rect;
instr.give(dstX1,dstY1,heroe->w,heroe->h,heroe_rect);



I did it correct?
Topic archived. No new replies allowed.