Hello! I have 20 pictures and I would like to randomly place 2 at a time on the screen next to each other. (possibly using a mouse click to change the pictures). Is it possible to randomly place two pictures next to each other? I have read another similar forum and it has helped me to get this far.
---Aside note: My pictures are 300x450 so I set my stage to 600x450 to allow for two pictures. Is this correct?
PImage[] myImageArray = new PImage[22];
void setup() {
size(600,450);
background(10,10,10);
smooth();
}
void draw() {
imageMode (CENTER);
for (int i=0; i < myImageArray.length; i++) {
myImageArray [0] = loadImage( "boat.jpg");
myImageArray [1] = loadImage( "boy.jpg");
myImageArray [2] = loadImage( "chicken.jpg");
myImageArray [3] = loadImage( "cross.jpg");
myImageArray [4] = loadImage( "dierks.jpg");
myImageArray [4] = loadImage( "drink.jpg");
myImageArray [5] = loadImage( "eye.jpg");
myImageArray [6] = loadImage( "fish.jpg");
myImageArray [7] = loadImage( "flag.jpg");
myImageArray [8] = loadImage( "food.jpg");
myImageArray [9] = loadImage( "girl.jpg");
myImageArray [10] = loadImage( "golf.jpg");
myImageArray [11] = loadImage( "hawaii.jpg");
myImageArray [12] = loadImage( "hole.jpg");
myImageArray [13] = loadImage( "mail.jpg");
myImageArray [14] = loadImage( "mexico.jpg");
myImageArray [15] = loadImage( "pole.jpg");
myImageArray [16] = loadImage( "rose.jpg");
myImageArray [17] = loadImage( "sign.jpg");
myImageArray [18] = loadImage( "surf.jpg");
myImageArray [19] = loadImage( "underside.jpg");
myImageArray [20] = loadImage( "weeds.jpg");
}
}
void mousePressed(){
image(myImageArray[(int)random(20)],width/4,height/2);
image(myImageArray[(int)random(20)],width-width/4,height/2);
}
-When I run it I just get a black screen with no errors. Is something in this wrong?
Thank You!!!
1