title: How to wait in p5.js
body: <p>I'm trying to create a program that does something, waits for a set amount of time does another thing, then waits again. However, what actually happens is the program waits at the beginning then does both things without any delay between them.</p>
  <pre><code>var start, current
  function setup() {
    createCanvas(500, 550);
  }
  
  function draw() {
    background(220);
    print('a');
    wait(500);
    print('b');
    wait(500);
  }
  
  function wait(time)
  {
    start = millis()
    do
    {
      current = millis();
    }
    while(current &lt; start + time)
  }
  </code></pre>