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 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(); }