Make your own free website on Tripod.com

import java.applet.*;                           
import java.awt.*;
import java.util.*;
import java.awt.event.*;
                                                
public class antworld extends Applet{
 Image image,bkgrnd;
 Graphics offscreen;
 boolean paintwalls=true,intro;
 Level level;
 AntManager antmanager;
 GameFrame gf;
 Console console;
 static final int width=630,height=440,Fieldwidth=width*4,Fieldheight=height*4;
 int x1=0,y1=0,scroll,xx,yy;
 String[] intromsg;
 boolean captureHillEvent=false;
 String msg;
 
   public void init(){                          
      MediaTracker t=new MediaTracker(this);
      Graphics temp;
      Image[] bantim=new Image[16];
      Image[] rantim=new Image[16];
      Image bkgrndgif;
      
      gf=new GameFrame(this,width,height);   //this one line determines if the geme creates its own window
      bkgrnd=createImage(Fieldwidth,Fieldheight);                                          
      image =createImage(Fieldwidth,Fieldheight);                                          
      offscreen=image.getGraphics();
      scroll=height;
      msg="";
      xx=width;
      yy=height;
      intro=true;
      Font f=new Font("Dialog",Font.BOLD,13);
      offscreen.setFont(f);
      
      for(int w=0;w<=15;w++){
         bantim[w]=getImage(getCodeBase(),"images/ant"+w+".gif");
         rantim[w]=getImage(getCodeBase(),"images/rant"+w+".gif");
         t.addImage(bantim[w],1);
         t.addImage(rantim[w],2);
      }
      bkgrndgif=getImage(getCodeBase(),"images/bkgrnd.gif");
      Image Anthill_incomplete=getImage(getCodeBase(),"images/antbuild.gif");
      Image Anthill_complete=getImage(getCodeBase(),"images/anthill.gif");
      Image RedAntHill=getImage(getCodeBase(),"images/redhill.gif");
      Image food0=getImage(getCodeBase(),"images/food0.gif");
      Image food1=getImage(getCodeBase(),"images/food1.gif");
      Image control_panel=getImage(getCodeBase(),"images/controls.gif");
      Image newant=getImage(getCodeBase(),"images/newant.gif");
      
      Image[] sceneryimgs=new Image[4];
      for(int r=0;r+Drag Rectangle
         if(level.antmanager.selected.size()==0){   //if no ants are selected...
            //showStatus("looking for anthill...");   //check if user clicked on a hill
            level.anthillSelect(width-this.xx+x1,height-this.yy+y1,x-x1,y-y1); //check for anthill select
         }
      }                         
      return true;              
   }
   /*public boolean mouseMove(Event e, int x,int y){
      if(console.rect.contains(x,y)){
         //showStatus("in area");
         console.detectControl(x,y);
      }
      return true;
   } */
   
   public boolean keyDown(Event e,int key){
      if(e.id==Event.KEY_ACTION){    //KEY_ACTION is used to check for arrow keys
         //showStatus("press "+key);
         switch(key){
            case 1005: {  //   down arrow = ASCII 1005
                 if(this.yy>-Fieldheight/2){   //barriers so as to not go off the screen
                    this.yy-=20;               //move down                                
                 }                                                                     
                 break;
            }
            case 1004: {  //   up arrow = ASCII 1004
                 if(this.yythe right arrow = ASCII 1007
                 if(this.xx>-Fieldwidth/2){  //barriers so as to not go off the screen
                    this.xx-=20;             //move right                             
                 }                                                                   
                 break;
            }
         }//end switch
      }else{
         if(e.id==Event.KEY_PRESS && key==104){  //key 104 = 'h'
            if(level.canCreateHill){
               captureHillEvent=true;
               level.displaymsg=false;  //stop displaying" press 'h' to create hill "
               showStatus("now click on location...");
            }else{
               showStatus("Create more ants first");  //can create new hill every 5 ants
            }
         }
      }

      return true;
   }
   
//end applet class
}

class GameFrame extends Frame{
   protected Panel p;
   protected int width,height;
   protected Applet a;
   public GameFrame(Applet a,int width,int height){
      super("nESt cOLLECTIVe");
      this.a=a;
      this.width=width;
      this.height=height;
      resize(width+10,height+40);     //make space for title bar,statusbar(at bottom),etc...
      setResizable(false);
      p=new Panel();
      p.setLayout(new FlowLayout(FlowLayout.CENTER));
      p.add(a);                      //I put it in a panel for the hell of it
      setLayout(new BorderLayout());
      add("Center",p);
      //this.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
      
      show();
   }
   public boolean handleEvent(Event e){
      if(e.id==Event.WINDOW_DESTROY){     //YES I KNOW IT'S DEPRECIATED alright..
         hide();
         a.stop();
         a.destroy();
         dispose();
         return true;
      }
      return false;
   }

}//end GameFrame class

class Console extends Thread{
 int locx,locy,width,height,offset;
 Applet a;
 Graphics g;
 String msg;
 Level level;
 Image control_panel;
 Rectangle rect;
 Rectangle[] controls;

