BRAINS – XNA A.I Library – Source Code

July 12, 2009 at 3:24 pm (A.I, XNA) (, , , , , )

image As mentioned in a previous post I have been working on an A.I library for use with XNA games. I have attached the latest source code to this post as well as the location to the SVN which I will be continuing to update.

If you do try it out and find any issues you would like to have fixed, please let me know and I’ll happily respond to requests. If anyone would like to contribute in the form of a patch or just contribute in the form of ideas and feedback, It’s all welcome.

Brains is only about 2 weeks old since I started the clean new project and it’s still very much a work in progress so there are still lots of features I could add to this middleware component to make it more useful.

Brains Source ZIP Download

Brains SVN Root

In the project is the main BRAINSFramework along with the debug AIRendering project. A Gamestatemanagement library for setting up a new game quickly and the AIDemos. There is also a very primitive Behavior tree designer which I’m currently working on making more friendly and feature rich.

I will be writing more comprehensive documentation in due course along with some articles to accompany the BRAINS library.


Permalink 6 Comments

IceCream Release (Update)

April 20, 2009 at 5:26 pm (IceCream, XNA) (, , , )

After finally releasing a release of IceCream early this morning which was probably not my wisest move as I was rushing and it showed in the release. Firstly I just messed up but secondly there were a couple of bugs I’ve been coping with that I should not have inflicted on anyone who tried it out. These were when you tried to open a project file and it couldnt find the scene file or no scene file was to be opened, the loading progress screen would stay alive and look like the app had hung. It didn’t, you just close the progress window and it’s ok to use. The second bug was deeper, when you open a project while already having a different project open, it would die a horrible death. I’ve been working hard on SBARG so it’s been a single project for me for some time. Both these bugs are now fixed in this release, along with an appropriate version number along with being compiled in Release mode so that should eliminate any debug performance issues.

You can grab the latest download of IceCream release here.

Again, please feel free to leave feedback, suggestions, comments or if you want some help email me at conkerjo at hotmail dot co dot uk.

Permalink 1 Comment

IceCream quick and dirty crash course.

April 20, 2009 at 1:18 am (IceCream, XNA) (, , )

So now that IceCream has been let out of the bag, how do you use it? well this post should give you a better idea of how a IceCream game is built and what are the basics of making your own game.

In the release there is a IceCreamPong demo sample, so let’s use this as our example.

This consists of a Visual Studio XNA Game 3.0 project, just like any other game project you would create. The installer adds a template for you which adds the reference and creates the default files. There is also a Game.icproj file. This file is the IceCream project file and is used by Milkshake to open your project.

Next is the file. This is a global data holder for template scene items and global assets such as materials.
Then you will have 1 or more scene files for your game, this sample contains TestScene.icescene. This is the main data store for any scene in your game. Both the scene files are xml and can be edited by hand, I highly recomend studying the data before attempting this though.

The game project contains a reference to the IceCream.dll. You will notice a lot of similarities with a standard XNA game project, we also gave a Game1.cs file which is our main game entry point. The difference is we inherit from IceCream.Game instead of the normal Game class from XNA.

public class Game1 : IceCream.Game
IceScene scene;
public Game1()

protected override void LoadContent()
scene = SceneManager.LoadScene("Content/TestScene.icescene");

All it takes is 2 lines of code to get a scene up and running.
This is important the base.LoadContent(); method call must come before you LoadScene call as this is what loads the global content potentially required by your scene data.

When the LoadScene method is called it loads the specified file into the SceneManager.ActiveScene property if it’s the first scene loaded.

Next we wil take a look at the components. In IceCream there are 2 types of Components. A IceSceneComponent which is added to the Scene.Components collection and a IceComponent which is added to a SceneItem’s Components collections.

These components are updated on every game update much like the component system built into XNA except with more flexibility.
The IceComponent contains a property called Owner which is a reference to its Owning SceneItem, but a IceSceneComponent has a property called Owner too which is a reference to its owning Scene.

In the sample game we have an IceSceneComponent called PongEngine. This has been added to the scene in the TestScene.icescene file.

When the LoadScene method is called this Component is added to the scene and the OnRegister method is called.

public override void OnRegister()
Instance = this;
Enabled = true;
BottomWall = (Sprite)Owner.GetSceneItem("WallBottom");
TopWall= (Sprite)Owner.GetSceneItem("WallTop");

A couple of things to point out here, the Owner property is a SceneItem so it needs to be casted to a Sprite in this instance. But if you look more closely we have Owner.GetSceneItem method, this will retrieve the SceneItem if it’s registered in the scene with the specified name.

If we look at the decleration of the Component we see how IceCream & Milkshake utilize your custom components.

public class PongEngine : IceSceneComponent

Some of the other types of SceneItem available are

  • Sprite
  • AnimatedSprite
  • TileGrid
  • ParticleEffect
  • TextItem
  • PostProcessAnimation
  • One of the cool things about IceCream is you can add Components to the scene and SceneItems from within Milkshake by right clicking an item in the main tree.

    I know this is only a brief overview of a tiny portion of what IceCream is. I will be writing more specific articles very soon.
    If you have a specific task you want to achieve, please post a comment and I’ll gladly help.

    Permalink 1 Comment