/* FLY.java - Produces flying turtles
   Created by Randel W McGirr
   blackturtle.us 2011
*/
import java.awt.*;
import java.applet.*;
import java.util.*;

public class FLY extends Applet implements Runnable{

  Dimension d;
  Image offI;
  RESIZE turts[] = new RESIZE[20];
  RESIZE t1, t2;
  int cycle, inc, curr, cnt, ccc;
  int body, fleg, bleg;
  Thread tt;

  public void init(){
    d = getSize();
//    r = new Random();
    for(int i=0; i<turts.length; i++)
      turts[i]=new RESIZE(d.width, d.height);
    offI = createImage(d.width, d.height);
    tt = new Thread(this);
    tt.start();
  }
  
  public void run(){
     while(true){
       for(int i=0; i<turts.length; i++) turts[i].move();
       repaint(); 
       try{ 
         Thread.sleep(150); 
       }catch(InterruptedException ie){ } 
    }
  }

  public void update(Graphics g){
    paint(g);
  }

  public void paint(Graphics g){
    Graphics og = offI.getGraphics();
    og.setColor(new Color(ccc,ccc,0));
    og.fillRect(0,0,d.width,d.height);
    for(int i=0; i<turts.length; i++)
      turts[i].draw(og);
    g.drawImage(offI, 0, 0, this);
    og.dispose();
  }
}
//<applet code=FLY.class height=600 width=1100></applet>
