Solving an exercise in Dan Shiffman "Learning Processing"

Hey there, You got your mousePressed as a void statement, but it is inside the draw() function. Take it out of the draw(), and it should work:

boolean moving = true;

int circleX = 0;
int circleY = 100;

void setup() {
  size(200, 200);
}
void draw() {
  background(100);
  stroke(255);
  fill(0);
  ellipse(circleX, circleY, 50, 50);

  if (moving) {
    circleX = circleX+1;
  }
}

void mousePressed() {
  moving = !moving;
}
1 Like