CodeBase - Nearly pixel perfect sprite collision detection

Return to the CodeBase listing

Category: Sprite

Version: 1.0



Uploaded: 11th Oct 2003 07:23

Modified: 15th Oct 2003 10:14

Author:  haggisman


It works for any sprite, no matter what the rotation or scaling of the sprites it will still retain the near pixel perfect collision.

Full Description

Everything needed can be found in the zip, both some simple code showing the collision detection routine and also the code for creating the collision template for the sprites.<br /> <br /> The collision template creator simply creates an outline of a sprite on the edge between the opaque and transparent areas, the outline is used to generate lines that the collision will be detected against. Normals will also be generated at this point, which will eventually allow me to make collision responses IE sliding/bouncing/sticking collision.<br /> <br /> The Simple example just shows the collision routine very basically between two objects. The one being controlled can be moved rotated and scaled and still produce accurate collision. It works on the very basic principle that if lines of either shape intersect then there is a collision. There is still a lot of optimization to do but I believe its still fast enough in its current state for some nice 2d games.


No comments yet.