Random Images loop

Hi,

First you should format your code using the </> icon on the editing window.
You can edit your post with the little pen icon in order to correct the formating.

For your questions I don’t really have time to go into details so I’ll just give you leads:
1- For the randomness (is that a word ?) you want to use an array of images.

PImage myArrayOfImage[] = new PImage[5];

Then you can use the random function to get a random image.

myArrayOfImage[(int)random(0, 5)];

2- You don’t want to load your image in draw. It’s a real performance issue. What you want to do is to load them in setup and then use them in draw. No need to fetch them 60 times a second.

3- For the delay, there are plenty of discussion on the forum. The basic idea is to use the millis() function: https://processing.org/reference/millis_.html

1 Like