Tilemaps & active tiles
by Randy Sewell · in Torque Game Builder · 09/02/2012 (7:25 am) · 5 replies
I have been reading a lot lately about tilemaps, active tiles, etc and had some questions.
I am trying to figure out whether I need to use active tiles, or if plain tiles with custom data would be enough.
I need tiles with the following attributes:
1. Are destructible.
2. Are place-able.
3. Have a life total.
4. Spawn resources/items on destruction.
5. Can damage the player.
6. Are animated and retain the prior requirements.
7. Available in vast quantities.
From my extensive reading, it seems like Active Tiles are the way to go, but maybe I am underestimating custom data on standard tiles.
Does anyone have any insight on this?
And if Active Tiles are the way to go, are there tutorials for creating them in source, or can you describe how I go about making them? I got one of them to spawn in the game, but I think I need to somehow duplicate it and change pieces to fit my needs.
Thanks.
I am trying to figure out whether I need to use active tiles, or if plain tiles with custom data would be enough.
I need tiles with the following attributes:
1. Are destructible.
2. Are place-able.
3. Have a life total.
4. Spawn resources/items on destruction.
5. Can damage the player.
6. Are animated and retain the prior requirements.
7. Available in vast quantities.
From my extensive reading, it seems like Active Tiles are the way to go, but maybe I am underestimating custom data on standard tiles.
Does anyone have any insight on this?
And if Active Tiles are the way to go, are there tutorials for creating them in source, or can you describe how I go about making them? I got one of them to spawn in the game, but I think I need to somehow duplicate it and change pieces to fit my needs.
Thanks.
About the author
#2
The disadvantage to using either of the Tile objects is that you can't really "move" them (except by entire grid spaces).
If organization, air-tight-placement, and ease of use are more important than freedom of placement and flexibility of use (more re-usable code) , then use Tile Layers.
Typically, if you're going farther than visuals and basic gameplay (collision) on a tile layer, you should use active tiles. Custom Scripts on tiles is a kind of half-step if you want slightly more gameplay out of static tiles. It becomes difficult to expand on and very difficult to re-use the more you use custom scripts.
09/06/2012 (9:58 am)
From all that I've read (have not used them), Active Tiles are great for breaking down tiles into sub-objects (with new methods, callbacks etc). Regular Tiles with custom script won't really function like an object of a specific class, but can do a lot of similar things.The disadvantage to using either of the Tile objects is that you can't really "move" them (except by entire grid spaces).
If organization, air-tight-placement, and ease of use are more important than freedom of placement and flexibility of use (more re-usable code) , then use Tile Layers.
Typically, if you're going farther than visuals and basic gameplay (collision) on a tile layer, you should use active tiles. Custom Scripts on tiles is a kind of half-step if you want slightly more gameplay out of static tiles. It becomes difficult to expand on and very difficult to re-use the more you use custom scripts.
#3
Then right before the user is allowed to play the level the tilelayer scans and fixes all the tiles according to what their data is set to. I use many tiles that just create an object because it's easier to paint a tile them copy&pasting the same object over and over again. But that method only helps when the game is very grid based or at least the game world is.
09/06/2012 (10:15 am)
I don't have much experience with using active tiles. But a method I've been using is you use the tilelayer editor in torque to make your levels using brushes to mass produce the same tile with the same custom script/custom data.Then right before the user is allowed to play the level the tilelayer scans and fixes all the tiles according to what their data is set to. I use many tiles that just create an object because it's easier to paint a tile them copy&pasting the same object over and over again. But that method only helps when the game is very grid based or at least the game world is.
#4
I worked out the ability to place and clear tiles the other night with simple static tiles, so if I can get the Custom Data to work as needed, it could work out.
Will custom data allow a tile to store a small amount of information such as how much damage it has taken?
And can custom data call a function that will spawn objects?
09/07/2012 (4:42 am)
Well I am aiming for a Terraria quality digging space, so everything should pretty much be air-tight and aligned to grid. I worked out the ability to place and clear tiles the other night with simple static tiles, so if I can get the Custom Data to work as needed, it could work out.
Will custom data allow a tile to store a small amount of information such as how much damage it has taken?
And can custom data call a function that will spawn objects?
#5
Custom data must be accessed on command which is good for say... collisions, you want to know what you just collided with but again it's YOU who has to do the hard work.
Now scripts can help you make destructible terrain objects easily because objects can do all that you want them to do but tiles can't as easily. Tiles just help you place them fast and accurately.
Now say you set a tile's script to 'DestructibleTerrain'. When the tile is rendered it calls the 'onTileScript' function. Then you can check for the tiles script like this:
09/07/2012 (9:58 am)
What you probably want to do is set your intended destructible terrain tiles with a script. As soon as the tiles are in the camera view or are close to the camera view they activate the tile script data. Custom data must be accessed on command which is good for say... collisions, you want to know what you just collided with but again it's YOU who has to do the hard work.
Now scripts can help you make destructible terrain objects easily because objects can do all that you want them to do but tiles can't as easily. Tiles just help you place them fast and accurately.
Now say you set a tile's script to 'DestructibleTerrain'. When the tile is rendered it calls the 'onTileScript' function. Then you can check for the tiles script like this:
t2dTileMap::onTileScript(%map, %layer, %tile, %script){
if(getWord(%script,0) $= "DestructibleTerrain")
{
//Create your Destructible Terrain object at the tile position
//with all the data you need.
//Say you have different types of destructible terrain? NOW you //can use custom data and change your object depending on it.
%customData = %layer.getTileCustomData(%tile);
}
}I hope I made sense and this helps.
Torque Owner Randy Sewell
Default Studio Name