Making a Random String Mouseclick
in
Programming Questions
•
1 years ago
Hello Processing Forum,
I trust you are all well.
I'm trying to make a program that displays a random image from a string with a mouse click. With a starting 'homepage' image that always loads first.
Is this possible or am I a fool?
int maxImages = 16; //total number of images
int imageIndex = 0; // Start with first image (0 not 1)
PImage b; //background
PImage[] images = new PImage [maxImages]; // The Image Array
String[] filenames = {"iBlame1.gif", "iBlame2.gif", "iBlame3.gif",
"iBlame4.gif", "iBlame5.gif", "iBlame6.gif", "iBlame7.gif", "iBlame8.gif",
"iBlame9.gif", "iBlame10.gif", "iBlame11.gif", "iBlame12.gif", "iBlame13.gif",
"iBlame14.gif", "iBlame15.gif", "iBlame16.gif"};
int index = int (random(images.length));;
void setup()
{
size(640,960);
b = loadImage("Homepage.gif");
image(b, 0, 0);
}
1