Bresenham

Bresenham

Flash player not detected

Get Adobe Flash player

This is simple demonstration of using the Bresenham line algorithm for ray casting against pixels in AS3. The class I've put together returns an escape vector for running a line into a wall of pixels. Click on any white area to relocate the start point for the ray cast.

Earlier versions of this code were used in the games Aquanaut and Bomba to resolve collisions against pixel surfaces. This demo uses revised code that has been optimised and made more generic to use.

Download this demo and its source code here.