Need help merging several sketches

Hello everyone, for a school project I am working on interactive visuals with the kinect. I have 3 processing sketches which I want to merge into one, so the visuals loop over into each other. However I am at a loss on how to do this. I have tried turning them into functions and play them in draw() but then nothing happens when playing the sketch. Im a beginner and all these sketches and the average point tracking were made using tutorials.

What I want to make is that the visuals loop over into another one after 20 seconds or so. Any help would be appreciated.

Since it is quite a lot of code I have uploaded my PDE files here:

The files uploaded with kinect in the filename have the kinect + point tracking code in them, the last 3 work on mouse tracking.

Thanks in advance :tada:

I think that’s similar but he has problems:

See Load a different background sketch and automatically change each 30 seconds

In general from draw() call new functions draw1, draw2 and draw3 depending on sketchNumber, a new variable you have to declare globally.

In draw1 / draw2/ draw3 copy your draw function from the old sketches

Increase sketchNumber when frameCount%10*frameRate==0

Hi, thanks for your reply! I managed to get it work yesterday evening luckily. It now changes on the amount of frames gone by, but changing it to seconds will probably work a bit better. Thanks for the reply to the right thread!

If anyone finds this thread in the future, this is the code I used;

void draw () {
  if (frameCount < 10 * frameRate) {
    drawSquare();
  } else if (frameCount < 20 * frameRate) {
    drawCircle();
  } else if (frameCount < 30 * frameRate) {
    drawEllipse();
  }
}

make sure all your code in the void functioncalls is working. change the numbers depending on how long you want them to last.

1 Like

Yeah, we could also make a timer using millis() etc.

Not sure whether your code works more than one cycle?

It doesn’t, but I am not too worried about that. Would it work in more than one cycle with millis()?

1 Like

Yes.

OR when you use my advice above

with

switch(sketchNumber) {
case 0:
draw1();
break;

case 1:

}

1 Like

Ah thats great! Ill try that out then as well. Thank you :slight_smile:

1 Like