Expecting EOF, found if. idk how to fix it

void setup(){
  size(2000,2000);
  background(0);
}
void keyPressed() {

//1st planet
  if (key == 'b' || key == 'B') {
  if (keyPressed)
      stroke(0);
      fill(0);
    }
   else {
    stroke(#18B733);
    fill(#18B733);
  }
  ellipse(200, 200,200,200);
}
     
  if(key == 'b' || key == 'B') {
  if (keyPressed)
      stroke(0);
      fill(0);
    }
   else {
    stroke(#FF002F);
    fill(#FF002F);
  }
  ellipse(150, 150,150,150);
}
1 Like

with ctrl-t you can get auto-indent

then you see, where the error is

You had one } too much

I marked it here for you:

void setup() {
  size(2000, 2000);
  background(0);
}
void keyPressed() {

  //1st planet
  if (key == 'b' || key == 'B') {
    if (keyPressed)
      stroke(0);
    fill(0);
  } else {
    stroke(#18B733);
    fill(#18B733);
  }
  ellipse(200, 200, 200, 200);
} // !!!!!!!!!!!!! delete this 

if (key == 'b' || key == 'B') {
  if (keyPressed)
    stroke(0);
  fill(0);
} else {
  stroke(#FF002F);
  fill(#FF002F);
}
ellipse(150, 150, 150, 150);
}
3 Likes