Game Development Community

Resize a tile layer

by dragonlady · in General Discussion · 10/09/2010 (12:44 pm) · 0 replies

Good morning,

I am trying to dynamically resize a tilemap layer using Torquescript. The game level randomly generates and places certain game objects, and the number varies depending on the number of players and some other factors. My strategy is to keep track of the min/max x and y position values of all the game objects on the board, then move and resize the tilemap and world boundaries based on that information. I am referencing the tilemap name as set in the Torque Game Builder level editor.

Code is as follows:

%newTileCountX = mCeil(($maxBoardX - $minBoardX)/tileMap.getTileSizeX());
   
%newTileCountY = mCeil(($maxBoardY - $minBoardY)/tileMap.getTileSizeY());
   
tileMap.resizeLayer(%newTileCountX SPC %newTileCountY);

The tilemap does not resize. However, I tested by setting %newTileCountX and %newTileCountY to some integers before calling resizeLayer, and in that case it did work. It seems like when the new tile count variables are calculated as in my code, they're coming out as floats, rather than integers, which is I guess why the resizeLayer call doesn't work. But I thought the mCeil call was supposed to return an integer. Please help, I'm stumped as to why this isn't working.

Thanks :)