This is a bouncing sprite simulation. See the inside comments for more details and customization.
Feel free to backpack this, but please give credit. Thank you