Created
August 13, 2013 16:55
-
-
Save antonijn/6223209 to your computer and use it in GitHub Desktop.
AreWallsBlockingSight 7DFPS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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