title: Why does this Java grid not function correctly?
body: <p>I am trying to make a grid (with minimal code) that blocks can snap to. What I want is when the mouse is in the grid square, the block moves to that square. What I have written essentially says that if the X or Y are beyond the grid block times the size of the block, move to the next grid block. Currently, this code creates a 3x3 grid, though the code SHOULD generate infinite gridspaces. I cannot move the block outside of this 3x3 grid.</p>
  
  <pre><code>public class Player extends Entity {
  public Player(double entSize, boolean collideA, boolean collideB, double x, double y) {
      super(entSize, collideA, collideB, x, y);
  }
  public void init() {
      Texture texFile = loadTexture("stone");
      texture(false, true);
      texFile.bind();
      render();
  }
  void input() {
      int gridPosX = 1;
      int gridPosY = 1;
          if(getX() &gt; gridPosX*entSize) {
              gridPosX += 1;
          } if(getX() &lt; gridPosX*entSize) {
              gridPosX -= 1;
          } if(getY() &gt; gridPosY*entSize) {
              gridPosY += 1;
          } if(getY() &lt; gridPosY*entSize) {
              gridPosY -= 1;
          }
          this.x = gridPosX*entSize;
          this.y = gridPosY*entSize;
  }
  </code></pre>
  
  <p>}
  The X and Y values are what define the blocks position and shape parameters.</p>