The wall bounce works, and the method behind it is one line long. That line flips the vertical part of the direction every time it runs. That is right when the ball enters a wall, and wrong at every other moment. This node puts a guard around the flip.