horizontal bounce

Declare a var named sign
and initialise it to 1
sign = 1 to move right
sign = -1 to move left

Declare and set cx and cy as before.

Add sign to cx.
This will increase cx if sign = 1
and decrease cx if sign = -1

If the circle touches the left or right edge
change sign to its opposite value.