Ball is not bouncing :(
while (lives > 0 && bricks > 0) { GRect rect = newGRect(162, 573, PWIDTH, PHEIGHT); // TODO add(window,rect); setFilled(rect,true); setColor(rect,"BLACK");
GOval circle = newGOval(190,300,35,35);
add(window,circle);
setFilled(circle, true);
setColor(circle,"RED");
while(true)
{
GEvent event =getNextEvent(MOUSE_EVENT);
if(event!=NULL)
{
if(getEventType(event)== MOUSE_MOVED)
{
double x = getX(event)-PWIDTH/2;
setLocation(rect,x,573);
}
}
}
double velocity= 2.0;
while(true)
{
move(circle, velocity, 0);
if(getX(circle)+getWidth(circle)>=getWidth(window))
{
velocity=-velocity;
}
else if( getX(circle) <=0 )
{
velocity= -velocity;
}
}
}