Skip to content
Andy De George edited this page Jul 20, 2016 · 20 revisions

Check the [Engine Concepts](Engine Concepts) page to learn how pieces of SadConsole work.

Read up on the Tutorials provided here which will walk you through doing various tasks with SadConsole.

Getting Started

SadConsole is pretty simple to get up and running. If you're working with the starter project included in the source code, you can tweak that to test out engine features. However, if you are starting with a new MonoGame or XNA project, you must follow these steps to integrate SadConsole:

TIP
Check out the NuGet starter instructions if you don't have MonoGame installed.

  1. After creating a new project, open the game1.cs or game1.vb source code file
  2. Build the project so the bin\debug or bin\release folders are created
  3. Copy the font definition file and the font graphics file to the build directory
  4. Add reference to the SadConsole.Core.dll to your project
  5. Add reference to either the XNA or MonoGame libraries to the project
  6. Add the code below to the three overrides: Initialize, Draw, Update

Initialize

Before anything can be done with SadConsole, the main engine must be initialized. The initialization routine takes a GraphicsDevice reference object.

At least one font file must be loaded into the engine as the default font. A font is a set of cells representing every character used by your game. The following example overrides the Initialize() method on a Game class:

protected override void Initialize()
{
    var firstConsole = SadConsole.Engine.Initialize(this, graphics, "IBM.font", 80, 60);

    // Initialization always creates a console ready and rendered.
    firstConsole.FillWithRandomGarbage();

    // Finish initialization.
    base.Initialize();
}

Update

The Update method of the Game class allows SadConsole to read the mouse and keyboard input devices as well as update any logic behind the scenes of the consoles the engine knows about.

protected override void Update(GameTime gameTime)
{
    SadConsole.Engine.Update(gameTime, this.IsActive);

    base.Update(gameTime);
}

Draw

The Draw method of the Game class allows SadConsole to render the SadConsole.Engine.ConsoleRenderStack consoles. When you create a console, you generally will be adding it to the ConsoleRenderStack.

protected override void Draw(GameTime gameTime)
{
    GraphicsDevice.Clear(Color.Black);

    SadConsole.Engine.Draw(gameTime);
            
    base.Draw(gameTime);
}
Clone this wiki locally