Archive for the Tutorials Category

February 9, 2010

Game Engine Tutorial Part IV, Section 2 – Sprite

In game development, a “sprite” is simply a 2D image place somewhere on the screen. They generally make up the majority of a 2D game, and in a 3D game they may be used for the targeting reticule, the heads up display, etc. We are going to create a simple Sprite class that will handle [...]

January 3, 2010

Correction: Component “Parent” Set Accessor

The “Set” accessor in the Component’s “Parent” property should be changed to the following to avoid a condition where a component’s would be “orphaned” (have its “parent” property set to null and not appear in any GameScreen’s list of components) when its parent is set to the same value.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public GameScreen Parent
{
get [...]

January 2, 2010

Game Engine Tutorial Part IV, Section 1 – 2D Components

This section will walk us through the creation of our 2D components: those that are drawn directly onto the screen as though it were a flat canvas. At the moment this will only include the Sprite class, which is responsible for drawing images at specific locations on screen, but later on we may add 2D [...]

January 2, 2010

Game Engine Tutorial Part IV – Building the Components

Now that we have built the core of the Engine, we can finally start building some real components by creating classes that inherit from the “Component” class.
Start by adding a new folder to the engine’s project called “Components”. The following sections will create new classes that we can add to that folder.

December 29, 2009

Correction: Engine Constructor

The Engine Constructor used in the XNA Game Engine Tutorial Series 2.0 so far is incorrect. It should actually be as follows:

1
2
3
4
5
6
7
8
9
10
11
public Engine(GraphicsDeviceManager Graphics)
{
services = new ServiceContainer();
services.AddService(typeof(IGraphicsDeviceService), Graphics);
services.AddService(typeof(IGraphicsDeviceManager), Graphics);
 
this.graphicsDevice = Graphics.GraphicsDevice;
content = new IEContentManager(Services);
[...]

December 29, 2009

Game Engine Tutorial Part III, Chapter 6 – Loading Content

We need to provide a way for components to load content. They can’t do it in their constructors because they may not have a GameScreen set to access the Engine’s content manager yet. To accomplish this we will add a Load() function to the Component class, which will be called (assuming the component has not [...]

December 29, 2009

Game Engine Tutorial Part III, Chapter 5 – Content Manager

XNA provides a ContentManager class that is used to load and unload content. However, we are going to create our own that caches loaded content so we only have to load an asset once to use it repeatedly, and also supports unloaded specific peaces of content (when entering a different area, for example). Add a [...]

October 21, 2009

Game Engine Tutorial Part III, Chapter 4 – Engine [Updated 11/5/2009 11:12PM PST]

The final core class of the engine is the “Engine” class. This class maintains the GameScreen stack, keeps track of utility classes, and is the starting point for updating and drawing all the GameScreens and thus all the Components. Later on it will also be in charge of saving and loading the state of the [...]

October 20, 2009

Game Engine Tutorial Part III, Chapter 3 – Component Draw Order

One feature of the GameScreen is that it can draw components in whatever order they want to be drawn in. This can be useful for features like transparency, where transparent objects must be drawn last so that they can draw over the object behind them. To implement this, we will provide a property on the [...]

October 20, 2009

Game Engine Tutorial Part III, Chapter 2 – GameScreen

Add a new class to your engine’s project, and this time call it “GameScreen”. Once again we can remove some of the “using” statements, until we are left with the following.

1
2
3
4
5
6
7
8
9
using System;
using System.Collections.Generic;
 
namespace InnovationEngine
{
public class GameScreen
{
}
}

As GameScreen is in charge of managing a [...]