I am trying to increment the framerate of my animation from 16fps to 1fps over a 4 second period of time with 4 second (4000 millis) delay in between. Is frameRate() the best way to do this? The current playback seems glitchy and inconsistent. It seems to get out sync after a while. Any ideas would be much appreciated.
PFont myFont;
String[] adjective = {"first", "second", "third"};
String[] gerund = {"first", "second", "third"};
String[] noun = {"first", "second", "third"};
int probability;
String sentence; // you don't need brackets b/c not an array
String temp1 = " ";
String temp2 = " ";
String temp3 = " ";
boolean start = true;
int framerate = 16;
void setup() {
size(displayWidth, displayHeight);
myFont = loadFont("Courier-Bold-66.vlw");
textAlign(CENTER);
frameRate(framerate);
}
void draw() {
background(255);
fill(0);
textFont(myFont);
int timer = second();
if (start == true) {
temp1 = adjective[int(random(0, adjective.length))];
temp2 = gerund[int(random(0, gerund.length))];
temp3 = noun[int(random(0, noun.length))];
start = false;
}
if (timer % 8 == 0) {
delay(4000);
probability = int(random(0, 3));
}
if (timer % 8 > 4) {
if (timer % 8 == 5) {
frameRate(framerate/2);
}
if (timer % 8 == 6) {
frameRate(framerate/4);
}
if (timer % 8 == 7) {
frameRate(framerate/framerate);
}
} else {
frameRate(framerate);
}
if (probability == 0) {
temp1 = adjective[int(random(0, adjective.length))];
}
if (probability == 1) {
temp2 = gerund[int(random(0, gerund.length))];
}
if (probability == 2) {
temp3 = noun[int(random(0, noun.length))];
}
text(temp1, width/2, height/2-66);
text(temp2, width/2, height/2);
text(temp3, width/2, height/2+66);
}