Skip to content

Instantly share code, notes, and snippets.

@antonijn
Created August 13, 2013 16:55
Show Gist options
  • Save antonijn/6223209 to your computer and use it in GitHub Desktop.
Save antonijn/6223209 to your computer and use it in GitHub Desktop.
AreWallsBlockingSight 7DFPS
private bool AreWallsBlockingSight(MainClass game, float playerDiffX, float playerDiffZ) {
Vector2 vec = new Vector2(playerDiffX, playerDiffZ);
vec.Normalize();
vec /= 100f;
playerDiffX = vec.X;
playerDiffZ = vec.Y;
float x = 0;
float z = 0;
while (x * x + z * z < MainClass.WallsDisappearAt) {
float xAbs = x + X;
float zAbs = z + Z;
int xWall = (int)xAbs;
int zWall = (int)zAbs;
if (game.BlockGrid [xWall, zWall] != null) {
return true;
}
x += playerDiffX;
z += playerDiffZ;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment