Chess Board: make all fields flash

Hi,
I am new in processing and I have to make my chess board flash (every field in a random color in a specific frame rate) when I press enter and make it stop flashing when I press it again. I already tried several things but I couldn’t figure out how to do this. So how does this work?

int farbe1 = 255;
int farbe2 = 0;
float feldbreite;
float feldhoehe;
float feldanzahl = 8;

void setup() {
  size(500, 500);
  feldbreite = width/feldanzahl;
  feldhoehe = height/feldanzahl;
}

void draw() {
  for ( int zeile = 0; zeile <= feldanzahl; zeile = zeile+1) {
    int farbaenderung = 1;
    if (zeile % 2 == 0 ) {
      farbaenderung = -1;
    }
    for ( int spalte = 0; spalte <= feldanzahl; spalte = spalte + 1) {
      farbaenderung = -farbaenderung;
      if (farbaenderung > 0) {
        fill(farbe1);
      } else {
        fill(farbe2);
      } 
      rect(feldbreite*zeile, feldhoehe*spalte, feldbreite, feldhoehe);
      noStroke();
    }
  }
}
1 Like

Well ok i got it now!

Glad you were able to solve your problem. What approach did you end up using?