A: 

(Sorry, first post.)

Anyways, I want my program to draw a line (using my algorithm) between consecutive clicked points on the screen. The problem is: the algorithm works great for any lines with positive slopes, but not for lines with negative slopes. I can't find where I've erred in the line drawing algorithm. Either (a) no line is drawn and things pause, or (b) an innaccurate line is drawn that doesn't connect both points.

Here is the line code piece of the program, to narrow your focus:

void createLine(int x0, int y0, int x1, int y1){
  if(x1 < x0){
   createLine(x1, y1, x0, y0);      // Swap points to draw Left to Right.
    return;                              // Regions: slope > 1; 0 < slope < 1; -1 < slope < 0; slope < -1.
  }
  int dx = x1 - x0;
  int dy = y1 - y0;        
  // Handle slanted lines...
  double tempDX = x1 - x0;
  double tempDY = y1 - y0; 
  double m = (-tempDY / tempDX);      // m = line slope. 
  int deltaN = (2 * -dx);        
  int deltaNE = (2 * (-dy - dx)); 
  int deltaE = (2 * -dy);         
  int deltaSE = (2 * (dy + dx));
  int deltaS = (2 * dx);
  int x = x0; 
  int y = y0;
  int d = 0;                      
  int region = 0;                 
 if(m > 1){                       
      d = -dy - (2 * dx);         
      region = 1;
  }
  else if(m == 1)
    region = 2;
  else if(m > 0 && m < 1){
      d = (2 * -dy) - dx;         
      region = 3;
  }
  else if(m < 0 && m > -1){          
      d = (2 * dy) + dx;          
      region = 4;
  }
  else if(m == -1)
    region = 5;
  else if(m < -1){
      d = dy + (2 * dx);          
      region = 6;
  }
  while(x < x1){                    // Until points are connected...
        if(region == 1){          // If in region one...
              if(d <= 0){                // and d<=0...
              d += deltaNE;            // Add deltaNE to d, and increment x and y.
              x = x + 1; 
              y = y - 1;
            }
            else{              
              d += deltaN;        // If d > 0 -> Add deltaN, and increment y.
              y = y - 1;
            }
        }
        else if(region == 2){
             x = x + 1;
             y = y - 1; 
        }
        else if(region == 3){     
                if(d <= 0){              
              d += deltaE;
              x = x + 1; 
            }
            else{
              d += deltaNE;
              x = x + 1;
              y = y - 1;
            }
        }
        else if(region == 4){    
              if(d <= 0){              
              d += deltaSE;
              x = x + 1; 
              y = y + 1;
            }
            else{
              d += deltaE;
              x = x + 1;
            }
        }
        else if(region == 5){
             x = x + 1;
             y = y + 1; 
        }
        else if(region == 6){        
              if(d <= 0){              
              d += deltaSE;
              x = x + 1; 
              y = y + 1;
            }
            else{
              d += deltaS;
              y = y + 1;
            }
          }
        point(x, y);          
  }
  return;
}
Blanka