title: Error; cannot run a push matrix more than 32 times, then "target VM failed to initialize"
body: <p>I keep getting a "cannot run pushMatrix more than 32 times" in the middle of running this sketch. I'm aware that this can be an issue of having pushMatrix(); calls without a matching popMatrix(); but I don't see it in my code. Any help appreciated.</p>
  
  <p>For the record; I'm aware this code is not very pretty and could be refactored extensively. I'm still new to programming and this is just an ongoing project I've been working on since the day I started coding. </p>
  
  <p>Thanks again for any help.</p>
  
  <pre><code>float x, y, d, r, g, b, t;
  float c = random(0, mouseY+75);
  float easing = 0.03;
  int diameter= 40;
  int timer= -3000;
  int direction = 1;
  float speed = .7;
  float angle = 0.0;
  float offset;
  float scalar = 60;
  boolean button = false;
  
  void setup() {
  size(1000, 400);
  smooth();
  strokeWeight(5);
  }
  
  void draw() {
    background(204);
    int currentTime = millis();
    textSize(16);
    fill (125);
    text ("Flying Circles", 20, 20);
  
  if ((currentTime &lt; 5000) &amp;&amp; (mousePressed==false)){ 
      r = noise(frameCount * 0.01) * 255;                   //clockwise spin
      g = frameCount % 255;
      b = 255 - noise(1 + frameCount * 0.025) * 255;
      rectMode(CENTER);
      background(204);
      pushMatrix();
      translate(mouseX, mouseY);
      pushMatrix();
      rotate(-angle);
      ellipse(0,0, 150, 150);
      ellipse(0,0, 125, 125);
      rect(0,0, 80, 80);
      popMatrix();
      pushMatrix();
      rotate(angle);
      rect(0, 0, 80, 80);
      rect(0, 0, 60, 60);
      popMatrix();
      pushMatrix();
      rotate(-angle);
      fill(r,g,b);
      rect(-270, 0, 80, 80);
      rect(270, 0, 80, 80);
      rect(0, 0, 40, 40);
      angle += 0.1;
      popMatrix();
      popMatrix();
  
  }else{
         drawCounterspin();
  }
  }
  
  
  void keyPressed() {
        button = !button;
      }
  
  void drawFighter(){
      float targetX = mouseX;
      float d = random(0, 150);
      x += (targetX - x) * easing*1.5;
      fill(mouseY, mouseY/2, mouseY/3);
      ellipse(x-300, mouseY, 100, 100);
      fill(d, d*1.2, d*1.5);
      ellipse(x, mouseY, 80, 80);
      fill(mouseY, mouseY/2, mouseY/3);
      ellipse(x+300, mouseY, 100, 100);
      line(x+40, mouseY,x+250, mouseY);
      line(x-40, mouseY,x-250, mouseY);
      fill(d, d, d);
      ellipse(x, mouseY+100, 80, 80);
      fill(d, d, d);
      ellipse(x, mouseY+200, 60,60);
      line(x+30,mouseY+30, width, mouseY*2);
      line(x-30,mouseY+30, 0, mouseY*2);
  }
  
  void drawOilbounce() {
         x = width/2;
         y += speed * direction;
         if ((y &gt; height/2+diameter) || (y &lt; 0)) {
           direction = -direction;
           scalar = -scalar;
         }
         float spinspeed = speed * .1;
         float spinx = x+ cos(angle) * scalar;
         float spiny = y+ sin(angle) * scalar;
         angle += spinspeed;
         scalar += spinspeed; 
        scalar = constrain(scalar, 30, 300);
        fill(r,g,b);
        ellipse(spinx, spiny, 30, 30);
        fill(r*.95, g*.85, b*.75);
        ellipse(x, y, diameter, diameter);
        fill(r*.85, g*.75, b*.65);
        ellipse(x, y*1.2, y*.02*diameter, diameter);
        fill(r*.75, g*.65, b*.55);
        ellipse(x, y*1.5, y*.05*diameter, diameter);
      }
  
  void drawCounterspin(){
    pushMatrix();                              
    rectMode(CENTER);             
    mouseX = constrain (mouseX, 250, width-250);
    mouseY = constrain (mouseY, 48, height-48);
    fill(mouseY, 80, 100);
    if (mouseButton == LEFT) {
    translate(mouseX, mouseY);
    scale(sin(angle));
    rotate(angle);
    ellipse(0,0, 150, 150);
    ellipse(0,0, 125, 125);
    fill(mouseY, mouseX/2, mouseX);
    rect(0, 0, 80, 80);
    fill(mouseY/2, mouseX/3, mouseX);
    rect(250, 0, 80, 80);
    fill(mouseY, mouseX, mouseX/2);
    rect(-250, 0, 80, 80);
    angle += 0.05;
    popMatrix();
    }
    }
  </code></pre>