0

I am really struggling to find some code that will help me create a canvas (will be positioned absolutely behind an element so I don't require any input from users) that I am able to place background images on balls (predetermined number of balls '10'). The balls need to bounce off the walls and each other while under the effect of gravity, eventually having the balls settle stacked up stationary is the dream.

Can anyone help me with this? Either using a WordPress free plug-in or direct me to some open source code that does this?

I have been through hundreds of articles and examples of code but none seem to apply to my use-case.

I appreciate this is quite a code heavy question failing the plug-in approach, however I am unable to write questions on stack-overflow even though I don't have any questions with a negative score (think the algorithm is broken for my account.)

Thanks, Jason.

1 Answer 1

1

This is not related to WordPress. Maybe your Question would get better answers at other more javasript related stack exchanges.

Anyways: I searched for "bouncing balls" at codepen and found this piece. I guess adding background images would be no problem with this as a foundation.

3
  • This is amazing - such depth. Commented Feb 25, 2019 at 15:52
  • I have brought that example back to the depth I require, can you help me stick my images in as backgrounds on the circles now please? codepen.io/anon/pen/YgzPyQ Commented Feb 25, 2019 at 16:01
  • If you was to refresh you could see the section initBalls and addBall now incorporates an attempt at including images. codepen.io/anon/pen/YgzPyQ Commented Feb 25, 2019 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.