Hello!
I have a question about a sketch. I am trying to draw a ellipse on a random position everytime a key is pressed in this case the key ‘a’. The situation is that it does draw the ellipse in a random position but it will draw it again in the same spot. I would like to know y i can make it draw in another spot evrytime the key ‘a’ is pressed. Here is my code:
tboolean a, q;
int x = int(random(20,2000));
int y = int(random(15, 1000));
void setup(){
size(2500, 1500);
colorMode(HSB, 360, 100,100);
background(0,0,0);
a = false;
q = false;
}
void draw(){
if(q == true){
for(int i = 0; i < 2501; i = i+250){
strokeWeight(1);
stroke(0, 0, 100, 5);
line(i, 0, i,1500 );
for(int z = 0; z <1500; z= z+150){
strokeWeight(1);
stroke(0, 0, 100, 1);
line(0, z, 2500,z );
}
}
}
if(a == true){
//int tono = int(random(299, 300));
stroke(299, 99, 99, 30);
strokeWeight(int(random(90,100)));
ellipse(x,y, 500, 500);
}
}
void keyPressed(){
if(key == 'a'){
background(0,0,0);
q = true;
a = true;
}
if(key=='q'){
background(0,0,0);
a = false;
q = true;
}
}
Thank you!