|
Project Information
Links
|
COLLISION DETECTION FUNCTIONSJeff Thompson | www.jeffreythompson.org - - - DESCRIPTIONA set of functions to do basic 2d collision detection in Processing (www.processing.org). While some tools already exist, like the excellent Box2D, the source code is not easy to understand and the implementation is a bit complex. Other examples (equally great), like the line-line collision in the toxiclibs collection, use vector math which isn't great for us "creative programmers" (ie: those who got bad grades in high school math). Instead, these tools can be used as simple, one-line commands to determine whether two objects have collided. Designed for simple games and interactive systems, they are intended to be building blocks for larger projects. Enjoy! - - - HOW TO USEThe example sketches are more fully-featured uses of the collision functions. To use the functions themselves, follow these steps:
Note: you can also paste the code into a new tab, which will be a bit cleaner to use - - - CURRENT FUNCTIONS:All functions return a simple true/false value whether there is collision or not. In many cases, code is included to also return the point of collision.
*A "ball" is defined as a circle - ellipses are really hard! The included example sketches should demonstrate the basic functionality. - - - REQUESTS and BUG REPORTINGA few things that would be great, but were just a little (or a lot) complex to include at this point:
A library may be in the works as well, but having never done anything like that before, it seemed better to release the code early and often. Finding that something is missing? Wish list? Major error? Little one? Email me at mail [at] jeffreythompson [dot] org. - - - THANKS TOSeveral online tutorials and examples were used for the more confusing examples. A special thanks goes to:
- - - LICENSE and USEThis code is licensed under a Creative Commons Attribution NonCommercial ShareAlike 3.0 Unported License. Feel free to use and hack, but please give credit and let me know if you do something particularly fantastic! - - - |