TNT Basic Forums > Programming Q&A
help with collisions
< Last Thread     Next Thread >
Thread        Post A Reply

12-02-2002 23:11

Posted by:
Brian Jones

Click Here to Email Brian Jones   Find more posts by Brian Jones

This question is more conceptual than technical. I have collisions working perfectly fine in my game; however, the vast majority of collisions that occur are balls bouncing off of blocks. With these collisions, I get overlapping. I guess this means that I'm drawing the ball before it bounces back, but I don't see how that's happening. If anyone has any general advice on addressing this kind of problem in TNT Basic, I'd like to hear it.

12-04-2002 10:53

Posted by:

Click Here to Email mark_667   Find more posts by mark_667


What type of sprite collision are you using,is it pixel perfect or set image bounds? Also check the example 'Bouncing splats' it sounds fairly similar graphics wise to what you're trying to do.
Hope this helps.

12-09-2002 21:09

Posted by:
Mark Tully

Find more posts by Mark Tully

Hmm... Sounds like you've got the classic collision detection problem! When two sprites are colliding, it means that if you draw them that frame then they will be overlapping - after all they are colliding!

So what you have to do is move them back a step if they are colliding and then handle the collision (eg bounce back etc). You must do this on the same frame that you detect the collision, you can't wait until the next frame to move them back or you will draw a frame where the sprites overlap (which is I think what you are seeing).


move my sprites
check for collisions
for each sprite
if collision
move back by amount moved this frame
handle collision (eg reverse velocity)
end if

position sprites

draw frame

Hope this helps!


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.