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 global.ice 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()
{
base.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");
SetupPlayers();
SetupBall();
}

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.


[IceComponentAttribute("PongEngine")]
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.

    Advertisements

    1 Comment

    1. indiexna said,

      Hi
      I have downloaded the beta of Icecream/Milkshake and I am really enjoying prototyping in it at the moment. Do you have any information on using the farseer component and is it possible to create menus using the editor?

      Great system. Looking forward to updates.

      Thanks

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s

    %d bloggers like this: