//
//    CHAPTERˇˇ27
//    Class Source Name [MoverSoftCoral.java]
//    Package name      [userClass.App]
//                                    1996.3
//                 Author [ Junzo hagimoto ]

package  userClass.App;

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

                                                  
public class   MoverSoftCoral  extends  Mover {      
    static Dimension d ;
    static boolean   start = true;
    public void   drawImage(Graphics g){          
       g.drawImage(owner.img[(imgCount/4) % owner.maxImage ],x,y,owner.a);
    }
    public void   calcxy(Dimension d,int speed)
    { 
        if(start){
	    start=false;
	    d = owner.a.size();
	}
        if( x  >  d.width - getImageWidth(0) ){   
            x = d.width   - getImageWidth(0) -1;   
        }                                               
        if( x  <  0 ){                                  
            x = 0;                                      
        }                                               
       if(y < d.height - getImageHeight(0) ){
             y++;
       
       }else{
         y  = d.height - getImageHeight(0);
         x +=  (int)(Math.random() * 3 ) - 1 ;
       }
       if(imgCount==0){
          owner.addMover( copy(new Bubbles()) );
       }
       imgCount++;
       if(imgCount > 300){
          imgCount=0;
       }
    
    }
}
              //