Why does my program not flash an ellipse once a second?

edited November 2015 in Questions about Code

Hi! With my beginner's understanding of things, below code should loop once a second, showing/not showing a circle. Result is not like that though, looks like it's looping very quickly....

int state=0;

void setup()

{

size (200, 200);

background (0);

frameRate=1; //1 second loop

}

void draw()

{

if (state==0) 

{

  state=1;              //toggle state

  background (0);   //clear screen

  fill (255);             //ellipse visible

  ellipse (100, 100, 10, 10);  //draw it

}

else

{

  state=0;               //toggle state

  background (0);   //clear screen

  fill (0);                  //ellipse invisible

  ellipse (100, 100, 10, 10);  //draw it

}

}

Thanks for looking! Ste.

Tagged:
Sign In or Register to comment.