I instatiated the bricks and paddle without any trouble, but when I try to have the paddle move with the mouse I get a segmentation fault. And this error doesn't occur until I move my mouse over the new window.
while (lives > 0 && bricks > 0)
{
GEvent event = getNextEvent(MOUSE_EVENT);
if (event != NULL)
{
if(getEventType(event) == MOUSE_MOVED)
{
double x = getX(event) - PWT / 2;
double y = PY;
setLocation(paddle, x, y);
}
}
}
I saw similar cases where people left NULL as the return for initPaddle, but I changed that return as below. Why do I get a segmentation fault? Am I putting in th wrong return, or did instatiating the bricks first somehow interfere?
GRect initPaddle(GWindow window)
{
GRect paddle = newGRect((getWidth(window) - PWT)/2 , PY, PWT, PHT);
setColor(paddle, "BLACK");
setFilled(paddle, true);
add(window, paddle);
return newGRect;
}