-1
while (lives > 0 && bricks > 0)
    {          
        GEvent event=getNextEvent(MOUSE_EVENT);
          if(event!=NULL)
          {   
            if(getEventType(event)==MOUSE_MOVED)
            { 
              double  x= getX(event);
              double  y=580;
               setLocation(paddle,x,y);
            }
          }
           double velocity=  6+ (int)(drand48()*10)% 4;

           while(true)  
     {    move(ball,0,velocity);
         if((getY(ball)+ 2*RADIUS)  >= (getHeight(window)- 20))
          {  velocity=-velocity; }
          else if(getY(ball) <= 0)
           { velocity = - velocity;}
           else if(getX(ball) + 2*RADIUS <= getWidth(window))
            { velocity = - velocity;}
            else if(getX(ball) <= 0)
             { velocity = - velocity;}
               pause(10);
                  }
0

As long as i can see your code , consider to remove while(true) because this one is never reached. You have already while loop for handle movements of the ball and paddle, so this is enough. Also try to reconsider how you should set the velocity (note: make a global variable that is constant ouside of the while loop)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .