Collision Detection with Moving Objects
To know which way a moving rectangle should bounce, test its NEXT position against the obstacle separately on the X axis and the Y axis, reversing only the axis whose next position would collide.
To know which way a moving rectangle should bounce, test its NEXT position against the obstacle separately on the X axis and the Y axis, reversing only the axis whose next position would collide.