class World {
/////////////////////////////////////////////////////////////////////////////////////
//Class Variables-------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////////
ArrayList wormPopulation; //Dynamic Array For World Population
int wormCount;
/////////////////////////////////////////////////////////////////////////////////////
//Class Constructors----------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////////
World(int _wormCount) { //Initialize
wormCount = _wormCount;
wormPopulation = new ArrayList(); //Initialize ArrayList
for (int i=0; i<wormCount; i++){ //Instantiate Worms
Vec3D wormBasePos = new Vec3D (random(0,width),random(0,height),0); //Create a vector for specifying start loc of worm
Worm newWorm = new Worm(wormBasePos); //Create a new instance of the worm
wormPopulation.add(newWorm); //Append newWorm to WormPopulation
}
}
/////////////////////////////////////////////////////////////////////////////////////
//Class Primary Methods (Update)----------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////////
void update() {
for (int i=0; i<wormCount; i++) { //loop through the worms
Worm _currWorm = (Worm) wormPopulation.get(i); //Get the current worm
_currWorm.update(); //Update
}
}
}
Update