forums

TNT Basic Forums > Programming Q&A
sprite to tile collision
< Last Thread     Next Thread >
Author
Thread        Post A Reply

08-20-2002 21:06

Posted by:
jamie

Find more posts by jamie

I'm just starting with TNT and can find how to detect a sprite to sprite collision easy enough, but how do you detect a sprite to tile collision?

08-21-2002 09:31

Posted by:
John Treece-Birch

Find more posts by John Treece-Birch

Tile Collision

There is no built in function for sprite to tile collision, but there is a function called "Sprite Col Rect" that can detect a collision between a sprite and a rectangle. As long as you know the position of the tile then you can test the sprite against the tile's rectangle.

Thanks,
John

08-21-2002 12:12

Posted by:
jamie

Find more posts by jamie

tile collision

Thanks John, I'll check that out. I did see that in the doc's and was kind of suspicious that is what I'd use.

What I'm trying to do is a platformer and was looking for a way to detect a floor or spikes or lava or whatever is under the players sprite.

Thanks for the tip.

jamie

08-21-2002 16:08

Posted by:
John Treece-Birch

Find more posts by John Treece-Birch

Tile Collision

The best way to detect what is underneath the player is usually to take the point at the bottom of the player and convert it into tile co-ordinates (usually just divide by tile width/height) and then use the function "Get Tile" to get that tile number.

If the tile number is the same as spikes/lava etc then you can take appropriate action.

Hope this helps,
John

08-21-2002 16:37

Posted by:
ERaZer

Find more posts by ERaZer

Something pretty good and probably faster is that when you load the game you create a matrix of the tiles that are not passable.
Like in the Saucer Wars "game"(its the beginning of a game)(can be found at basicallyreal.com )

08-22-2002 18:39

Posted by:
jamie

Find more posts by jamie

tile collision

Thanks, My basic sprite to tile collision is working now!

Now just have to work on a more robust use. I may be bombarding the board with questions, while i learn TNT basic ive also decided to enter the udevgames competition to keep me motivated!

If anyone is interested my development diary will be here: www.clay-communications.com/temple

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.