Screenshots

Quick Start

GameConsole

GameConsole console = new GameConsole(this, spriteBatch); // where `this` is your `Game` class

OemTilde

Options

Features

Source and Downloads

Notes

Clipboard Support

STAThread

static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { using (Game1 game = new Game1()) { game.Run(); } } }

Adding Commands

class MovePlayerCommand:IConsoleCommand { public string Name { get { return "move"; } } public string Description { get { return "Moves the player"; } } private Player player; public MovePlayerCommand(Player player) { this.player = player; } public string Execute(string[] arguments) { var newPosition = new Vector2(float.Parse(arguments[0]), float.Parse(arguments[1])); player.Position = newPosition; return "Moved player to " + newPosition; } }

console.AddCommand(new MovePlayerCommand(player));

IConsoleCommand

console.AddCommand("rotRad", a => { var angle = float.Parse(a[0]); player.Angle = angle; return String.Format("Rotated the player to {0} radians", angle); }, "Rotates the player");

Writing to the Console

WriteLine

console.WriteLine("Writing from the code");

Console Options

GameConsoleOptions

GameConsoleOptions

GameConsole

GameConsoleOptions options = new GameConsoleOptions { FontColor = Color.Crimson, Prompt = ">", BackgroundColor = Color.DarkGreen }; GameConsole console = new GameConsole(this, spriteBatch, options);

Options

GameConsole

console.Options.Height = 200;

Microsoft.Xna.Framework.Input.Keys

Keys.OemTilde

Microsoft.Xna.Framework.Graphics.Color

new Color(0, 0, 0, 125)

Microsoft.Xna.Framework.Graphics.Color

BufferColor

PastCommandColor

PastCommandOutputColor

PromptColor

CursorColor

Color.White

Microsoft.Xna.Framework.Graphics.Color

Color.White

Microsoft.Xna.Framework.Graphics.Color

Color.White

Microsoft.Xna.Framework.Graphics.Color

Color.White

Microsoft.Xna.Framework.Graphics.Color

Color.White

Microsoft.Xna.Framework.Graphics.Color

Color.White

float

1

float

0.5f

int

300

string

$

char

_

int

30

int

30

bool

true

Microsoft.Xna.Framework.Graphics.SpriteFont

This is a project I was recently working on and it's a developer console for XNA games. It can easily be added to any XNA game and modifiedAdd the compiled XnaGameConsole dll as a reference and initialize theBy default, the console is opened with the ` (key) but this, amongst other settings, can be changed via theproperty.You can then add commands and customize the console.You can checkout a copy of the source at the Google Code page: http://code.google.com/p/xnagameconsole/ The compiled dll of XNAGameConsole can also be downloaded from here: http://code.google.com/p/xnagameconsole/downloads/list The console supports pasting via CTRL+V but this requires the game to be running in a Single Threaded Apartment.To do this, add theattribute to the entry point of your game:There are currently 2 ways how to add custom commands to the console:Console commands can be built via the IConsoleCommand interface.The following is an example of a command:Such a command can then be added to the console like such:Commands can also be added without using, like the following:The advantage of adding a command like this is that in the Func<> you have access to the variables outside the closure.You can dynamically write to the console via themethod:The console can be customized with a number of options. These options can be accessed through theclass.To set the initial options, instantiate a newclass, set your desired options and pass it through one of the's overloaded constructors:The options can also be changed dynamically through theproperty ofThe following are the current available options:Gets or sets the key that is used to show / hide the consoleDefault:Gets or sets the color for the background of the consoleDefault:Sets the same specified color for all of the following properties:Default:Gets or sets the color of the text in the bufferDefault:Gets or sets the color of the past commandsDefault:Gets or sets the color of the past command outputsDefault:Gets or sets the color of the promptDefault:Gets or sets the color of the cursorDefault:Gets or sets the speed by which the console opens/closesDefault:Gets or sets the speed by which the cursor blinksDefault:Gets or sets the height of the console, in pixelsDefault:Gets or sets the promptDefault:Gets or sets the cursor display characterDefault:Gets or sets the padding, in pixels, between the border of the console and the inner textDefault:Gets or sets the margin, in pixels, between the left and right side of the screen to the console borderDefault:Gets or sets a boolean value that indicates whether to open the console, if it's closed, when writing to the consoleDefault:Gets or sets the font that is used in the consoleDefault: Consolas, Regular, 11pt