public void update() { // Update movement m.update(); // If distance from first element if too big if (m.getPosition().dist(elements[0]) > elementChangeDist) { // Change values of all elements for (int i = elements.length - 1; i > 0; i--) { elements[i].set(elements[i - 1]); elementColors[i] = elementColors[i - 1]; } // Set position and color of first element elementColors[0] = getColor(); elements[0].set(m.getPosition()); elementChangeDist = p.random(elementMinDist, elementMaxDist); } }
public void setup() { size(WIDTH, HEIGHT, OPENGL); noStroke(); // Instantiate world // world = new SimpleWorld(); world = new IslandWorld(); world.init(this); // Instantiate worm movement IWormMovement movement = new MouseMovement(); // Mouse setup // IWormMovement movement = new SimpleNoiseMovement(); //'Random' movement // IWormMovement movement = new SinusMovement(); //Oscillating in world movement.init(this, world.getSize(), world.getCenter()); // Instantiate worm // worm = new SimpleWorm3D(); //Drawn with ellipse // worm = new StickWorm(); //Draw worm as lines worm = new TriangleWorm(); worm.init(this, movement); // Extra worms for (int i = 0; i < extraNum; i++) { // setup behavior for extra worms IWormMovement extraMovement = new SinusMovement(); // Oscillating in world extraMovement.init(this, world.getSize(), world.getCenter()); // Initiate worms extraWorms[i] = new TriangleWorm(); extraWorms[i].init(this, extraMovement); } // Setup eye for camera eyeDist += worm.getLength() * 3f; eyeZ = worm.getPosition().z - eyeDist; eye = new PVector(eyeX, eyeY, eyeZ); }
public void init(PApplet processing, IWormMovement movement) { // Get parent p = processing; // Get movement m = movement; // Setup parts for (int i = 0; i < elements.length; i++) { // Position elements[i].set(m.getPosition()); // Color elementColors[i] = getColor(); } }
public PVector getPosition() { return m.getPosition(); }