Skip to main content
1 of 2

pset4:bouncing the ball up and down

i don't know why this code is not making the ball bouncing up and down!!

    while (lives > 0 && bricks > 0)
   {
            // moving paddle
  
            double velocity = 2.0; 
    
           move(ball,0,velocity);
    
           if (getY(ball)<= 0)
           {
                   velocity = -velocity;
           }
           else if (getY(ball) + 2 * RADIUS >= getHeight(window))
           {
                        velocity = -velocity;
           }
     
            pause(10);
    
    
 }