I would suggest replacing the new dir calculation through a vector based one as it will work consistently with any surface of which you know its normal vector.
The new direction is just
OldDirection - 2*ScalarProduct(OldDirection, SurfaceNormal)
ScalarProduct(a,b) in 2D simple means a.x*b.x + a.y*b.y
The new direction is just
OldDirection - 2*ScalarProduct(OldDirection, SurfaceNormal)
ScalarProduct(a,b) in 2D simple means a.x*b.x + a.y*b.y