Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Confluence
For you

Programming
Results will update as you type.
  • Tiling and Repetition
  • Reactors
  • Programming Basics: Parametric and Generative Graphic Design 2016
  • Archive
    • End Exercise 2014
    • End Exercise 2015
      • Set max length of Racer trail
    • Ext. Lektion 1 (Force Fields)
    • Ext.Lektionen 2 (Rekursive Funktionen / Fraktale)
    • How Computers Think
    • End Exercise 2016 - Asteroids
  • High Scores
  • Artificial Neural Network
  • Alternatives to the Processing IDE
  • p5.js Programming
  • Programming in Processing (java)

/
Set max length of Racer trail

Set max length of Racer trail

Nov 11, 2015

The following method can be used to set the maximum length of the Racer trail. Simply modify the age() method to check both the length of the line using the method below.

float calculateLength() {
  float _length = 0;
  PVector p1 = posList.get(0);
   
    for (int i=1; i < posList.size(); i++)
    {
     PVector p2 = posList.get(i);
      if (p1 != null && p2 != null)
         _length += dist(p1.x, p1.y, p2.x, p2.y);
      p1 = p2;
    }
    _length += dist( p1.x,  p1.y, curPos.x, curPos.y);
  return _length;
};
, multiple selections available,
{"serverDuration": 40, "requestCorrelationId": "6dbf0fe40c6340a0877335d472835a73"}