Build a simple Circle-Based Physics Simulation with pi2.js
Have you ever wanted to quickly build some Circle based Physics with JavaScript, where circles collide and repulse from each other, and experience the gravity that pulls each circle to the ground, or even to the walls?
If so, then I present to you pi2.js: it’s a simple Circle based Physics library which I wrote so I can quickly build JavaScript apps that simulate the Physics of circles. Also, I love circles!
Here is a demo of what we’ll achieve
I’m going to show you how to quickly build something like the simulation above with only the basics of pi2.
Note that I was able to build few more complicated apps with pi2.js, like: Pool game, Snake & Pool game, simple sling simulation, and some other interesting things.
It’s going to be a very quick article, so, a small cup of coffee with 3 sips will be fair enough to get you through it :)
Let’s create a folder and have 2 files in it: index.html and index.js