Random number grid, loops needed!
in
Programming Questions
•
2 years ago
Hi everyone, I created a simple program to generate a grid showing a random number and the eight consecutive numbers.
Heres my code so far;
int RandomNum = 1;
void setup(){
size(270, 270);
PFont font;
font = loadFont("Arial-Black-32.vlw");
textFont(font);
noLoop();
}
void draw() {
fill(0, 255, 6);
rect(0, 0, 90, 90);
fill(0);
text(RandomNum++, 32, 60);
fill(255, 255, 0);
rect(90, 0, 90, 90);
fill(0);
text(RandomNum++, 122, 60);
fill(0, 255, 6);
rect(180, 0, 90, 90);
fill(0);
text(RandomNum++, 212, 60);
fill(255, 255, 0);
rect(0, 90, 90, 90);
fill(0);
text(RandomNum++, 32, 150);
fill(0, 255, 6);
rect(90, 90, 90, 90);
fill(0);
text(RandomNum++, 122, 150);
fill(255, 255, 0);
rect(180, 90, 90, 90);
fill(0);
text(RandomNum++, 212, 150);
fill(0, 255, 6);
rect(0, 180, 90, 90);
fill(0);
text(RandomNum++, 32, 240);
fill(255, 255, 0);
rect(90, 180, 90, 90);
fill(0);
text(RandomNum++, 122, 240);
fill(0, 255, 6);
rect(180, 180, 90, 90);
fill(0);
text(RandomNum++, 212, 240);
}
void mousePressed() {
RandomNum = int(random(1,91));
redraw();
}
1