Tutorial 1.3: Integrating The X-Engine Into The Project
Your game is now ready to implement the X-Engine. In this tutorial, we will add all the necessary code to make the X-Engine function.

Note: I am not goind to get into how to programming works here. If you are not familiar with C#, then I would recommend looking online for some help.

We need to modify the functions that XNA has provided us to be able to use the X-Engine. Every XNA game has 5 basic functions:
  • Initialize() - This is called when the game is first started. This is where variables are set, etc.
  • LoadContent() - This called when it is time to load the game. This takes place right after Initalize().
  • UnloadContent() - This is called when the game is closing to clear out memory.
  • Update() - This is called every frame before it is drawn. This is where things like health, physics, ammo counter, etc. are updated.
  • Draw() - Finally, Draw() draws the frame

We will change four of these function to look like the following:

Initialize():
protected override void Initialize()
{
    XE2.Initialize(this, graphics);
    base.Initialize();
}


LoadContent()
protected override void LoadContent()
{
    XE2.LoadContent();
}


Update()
protected override void Update(GameTime gameTime)
{
    XE2.Update(gameTime);
    base.Update(gameTime);
}


Draw()
protected override void Draw(GameTime gameTime)
{
    XE2.Draw(gameTime, graphics.GraphicsDevice);
    base.Draw(gameTime);
}


Also, you can remove SpriteBatch spriteBatch; from the top of the file. Run this code and you should see an empty black screen. There is just one thing you need to do before you can fully use the engine: set up the system font. We will do this in the next tutorial: Tutorial 1.4: Displaying the framerate

Last edited Mar 23, 2008 at 6:25 AM by Hazardous101, version 7

Comments

gaurdianAQ Jul 24, 2008 at 5:50 PM 
need updated documentation