Planck Box2D Physics for JavaScript P5

Planck.js is a rewrite of the Box2D C++ physics engine for cross-platform HTML5 game development. It is the only JavaScript version, in my opinion, that has active update support and that tracks improvements to Box2D C++, which was coded by Erin Catto.

"p5.js is a JavaScript library for creative coding, with a focus on making coding accessible and inclusive for artists, designers, educators, beginners, and anyone else! p5.js is free and open-source because we believe software, and the tools to learn it, should be accessible to everyone."

Watch the video to view an interactive introduction to P5. My home page provides a course add-on to the P5-based graphics and game programming courses at Khan academy.

I implemented a library (p2.js) to meld P5 and the capabilities of Planck.js. Click on an example's title to see the code in the P5 editor. Click here for examples. And for more examples.


I am working on my own tutorial for the p2.js library for P5. The current P2 documentation is posted here.

Mr. Catto's manual is posted at https://box2d.org/documentation/. The premier tutorial for Box2D was written by Chris Campbell and is also C++ based. Unfortunately, the pages are on an http (not https) web site and 1) may be blocked sometime in the future and 2) will generate a warning when you follow the link https://www.iforce2d.net/b2dtut/. Nevertheless, I have tried to recreate the C++ code in P5 for each of the tutorials. It can be instructive to read the tutorials and follow along with the P5 examples for Planck. Part 1 Part 2