Unclick and it goes back as it started -- a beginner needs help

I´ve literally been an hour into Processing and I´ve made this

void setup(){
  size(500,400);
background(#FA9E8D);}
void draw(){
  stroke(#FAD5BD);
fill(#FAD5BD);
ellipse(250, 200, 350, 350);
stroke(#FA5D5D);
fill(#FA5D5D);
rect(170, 250, 180, 20);
stroke(#5A100E);
fill(#5A100E);
ellipse(180, 130, 120, 120);
ellipse(320, 130, 120, 120);
if(mousePressed){
  background(#F559E3);
stroke(#4DEAF7);
fill(#4DEAF7);
ellipse(250, 200, 350, 350);
stroke(#AD77FA);
fill(#AD77FA);
rect(150, 200, 180, 100);
stroke(#95FA77);
fill(#95FA77);
ellipse(150, 100, 120, 120);
ellipse(300, 100, 120, 120);
  stroke(#FFFFFF);
fill(#FFFFFF);
rect(150, 200, 30, 30);
rect(200, 200, 30, 30);
rect(250, 200, 30, 30);
rect(300, 200, 30, 30);
rect(150, 270, 30, 30);
rect(200, 270, 30, 30);
rect(250, 270, 30, 30);
rect(300, 270, 30, 30);
ellipse(150, 100, 60, 60);
ellipse(300, 100, 60, 60);
}
}

the thing is, when you click, it´s all good, but I don´t know how to quit the remaining part of the green circle and also to go back to the peachy background, like, click it and the other face shows up, unclick and it goes back as it started, but I don´t know what do I have to change

2 Likes

if you move that from setup to ( first line in ) draw it might look like you wanted?

but pls. take some comments to your first post here:
-a- posting code:
you edit your code in processing IDE ( now ver. 3.5.3 )
and press [ctrl][t] to format it there ( and pls. save it )

you edit above post here at the forum and delete that code part.

now press

</> code format

and paste your code inside

-b- to understand / test / and discuss code here it does not need
– 100 circles / rectangles
– big formats like canvas(5000,5000) or fullscreen

something small but pointing out the program flow
and indicating where the errors might be.


for you program flow i would say you take also a look at

so idea is to have that outside of draw()…
set some variables ( in case of click )
and use that variables in draw()

boolean mousetoggle = false;
void setup(){}
void draw() {
 if ( mousetoggle ) {
   background(200,200,0);
 } else {
   background( 0,0,80);
 }
}

void mousePressed() {
  mousetoggle = ! mousetoggle;
}

play with it

3 Likes

Hey, @dianap it is nice that you shared your problem. But help us to help you, write your code inside </> tag.

2 Likes

wow, thank you so much for your help!

2 Likes