Game Development Community

a switch/case scenario

by rennie moffat · in Torque Game Builder · 02/18/2010 (1:49 pm) · 1 replies

I am not sure exactly what this is telling me and how to read it.




switch ( %srcObj.getGraphGroup() )
	{  
                ///"case $ballGroup:"
		case $ballGroup: // the ball hits something
		switch ( %dstObj.getGraphGroup() )
        }

why is the programmer calling for %srcObject.getGraphGroup(), then calling "case $ballGroup://"switch" again then for the %dstObject to getGraphGroup().

this makes no sense to me.




About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
02/18/2010 (1:52 pm)
never mind I found a case where the case reads more like this, which makes sense.



switch$ (%spawnLocation)
   {
      case "Area":
         %xPos = getRandom(getWord(%this.owner.getAreaMin(), 0), getWord(%this.owner.getAreaMax(), 0));
         %yPos = getRandom(getWord(%this.owner.getAreaMin(), 1), getWord(%this.owner.getAreaMax(), 1));
      case "Center":
         %xPos = %this.owner.position.x;
         %yPos = %this.owner.position.y;
      case "Top":
         %xPos = getRandom(getWord(%this.owner.getAreaMin(), 0), getWord(%this.owner.getAreaMax(), 0));
         %yPos = getWord(%this.owner.getAreaMin(), 1);
      case "Bottom":
         %xPos = getRandom(getWord(%this.owner.getAreaMin(), 0), getWord(%this.owner.getAreaMax(), 0));
         %yPos = getWord(%this.owner.getAreaMax(), 1);
      case "Left":
         %xPos = getWord(%this.owner.getAreaMin(), 0);
         %yPos = getRandom(getWord(%this.owner.getAreaMin(), 1), getWord(%this.owner.getAreaMax(), 1));
      case "Right":
         %xPos = getWord(%this.owner.getAreaMax(), 0);
         %yPos = getRandom(getWord(%this.owner.getAreaMin(), 1), getWord(%this.owner.getAreaMax(), 1));
   }