I’m starting to make the game “Simon says” and I do not know how to start generating the “guessList”, that the random colors come out so that the user can then repeat the sequence, how do I continue? for the moment I have done this:
class Quadrant{
void darkQuadrant(){
//quadrant1
fill(100,0,0);
rect(0, 0, width/2, height/2);
//quadrant2
fill(0,0,100);
rect(width/2, 0, width/2, height/2);
//quadrant3
fill(0,100,0);
rect(0, height/2, width/2, height/2);
//quadrant4
fill(100,100,0);
rect(width/2, height/2, width/2, height/2);
}
/ *********************** AUXILIARY FUNCTIONS ******************* ******* /
// We define the quadrant 1 as a function not to repeat
void c1() {
fill(255,0,0);
rect(0, 0, width/2, height/2);
}
// We define the quadrant 2 as a function not to repeat
void c2() {
fill(0,0,255);
rect(width/2, 0, width/2, height/2);
}
// We define the quadrant 3 as a function not to repeat
void c3() {
fill(0,255,0);
rect(0, height/2, width/2, height/2);
}
// We define the quadrant 4 as a function not to repeat
void c4() {
fill(255,255,0);
rect(width/2, height/2, width/2, height/2);
}
}
class List{
int[] guessList={};
int[] userTest={};
int[] showSequence={};
void generateVector(){
guessList=append(guessList, int(random(1, 4)));
}
void mousePressed(){
if (mousePressed) {
if (mouseX < width/2 && mouseY < height/2) {
quadrant.c1();
userTest=append(userTest,1);
} else if(mouseX > width/2 && mouseY < height/2) {
quadrant.c2();
userTest=append(userTest,2);
} else if(mouseX < width/2 && mouseY > height/2) {
quadrant.c3();
userTest=append(userTest,3);
} else if(mouseX > width/2 && mouseY > height/2) {
quadrant.c4();
userTest=append(userTest,4);
}
}
}
}
Quadrant quadrant=new Quadrant();
List list=new List();
void setup(){
size(600,600);
}
void draw(){
background(0);
quadrant.darkQuadrant();
list.generateVector();
list.mousePressed();
}