Well, I don't see the point behind waiting for a click then creating the ball. Besides, if you did as you described (i.e., called
waitForClick() then created the ball), the ball won't show up until you click the mouse.
The move function is supposed to be called inside the while loop and that makes sense because the ball is constantly moving. The function
move(), as its name suggests, moves the ball by a specific number of pixels on the x-axis and a specific number of pixels on the y-axis just one time. To keep it doing that, we need to put it into a loop.
But if we're gonna call
move() inside the loop, how are we gonna move the paddle? Well, the paddle is supposed to be moving as your program receives a MOUSE_MOVED event. So you're supposed to be having a condition inside your loop that detects if this type of event occurs. If so, you move the paddle appropriately.
Notice that the body of the while loop executes really fast. So you won't be having issues with moving the paddle and the ball at the same time as you might have imagined.
What could possibly go wrong with your ball/paddle? The
initPaddle() functions both should return an instance of the ball and the paddle respectively (they shouldn't return
NULL) after they create them and add them to the window so that you can access them using the variables named
paddle respectively in
main() after they're assigned the values returned by these functions (which are the ball and the paddle
GObjects that we created in these functions).