Stand Alone Neat Console
Today I made a few changes in Neat Console that allows it to be used outside a NeatGame class, as a stand alone component.
So, here’s how you can use Neat Console independently:
- Create a regular Windows Game project.
- Add a reference to Neat. (you can either do that by adding Neat project to your solution or just using the binary file. you don’t need to add any of Neat’s content files to your game.)
- Create a Neat.Components.Console object:
Neat.Components.Console console = new Neat.Components.Console(this); - Add the console object to your game’s components:
Components.Add(console); - Since you are not using Neat Engine, you have to manually assign a font to the console. You can also change console’s background texture the same way. write this in your LoadContent() method:
f = Content.Load<SpriteFont>("spritefont1");
console.StandAloneFont = f;
console.StandAloneTexture = someTexture2DObject; - Now all you have to do is telling the console to draw itself each frame. (You have to do this manually since Console isn’t a drawable component):
spriteBatch.Begin();
console.Draw(spriteBatch, false);
spriteBatch.End();
Adding commands is like before, just create a function that returns void and accepts a IList<string> as parameter and hook it to the console by writing console.Add(commandName, function);
That’s all.
Download Neat Game Engine: http://neat.codeplex.com
Posted on December 14, 2010, in Game Development / XNA and tagged C#, Console, Neat, XNA. Bookmark the permalink. 2 Comments.
Hey, that’s awesome.
Detecting key presses using a polling mechanism can miss keys when the framerate stutters, and it can switch key press order if they are pressed in the same frame. Ideally you need to listen to keyboard events at a lower level, Promit’s code here does exactly that. http://www.gamedev.net/community/forums/topic.asp?topic_id=457783
Also, it would be pretty easy to use reflection to bind a function that took any sort of arguments, so long as those arguments could be converted from string.
Thanks,
I know that the current input method used by the console has these problems, and I will find a way to fix them. I also have to mess with the draw method of the console to be able to introduce colors to it.
Promit’s code uses Windows API, I’m not sure I can use it in Windows Phone versions of the game :-/
The reflection is a good idea, I will implement it in the future. right now you have to convert the parameters manually.