// The Flock (a list of Boid objects) But now with gremlins. class Basement { ArrayList gremlins; // An arraylist for all the gremlins Basement() { gremlins = new ArrayList(); // Initialize the arraylist } void run() { for (int i = 0; i < gremlins.size(); i++) { Gremlin g = (Gremlin) gremlins.get(i); g.run(gremlins); // Passing the entire list of gremlins to each gremlin individually } } void clear() { gremlins.clear(); } void update(){ for (int i = 0; i < gremlins.size(); i++) { Gremlin g = (Gremlin) gremlins.get(i); g.update(); // updatethebeezies. } } void render(){ for (int i = 0; i < gremlins.size(); i++) { Gremlin g = (Gremlin) gremlins.get(i); g.render(); // drawthebeezies. } } void addGremlin(Gremlin g) { gremlins.add(g); } void removeGremlin(Gremlin g){ gremlins.remove(g); g = null; } void clean(){ for (int i = 0; i < gremlins.size(); i++) { Gremlin g = (Gremlin) gremlins.get(i); g.clean(gremlins); // every once and a while combine like gremlins } } int getCount() { return gremlins.size(); } double getTimeAvg(float bandcentery, float bandwidth) { double timeavg = 0; int hits = 0; for (int i = 0; i < gremlins.size(); i++) { Gremlin g = (Gremlin) gremlins.get(i); float locy = g.getLoc().y; if ( (locy <= bandcentery + ( bandwidth / 2)) && (locy >= bandcentery - ( bandwidth / 2)) ) { timeavg += g.getTime(); hits++; } } if (hits != 0) { timeavg = timeavg/hits; return timeavg; } else { return 0; } } float getDeweyAvg(float bandcenterx, float bandwidth) { float deweyavg = 0; int hits = 0; for (int i = 0; i < gremlins.size(); i++) { Gremlin g = (Gremlin) gremlins.get(i); float locx = g.getLoc().x; if ( (locx <= bandcenterx + ( bandwidth / 2)) && (locx >= bandcenterx - ( bandwidth / 2)) ) { deweyavg += g.getDewey(); hits++; } } if (hits != 0) { deweyavg = deweyavg/hits; return deweyavg; } else { return 0; } } }