public static boolean CanSeeTarget(int x, int y, int z,int tx, int ty, int tz) { final double dx = (tx - x); //dystans x final double dy = (ty - y); //dystans y double distance = Math.sqrt(dx*dx + dy*dy); double sin = dy/distance; double cos = dx/distance; double poprzedni_x = x; double poprzedni_y = y; int kierunek = //obliczyc - to ma byc zwykly kat while (Math.round(x) != tx || Math.round(y) != ty) { if ((int)poprzedni_x != (int)x && (int)poprzedni_y != (int)y) { //przeskok po ukosie if (!NSWE(x,y,z, kierunek-5) || !NSWE(x,y,z, kierunek+5))//obchodzimy jednym lub drugim bokiem { //nie ma mozliwosci przejsc przez ta kratke return false; } System.out.print("\n Ukos!"); } else if (!NSWE(x,y,z, kierunek)) { return false; } poprzedni_x = x; poprzedni_y = y; x += cos; y += sin; System.out.print("\nX: " +Math.round(x)+ " Y: "+Math.round(y)); } return true; }