title: Processing function does nothing but freezes the program
body: <p>I'm working on a pathfinding algorithm in processing. If I don't draw a line that crosses the path between the green and the red dot, it works, but if I do, I've got a problem, that if I call a function, the program does absolutely nothing but freezes, and I have no idea why. The pixelss stores what you draw, and there are all kinds of stuff, that don't matter at this problem.
  When you paste it to processing, press ctrl+t to auto-format it so you can understand it better, but I'd bet it's a newbie issue.</p>
  <pre><code>int[][] pixelss = new int[500][500];
  void setup() {
    background(255);
    size(500, 500);}
  int[][] badcoos = new int[500][500];
  void golinego() {
    stroke(200, 200, 255);
    line(30, 30, 470, 470);
    int j = 30;
    int i = 30;
    while (dist(i, j, 470, 470) &gt; 10) {
      stroke(0, 0, 180);
      circle(i, j, 1);
      if (pixelss[i+1][j+1]==0) {
          i++;j++;}
      if (pixelss[i][j]==1) {
        if (pixelss[i][j+1]==1) {
          if (pixelss[i+1][j]==0) {
            i++;}
        } else if (pixelss[i+1][j]==1) {
          if (pixelss[i][j+1]==0) {
            j++;}
        } else {
          i-=1;
          j-=1;}}}}
  void draw() {
    stroke(0, 255, 0);
    fill(0, 255, 0);
    circle(30, 30, 10);
    stroke(255, 0, 0);
    fill(255, 0, 0);
    circle(470, 470, 10);
    if (mousePressed == true) {
      try {
        stroke(0);
        fill(0);
        circle(mouseX, mouseY, 2);
        pixelss[mouseX][mouseY] = 1;
        pixelss[mouseX+1][mouseY] = 1;
        pixelss[mouseX-1][mouseY] = 1;
        pixelss[mouseX][mouseY+1] = 1;
        pixelss[mouseX][mouseY-1] = 1;
        pixelss[mouseX+1][mouseY+1] = 1;
        pixelss[mouseX-1][mouseY+1] = 1;
        pixelss[mouseX+1][mouseY-1] = 1;
        pixelss[mouseX-1][mouseY-1] = 1;
      }catch(ArrayIndexOutOfBoundsException e) {}}}
  void keyPressed() {
    if (key=='r') {
      pixelss = new int[500][500];
      badcoos = new int[500][500];
      background(255);}
    if (key==' ') {
      golinego();}
    if (key=='d') {
      background(0);
      for (int i = 0; i &lt; 500; i++) {
        for (int j = 0; j &lt; 500; j++) {
          if (pixelss[i][j]==1) {
            stroke(255);
            circle(i, j, 1);}}}}}
  </code></pre>