-
Notifications
You must be signed in to change notification settings - Fork 297
Getting 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.
Download the latest release How to add a library to your p5.js sketch
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="https://unpkg.com/p5"></script>
<!-- Includes the p5.collide2D addon library -->
<script defer src="https://unpkg.com/p5.collide2d"></script>
- Collection of all examples of collision functions
- Basic Usage
- Button with a callback
- Object oriented collision
- Randomly placing objects without touching
- Swords Game
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.
- collidePointPoint()
- collidePointCircle()
- collidePointEllipse()
- collidePointRect()
- collidePointLine()
- collidePointArc()
- collideRectRect()
- collideCircleCircle()
- collideRectCircle()
- collideLineLine()
- collideLineCircle()
- collideLineRect()
- collidePointPoly()
- collideCirclePoly()
- collideRectPoly()
- collideLinePoly()
- collidePolyPoly()
- collidePointTriangle()
- collide 2D primitive triangle