   public Console(int startx,int starty, int width,int height,Level level,Applet a,Graphics g,Image control_panel){
      locx=startx;
      locy=starty;
      this.width=width;
      this.height=height;
      offset=startx;   //indictes how far to left to begin painting
      this.a=a;
      this.level=level;
      this.g=g;
      this.control_panel=control_panel;
      rect=new Rectangle(locx,locy+130,126,25);
      controls=new Rectangle[6];
      for(int r=0;r>left of screen           
      generate(width,0,width,height);
      p[1]=new Polygon(x,y,n);          //<<>>right of screen
      generate(height,0,height,width);   //invert x&y in creation of poly for bottom & top
      p[2]=new Polygon(y,x,n);          //<<>>bottom of screen
      generate(0,0,0,width);           //note simular craetion values: left->top  right->bottom 
      p[3]=new Polygon(y,x,n);          //<<>>top of screen
                                         
      /*for(int n=0;n<4;n++){
         wallsToPaint[n]=true;
      }*/
   }                                            
   public void generate(int firstx,int firsty,int lastx,int lasty){
      x[0]=firstx;    //start at the specified zero
      y[0]=firsty;
      for(int q=1;q1)  //when drawing image use next pic to give illusion of walking
            statepic=0;
      }
      
   }
   public void update(){
      //implemented in subclass
   }
   public void getTarget(Ant a){
      target=a;
   }
   public boolean isAlive(){
      return alive;
   }

