Giter Club home page Giter Club logo

collisiondetectionfunctionsforprocessing's Introduction

screenshot

COLLISION DETECTION FUNCTIONS

(Version 0.9)

A 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 more than a bit complex. Other examples (equally great), like the line-line collision in the toxiclibs collection, use vector math which isn't easy 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 EXPERIMENT AND SEE WHAT THE FUNCTIONS DO The folder examples has sketches to demonstrate each function "live". These are meant to quickly try the functions, hack them, and otherwise experiment.

####HOW TO USE IN YOUR OWN CODE The example sketches are more fully-featured uses of the collision functions. To use the functions themselves, follow these steps:

  1. Open the function you want to use (ex: "pointPoint.pde) - NOT the example file
  2. Copy the code
  3. Paste the code into your sketch after the end of the draw function

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.

  • Point/Point

  • Point/Rect

  • Point/Ball*

  • Rect/Rect

  • Ball/Ball*

  • Ball/Rect*

  • Point/Line

  • Line/Line

  • Ball/Line*

* A "ball" is defined as a circle - ellipses are really hard!

- - -

####REQUESTS and BUG REPORTING A few things that would be great, but were just a little (or a lot) complex to include at this point:

  • Ellipses
  • Triangles
  • Polygons
  • Curved lines (definitely not happening any time soon!)

Finding that something is missing? Wish list? Major error? Little one? Please post here!

- - -

####THANKS TO Several online tutorials and examples were used for the more confusing examples. A special thanks goes to:

- - -

[ all code available under Creative Commons BY-NC-SA license - feel free to use but please let me know ]

collisiondetectionfunctionsforprocessing's People

Contributors

jeffthompson avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.