From 1ff503471302cc484083a9b22b971979666182aa Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Sat, 15 Feb 2020 20:57:10 +0000 Subject: [PATCH] --- Code-Snippets.md | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/Code-Snippets.md b/Code-Snippets.md index 21e81f7..39b1cf2 100644 --- a/Code-Snippets.md +++ b/Code-Snippets.md @@ -1,13 +1,21 @@ ```csharp - public static class Geometry { - public static bool PointInCone( - float visionRangeSq, float fovCos, Vector2 eyePos, Vector2 direction, Vector2 test) { - Vector2 delta = Vector2.Subtract(test, eyePos); - if (delta.LengthSquared() > visionRangeSq) { - return false; - } - float dot = Vector2.Dot(Vector2.Normalize(direction), Vector2.Normalize(delta)); - return dot > fovCos; +public static class Geometry { + public static bool PointInCone( + float visionRangeSq, float fovCos, Vector2 eyePos, Vector2 direction, Vector2 test) { + Vector2 delta = Vector2.Subtract(test, eyePos); + if (delta.LengthSquared() > visionRangeSq) { + return false; } + float dot = Vector2.Dot(Vector2.Normalize(direction), Vector2.Normalize(delta)); + return dot > fovCos; } +} +``` + +```csharp +// Make a 1x1 white texture: +Texture2D whiteTexture = new Texture2D(GraphicsDevice, 1, 1); +whiteTexture.SetData(new Color[] { Color.White }); +// When done with it: +whiteTexture.Dispose(); ``` \ No newline at end of file