I'm having some trouble getting the ball to move when the user clicks at the start of the game. I have the code below positioned in main
, right after everything is instantiated, and before the while (true)
loop. I created double xvel
and double yvel
global variables. When I run breakout, everything sets up correctly and the paddle follows my mouse, but the ball won't move on my click. Any help is appreciated. Thanks!
xvel = drand48();
yvel = - 2.0 * drand48();
GEvent start = getNextEvent(MOUSE_EVENT);
if (start != NULL)
{
if (getEventType(start) == MOUSE_CLICKED)
{
move(ball, xvel, yvel);
}
}