//
//    CHAPTER@25
//    Class Source Name [Bubbles.java]
//    Package name      [userClass.App]
//                                    1996.3
//                 Author [ Junzo hagimoto ]

package  userClass.App;

import java.applet.*;
import java.awt.*;
import userClass.App.*;

                                                  
public class   Bubbles  extends  Mover {      
    boolean kill = false;
    int     maxBubbles =6;
    Point   point[];
    int     size[];
    public Bubbles(){
         maxBubbles  = (int)(Math.random() * 25) + 2 ;
         point       = new Point[maxBubbles];
         size        = new int[maxBubbles];
         for(int i=0;i < maxBubbles;i++){
              point[i]     = new Point( (int)(Math.random() * 15) ,
                                        (int)(Math.random() *  12) ) ;
              size[i]      = ((int)(Math.random() *  3) + 2)*2 ;
         }
    }
    public void   drawImage(Graphics g){          
       int z,over=0;
       color(g);
       y--;
       for(int i=0;i < maxBubbles;i++){
          z = (int)( Math.random() * 20)  ;
          if( z  < 10 ){
               z = -1 ;
          }else{
               z =1 ;
          }
          point[i].x  += (int)(Math.random() * 4) * z  ; 
          point[i].y  += (int)(Math.random() * 5) ;
          draw(g,i);
          over = Math.max(over, y - point[i].y);
       }
       if(over <  5 ){
         owner.deleteMover(this);
       }
    }
    public void   calcxy(Dimension d,int speed){ }

    protected void   color(Graphics g){
       g.setColor(Color.white);
    }
    protected void   draw(Graphics g, int i){
       g.drawOval( x + point[i].x, y - point[i].y, size[i],size[i]);
    }
}
              //