Monday, July 27, 2009

Pixel Perfect Collisions Demos


These are a bunch of pixel perfect collision demos that I made. These particular ones are for the Nintendo DS, via homebrew. The current version as of this post is Demo 4, and can be found at the links below.

Download Info

Demo 1 Files: Click Here

Demo 1 Instructions:
Go to the folder Demo 1 and download the files. Unzip PP_Demo.rar to the root folder of you card, the run PP_Demo.nds. Touch the screen to move the sprite. When a part of the sprite that has color is at position 256, 192, the sprite will go back to position 0, 0. When it no longer touches there, it will go back to the place you are touching.

Alternate Demo 1 Instructions:
Instead of downloading the files and the normal PP_Demo.nds, just download PP_Demo(No Fat).nds for the demo that uses NitroFS.

Demo 2 Files: Click Here

Demo 2 Instructions:
This demo uses NitroFS only. Download the demo, and then launch it. To test this demo, use the control pad to move around. Your position will be shown on the top screen. If one of the colored parts of the sprite touches a dot on the screen, the word collision will appear above your position coordinates on the top screen. Otherwise, it will be blank.

Demo 3 Files: Click Here

Demo 3 Instructions:
This demo is exactly the same as demo 2, but includes a major speed change.

Demo 4 Files: Click Here

Demo 4 Instructions:
To play, follow the instructions from demo 2. I've added different colors to it now, and changed it to update every 4 VBLs. When you pass over a color, it will display 2 numbers under "Collision Info:". The first one is a number representing a color from the sprite. The number is based on the position of the color (starting from the top left corner, and ending at the bottom right corner, increasing each time it reaches a new colored pixel). The second one is a number represents this same info, but for the background. I've added as much of this info as I could fit nicely on the DS top screen as well.This demo also only uses EFS.

Change Log:

Demo 1:

(Initial Relase)

Demo 2:

-Changed controls to use control pad
-Only uses NitroFS
-Changed to use collision map

Demo 3:

-Improved speed greatly

Demo 4:

-Changed to update every 4 VBLs
-Now has most of the info on the top screen of the DS
-Added color to the graphics
-Added a color checking function to check each color and represent it with a number

Purpose Behind these demos:
The purpose behind these demos was to test how well pixel perfect collisions work on the Nintendo DS. In these 2 demos, what you saw was collisions that did not use general bounding boxes or circles. It was literally checking each pixel, with specific formulas to get each collision. You are able to get each different color as well. For example: if one pixel on the sprite image is red, and another is blue, you can check to see if only the blue pixel is touching something. This becomes very useful for doing things like character collisions, as it makes it way more accurate then a bounding box or bounding circle. I would like to know though, how the speeds are for everyone, so please leave a comment about how well this works if you've tested it. Please only post though if you've tried demo 2, as demo 1 should never have any lag, however, there is no guarantee

No comments:

Post a Comment