title: Button not working on a sine wave project in processing
body: <p>I'm creating a sine wave and I want the amplitude and frequency to be adjustable by mouse, so I made a button that turns this on and off. It doesn't seem to be working. The <code>//Button Script</code> part is where the button is defined, and it should work but when I click in the box while running it, it doesn't do anything, even though I have fulfilled all the conditions in the <code>if</code>.</p>
  
  <p>
      void setup() {
          size(1600,900);
      }</p>
  
  <pre class="lang-java prettyprint-override"><code>//Define variables.
  float amp = 0.0;
  float freq = 0;
  int totalwavelength = 50;
  int mouse = 0;
  
  
  void draw(){
      background(0);
      freq = 0;
  
      while (freq &lt; totalwavelength) {
          //When button is not pressed, run this script:
          if (mouse == 0) {
              fill(255);
              ellipse(freq * 50 + 20, sin(amp) * 100 + 450, 20, 20); 
              freq += 1;
              amp += 0.5;
  
              //Create Button
              fill(255);
              rect(800, 800, 200, 100);
  
              //Mouse Coordinates
              fill(255, 0, 0);
              text("X=" + mouseX, mouseX, mouseY - 10);
              text("Y=" + mouseY, mouseX, mouseY);
  
              //Button script
              if (mouseX &gt;700 &amp;&amp; mouseX &lt; 900 &amp;&amp; mouseY &gt;750 &amp;&amp; mouseY &lt; 850 &amp;&amp; mousePressed == true &amp;&amp; mouse == 0) {
                  mouse = 1;
              } 
  
              if (mouseX &gt;700 &amp;&amp; mouseX &lt; 900 &amp;&amp; mouseY &gt;750 &amp;&amp; mouseY &lt; 850 &amp;&amp; mousePressed == true &amp;&amp; mouse == 1) {
                  mouse = 0;
              } 
          }
  
  
          //When button pressed run this script:
          if (mouse == 1) {
              fill(255);
              ellipse(freq * 50 + 20, sin(amp) * 100 + 450, 20, 20); 
              freq += mouseX;
              amp += mouseY;
  
              //Create Button
              fill(255);
              rect(800, 800, 200, 100);
  
              //Button script
              if (mouseX &gt;700 &amp;&amp; mouseX &lt; 900 &amp;&amp; mouseY &gt;750 &amp;&amp; mouseY &lt; 850 &amp;&amp; 
         mousePressed == true &amp;&amp; mouse == 0) {
                  mouse = 1;
              } 
  
              if (mouseX &gt;700 &amp;&amp; mouseX &lt; 900 &amp;&amp; mouseY &gt;750 &amp;&amp; mouseY &lt; 850 &amp;&amp; 
                  mousePressed == true &amp;&amp; mouse == 1){
                  mouse = 0;
              } 
  
          }
      }
  }
  </code></pre>