I’m trying to have the array reset all of the numbers to random numbers when I press the ‘r’ key but it’s not working
int many=20;
int[] array = new int[many];
void setup() {
size(640, 480);
}
void draw() {
scene();
// controls();
// showAll();
reset(array, many);
show(array, many);
noLoop();
}
void reset(int[] a, int m) {
for (int i=0; i<m; i++) {
a[i] = int(random(0, 1000));
}
}
void show(int[] a, int m) {
for (int i=0; i<m; i++) {
textSize(16);
text(a[i], 75, 70+i*15);
}
}
void scene() {
background(195, 103, 207);
textSize(24);
// text( title, 275, 25);
textSize(18);
text( " Numbers ", 45, 45);
// text( " Controls ", 225, 45);
}
void keyPressed() {
if (key == 'q') exit();
if (key == 'r') reset(array, many);
}