Hi guys I'm really new to the forum and fairly new to c++, but have been really struggling with making a game pong. At my university we use a thing called Gwin, to program, (its equivalent for cin>> would be Gwin.write) etc. I have used two images for the game, firstly an image of the paddle and secondly an image of a ball, and I am having problems with getting the ball to collide with the paddle. If anyone could give me any tips or hints I would be really grateful.my coding is posted below
int ball_width = blueball.getWidth();
int ball_height = blueball.getHeight();
int Paddle_width = Paddle.getWidth();
int Paddle_height = Paddle.getHeight();
// Seed the random-number generator with current time so that
// the numbers will be different every time we run.
srand( (unsigned)time( NULL ) );
bool isRequired = true;
int x = 90;
// Loop until user presses Esc
while (isRequired)
{
Gwin.clear();
if (Keyboard.isPressed(GwinKeyNames::CURSOR_DOWN))
{
Gwin.drawImage(2,x++, &Paddle);
}
if (Keyboard.isPressed(GwinKeyNames::CURSOR_UP))
{
Gwin.drawImage(2,x--, &Paddle);
}
++z;
}
Gwin.refresh();
if (Keyboard.isKeyReady())
{// check if they want to exit
if (Keyboard.waitKey() == GwinKeyNames::ESCAPE)
{// let them exit
isRequired = false;
}
}
}
return 0;
}