Shape Bounce
This program shows how you can control an objects motion based on position. Notice the use of the boolean variable open to control the mouth in shapeBounce2.
shapeBounce1
shapeBounce2 screen
shapeBounce2 code