Getting Started! - bmoren/p5.collide2D Wiki

Original URL:!

Get Started!

p5.collide2D assumes the default p5.js rectMode(CORNER) and ellipseMode(CENTER). All p5.collide2D functions return true if the specified geometry is colliding and false if they are not.

Adding p5.collide2D to your project

Download the latest release How to add a library to your p5.js sketch

CDN Links

How to use a CDN hosted version of the p5.collide2D library

To include the library via a CDN, add the library's CDN link using a <script> tag inside the index.html file within your project.

This enables the p5.js core library (automatically added within the p5.js web editor).
You'll need to include the core p5.js before using p5.collide2D.
<script defer src=""></script>

<!-- Includes the p5.collide2D addon library -->
<script defer src=""></script>

Live Examples in the p5.js editor

Using p5.collide2D with vector inputs

p5.collide2D supports vector version of all functions. Use the function names below with Vector added on to the name to utilize the vector version of the function. The function's arguments will then take in vectors instead of x/y values. Each of the examples below has a commented example to demonstrate vector usage. We will be updating the documentation and examples in the future to make this distinction more clear. This in no way affects the original functionality of the library.