Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

PhysicsLab+

edited October 30 in Code Sharing Posts: 1,547

I hope Codea beginners and beginners to 2D physics alike find this helpful.

It’s called PhysicsLab+.

It basically turns the original PhysicsLab into a class you can use in your own projects.

Almost everything demonstrated in the original has been made into an easy-to-use function. For example, the very first test in PhysicsLab creates random polygons anywhere you tap. PhysicsLab+ simply wraps that code in a makeRandomPolygon(…) function that you can easily access from any other project.

And PhysicsLab+ goes a few steps farther too:

  • There are two all-new tests
  • Two of the existing tests have been almost completely revamped.
  • There’s also a bonus test that @John had intended to include in the original project, but had to leave out due to time constraints.
  • Every test now includes short explanatory text in the overlay panel, so you know what you’re looking at.
  • Walls have been added to tests that use a ground, so it’s much harder to accidentally lose objects by dropping them off the edges.
  • The functions for creating joints have been given names that clearly describe what they do, so you no longer have to search the web for the definition of PRISMATIC.
  • Each of the tests is now a self-contained class that can be run on its own from any other project.
  • Potentially its most helpful contribution, PhysicsLab+ includes a category manager that simplifies categories by a jillion percent. Not only does it completely pave over many annoying pitfalls that can trip you up, with PhysicsLab+ you never even have to learn what a ‘map’ is. You just put objects into named categories, using the putIn(…) command. Once you’ve done that, you simply tell some objects to detect them using the detect(…) command, and other objects to ignore them using the ignore(…) command. That’s basically it!
  • Lastly, most of the abilities of PhysicsLab+ are modularized into stand-alone classes, so you can use those features on their own even if you don’t need to use the whole thing. The joint maker, the shape drawer, the category manager, etc—all can be used as part of the PhysicsLab class or on an as-needed basis.

I hope this is a help to some people at the beginning of the 2D physics learning curve! With luck it will turbo-boost the development of your own projects.

Comments

Sign In or Register to comment.