Game Development Community

Experience on heavy usage of SimSet

by Kevin James · in Torque Game Builder · 11/25/2012 (1:12 pm) · 2 replies

Hey all,

I'm making a code framework for animating groups of static/animated sprites as a single "model"

The purpose is to have an animated model that by default responds smoothly and correctly to timescale changes, allows dynamic tweaks to the animation based on altitude, speed, etc, and allows independent concurrent animations to occur on the same model. I'm making it generic so that it's useful to other people and for other models in my own game.

I'm starting to require some hefty data structures such as a 2D SimSet, viz. a SimSet of SimSets. Does anyone have experience in using SimSets in a manner like this? Is this a winning strategy, or is the resource consumption most likely going to make usage of my custom models not worth it?

Additionally, I'm also making custom functions which act as constructors and one class has multiple levels of subclasses. TorqueScript makes me nervous because it includes no keywords for such things, but has anyone experienced success in using pseudo-constructors and a basic class-superclass structure?

About the author

Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/


#1
11/25/2012 (2:38 pm)
SimSets of SimSets gets cumbersome (and I eventually just made a C++ class that handled the logic), but it is straight-forward and (depending upon the application) fast enough.

I never sub-class more than one level because I worry about debugging the code. It often creates a minimal amount of duplicate code, but that doesn't bother me a lot.

As a side, I'll often create constructions too in the following manner.
function Target::spawn( %type, %position )
{
  %t = new t2dStaticSprite() {
    scenegraph = <Your Scene Graph>;
    imageMap = %type @ "ImageMap";
    positon = %position;
    size = "64 64";

    class = %type;
    superclass = "Target";
  };
  return %t;
}

function Target::hit( %this, %player )
{
  %this.safeDelete();
}

function SpeedBoost::hit( %this, %player )
{
  Parent::doSomething( %this, %player );

  // Speed Boost Target-specific code
  alxPlay( BoostAudio );
  %player.increaseSpeed();
}

$theTarget = Target::spawn( "SpeedBoost", "0 0" );
$theTarget.hit( $thePlayer );
#2
11/25/2012 (3:46 pm)
Cool, awesome to know. My 2d SimSets will probably be at most 10x10 and probably be referenced no more than once every couple seconds.

How's subclassing more than 2 levels make debugging difficult?

Nice, yeah I meant to include one of my constructors, but they're pretty similar:

function createPSPart(%sName, %sAnimationName){  //sy:probably have to pass in more
   %newPSPart = new t2dAnimatedSprite(%sName)
   {
      animationName = %sAnimationName;
      class = "PSPart";
      aAnims = "";   //an array of PSAnimations (must know what animations we can do)
   };
   %newPSPart.aAnims = new SimSet();
   
   return %newPSPart;
}