Original Post
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.