Hi,
I have a tile map filled with 2 types of tiles walkable (0) and nonwalkable (1)... Now I have 2 points on my map, player and the exit and I need to know if they can see each other or if there is a nonwalkable tile in between them.
all I could manage to do is compute the distance between the points like this:
distance = sqrt(
(currentLevel.getExitX() - player.getX()) * (currentLevel.getExitX() - player.getX()) +
(currentLevel.getExitY() - player.getY()) * (currentLevel.getExitY() - player.getY())
);
but from this point I am kind of clueless what to do next... how do I check all the tiles that this line is crossing if they are 1 or 0?
Ideally I would make a class which I could use like checkPoints(x1, y1, x2, y2) which will return either true or false based on if there is a non walkable tile between these 2 points... so I can use it like if( checkPoints(x1, x2, y1, y2) == true ) { do something } else { do something else }
any ideas how could I do this?