Game Development Community

dev|Pro Game Development Curriculum

My updates ...

by David Higgins · 04/04/2007 (1:05 pm) · 4 comments

For those of you who were following the Dungeon Builder progress, don't fret ... the projects not dead, just on hold ...

and here's Why ...

I was contacted earlier last month and have accepted a coding contract to work on a TGB Side-Scroller game. Since I only really work with Game Dev on my free time (real world job as an Application Developer), I had to make a choice, and I opted to go the route of making a few bucks and getting something 'published' ... now, here's some updates on what I'm doing with this project ... and some of the delima's I've run across so far ...

The project is a simple 2D Side-Scroller, so you'd think It'd be a snap, with the scrollerDemo shipping with TGB and all, right?

Errr ... wrong? Wrong!

This side-scroller relies heavily on art, every level has it's own art assets, and almost none of the levels share any assets in common with each other -- some of the levels have well over 10mb of art assets (we're working on trimming this down with some cropping and resizing magic, ...) ... Shipping with at least 15 levels, there's ... oh ... a TON of art ...

Can TGB handle this .... sure ... can my system ... No ... If I had like 5gb of RAM and a Quad Xeon ... maybe I could load Level Builder in under 5 minutes ... with all these art assets loaded into the project in the managed/datablocks.cs for Level Builder ... my system was more or less ... unstable and useless ...

So ... I decided to fix this real quick ... when I accepted the contract, all the level design was more or less completed, there's little left to do in the art department, they just need code to drive the art ... well, loading up all these resources when the Game.exe launches is not going to work ... no one wants to wait for more then 10-15 seconds for a 2D game to launch into a menu ... so ... I created what I call the ResourceManager class in TorqueScript ... what this does is basically turn my /data/levels/ into a 'mod system' ... inside of /data/levels/ I create a directory for each level, and each level directory has a resources.cs, and a level.cs ... along with an 'img' folder that stores the art for the level ... and a 'shapes' folder that stores the 3D Shapes when the level uses them (yep, we use em in at least one level ...)

What does ResourceManager do for me? Well, it prevents me from having to load up the massive number of resources at game start ... rather, I more or less strip the level datablocks out of the managed/datablocks.cs and put them in the resources.cs ... I also build a SimSet and store a reference to the datablock so when I want to unload the resources, I can delete the datablock (I tried deleteDatablocks() as an alternative, but I had issues where it was removing things all goofed and leaving the game unstable) ... so, yeah, I have a 'loadLevelResources' and 'unloadLevelResources' function which basically exec's the resources.cs, which builds my datablocks for the level, and keeps them in a SimSet so I can easily go through and delete them 'on the fly' ... then I exec the level.cs ... which is a hybrid of the Level Builders 't2d' file format ... it contains the SceneGraph portion at the top, but doesn't attach it to anything, and isn't called from the SceneWindow.loadLevel ... so the scenegraph is just 'there' at this point ... I then have a series of other Manager classes, such as SpawnManager ... where I create object instances for things I need, and I either add them to the scenegraph 'as is' (like my Player object, for example, is just added to the scenegraph) ... my ResourceManager also stores a reference to all the objects I create in the world as well ... so I have a simple single location to 'delete' things from ...

Here's a short example of a level.cs;

// level.cs
%sceneGraph = new t2dSceneGraph()
{
   // ... sceneGraph fields
};

%obj = new t2dAnimatedSprite(Player)
{
  // ... object fields
};
resMgr.addObject(%obj);

%obj = new t2dAnimatedSprite()
{
  // .. spawnable object fields
};
resMgr.addObject(%obj);
spwMgr.addObject(%obj); 
// the object fields have values which the SpawnManager uses to spawn the object

%obj = new t2dStaticSprite()
{
  config = "SceneryDataBlock";
  // scenery (background or foreground object) fields
};
resMgr.addObject(%obj);
scnMgr.addObject(%obj);
// the SceneManager class is cool, if the object is no longer needed, 
// it unloads the object AND the datablock, freeing up memory ...


So yeah ... that's a quick and simple ... "What I've been up to for the past few weeks" ... I will most likely be working on this project for at least a few more weeks ... when I'm done, I hope to have some time to work on the Dungeon Builder again and possibly get a 'beta' available ... depending on my intentions behind the code base, I may have a 'closed beta' ... might be public, who knows ...

#1
04/04/2007 (2:47 pm)
Awesome work. Looking forward to seeing the game!
#2
04/05/2007 (1:53 am)
David: if I understand it correctly, you are only loading one level given art at a time, instead of loading everything, or is it a bit more complex?
#3
04/05/2007 (12:52 pm)
Stephan, I load the resources for the level at the time the level is being loaded ... I also delete the resources, when the level is finished ...
#4
07/10/2007 (7:03 am)
Your arithmetic is very interesting. I wonder if it works in one level which has tons of art assets.

I wish to here suggestions from you, thank you very much!