   public void moveTo(Point pos){
      moving=true;
      move(pos.x,pos.y);
      if(locx==pos.x && locy==pos.y){
         moving=false;
      }
   }
   public void move(int x,int y){
      if(alive){
         if(x==locx && y==locy){
            state[0]=0;   
            state[1]=1;
         }else{
            if(xlocx && y>locy){
                  state[0]=10;//2
                  state[1]=11;//3
                  locx++;
                  locy++;
               }else{
                  if(xlocy){
                     state[0]=12;//6
                     state[1]=13;//7
                     locx--;
                     locy++;
                  }else{
                     if(x>locx && ylocx){
                              state[0]=2;
                              state[1]=3;
                              locx++;
                           }else{
                              if(y=0){
            for(r=0;r=0){
            for(r=0;r=bant[r].locx&&y<=bant[r].locy+bant[r].pixheight&&y>=bant[r].locx) || (x1<=bant[r].locx+bant[r].pixwidth&&x1>=bant[r].locx&&y1<=bant[r].locy+bant[r].pixheight&&y1>=bant[r].locx)){
         if(temprect.intersects(bant[r].rect)){   
            a.showStatus("Ant/s selected...");
            if(bant[r].isAlive()){
               selected.addElement(bant[r]);
               bant[r].selected=true;
            }else{
               a.showStatus("Sorry it's dead");
            }
         }
      }
   }

   public void deselectAll(){
      for(int rr=0;rr0){
         Rectangle temprect=new Rectangle(x,y,x1,y1);
         for(int r=0;r=rant[r].locx&&y<=rant[r].locy+rant[r].pixheight&&y>=rant[r].locx) || (x1<=rant[r].locx+rant[r].pixwidth&&x1>=rant[r].locx&&y1<=rant[r].locy+rant[r].pixheight&&y1>=rant[r].locx)){   
            if(temprect.intersects(rant[r].rect)){   
               if(rant[r].isAlive()){
                  for(int rr=0;rr0){
         for(int rr=0;rr=bant[r].locx&&ant.locx<=bant[r].locx+5&&ant.locy>=bant[r].locy&&ant.locy<=bant[r].locy+5){
         //if(bant[r].isAlive()&&ant!=bant[r]&&ant.rect.intersects(bant[r].rect)){
            offset(ant);    //slightly buggy code
            break;
         }
      }
   }
   public void checkBoundaries(RedAnt ant){                                                 
      for(int r=0;r=rant[r].locx&&ant.locx<=rant[r].locx+10&&ant.locy>=rant[r].locy&&ant.locy<=rant[r].locy+10){ 
            moveTo(ant,ant.locx+20,ant.locy+3); //buggy code                                  
            break;                                                                            
         }                                                                                    
      }                                                                                       
   }
   public AntHill getNearestHill(int antlocx,int antlocy){
      //need code to work
      return new AntHill(56,56,this);
   }

//end antmanager class   
}

/*class Position{
   int posx,posy;
   static final int numLevels=8;
   Point[] EndPos,bStartPos,rStartPos;
   protected int currentLevel,width,height;
   
   public Position(int x,int y){        //class created by individual ants; which simply holds
      posx=x;                           //an x & y coordinate
      posy=y;
   }
   public Position(int currentLevel,int width,int height){   //created by AntManager; holds the point that ants
      EndPos=new Point[numLevels];  //go to when starting & when all targets are dead
      bStartPos=new Point[numLevels];
      rStartPos=new Point[numLevels];
      this.currentLevel=currentLevel;
      this.width=width;
      this.height=height;
      createPositions();
   }
   public void createPositions(){
      EndPos[0]=new Point(100,-30);
      EndPos[1]=new Point(150,-30);
      EndPos[2]=new Point(width+20,150);
      EndPos[3]=new Point(width+20,300);
      EndPos[4]=new Point(width+20,250);
      EndPos[5]=new Point(300,-30);
      EndPos[6]=new Point(width/2,-30);
      EndPos[7]=new Point(100,100);
      
      bStartPos[0]=new Point(600,300);
      bStartPos[1]=new Point(100,height+20);
      bStartPos[2]=new Point(150,height+20);
      bStartPos[3]=new Point(-20,150);
      bStartPos[4]=new Point(-20,300);
      bStartPos[5]=new Point(-20,300);
      bStartPos[6]=new Point(300,height+20);
      bStartPos[7]=new Point(200,height+20);

      rStartPos[0]=new Point(200,0);
      rStartPos[1]=new Point(300,-20);
      rStartPos[2]=new Point(width+20,-20);
      rStartPos[3]=new Point(width+20,200);
      rStartPos[4]=new Point(width+20,60);
      rStartPos[5]=new Point(width+20,0);
      rStartPos[6]=new Point(0,140);
      rStartPos[7]=new Point(100,20);
   }
   public Point currentEnd(){
      return EndPos[currentLevel];
   }
   public Point currentStart(boolean red){
      if(red){
         return rStartPos[currentLevel];
      }else{
         return bStartPos[currentLevel];
      }
   }
   public void incrementLevel(){
      ++currentLevel;
   }
   public void blackAdjustStart(int amt){
      bStartPos[currentLevel].x+=amt;
   }
   public void redAdjustStart(int amt){
      rStartPos[currentLevel].x+=amt;    
   }                                     
//end position class
}*/ 

class AntHill extends Thread{
 protected int locx,locy,time,food;
 Image complete,incomplete,newAnt;
 int health;
 boolean completed_build,create_ant,destroyed,selected;
 Applet a;
 AntManager antmanager;
 Level level;
 Rectangle rect,newAntRect;

   public AntHill(int locx,int locy,Image complete,Image incomplete,Image newAnt,AntManager antmanager,Applet a,Level level){
      this.locx=locx;
      this.locy=locy;
      this.a=a;
      this.complete=complete;
      this.incomplete=incomplete;
      this.newAnt=newAnt;
      time=0;
      food=6;  //starting food reserves
      health=20;
      destroyed=false;
      completed_build=false;
      selected=false;
      this.antmanager=antmanager;
      this.level=level;
      rect=new Rectangle(locx,locy,100,100);
      newAntRect=new Rectangle(locx+80,locy,20,20);
   }
   public AntHill(int locx,int locy,AntManager antmanager){
      //this.AntHill(locx,locy,complete,incomplete,antmanager,a);
   }
   public void run(){
      while(!destroyed){
         if(!completed_build){  //takes this long to 'build'
            time++;
            if(time>20){    
               completed_build=true;
               time=0;
            }
         }else{                 //once built the code below is where the action is
            if(health<0)
               destroyed=true;
            if(create_ant){
               time++;
               if(time>10){
                  antmanager.increaseAnts(new Point(locx+25,locy+26),this);
                  create_ant=false;
                  time=0;
                  //antBuilt();
               }
            }
         }
         if(selected){
            //a.showStatus(" AntHill selected...");
         }
         try{                                
            Thread.sleep(3000);
         }catch(InterruptedException ie){}
      }//end while
   }
   public void paint(Graphics g){
      if(completed_build){
         g.drawImage(complete,locx,locy,a);
         if(selected){
            g.setColor(Color.blue);
            g.drawRect(locx,locy,100,100);
            g.drawImage(newAnt,newAntRect.x,newAntRect.y,a);

            g.drawRect(locx,locy+100,100,2);
            g.fillRect(locx,locy+100,health*5,2);
            g.drawString("Food:"+food,locx+80,locy);
            if(create_ant){
               g.setColor(Color.blue);
               g.drawRect(locx,locy+104,100,2);  
               g.fillRect(locx,locy+104,time*10,2); 
            }
         }//end if(selected)
      }else{
         g.drawImage(incomplete,locx,locy,a);
         //g.drawImage(newAnt,locx+100,locy,a);

         if(selected){
            g.setColor(Color.blue);              
            g.drawRect(locx,locy+100,100,2);  
            g.fillRect(locx,locy+100,time*5,2); 
         }
      }
   }
   
   public void createAnt(){
      if(completed_build&&selected&&food>=3&&!create_ant){
         food-=3;
         create_ant=true;
         a.showStatus("incubating ant...");
      }else{
         if(food<3)
            a.showStatus("Not enough food");
         else{
            if(!completed_build)
               a.showStatus("wait till completion");
            else
               a.showStatus("Busy, just wait...");  //a catch all msg for exceptions
         }
      
      //a.showStatus("Not enough resources!");
      }
   }
   public boolean depositFood(int amt){
      if(completed_build){
         food+=amt;
         return true;
      }else{
         return false;
      }
   }
   public int withdrawFood(){
      if(food>0){
         int temp=food;
         food=0;
         return temp;
      }
      return 0;
   }
//end class
}

class RedAntHill extends Thread{
 protected int locx,locy,time,food;
 Image complete;
 int health;
 boolean create_ant,destroyed;
 Applet a;
 AntManager antmanager;
 Level level;
 Rectangle rect;

   public RedAntHill(int locx,int locy,Image complete,AntManager antmanager,Applet a,Level level){
      this.locx=locx;
      this.locy=locy;
      this.a=a;
      this.complete=complete;
      time=0;
      food=12;  //starting food reserves
      health=20;
      destroyed=false;
      this.antmanager=antmanager;
      this.level=level;
      rect=new Rectangle(locx,locy,100,100);
      createAnt();
   }
   
   public void run(){
      while(!destroyed){
         if(health<0)
            destroyed=true;
         if(create_ant){  //always true so continious production providing avaliable resources
            time++;
            if(time>10){
               antmanager.increaseRedAnts(new Point(locx+60,locy+31),this);
               time=0;
               create_ant=false;
            }
         }
         createAnt();
         //antmanager.a.showStatus("red food "+food);
         try{                                
            Thread.sleep(10000);   //not a major thread, so it can sleep for a loong time
         }catch(InterruptedException ie){}  //and not hogging CPU execution
      }//end while
   }//end run()
   
   public void paint(Graphics g){
      g.drawImage(complete,locx,locy,a);
      /*if(create_ant){
         g.setColor(Color.blue);
         g.drawRect(locx,locy+104,100,2);  
         g.fillRect(locx,locy+104,time*10,2); 
      }*/ //above used to display status of creating ant
   }
   
   public void createAnt(){
      if(food>=3&&!create_ant){
         food-=3;
         create_ant=true;
      }
   }
   public void depositFood(int amt){
      food+=amt;
   }
}//end RedAntHill class

class Scenery{
 Image[] images;             
 int[] posx,posy;
 Rectangle[] rect;
 static int width,height;
 Applet a;
   public Scenery(Image[] images,int width,int height,Applet a){
      this.images=images;
      this.width=width;
      this.height=height;
      this.a=a;
      posx=new int[images.length*6];   //6 times as many coordinates than images as I will...
      posy=new int[images.length*6];   //...draw the same image in more than one location
      rect=new Rectangle[images.length*6];
      createScenery();
   }
   public void createScenery(){
      int x,y;
      for(int r=0;r0){                                    
         g.setColor(Color.red);                        
         g.fillRect(locx,locy+pixheight,(int)health/80,2);  //draw health shorter than actual num(ie health/80) 
      }
      //g.drawRect(attackArea.x,attackArea.y,attackArea.width,attackArea.height);  //debug purposes
   }

   public void update(){
      if(alive){
         rect.setLocation(locx+10,locy+11);   //put bounding rect at current location
         antmanager.checkBoundaries(this);
         attackArea.setLocation(locx-150,locy-150); // <-I shouldn't hard code, but must cut calculations
         if(moving){        
            //lookForEnemy();  //can be resourse sucking as it is done every iteration
            moveTo(pos);
         }else{
            if(attacking){
               bite();
            }else{
               if(patrolling){
                  pos=patroll[n];
                  moveTo(pos);
                  if(pos==patroll[n]){
                     if(++n>1)
                        n=0;
                  }
                  lookForEnemy();
                  if(attacking)
                     patrolling=false;  //stop patrolling if found an enemy
               }else{
                  if(gettingFood){                       
                     lookForEnemy();
                     if(attacking)
                        gettingFood=false;  //if found an enemy stop gettingFood
                     if(rect.intersects(food.rect)){     
                        patrolling=false;                
                        gettingFood=false;               
                        carryingFood=food.withdrawFood();
                     }
                  }else{                                 
                     if(carryingFood){                   
                        pos=homePoint;                   
                        moveTo(pos);                     
                        if(home.rect.intersects(rect)){  
                           home.depositFood(1);     
                           carryingFood=false;           
                           //getFood(food);
                           //HERE GET FOOD ********
                           pos=new Point(food.locx+25,food.locy+25);
                           moveTo(pos);                     
                        }                                
                     }else{
                           lookForEnemy();
                        //if(food.amt==0){
                           food=antmanager.foodmanager.food[(int)(Math.random()*10)]; //10 represents the total num of food
                           gettingFood=true;
                           pos=new Point(food.locx+25,food.locy+25);
                           moveTo(pos);
                        //}
                           /*patrolling=true;
                           patroll[0]=new Point(locx+200,locy+200);
                           patroll[1]=new Point(home.locx-200,home.locy-200);
                           */
                           //REPLACE THIS WITH IDLE ACTION

                        //}
                     }
                  }
               }                                                     
            }
         }                  

         if(health<0)       
            alive=false;
      }
   }
   public void bite(){                                                                                                                                                                                                                   
      if(target.isAlive()){                                                                                                                                                                                                              
         if(rect.intersects(target.rect)){                                                                                                                                                                                               
         //if((locx>=target.locx-((int)target.pixwidth/2) && locx<=target.locx+target.pixwidth-((int)target.pixwidth/2))&&(locy>=target.locy-((int)target.pixheight/2) && locy<=target.locy+target.pixheight-((int)target.pixheight/2))){
            //use above if rectangle overlap is unacceptable                                                                                                                                                                             
         //if((target.locx+pixwidth>=locx)&&(locx+pixwidth>=target.locx)&&(target.locy+target.pixheight>=locy)&&(locy+pixheight>=target.locx))                                                                                           
            //the above if is too specific the attacking ant HAS to be in the bounding box                                                                                                                                               
            target.health-=bitingPower;                                                                                                                                                                                                         
         }else{                                                                                                                                                                                                                          
            move(target.locx,target.locy);     //ant not close enough, so move to target                                                                                                                                                 
         }                                                                                                                                                                                                                               
      }else{                                                                                                                                                                                                                             
         //attacking=false; //this boolean determines if the ant should seek out other targets after killing
         antmanager.getNextTarget(this,red);    //red==true if red ant
         //uncomment the above if you want the ant to cycle thru the enemy array, attacking each
      }                                                                                                                                                                                                                                  
   }
   public void lookForEnemy(){
      for(int r=0;r0){                                    
         g.setColor(Color.red);                        
         g.fillRect(locx-5,locy+pixheight,(int)health/20,2);   
      }else{                                           
         //g.setColor(Color.red);                        
         //g.drawString("dead",locx,locy);               
      }                                                
   }
   /*public boolean Intersect(int x1,int x2,int y1,int y2){                        
       return (x2>=locx)&&(locx+pixwidth>=x1)&&(y2>=locy)&&(locy+pixheight>=y1);  
   }*/
   public void draw_setRect(Graphics g,Color color){
      g.setColor(color);
      g.drawOval(locx-5,locy-5,pixwidth,pixheight);
      //g.drawRect(attackArea.x,attackArea.y,attackArea.width,attackArea.height);
   }

   public void update(){   
      if(alive){
         rect.setLocation(locx,locy+5);  //set bounding rect to current locx & locy
         antmanager.checkBoundaries(this);
         attackArea.setLocation(locx-100,locy-100);
         if(moving){       
            moveTo(pos);   
         }else{
            if(attacking){
               bite();        
            }else{
               if(building){
                  //anthill2=new AntHill(locx,locy,antpics[0],antpics[3],antmanager,a);
                  //anthill2.start();
                  moving=false;
                  attacking=false;
                  patrolling=false;
                  //building=false;
                  
               }else{
                  if(gettingFood){
                     if(rect.intersects(food.rect)){
                        patrolling=false;
                        gettingFood=false;
                        carryingFood=food.withdrawFood();
                     }
                  }else{
                     if(carryingFood){
                        pos=homePoint;
                        moveTo(pos);
                        if(home.rect.intersects(rect)){
                           if(!home.depositFood(1)){
                              //need code here
                           }//if Anthill is incomplete, this stops them from depositing
                           carryingFood=false;
                           getFood(food);
                        }
                     }else{ 
                        if(patrolling){        
                           pos=patroll[n];     
                           moveTo(pos);        
                           if(pos==patroll[n]){
                              if(++n>1)        
                                n=0;          
                           }
                           lookForEnemy(); //when patrolling keep an eye out for possible target
                        }else{
                           lookForEnemy(); //if here, then ant is idle so just look out for a close enemy
                        }
                     }
                  }
               }
            }
         }                 
         
         if(health<0){      
            alive=false;
            selected=false;
         }
      }                    
   }
   public void lookForEnemy(){
      for(int r=0;r=target.locx-((int)target.pixwidth/2) && locx<=target.locx+target.pixwidth-((int)target.pixwidth/2))&&(locy>=target.locy-((int)target.pixheight/2) && locy<=target.locy+target.pixheight-((int)target.pixheight/2))){
            //use above if rectangle overlap is unacceptable                                                                                                                                                                             
         //if((target.locx+pixwidth>=locx)&&(locx+pixwidth>=target.locx)&&(target.locy+target.pixheight>=locy)&&(locy+pixheight>=target.locx))                                                                                           
            //the above if is too specific the attacking ant HAS to be in the bounding box                                                                                                                                               
            target.health-=bitingPower;  //'bitingPower' is kind of like each ants biting strength                                                                                                                                                                                                       
         }else{                                                                                                                                                                                                                          
            move(target.locx,target.locy);     //ant not close enough, so move to target                                                                                                                                                 
         }                                                                                                                                                                                                                               
      }else{                                                                                                                                                                                                                             
         //attacking=false;  //PUT BACK if want to stop attacking after killing target
         antmanager.getNextTarget(this,red);    //red==false if black ant
         //uncomment the above if you want the ant to cycle thru the enemy array, attacking each
         //looks like (in game) as if ant has bloodlust
      }                                                                                                                                                                                                                                  
   }
   public void getFood(){   //this is used to set a starting food in initilization
      food=antmanager.foodmanager.food[0];
      gettingFood=true;
      pos=new Point(food.locx+30,food.locy+30);
      moveTo(pos);
   }
   public void getFood(Food food){ //this function is used to switch food during gameplay
      this.food=food;
      gettingFood=true;                  
      pos=new Point(food.locx+30,food.locy+30);
      moveTo(pos);                       
   }
   public void setPatroll(Point point){
      patroll[0]=new Point(locx,locy);
      patroll[1]=point;
      patrolling=true;
   }
                                                                                                                                                                                                                                            
//end class
}

class Food{
 protected int locx,locy,amt;
 protected Image current,finished; //the image of finished food is displayed when amt<0
 Rectangle rect;
 Applet a;

   public Food(Image current,Image finished,int locx,int locy,int amt,Applet a){
      this.current=current;
      this.finished=finished;
      this.locx=locx;
      this.locy=locy;
      this.amt=amt;
      this.a=a;
      rect=new Rectangle(locx,locy,70,70);
   }
   public void paint(Graphics g){
      if(amt>0){
         g.drawImage(current,locx,locy,a);
      }else{
         g.drawImage(finished,locx,locy,a);
      }
   }
   public boolean withdrawFood(){
      if(amt>0){
         amt--;
         return true;
      }else{
         return false;
      }
   }

}//end class Food

class FoodManager{
 Food[] food;
 AntManager antmanager;
 final static int width=2200,height=1500;  //Change these to variables

 public FoodManager(int numfood,Image image0,Image image1,AntManager antmanager){
   food=new Food[numfood];
   this.antmanager=antmanager;
   for(int r=0;r0){
            for(int rr=0;rr=5){ //can create hill every 5 ants
            canCreateHill=true;
            //antmanager.a.showStatus("sum: "+antmanager.numbants/(numAntHills+1));
            if(displaymsg){  //without this the ONLY msg displayed is the one below
               antmanager.a.showStatus("Press 'h' to create hill");
               //displaymsg=false;  //this alows the msg to be displayed but once.
            }
         }
         if(antmanager.allRedDead){
            //nextLevel();
            GameWon=true;
            redanthill.destroyed=true;
         }
         if(antmanager.allBlackDead){  //->OBVIOUSLY! (computers are sooo slow)
            GameOver=true;
            for(int r=0;r=totalLevels){ 
         GameWon=true;
         antmanager.stop();
         for(int r=0;r<=numAntHills;r++){
               anthill[r].stop();
         }
      }else{
         liveAnts=1;
         getRemainingAnts();     //function changes the value of'liveAnts'
         antmanager.increaseLevel(liveAnts,currentLevel+1,currentLevel);
         w=new Walls(antmanager.width,antmanager.height);
         scenery=new Scenery(scenery.images,antmanager.width,antmanager.height,antmanager.a);
      }
   }*/

   /*public void createAntsLookup(){
      antsPerLevel=new int[totalLevels]; //create lookup for additional Ants per level
      for(int t=0;t