// (c) Alex McLean 2005 // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. class Environment { LinkedList things = new LinkedList(); int maxx, maxy; Envelope[] envelopes; public Environment(int maxx, int maxy) { this.maxx = maxx; this.maxy = maxy; size(maxx, maxy, P3D); background(0); initEnvelopes(); } void initEnvelopes() { envelopes = new Envelope[10]; // percussive float[] percussive = {0, 1, 0.4, 0.3, 0.35, 0.3, 0.2, 0.1, 0.1, 0}; envelopes[0] = new Envelope(percussive); } public void addThing(float x, float y, float speed, float direction, float volume, float width, float length, int reverb, float curve, String imageFn) { x *= maxx; y *= maxy; Thing thing = new Thing(x, y, speed, direction, volume, width, length, reverb, curve, envelopes[0], imageFn); things.add(thing); } public void tick() { Iterator iterator = things.iterator(); for (int i = 0; i < things.size();) { Thing thing = (Thing) things.get(i); thing.tick(); if (thing.isExpired()) { kill(thing); } else { ++i; } } } public void draw() { for(int i = 0; i < things.size(); ++i) { Thing thing = (Thing) things.get(i); thing.draw(); } } public boolean kill(Thing thing) { return(things.remove((Object) thing)); } }