Problems with random image displaying

hello processing community, i'm new to programming(processing is the first thing i've tried). and I was having some problems with my code. I'm trying to make my background change every few seconds for a brief amount of time, but it just won't work, can you help me out? Thanks in advance :)

PImage bg;
PImage bg2;

void setup() {
framerate(10);
size(720, 720);
bg = loadImage("bg.jpg");
bg2 = loadImage("bg22.jpg");
}
void draw() {
background(bg);
float X = random(60);
if(X == 1) {
background(bg2);
}
}

Tagged:

Answers

Sign In or Register to comment.