Archived

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

MangoMan

Collision

Recommended Posts

I am making a 2d engine, but i need help with how to handle collision. My plan is : 1) The user or object specifies a collision area, determined by a set of points, which makes up a polygon. 2) The collision area can be used for anything. It can be linked to objects so they can perfom various tasks depending on if something has collided with it. 3) The collision area can call upon functions of a collided object in order for it to comphensate(for instance, make the object find a spot where it has not collided) 4) The collision area can also edit properties of objects freely.(for instance, you could make a teleporter) 5) The collision area must be linked to an object in order to function. It can even be linked to multiple objects, or an object can use multiple collision areas. 6) Each game frame, the engine determines what has collided in that frame. Several object can therefor determine if something has collided without performing unneccesary collision detection steps, as the engine has already done the hard work. Whats my problem? Well.. the first thing is... How can i determine if an object is within a collision area? I find it difficult to figure out how to do it with all the possible shapes of the collision Area. One idea i''ve thought up of is to determine what are the exact pixels that make up the collision area, however, wouldn''t this lag the game, as i''d have to call this every frame(seeming that the collision areas will be allowed to move if they are linked to moving objects) Can anyone help? Has anyone got a better solution, or would like to improve my idea? Thanks for your help.

Share this post


Link to post
Share on other sites
vectors are the answer to your problem...
simply set up a vector network of each object you want to have
a collision, then test if the lines have intersected.


-eldee
;another space monkey;

Share this post


Link to post
Share on other sites
You could start by testing if the two objects are overlapping with just their bounding rectangles. If you test for that then go through a more rigorous test. You could do what eldee said ... simply loop through all the vertices of each object and test if any of the lines intersect. Or, you could loop through each vertex of one object and test if the position of that vertex lies somewhere in the other object''s area ... and do the same for the other object.

Just merely suggestions ... both methods would do the job and you can easily search them on google ...

Good luck.

Share this post


Link to post
Share on other sites
Vectors seem soo confusing...
Does anyone know of any good, easy to understand explanations of vectors?

Edited by - MangoMan on January 1, 2002 12:33:45 PM

Share this post


Link to post
Share on other sites