Creating a simple, interactive shuffle gallery
in
Programming Questions
•
6 months ago
Hey!
I am a very novice programmer, and am creating a simple interactive piece that allows the audience to shuffle between an array of images arranged in tiles (250x250 pixels, 4 on the top and 4 on the bottom). Each tile can only be shuffled when the cursor is hovering over its coordinates, and some tiles are only specific to certain images. This is what I have so far:
PImage[] myImageArray = new PImage[5];
void setup() {
size(1000,500);
background(10,10,10);
smooth();
}
void draw() {
for (int i=0; i < myImageArray.length; i++) {
myImageArray [0] = loadImage( "one.jpg");
myImageArray [1] = loadImage( "two.jpg");
myImageArray [2] = loadImage( "three.jpg");
myImageArray [3] = loadImage( "four.jpg");
myImageArray [4] = loadImage( "five.jpg");
}
}
void mousePressed(){
image(myImageArray[(int)random(5)],0,0);
image(myImageArray[(int)random(5)],250,0);
image(myImageArray[(int)random(5)],500,0);
image(myImageArray[(int)random(5)],750,0);
image(myImageArray[(int)random(5)],0,250);
image(myImageArray[(int)random(5)],250,250);
image(myImageArray[(int)random(5)],500,250);
image(myImageArray[(int)random(5)],750,250);
}
At this point I need to know how to shuffle a single tile inside its coordinates (as of right now wherever I click inside the sketch all tiles shuffle simultaneously).
Also...how difficult would it be to add a fade in (or out) effect after clicking?
Thanks to anyone in advance. I really appreciate the help I have received on this forum for previous projects. So thank you!
1