public double[] moveTo(GameObject other, double[] move) { GameObject g1 = this; GameObject g2 = other; GameShape s1 = g1.getShape(); GameShape s2 = g2.getShape(); double[] offset = new double[2]; offset[0] = g2.getCenter()[0] - g1.getCenter()[0]; offset[1] = g2.getCenter()[1] - g1.getCenter()[1]; // calculate the maximum allowable move double[] result = s1.moveTo(s2, offset, move); // figure out whether this is the same move or an altered one if (move[0] == result[0] && move[1] == result[1]) { return(move); } return(result); }