import java.awt.*;

public class Ball {
private Color mycolor;
private int radius;
private int YOFFSET;
private double XMIN=-1.0,XMAX=1.0,YMIN=-1.0,YMAX=1.0;
private double VX=4.0,VY=4.0;
public double x,y,vx,vy;
private double xscale,yscale;

// Constructor method sets up initial position and velocity and saves
// name of applet.  Also sets the color and radius of the ball

Ball(Color c, int r, int xl, int yl){
mycolor=c;
radius=r;
x=XMIN+(XMAX-XMIN)*Math.random();
y=YMIN+(YMAX-YMIN)*Math.random();
vx=VX*(Math.random()-0.5);
vy=VY*(Math.random()-0.5);
xscale=xl/(XMAX-XMIN);
yscale=-yl/(YMAX-YMIN);
YOFFSET=yl;
}


// this method draws ball to screen

public void draw(Graphics g){

  g.setColor(mycolor);
  g.fillOval((int)((x-XMIN)*xscale)-radius,
             (int)((y-YMIN)*yscale)-radius+YOFFSET,
             2*radius,2*radius);
}

}

