# Chess Board: make all fields flash

**URL:** <https://discourse.processing.org/t/chess-board-make-all-fields-flash/4943>\
**Category:** Coding Questions\
**Created:** [October 28, 2018, 10:52am UTC](https://discourse.processing.org/t/chess-board-make-all-fields-flash/4943 "2018-10-28T10:52:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hexe43](https://avatars.discourse-cdn.com/v4/letter/h/50afbb/32.png) [@hexe43](https://discourse.processing.org/u/hexe43)\
**Post date:** [October 28, 2018, 10:52am UTC](https://discourse.processing.org/t/chess-board-make-all-fields-flash/4943/1 "2018-10-28T10:52:40Z")

</div>

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?

```auto
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();
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![hexe43](https://avatars.discourse-cdn.com/v4/letter/h/50afbb/32.png) [@hexe43](https://discourse.processing.org/u/hexe43)\
**Post date:** [October 28, 2018, 11:14am UTC](https://discourse.processing.org/t/chess-board-make-all-fields-flash/4943/2 "2018-10-28T11:14:42Z")

</div>

Well ok i got it now!

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [October 31, 2018, 5:22pm UTC](https://discourse.processing.org/t/chess-board-make-all-fields-flash/4943/3 "2018-10-31T17:22:56Z")

</div>

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