Hi, I'm currently attempting to perform 2D collision detection using a color map.
I've searched around on google intensely trying to find something similar. I managed to find a couple tutorials that were similar, although I can't seem to quite grasp logic.
Here's basically what I am trying to achieve:
This is my 'room' texture. It's one big ugly picture.
This is my 'map' texture. It contains 2 colors. Black and Magenta. (I recently found out XNA turns magenta to an alpha. I'm not sure if it can still be considered magenta as far as Color.Magenta goes, but for now we will assume it can be. Otherwise I'll just change it to another color later.)
The tutorials I have as references can be found here:
http://www.ziggyware.com/readarticle.php?article_id=48
http://www.xnadevelopment.com/tutorials/theroadnottaken/theroadnottaken.shtml
http://www.berecursive.com/blog/2008/uncategorized/collision-textures-and-2drendertargets-in-xna
The main thing I've noticed about all of these techniques is that they all use the Texture2D.GetData() method.
Apparently it is essential... although I seem to lack the understanding to test the color against a rectangle associated with a sprite.
This is more about obtaining the logic behind "if this rectangle touches this color, preform action X" rather than the "preform action X" part (hope that made sense).
Another key issue I noticed was RenderTarget2D. I can't seem to think why I personally would need to use this, although maybe I do? Who knows.
Any help on this particular issue would be outstanding. Thank you very much.
Oh btw, I'm kinda new to programming so be gentle ;p