Adding FlatRedBall to a MonoGame/XNA Project

Introduction

FlatRedBall can be added to any MonoGame/XNA project with only three lines of code. This tutorial describes the process of adding FlatRedBall to a project created from a MonoGame/XNA template.

Downloading .dll Files

First we’ll download the FlatRedBall .dll files. Note that FlatRedBall provides different files depending on the platform you are targeting.

  1. Go to the prebuilt file location.
  2. Select your platform

  3. Select Debug or Release. You may want to start with Debug, then grab the release .dlls when you are ready to test your game for release.

  4. Download the .dll for FlatRedBall, and the associated .pdb file if you would like additional debugging information.

    Note that the folder will include other files, which may be needed if you would like to add FlatRedBall.Forms to your project. However if you are interested in only the core FlatRedBall functionality, you will only need the single .dll.

Referencing Files

Most FlatRedBall platforms only require a single – the engine .dll.  Add this file to your existing game project’s references.

  1. Open your project in Visual Studio
  2. Expand the game project in the Solution Explorer
  3. Right-click on the References item
  4. Select Add Reference

  5. Select the Browse category
  6. Click the Browse… button

  7. Navigate to where you have downloaded the .dll in the previous steps and select it to add it to your project.

Adding Code

Now that your project is referencing FlatRedBall, add the following code:

In Game1.Initialize:

In Game1.Update:
In Game1.Draw:

Note about Clearing Screen

The default template includes code for clearing the screen in the Draw method. FlatRedBall automatically clears the screen for you, so having the call outside of FlatRedBall is redundant. Therefore, the following line of code can be removed after FlatRedBall is added: