Game Development Community

How to set a tile that falls?

by Adam Johnston · in Torque Game Builder · 01/19/2006 (8:23 am) · 6 replies

I'm trying to implement "tiles" that falls after the player steps over

I'm using a t2dAnimatedSprite as image, and activating the falling
with:

%gpx.setConstantForce (0 SPC $actCrumble::gravity, 1);

if the player is over the "tile" they falls but very slowly
if the player is not over the tile falls normally (as must to be)

I'm wondering if someone as tryied this before...

#1
01/20/2006 (12:41 am)
Standard tiles cannot be moved individually. In alot of games, the tile simply animates to look like it's crumbling and/or an effect is added to make the illusions more realistic. If you do want to do this though, you need to look at implementing an active-tile class to do it. Active-tiles can do pretty much anything!

- Melv.
#2
01/20/2006 (8:19 am)
Hi Melv I could fake this changing material and disabling the
physics. Yes I have some kind of "active-tile"
Thanxs for your interest.
#3
01/20/2006 (11:12 am)
Adam,

If you've created an acitve-tile then only you know its functionality. Your solution depends on where you want to code it, script or C++, which I don't know.

Essentially though, the thing to remember is that tiles don't receive collisions directly (at the moment), only t2dSceneObjects do. This doesn't stop you achieving your goals though because sub-objects (as is the case of tiles as they are sub-objects of the t2dTileLayer) encode a reference-string. In the case of tiles, they encode the logical X/Y position (not world-position as this is part of the standard collision-return). In the engine, you'll get the call to "onScriptCollision()" and in the scripts, "onCollision()". Both these have this reference-value. Look for the "getRefMetaString()" call in the engine. Either in "t2dSceneObject::onScriptCollision()" or in a sub-class, you can insert code to do "something" to your active-tile.

Of course, you can do this in script by handling the "%srcRef" or "%dstRef" which in the case of tiles will be the logical position of the tile. Only tiles return something in this string (but more will in the future). If the objects is the tile-layer, you can check the position to see if it's the active-tile class for your falling-levels and then do the custom call on it you've setup to make it "fall".

In scripts, use the "onCollision()" "%srcRef" or "%dstRef" or in the engine, look at the "onScriptCollision()".

I had a plan to provide a callback in the engine specifically for sub-objects but I never got around to adding it. I will do though.

- Melv.
#4
01/20/2006 (12:56 pm)
It's easy enough to simply use scene objects for those tiles. As in, those aren't part of the tilemap; they're actually game entities that you can walk on.

That's how older games did it. Either that, or they would swap the tile with an entity when it was time for it to move.
#5
01/20/2006 (1:35 pm)
@Melv: at the moment my T2D skills don't allowme to do this in C++
*still awaiting your C++ tutorial ;)*

@smaug: yes I did it that way.

Thank you.
#6
01/20/2006 (6:27 pm)
You could place any tiles that should be active in a special layer that is invisible in game, and when loading the tilemap simply do a check on the tiles in that special layer and use getTileType to figure out what kind tile it is, and then what kind of scene object / sprite should be placed there.