Game Development Community

Tutorials

by Dave D · in Torque Game Builder · 11/16/2005 (2:25 pm) · 3 replies

I tried the tutorials over at TDN and I know they're for the next version, but could some please explain to me how to load a map with 3 layers. Sky, ground, and dirt( underneath the ground.) Maybe I am just making the map wrong? I will be bald at the end of the day if I keep going the way I am.

#1
11/16/2005 (3:47 pm)
Here is some sample code that I used for loading 2 layers. It's based off of the TDN Platformer tutorial, albeit very modified.


$backgroundGroup = 0;
$platformGroup = 1;
$playerGroup = 2;

$backgroundLayer = 6;
$platformLayer = 5;
$playerLayer = 2;

function createLevel()
{
//Create a tile map and load our map into it
   %tileMap = new fxTileMap2D() { scenegraph = t2dSceneGraph; };
   %tileMap.loadTileMap("./maps/platformer.map");
   
//Load the first layer (Background and completely solid surfaces)
   %layerBackground = %tileMap.getTileLayer(0);
   %layerBackground.setImmovable();
   %layerBackground.setCollisionActive(false, true);
   %layerBackground.setGroup($backgroundGroup);
   %layerBackground.setLayer($backgroundLayer);
   %layerBackground.setCollisionMasks(BIT($playerGroup), BIT($playerLayer));
   %layerBackground.setPosition("0 0");

//Load the second layer (Platforms, in a separate layer so we can make them one way passable)
   %layerPlatform = %tileMap.getTileLayer(1);
   %layerPlatform.setImmovable();
   %layerPlatform.setCollisionActive(false, true);
   %layerPlatform.setGroup($platformGroup);
   %layerPlatform.setLayer($platformLayer);
   %layerPlatform.setCollisionMasks(BIT($playerGroup), BIT($playerLayer));
   %layerPlatform.setPosition("0 0");

//  layer.getArea() not available in 1.0.2, use long way until 1.1 released
//   $camera.setLimits(%layerBackground.getArea(), true);
	%tileCount = %layerBackground.getTileCount();
	%tileSize = %layerBackground.getTileSize();
	%SizeX = getWord(%tileCount,0) * getWord(%tileSize,0);
	%SizeY = getWord(%tileCount,1) * getWord(%tileSize,1);
	$camera.setLimits( "-" @%SizeX/2 SPC "-" @ %SizeY/2 SPC %SizeX/2 SPC %SizeY/2, true);

}
#2
11/16/2005 (5:10 pm)
Thanks, for that.
Not sure what I am doing wrong yet, but I will check into it and reply back later.
#3
11/16/2005 (7:19 pm)
If you want to post the code you are using, I'm sure somebody will be able to help figure out how to get it working.