# Help: Loop/While with millis

**URL:** <https://discourse.processing.org/t/help-loop-while-with-millis/41433>\
**Category:** Coding Questions\
**Created:** [March 24, 2023, 5:31pm UTC](https://discourse.processing.org/t/help-loop-while-with-millis/41433 "2023-03-24T17:31:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xnainie](https://avatars.discourse-cdn.com/v4/letter/x/3be4f8/32.png) [@xnainie](https://discourse.processing.org/u/xnainie)\
**Post date:** [March 24, 2023, 5:31pm UTC](https://discourse.processing.org/t/help-loop-while-with-millis/41433/1 "2023-03-24T17:31:19Z")

</div>

Hi, i want to make an disco room and it has too keep chaning in the meanwhile you are there. i have it with millis but then i have to make a lot of codes

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 24, 2023, 5:35pm UTC](https://discourse.processing.org/t/help-loop-while-with-millis/41433/2 "2023-03-24T17:35:08Z")

</div>

millis() is not complicated

Alternatively you can say frameRate(3); for example

---

<div class="post-metadata">

**Author:** ![xnainie](https://avatars.discourse-cdn.com/v4/letter/x/3be4f8/32.png) [@xnainie](https://discourse.processing.org/u/xnainie)\
**Post date:** [March 24, 2023, 5:52pm UTC](https://discourse.processing.org/t/help-loop-while-with-millis/41433/3 "2023-03-24T17:52:38Z")

</div>

```auto
int scene = 0;

//-------------------------------------------------------------------------

void setup() {

  size(1500, 900);//frame maat

  frameRate(30);
}

//---------------------------------------------------------------------------

void draw() {
  if (scene == 0) {
    tekenScene0();
  }
  if (scene == 1) {
    tekenScene1();
  }
}

void tekenScene0() {
  background(#EAD895); //is de muur
  fill(#E8E7E5); //kleur van de vloer
  noStroke(); //omleining van de vloer is weg
  quad(730, 546, 1503, 546, 1500, 900, 0, 900); //vorm van de vloer

  strokeWeight(1);
  stroke(#0300F2);
  line(732, 0, 730, 546);

  if (millis() > 0000) {
    fill(#c6a902, 60); //kleur raam (geel, disco)
  }
  if (millis() > 2000) {
    fill(#4deeea, 60); //kleur raam (blauw, disco)
  }
  if (millis() > 3000) {
    fill(#74ee15, 60); //kleur raam (groen, disco)
  }
  if (millis() > 4000) {
    fill(240, 0, 255, 60); //kleur raam (roze, disco)
  }
  if (millis() > 5000) {
    fill(0, 30, 255, 60); //kleur raam (paars, disco)
  }
  noStroke();
  square(0, 0, 1500);
}

void tekenScene1() {
  background(#030303);
  background(#4DBCFF); //is de muur
  fill(#E8E7E5); //kleur van de vloer
  noStroke(); //omleining van de vloer is weg
  quad(730, 546, 1503, 546, 1500, 900, 0, 900); //vorm van de vloer

  //sttoel links
  fill(#706f6f);
  quad(472, 568, 472, 707, 642, 707, 642, 568);
  fill(#575756);
  quad(420, 508, 420, 673, 486, 673, 481, 499);
  fill(#3c3c3b);
  quad(420, 590, 420, 729, 629, 729, 629, 590);

  //open haard
  fill(#3c3c3b);
  quad(917, 323, 917, 546, 1267, 546, 1267, 323);
  fill(#000000);
  rect(989, 402, 200, 130);

  //muurschilderijen
  fill(#AFAFAD);
  strokeWeight(3);
  stroke(#0300F2);
  ellipse(933, 118, 56, 123);
  fill(#08FFEC, 40);
  ellipse(1011, 84, 81, 54);
  fill(#08FF89, 40);
  ellipse(1011, 152, 81, 54);
  fill(#4808FF, 40);
  ellipse(1125, 119, 108, 108);
  fill(#FF08E3, 40);
  ellipse(1235, 118, 69, 123);

  //vloerkleed
  noStroke();
  fill(#366A66);
  ellipse(1020, 707, 608, 224);

  strokeWeight(1);
  stroke(#0300F2);
  line(732, 0, 730, 546);
}

//----------------------------------------------------------------------------------------------

void mousePressed() {
  // scene 0 -> 1
  if (mouseX > 285 && mouseX < (285+79) && mouseY > 520 && mouseY < (520+79) && scene == 0) {
    scene++;
  }
  if (scene>1) {
    scene=0;
  }

  // scene 0 -> 3
  if (mouseX > 110 && mouseX < (110+79) && mouseY > 327 && mouseY < (327+79) && scene == 0) {
    scene++;
  }
  if (scene>3) {
    scene=0;
  }

  //scene 1 -> 2
  if (mouseX > 35 && mouseX < (35+155) && mouseY > 715 && mouseY < (715+155) && scene == 1) {
    scene++;
  }
  if (scene>2) {
    scene=1;
  }
}

i got this but i dont get i really..

```
