project2D/CollisionManager.cpp
//--------------------------------------------------------------------------------------
// Bounce: Resolve a collision with a bounce.
//
// Param:
//		pObject: An entity of the object you want to bounce.
//		dir: A Vector2 for the direction you want the object to bounce.
//		pos: A Vector2 for the pos of the object.
//--------------------------------------------------------------------------------------
Resolve a collision with a bounce.
Param:
pObject: An entity of the object you want to bounce.
dir: A Vector2 for the direction you want the object to bounce.
pos: A Vector2 for the pos of the object.
Resolve a collision with a bounce . Param : pObject : An entity of the object you want to bounce . dir : A Vector2 for the direction you want the object to bounce . pos : A Vector2 for the pos of the object .
Vector2 CollisionManager::Bounce(Entity* pObject, Vector2 dir, Vector2 pos)
{
	Vector2 result;
	result = pos - pObject->GetPosition();
	if (fabsf(result.x) > fabsf(result.y))
		result.y = 0;
	else
		result.x = 0;
	Vector2 normal = Vector2::Normalised(result);
	return dir - 2 * dir.dot(normal) * normal;
}
Vector2 CollisionManager :: Bounce ( Entity * pObject , Vector2 dir , Vector2 pos ) { Vector2 result ; result = pos - pObject -> GetPosition ( ) ; if ( fabsf ( result . x ) > fabsf ( result . y ) ) result . y = 0 ; else result . x = 0 ; Vector2 normal = Vector2 :: Normalised ( result ) ; return dir - 2 * dir . dot ( normal ) * normal ; }
Bounce: Resolve a collision with a bounce.
Bounce : Resolve a collision with a bounce .