/**boing(number).java by gregvan 
 * RECOMMENDED SIZE: height 520, width 740
 **/

import java.applet.*;
import java.awt.*;

public class boing68 extends Applet implements Runnable
{
int earth;
int art=1;
int artq=8;
int fart=1;
int fartq=5;
int fred=1;
int fredq=1;
int womama=1;
int joemama=2;
int blowmama=1;
int cat=1;
int dog=1;
int cow=1;
int pig=1;

int john=1;
int george=1;
int paul=1;
int ringo=100;
int martin=1;
int fartin=1;

int i2cube=1;
int i2sq=1;
int king=1;
int kong=1;
int ping=1;
int pong=1;

int god=1;

int dawn=1;
int dawn8=1;
int people=1;

int abba;
int abba1=3;
int jabba;
int jabba1=4;

int abbah;
int jabbah;
int lucysky=3;
int diamonds=2;
int dream=1;
int moody;
int blues=1;
int delta=1;


int rr,gg,bb;//color variables 
int bw=1;
int bwq=1;     
int rq=1; // color up-down factors
int gq=1;
int bq=1;

int cx; //center of screen x
int cy; //center of screen y

        Thread    myRunner;
        Image     buffer;         
        Dimension appletSize;     
        Graphics  bufferGraphics; 

        public void init()
        {    
        setBackground(Color.black);
        appletSize = this.getSize();     
        buffer = this.createImage(appletSize.width, appletSize.height);
        bufferGraphics = buffer.getGraphics();
	cx=appletSize.width/2;
        cy=appletSize.height/2;

        }

        public void start()
        {
             if (myRunner == null)
             {
                 myRunner = new Thread(this);
                 myRunner.start();
             }
        }

        public void run()
        {
            Thread  executingThread;                   
            executingThread = Thread.currentThread();

            while (myRunner == executingThread)
            {
               //new random numbers to start animation
	 

//random starting colors
rr=(int)(Math.random() *255);
gg=(int)(Math.random() *254);
bb=(int)(Math.random() *253);
bw=(int)(Math.random() *252);
cat=rr;
dog=gg;
cow=bb;
pig=bw;
womama=cow+pig;

abba=127-gg;
jabba=127-bb;



               repaint();
               try
               {Thread.sleep(1000);}
               catch(InterruptedException e) {} 

               while (myRunner != null)
               {
                  repaint(); 
                  try
                  {Thread.sleep(100); }
                  catch (InterruptedException e) {}
               }  
           } 
        }

       // make sure the animation really stops when exiting webpage
        public void stop()
        { 
          if (myRunner != null)
             { myRunner = null; }
        }

        //used to prevent blinking graphics....
        public void update(Graphics g)
        {paint(g);}

