title: Checking for click not working - java
body: <p>I'm developing a game about where you have to match pairs in a grid of blocks.Right now I'm just testing the click,so when you click the block turns blue. I made a thing where you can click once and click again, and both of them will stay. However, it only works when you click the second time to the left of where you clicked before. I'm thinking it has something to do with how I checked for a click and where. I drew the blocks from upper left down, so the blocks on the left are less in the number in the array. And the 'if statement' only has greater checks, so maybe there's something there??  Here's my code:</p>
  
  <pre><code>for(int i = 0; i &lt; 100; i++) {
  
          Tiles rect = squares.get(i);
  
          // x of the rect    // on the clicked
          if(rect.getTileX() + squareWidth &gt; mouseX &amp;&amp; rect.getTileY() + squareHeight &gt; mouseY &amp;&amp; rect.getTileX() + squareWidth * 2 &gt; mouseX + squareWidth) {
  
              if(clickNumber == 1) {
  
                  if(change1pressed == false) {
  
                      changeColor1 = i;
  
                      System.out.println("1 - 1: " + changeColor1);
                      System.out.println("2 - 1: " + changeColor2);
  
                      change1pressed = true;
  
                  }
  
              }
  
              if(clickNumber == 2) {
  
                  if(change2pressed == false) {
  
                      changeColor2 = i;
  
                      System.out.println("1 - 2: " + changeColor1);
                      System.out.println("2 - 2: " + changeColor2);
  
                      change2pressed = true;
  
                  }
  
              }
  
              squares.get(changeColor1).tileColor = Color.BLUE;
              squares.get(changeColor2).tileColor = Color.BLUE;
  
          }
  
          g.setColor(squares.get(i).getColor());
  
          g.fillRect(rect.getTileX(), rect.getTileY(), rect.getTileWidth(), rect.getTileHeight());
  
      }
  </code></pre>