I am making a roguelike game and I'm trying to implement the "Quick and Dirty" FOV technique into my game, but I'm having some issues. I'm almost certain it's in my function where the line calculation is done in which I have a x and y variable move along an angle between 2 points (the tile I'm checking and the player).
If you don't know what the "quick and dirty" FOV is, here is the link http://www.roguebasin.com/index.php?title=Quick_and_dirty_FOV/LOS
Code
public static boolean lineOfSight( int xx, int yy, int xx2, int yy2) {
float deltaX = xx - xx2;
float deltaY = yy - yy2;
float angle = (float) Math.atan2(deltaY,deltaX);
int distance = distanceCheck(player.x,player.y,xx2,yy2);
int counter = 0;
while(counter < distance) {
counter ++;
xx += (int) (Math.sin(angle));
yy += (int) (Math.cos(angle));
if(map[xx][yy] == 1) {
return false;
}
}
return true;
}