As my first C++ game I'm making PONG. I have a good understanding of loops, ifs, functions, and graphics and am willing to learn other things to make this work. I need to make the ball move and bounce off walls and paddles. I know I probably have to use a loop to do this but how do I make the ball bounce.
So far I have this source for the game part:
//field dimensions are 600 X 440
for (x=20;x<=580;x=x+.1)
{
y=y+.08;
testWindow.SetBrush(White);
testWindow.DrawCircle(x-.1, y-.08, 15); //Draws circle with a 15 r
testWindow.SetBrush(RED);
testWindow.Drawcircle(x, y, 15);
}
this loop draws a red ball then covers it up with a white one (because white is the background color) every time. The ball will just move slanted in animation all the way past the edge of bottom center of the screen. How do I make it bounce? I know I have to change the y coordinate to start getting smaller, but how? Also, if it's not too much trouble, can you tell me how to make paddles move with arrowkey input? Thanks a lot!