Hey guys!
i have yet another problem and cant find a way around it :O
i have this function in the class Platform
void Platform::set_clips(SDL_Rect platClip[], int i)
{
for( int j = 0; j < i; j++ )
{
platClip[j].x = 0;
platClip[j].y = 0;
platClip[j].w = random_number_w();
platClip[j].h = 5;
}
}
and i also have another function that checks for collisions, this is not included in the platform class because it uses another class
bool check_collision(Stick C, Platform D, SDL_Rect A[], SDL_Rect B[])
{
//side of rectangles
int leftB;
int rightA;
//calculate rect A sides
rightA = C.x + A[C.frame].w;
//calculate sides rect B
leftB = //this is where i want it to get platClip[j].x ;
//if any of sides from A are outside B
if( rightA <= leftB )
{
return false;
}
//if none of sides from A are outisde B, collision
return true;
}
problem is that i want the int leftB to hold the value of the platClip[j].x
but there is no way of getting the variables from platClip because it was initialized in the function parameter..
a copy of my whole source code can be found here on google docs : Full Source
The source code is a little old and only has outdated check_collision()
function. i have posted the new check_collision function that im using above.
i tried making a SDL_Rect plats[]
variable in the class platform so i could access it but i need to put a number in the array to define its size. The reason i made the class is so that i dont have to define the array size..
Thanks for any help :D