Basically, if I have an array along the lines of
bool[] collision;
Filled with a value for each pixel in the sprite I am checking collision against (pixel 1 = true, pixel 2 = false etc), how do I use it to check collision between the player and the texture?
protected void GetCollisionData()
{
// Declare an array to hold the pixel data
uint[] pixelLevelData = new uint[textureLevel.Width * textureLevel.Height];
// Populate the array
textureLevel.GetData(pixelLevelData, 0, textureLevel.Width * textureLevel.Height);
for (int x = 0; x < textureLevel.Width; x++)
{
for (int y = 0; y < textureLevel.Height; y++)
{
if (x < textureLevel.Width && x > 0 && y > 0 && y < textureLevel.Height)
{
//If it's black, make a note that collision will happen
if (pixelLevelData[(x + y * textureLevel.Width)] == 4278190080)
{
collision[x + y * textureLevel.Width] = true;
debug = 9;
}
//else it's either something black already covers or transparent; no collision necessary
else
collision[x + y * textureLevel.Width] = false;
}
}
}
}
This is the relevant part that covers how I got my array of bools. How to I check collision between the set of bools and a normal rectangle?