//SHELL.java - Called by MULTITURT to produce different shell shapes
//Created by Randel McGirr, Trona, California, 2011

import java.awt.*;
import java.util.*;

public class SHELL{

  Color colors[] = { Color.red, Color.yellow, Color.green, Color.cyan,
                     new Color(125,125,125), Color.magenta, new Color(99,50,255), 
                     Color.orange, Color.pink };
  Random r;
  int x, y, start;
  
  SHELL(int a, int b){
    x=a;
    y=b;
    start=a;
    r = new Random();
  }
  
  public void reset(){
    x=start;
  }

  public void move(){
    x+=12;
  }

  public void draw(Graphics g, int s){
    int pick=Math.abs(r.nextInt()%colors.length);
    g.setColor(colors[pick]);
    if(s==0) g.fillRect(x,y,18,18);
    else if(s==1){ // triangle
      int xpts[] = { x, x+9, x+18, x};
      int ypts[] = { y+18, y, y+18, y+18};
      Polygon tri = new Polygon(xpts, ypts, 4);
      g.fillPolygon(tri);
    }
    else if(s==2){ // star
      int xpts[] = { x, x+6, x+9, x+12, x+18, x+13, x+16, x+9, x+2, x+5, x};
      int ypts[] = { y+6, y+6, y, y+6, y+6, y+10, y+18, y+13, y+18, y+10, y+6};
      Polygon star = new Polygon(xpts, ypts, 11);
      g.fillPolygon(star);
    }
    else if(s==3){ // diamond
      int xpts[] = { x, x+9, x+18, x+9, x};
      int ypts[] = { y+9, y, y+9, y+18, y+9};
      Polygon diamond = new Polygon(xpts, ypts, 5);
      g.fillPolygon(diamond);
    }
    else if(s==4){ // heart
      g.fillOval(x,y,9,9);
      g.fillOval(x+9,y,9,9);
      int xpts[] = { x+2, x+16, x+9, x+2};
      int ypts[] = { y+8, y+8, y+18, y+8};
      Polygon heart = new Polygon(xpts, ypts, 4);
      g.fillPolygon(heart);
    }
    else g.fillOval(x,y,18,18);
  }
}
