Hello, everyone. This is my first post, so I'm sorry if I've missed something.
I've made 2 classes - a Paddle and a Ball class. Both within them have a SDL_Rect object which I need to get out for the SDL_HasIntersection() function, but, no matter what I try, I'm getting this error:
\dir\ - timer.cpp|140|error: cannot convert 'SDL_Rect' to 'const SDL_Rect*' for argument '1' to 'SDL_bool SDL_HasIntersection(const SDL_Rect*, const SDL_Rect*)'|
\dir\ - timer.cpp|141|error: cannot convert 'Ball' to 'const SDL_Rect*' for argument '1' to 'SDL_bool SDL_HasIntersection(const SDL_Rect*, const SDL_Rect*)'|
Both of the classes have a Draw(SDL_Renderer* gRenderer) method which I think acts just like SDL_FillRect(), so I tried making it available like this:
void Paddle::Draw(SDL_Renderer* gRenderer){
SDL_Rect Paddle;
Paddle.x = posX;
Paddle.y = posY;
Paddle.w = PADDLE_WIDTH;
Paddle.h = PADDLE_HEIGTH;
SDL_SetRenderDrawColor(gRenderer, 255, 255, 255, 255);
SDL_RenderDrawRect(gRenderer, &Paddle);
thisPaddle = Paddle;
}
AND in my game loop - SDL_HasIntersection(ball.thisBall, paddle2.thisPaddle), but it didn't work. Using a method like this
SDL_Rect Ball::getRect()
{
return thisBall;
}
also didn't work. I'm guessing getting rid of the classes isn't a great idea?
Any help, tips, code is appreciated.