        public void paint(Graphics g)
        {
//generate a new random direction
earth=earth+1;
if(earth>20){
earth=1;
art=(int)(Math.random() *12);
artq=art-6;
fart=(int)(Math.random() *10);
fartq=fart-6;
}

god=god+1;
if(god>6){god=1;}


people=people+1;
if(people>5){
people=1;
ringo=ringo+1;
if(ringo>cx){ringo=-cx;}
dawn=dawn+1;
if(dawn>48){dawn=3;}
dawn8=dawn8+1;
if(dawn8>98){dawn8=3;}
pong=pong+1;
if(pong>5){pong=1;}
ping=ping+1;
if(ping>pong){ping=1;}
}
womama=womama+1;
if(womama>300+dawn+dawn8){womama=-(300+dawn+dawn8);}

joemama=joemama+2;
if(joemama>400-dawn-dawn8){joemama=-(400-dawn-dawn8);}

blowmama=blowmama+3;
if(blowmama>400-dawn-dawn8){blowmama=-(400-dawn-dawn8);}

//for loop to paint many images before sleeping .1 second     
       for (int i=0;i<2;i++)
        {



moody=moody+blues;
if(moody>4+god){blues=-1;}
if(moody<-(5+god)){blues=1;}

dream=dream+delta;
if(dream>5+god){delta=-1;}
if(dream<-(6+god)){delta=1;}


             //color changer up-down counters
       rr=rr+rq;
           if(rr>253){rq=-13;}
           if(rr<3){rq=1;}
       gg=gg+gq;
           if(gg>252){gq=-1;}
           if(gg<4){gq=2;}
       bb=bb+bq;
           if(bb>251){bq=-1;}
           if(bb<5){bq=1;}
       bw=bw+bwq;
           if(bw>250){bwq=-god;}
           if(bw<6){bwq=god;}

if (rr>255){rr=32;}
if (gg>255){gg=255;}
if (bb>255){bb=255;}
if (bw>255){bw=32;}
if (rr<0){rr=224;}
if (gg<0){gg=0;}
if (bb<0){bb=0;}
if (bw<0){bw=224;}
//new ovals in grey*****************************
if (john<paul){
       rr=rr+rq;
           if(rr>245){rq=-8;}
           if(rr<12){rq=8;}
if (rr>255){rr=rr-205;}
if (rr<0){rr=rr+205;}
martin=martin-1;
if(martin<2){martin=cx+100;}
fartin=fartin+2;
if(fartin>cx+100){fartin=1;}
//apply the new numbers for color
        Color martinNew = new Color(rr,rr,rr);
        bufferGraphics.setColor(martinNew); 
bufferGraphics.drawOval(cx-martin,cy-fartin,martin+martin,fartin+fartin);
bufferGraphics.drawOval(cx-fartin,cy-martin,fartin+fartin,martin+martin);
}//end of john<paul


//new july second circles away from center========
fred=fred+fredq;
if(fred>cx+80){fredq=-2;}
if(fred<10){fredq=1;}

if(blowmama<womama){
//apply the new numbers for color
        Color fredNew = new Color(rr,rr,bb);
        bufferGraphics.setColor(fredNew);
bufferGraphics.drawOval(cx-ringo-fred,cy-ringo-fred,fred+fred,fred+fred);
bufferGraphics.drawOval(cx-ringo-fred,cy+ringo-fred,fred+fred,fred+fred);
bufferGraphics.drawOval(cx+ringo-fred,cy-ringo-fred,fred+fred,fred+fred);
bufferGraphics.drawOval(cx+ringo-fred,cy+ringo-fred,fred+fred,fred+fred);
}else{
//apply the new numbers for color
        Color fredbwNew = new Color(gg,gg,rr);
        bufferGraphics.setColor(fredbwNew);
bufferGraphics.drawOval(cx-ringo-fred,cy-fred,fred+fred,fred+fred);
bufferGraphics.drawOval(cx-fred,cy+ringo-fred,fred+fred,fred+fred);
bufferGraphics.drawOval(cx+ringo-fred,cy-fred,fred+fred,fred+fred);
bufferGraphics.drawOval(cx-fred,cy-ringo-fred,fred+fred,fred+fred);
}//end of blowmama>womama

// new july second 2006 ----star in center--------
if(pig>cow){
//apply the new numbers for color
        Color johnNew = new Color(bw,gg,bb);
        bufferGraphics.setColor(johnNew);
}else{
//apply the new numbers for color
        Color john2New = new Color(bb,gg,gg);
        bufferGraphics.setColor(john2New);
}

george=george+1;
if(george>moody+dream+pong+ping){george=-(moody+dream+pong+ping);}

john=john-1;
if (john<2){john=262-dawn8-dawn8;}

bufferGraphics.drawLine(cx+george,cy-john+george,cx-george,cy+john-george);
bufferGraphics.drawLine(cx-john+george,cy+george,cx+john-george,cy-george);
bufferGraphics.drawLine(cx-george,cy-john+george,cx+george,cy+john-george);
bufferGraphics.drawLine(cx-john+george,cy-george,cx+john-george,cy+george);

paul=paul-1;
if(paul<2){paul=194-dawn-dawn;}

bufferGraphics.drawLine(cx-paul-george,cy-paul+george,cx+paul+george,cy+paul-george);
bufferGraphics.drawLine(cx-paul+george,cy+paul+george,cx+paul-george,cy-paul-george);
bufferGraphics.drawLine(cx-paul+george,cy-paul-george,cx+paul-george,cy+paul+george);
bufferGraphics.drawLine(cx-paul-george,cy+paul-george,cx+paul+george,cy-paul+george);

///gnu gnu gnu%%%%%%%% July 1 2006 %%%%%%%%%%%%%%

if(joemama>blowmama){
dog=dog-1;
if (dog<5){dog=cx+100;}
cat=cat+2;
if (cat>cx+100){cat=1;}
cow=cow+3;
if (cow>cx+100){cow=1;}
pig=pig+4;
if (pig>cx+100){pig=1;}
}else{//joemama>blowmama
dog=dog+3;
if (dog>cx+100){dog=1;}
cat=cat+1;
if (cat>cx+100){cat=1;}
cow=cow-4;
if (cow<7){cow=cx+100;}
pig=pig-2;
if (pig<8){pig=cx+100;}
}//end of joemama>blowmama

//apply the new numbers for color
        Color sirdogNew = new Color(bb,rr,gg);
        bufferGraphics.setColor(sirdogNew); 
bufferGraphics.drawLine(cx,cy-pig,cx+pig,cy);
bufferGraphics.drawLine(cx,cy+pig,cx+pig,cy);
bufferGraphics.drawLine(cx,cy-pig,cx-pig,cy);
bufferGraphics.drawLine(cx,cy+pig,cx-pig,cy);

bufferGraphics.drawRect(cx-pig,cy-pig,pig+pig,pig+pig);

bufferGraphics.drawOval(cx-dog,cy-dog,dog+dog,dog+dog);
bufferGraphics.drawOval(cx-cat-40,cy-cat-40,cat+cat+80,cat+cat+80);
//apply the new numbers for color
        Color sircatNew = new Color(gg,rr,256-bb);
        bufferGraphics.setColor(sircatNew); 

bufferGraphics.drawLine(cx,cy-dog,cx+dog,cy);
bufferGraphics.drawLine(cx,cy+dog,cx+dog,cy);
bufferGraphics.drawLine(cx,cy-dog,cx-dog,cy);
bufferGraphics.drawLine(cx,cy+dog,cx-dog,cy);
bufferGraphics.drawRect(cx-dog,cy-dog,dog+dog,dog+dog);

bufferGraphics.drawOval(cx-cat,cy-cat,cat+cat,cat+cat);
bufferGraphics.drawOval(cx-cow-50,cy-cow-50,cow+cow+100,cow+cow+100);
//apply the new numbers for color
        Color sircowNew = new Color(256-bb,rr,256-gg);
        bufferGraphics.setColor(sircowNew); 
bufferGraphics.drawLine(cx,cy-cat,cx+cat,cy);
bufferGraphics.drawLine(cx,cy+cat,cx+cat,cy);
bufferGraphics.drawLine(cx,cy-cat,cx-cat,cy);
bufferGraphics.drawLine(cx,cy+cat,cx-cat,cy);
bufferGraphics.drawRect(cx-cat,cy-cat,cat+cat,cat+cat);

bufferGraphics.drawOval(cx-cow,cy-cow,cow+cow,cow+cow);
bufferGraphics.drawOval(cx-pig-50,cy-pig-50,pig+pig+100,pig+pig+100);

//apply the new numbers for color
        Color sirpigNew = new Color(256-gg,256-bb,rr);
        bufferGraphics.setColor(sirpigNew); 
bufferGraphics.drawLine(cx,cy-cow,cx+cow,cy);
bufferGraphics.drawLine(cx,cy+cow,cx+cow,cy);
bufferGraphics.drawLine(cx,cy-cow,cx-cow,cy);
bufferGraphics.drawLine(cx,cy+cow,cx-cow,cy);
bufferGraphics.drawRect(cx-cow,cy-cow,cow+cow,cow+cow);

bufferGraphics.drawOval(cx-pig,cy-pig,pig+pig,pig+pig);
bufferGraphics.drawOval(cx-dog-30,cy-dog-30,dog+dog+60,dog+dog+60);
//&&&&&&&&&&&&end of squares and circles&&&&&&&&&&&&&&&

lucysky=lucysky+abba1;
if(lucysky>15-moody){abba1=-1;}
if(lucysky<-(6+dream)){abba1=1;}

diamonds=diamonds+jabba1;
if (diamonds>18-dream){jabba1=-1;}
if (diamonds<-(7+moody)){jabba1=1;}

if(pig>cat){
abba=abba+artq;
}else{
abba=abba-lucysky;
}
if (abba>cx+100){abba=-100;}
if (abba<-(cx+100)){abba=100;}

if(dog>cow){
jabba=jabba+fartq;
}else{
jabba=jabba-diamonds;
}
if (jabba>cx+100){jabba=-100;}
if (jabba<-(cx+100)){jabba=100;}


//@@@@@@@@@@new july 1 2006@@@@@@@@@@@@@@@@@@@

///testing people ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(fartin>martin){
king=1;
kong=2;
}else{
king=2;
kong=4;
}
for (int i3=0;i3<=9-people;i3++)
{
abba=abba-(i3*i3);
for (int i2=0;i2<=people+3;i2++)
{
if(jabba>abba){i2cube=i2*i2*i2;}
else{i2cube=i2*i2;}
i2sq=i2*i3;
abba=abba+i2cube;
jabba=jabba+i2sq;
if(dog>cat){
bw=bw+bwq;
if(bw>240){bwq=-9;}
if(bw<16){bwq=9;}
//8888888888888888888888888888888888shredded b&w 8888888
//apply the new numbers for color
        Color topwNew = new Color(gg,gg,gg);
        bufferGraphics.setColor(topwNew); 
}else{
//apply the new numbers for color
        Color topcolNew = new Color(bw,bw,bw);
        bufferGraphics.setColor(topcolNew); 
}//end of dog>cat
if(john>paul){
bufferGraphics.fillRect(cx+abba-king,cy+jabba-king,kong,kong);
bufferGraphics.fillRect(cx-abba-king,cy-jabba-king,kong,kong);

bufferGraphics.fillRect(cx+jabba-king,cy-abba-king,kong,kong);
bufferGraphics.fillRect(cx-jabba-king,cy+abba-king,kong,kong);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bufferGraphics.fillRect(cx+abba+jabba-king,cy-abba+jabba-king,kong,kong);
bufferGraphics.fillRect(cx-abba+jabba-king,cy-abba-jabba-king,kong,kong);

bufferGraphics.fillRect(cx-abba-jabba-king,cy+abba-jabba-king,kong,kong);
bufferGraphics.fillRect(cx+abba-jabba-king,cy+abba+jabba-king,kong,kong);
//#############basketball jones#################################

abba=-abba;
bufferGraphics.fillRect(cx+abba-king,cy+jabba-king,kong,kong);
bufferGraphics.fillRect(cx-abba-king,cy-jabba-king,kong,kong);

bufferGraphics.fillRect(cx+jabba-king,cy-abba-king,kong,kong);
bufferGraphics.fillRect(cx-jabba-king,cy+abba-king,kong,kong);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bufferGraphics.fillRect(cx+abba+jabba-king,cy-abba+jabba-king,kong,kong);
bufferGraphics.fillRect(cx-abba+jabba-king,cy-abba-jabba-king,kong,kong);

bufferGraphics.fillRect(cx-abba-jabba-king,cy+abba-jabba-king,kong,kong);
bufferGraphics.fillRect(cx+abba-jabba-king,cy+abba+jabba-king,kong,kong);
abba=-abba;
}//end of john>paul

abba=abba-i2cube;
jabba=jabba-i2sq;
}//end of i2 for loop
abba=abba+(i3*i3);
}//end of i3 for loop
//}//end of select drawlines or filled boxes
   }//end of for loop i
     // move the entire buffer onto the display screen and change
     // pixels that are a different color...
      g.drawImage(buffer, 0, 0, this);
    }
} // end of the program...

