Collision Detection Functions for Processing Released!

UPDATE: these functions have been updated and moved to GitHub

Released today, version 0.9 of my 2d collision detection functions for Processing!

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 like me 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.

Functions include:

  • Point/Point
  • Point/Rect
  • Point/Ball
  • Rect/Rect
  • Ball/Ball
  • Ball/Rect
  • Point/Line
  • Line/Line
  • Ball/Line

Download here via Google Project Hosting

Maxwell’s Demon Game

Screenshots from the games I made yesterday for games++, the 12-hour game jam we hosted at Drift Station.

Inspired by Maxwell’s Demon, a thought-experiment with a box, separated by a wall with a hole in it and one side filled with gas.  The experiment asks the question of why does the gas “know” to go through the other hole and fill the second chamber so that it is dispersed evenly?

Written in Processing, the source code is here.

Ride The Lightning – Sorted

Metallica’s Ride the Lightning with all sample values sorted, then arcs are traced back to the sample’s original position.  Several iterations here with varying levels of arc transparency.

Click on images for full-resolution versions.

Unix Commands Within Processing

I keep finding myself needing to be able to run Unix commands within Processing sketches (maybe too much time spent writing Bash scripts lately), but no one seems to have a good solution.  Today I was able to get the Java exec() command to work within Processing… hooray!

EDIT: want to do something more complex?  You can run a Bash script too!

Sample-Tracing

The above image is the result of a Processing sketch that takes an audio file, sorts its sample values, and visualizes the current and original position of each sample.  At 44,100 samples per second, the above 10-second audio file has 441,000 arcs.  Height and line color are proportionate to the distance the line travels, otherwise the image would basically be a big block.

Still in refinement, source code forthcoming…