Archived

This topic is now archived and is closed to further replies.

danielg

Collision Detection !!!

Recommended Posts

danielg    122
Hi! I have one silly question but I couldn''t find any answer or simple tutorial. My question is "How to make collision detection like in platform games with enemies, world, etc.". I''m trying to do that myself but I can''t. When I make rect collision with two objects it works, but if I increse the speed of object... it doesn''t work. Help me please!!!

Share this post


Link to post
Share on other sites
kVandaele    138
my friend who developed a mini mario-battle clone had the same problem (or was it that he did get the collision detection but depending on the char''s previous location his feet were up to 2 pixels into the floor).

What you''ll want to do is (before drawing anything) calculate everything''s next position. Then you check for collisions (if rect x is somewhere partly inside of rect y). That should work, unless the objects are fast enough to move ''through'' each other in a single frame (very doubtful, if they do, it''s not real movement, it''s teleportation). If the rect''s are ''inside'' each other, fix one (either one, the one that makes more sense... like if you have a rock and a mario, you probably don''t want to move the rock... unless that''s part of the game) so that they are only touching.

Share this post


Link to post
Share on other sites