package MissileCommand;




public class BadExplosion extends GP.Animator implements MCConstants {


  private GP.Graphics.Line _line;
  private int _size;
  private GP.Graphics.FilledOval _radius;
  private Turret _target;


  public BadExplosion(GP.Container frame, GP.Graphics.Line line, Turret target, double x, double y) {

    super(frame);

    _line=line;
    _target=target;
    _size=10;

    // we'll make our blast radius a circle, and grow it through use of an animator
    _radius=new GP.Graphics.FilledOval(frame);
    _radius.SetColor(new GP.Attributes.Colors.Green());
    _radius.SetSize(new GP.Attributes.Size(_size,_size));
    _radius.SetPosition(new GP.Attributes.Position(x,y));


  }



  public void Action() {
    
    _size +=10;

    _radius.SetSize(new GP.Attributes.Size(_size,_size));
    
    /** This bit here is just a snazzy color cycling routine to make the
      * explosions easier to pick up onscreen.  It picks 3 random numbers
      * between 3 and 240, one each for red, green, and blue.  It then sets
      * the color of _radius, the circle indicating the blast radius of the
      * explosion, to those values.  Since Action for this class gets called
      * roughly 8 times, the color changes roughly 8 times.
      */
    int r=cs015.SP.RandomNumberFactory.RandomNumber(3,240);
    int g=cs015.SP.RandomNumberFactory.RandomNumber(3,240);
    int b=cs015.SP.RandomNumberFactory.RandomNumber(3,240);
    _radius.SetColor(new GP.Attributes.Color(r,g,b));
    
  
    if (_size > BLAST_RADIUS) {
      _radius.Hide();
      _line.Hide();
      _target.blowUp();
      this.Stop();
     
    }
    
  }




}

