private Rectangle HandleCollision(Rectangle bounds, TileTerrain collision, Rectangle tileBounds) { Vector2 depth = RectangleExtensions.GetIntersectionDepth(bounds, tileBounds); if (depth != Vector2.Zero) { float absDepthX = Math.Abs(depth.X); float absDepthY = Math.Abs(depth.Y); if (collision == TileTerrain.Passable) // Ignore platforms. { // Resolve the collision along the X axis. if (direction == Direction.dLeft || direction == Direction.dRight) { position = new Vector2(position.X + depth.X, position.Y); } else { position = new Vector2(position.X, position.Y + depth.Y); } // Perform further collisions with the new bounds. bounds = BoundingRectangle; } } return(bounds); }