RuntimeException: Waited 5000ms - error on setup() for statement

edited January 2018 in Library Questions

Hi My code gets stuck once I add more than a number of letters to a string that setup() for function looks through.

I'm not sure how to approach it, google wasn't super useful

Error is probably happening within the "for" loop in rows 56-58

String str = "אאא";
String alphabet = "אבגדהוזחטיכךלמםנסעפצץקרשת";
int wordsNum = 2;


int t = 0;

int[] wordsLength;

float fontMultiplier = 2;

float kerning =-210;
float leading =-100;
float charLocation = 0;
float lineLocation = 0;

float fontHeight = 122*fontMultiplier;
float fontWidth = 160*fontMultiplier;

float horMargin = 100+fontWidth;
float vertMargin = 70;

Movie[] letterAsso;


import processing.video.*;
void setup() {
  size(1200, 900, P2D);

  frameRate(120);
  // finding out how many words are there    (important for the wordsLength array)

  for (int i = 0; i<str.length(); i++) {
    if (str.charAt(i)==' ') {
      wordsNum++;
    }
  }

  println("number of words is: ", wordsNum);

 int letCount = 0;

  wordsLength = new int[wordsNum];
  for (int i = 0; i<str.length(); i++) {
    if (str.charAt(i)==' '||i==str.length()-1) {
      wordsLength[t]=letCount;
      letCount=0;
      t++;
    } else {
      letCount++;
    }
  }
  println(wordsLength);

  letterAsso = new Movie[alphabet.length()];
  for (int i=0; i<alphabet.length(); i++) {                                              //inside this is probably where the error occurs
      letterAsso[i] = new Movie(this, alphabet.charAt(i)+".mov");
      letterAsso[i].loop();
      println("breakpoint"+i);
    }

  t=0;
}

void draw() {

  background(255);
  blendMode(MULTIPLY);
  charLocation = 0;
  lineLocation = 0;
  t = 0;
  for (int let = 0; let < str.length(); let++) {
    float letterxLocation = width-horMargin+charLocation-fontWidth;

    image(letterAsso[alphabet.indexOf(str.charAt(let))], letterxLocation, vertMargin+lineLocation, fontWidth*fontMultiplier, fontHeight*fontMultiplier);
    println(letterAsso[alphabet.indexOf(str.charAt(let))]);

    //for (int i=0; i<str.length(); i++) {
    //  if (str.charAt(i)!=' ') {
    //    currentLetter[i] = new Movie(this, str.charAt(i)+".mov");
    //    //currentLetter[i].frameRate(2);
    //    currentLetter[i].loop();
    //    currentLetter[i].jump(random(0, 7));
    //  } else {
    //    currentLetter[i] = new Movie(this, "space.mov");
    //  }
    //}

    // Character Location

    charLocation = charLocation - fontWidth - kerning;

    // checking if it's a new word

    if (str.charAt(let)==' ' && t < wordsNum) {

      // creatng a new line

      if (width-horMargin+charLocation-wordsLength[t+1]*(fontWidth+kerning) < horMargin) {
        charLocation = 0;
        lineLocation = lineLocation + fontHeight + leading;
      }
      t++;
    }
  }
  fill(0);
  textSize(16);
  text("Frame rate: " + int(frameRate), 10, 20);
  //saveFrame("output/framer_####.jpg");

  blendMode(BLEND);
  filter(INVERT);
}


void keyPressed(){
  if (keyCode == BACKSPACE) {
  if (str.length() > 0) {
    str = str.substring(0, str.length()-1);
  }
} else if (keyCode == DELETE) {
  str = "";
} else if (keyCode != SHIFT) {
  str = str + key;
}
}

void movieEvent(Movie m) {
  m.read();
}
Sign In or Register to comment.