Wednesday, February 18, 2009

Update: rewritten to be more clear.
I forgot to mention how to use the console. Here's what I do to add it to a new project:
  1. Add the DebugConsole.dll as a reference to your project.
  2. Create a new public class file, call it GameInfo.cs
  3. Make your new GameInfo class implement the DebugConsole.IContainGameInfo interface. (i.e change the line "public class GameInfo" for "public class GameInfo : DebugConsole.IContainGameInfo"
  4. Add the 4 public properties mentioned later to your GameInfo class
  5. Create a static instance of the DebugConsole somewhere you can reach easily, something like Game1.Console (just add a DebugConsole variable in your Game1.cs file)
  6. Construct the console with a new GameInfo instance (i.e add new DebugConsole.DebugConsole(new GameInfo());to your initialize method)
  7. Add the console as a GameComponent (Game1.Components.Add(Game1.Console);)
  8. That's it. Start using the console (i.e Game1.Console.Show("My var", myLocalVar);)
This are the properties you need to add to GameInfo, just copy and paste and replace the comments:
  • public Game Game { get { /* return your Game class here */ } }
  • public Matrix WorldMatrix { get { return Matrix.Identity; } }
  • public Matrix ViewMatrix { get { /* return your view matrix here */ } }
  • public Matrix ProjectionMatrix { get { /* return your projection matrix here */ }
If you have a 2D project, you can return Matrix.Identity in the View and Projection properties, but you won't be able to use marks.

I will upload an example project soon.