void Entity::TestCollision(Entity *one, Entity *two)
{
RECT rect1;
RECT rect2;
int x;
int y;
int x2;
int y2;
x = one -> pos.x;
y = one -> pos.y;
x2 = two -> pos.x;
y2 = two -> pos.y;
rect1.left = (long)one -> pos.x;
rect1.top = (long)one -> pos.y;
rect1.right = (long)rect1.left + one -> width;
rect1.bottom = (long)rect1.top + one -> height;
rect2.left = (long)two -> pos.x;
rect2.top = (long)two -> pos.y;
rect2.right = (long)rect2.left + two -> width;
rect2.bottom = (long)rect2.top + two -> height;
if (rect1.right > rect2.left && rect1.left < rect2.right && rect1.bottom > rect2.top && rect1.top < rect2.bottom)
{
one -> pos.x = x;
one -> pos.y = y;
two -> pos.x = x2;
two -> pos.y = y2;
}
}
i tested the collision by making the second object redraw itself in another random location when it came in contact with the first object...i did this just to see if the collision system was working..which it is. Now however i want there to be actual collision..meaning when the object come into contact with one another they should not be able to pass through eachother. I know i probably did something wrong in my code but i cant figure out how to go about doing this. Any help? Thanks






