forums

TNT Basic Forums > Bugs!
Bug or bad programming?
< Last Thread     Next Thread >
Author
Thread        Post A Reply

02-23-2002 03:32

Posted by:
Chris

Find more posts by Chris

Working on tile collision in a jump 'n run and have found that tile collision fails with the leftmost tile of a "platform." Works everywhere else. Thought perhaps it was a bug, though that's probably wishful thinking... :) Code is posted under Programming Q&A thread "Tile Collision (woo-hoo)" if you care to check it out. If it's something in the code, I'm sure stumped.

Keep up the great work guys, TNT Basic is awfully cool...

02-27-2002 18:59

Posted by:
Mark Tully

Find more posts by Mark Tully

I've just read through your code and I think I know what the problem is. When you do the walking collision detection, to figure if your hero is still on a platform you use the code:

int tileX = char_x/32

To work out the x tile the character is on. The problem is that this is that char_x is just a point, probably on the left side of your sprite. What you really need to do is check the bottom left corner and the bottom right corner and only begin falling if they both aren't on tiles.

int tileXLeft = char_x/32
int tileXRight = (char_x+herowidth)/32

Then if neither is on a tile you can start falling.

The rule of thumb for tile collision detection is not to think of your sprite as being at a single point on the screen, but think of it as 4 points, one at each corner of the sprite (ie a box around the sprite that you don't want to go over the tiles with).

Only move left if the two left points are clear, only right if the two right points are clear, only up if the two above ones are clear and only down if the two ones below are clear.

Hope this helps!

Mark

02-27-2002 19:45

Posted by:
Chris

Find more posts by Chris

Heh...

Thanks Mark. Actually, I determined that a while ago and have now moved along to working on firing procedures. I do appreciate you taking the time to get back to me on it though. Thanks very much.

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.