about 3 months ago - No comments
I recently became interested in doing MVC inside of a Windows Forms app. I found a few MVC frameworks which work with WinForms (see here) but they didn’t really interest me. Too heavy I felt for what I was looking to do. I ended up with a solution looking something like this: There is really
about 5 months ago - No comments
Just a quick code snippet which adds an extension method for drawing Rectangles to SpriteBatch: public static class SpriteBatchHelper { static Texture2D pixel; private static void LoadPixel(GraphicsDevice graphicsDevice) { if(pixel == null) { pixel = new Texture2D(graphicsDevice, 1, 1); pixel.SetData<Color>(new Color[] { Color.White }); } } public static void DrawRectangle(this SpriteBatch spriteBatch, Rectangle rectangle, Color
about 1 year ago - No comments
When you need to calculate an angle from a Vector2 structure, you can use this piece of code: public static class Vector2Helper { public static float CalculateAngle(Vector2 v) { float angle = 0.0f; if(v != Vector2.Zero) { v.Normalize(); angle = (float)Math.Acos(v.Y); if(v.X < 0.0f) angle = -angle; } return angle; } } I used this
about 1 year ago - 3 comments
I’ve been talking with a guy on the creator forums lately about SpriteSheets and so I decided it might be a good idea to post my SpriteSheet class. It’s very simple. Only reads sprites from left to right and assumes all Sprites are the same width and height. #region Using using System; using Microsoft.Xna.Framework; using
about 1 year ago - No comments
I recently needed to write out Color(s) as an xml attribute. I wrote 2 methods to read and write the Color(s) as Hex strings. Here ya go: namespace Snow.Xna.Graphics { public static class ColorHelper { private static char[] _hexDigits = {’0′, ’1′, ’2′, ’3′, ’4′, ’5′, ’6′, ’7′, ’8′, ’9′, ‘A’, ‘B’, ‘C’, ‘D’, ‘E’,
about 1 year ago - No comments
Nick Gravelyn has released an open source set of C# extension methods for use with Xna. See the post here for more information. http://www.nickontech.com/2008/12/new-open-source-project-time/