jeudi 21 mars 2019

Random number generator with boolean & array

I'm trying to create a generator that prints 1 to 4 from an array as well as a corresponding background color. How do I phrase it so that a specific number is tied to a color?

Here is just the number gen setup so far:

void setup() {

size(500, 500);

}

void draw() {

background(100);

int myArray[] = {1, 2, 3, 4};

int rand = (int)random(myArray.length);

println(myArray[rand]);

}

Thanks!




Aucun commentaire:

Enregistrer un commentaire