public void defineExplosion(Texture2D tex, int size)
        {
            // Create the explosion object
            cExplosion e = new cExplosion();

            e._data    = new byte[tex.Width, tex.Height];
            e._partVel = new Vector4[tex.Width, tex.Height];

            // Grab the texture data
            Color[] data = new Color[tex.Width * tex.Height];
            tex.GetData <Color>(data);

            // Init some vars
            int     x    = 0;
            int     y    = 0;
            Vector2 diff = new Vector2();
            Random  r    = new Random();

            // Loop through each pixel
            for (int i = 0; i < data.Length; i++)
            {
                diff = new Vector2(x - (size / 2), y - (size / 2));
                float mag = diff.Length();
                if (mag < 8)
                {
                    mag = 8;
                }
                diff.Normalize();
                diff.X          *= (size / 2) / (mag * 0.6f);
                diff.Y          *= (size / 2) / (mag * 0.6f);
                diff.Y          += r.Next(-1 * size, 1 * size) / 100f;
                diff.X          += r.Next(-1 * size, 1 * size) / 100f;
                e._partVel[x, y] = new Vector4(diff.X, diff.Y, 0, 0);
                e._data[x, y]    = data[i].A;
                x++;
                if (x >= tex.Width)
                {
                    x = 0; y++;
                }
            }



            _explosions.Add(size, e);
        }
        public void Explode(Vector2 where, Vector2 direction, int size)
        {
            if (!_explosions.ContainsKey(size))
            {
                return;
            }
            cExplosion e = _explosions[size];

            byte[,] data = e._data;

            // Move to the top left of the explosion
            where.X -= size / 2;
            where.Y -= size / 2;
            int intX = (int)where.X;
            int intY = (int)where.Y;

            if (intX < 0 || intY < 0)
            {
                return;
            }
            int ex = 0;
            int ey = 0;

            _explosionAdded = true;

            List <Vector2> positions = new List <Vector2>();
            List <Vector2> velocities = new List <Vector2>();
            List <Color>   colors = new List <Color>();
            Vector2        pos, vel;

            int maxP = 50;
            int part = maxP;

            // Loop through all y values
            for (int y = intY; y < intY + size - 1; y++)
            {
                // If its outside the collision area then we go no further
                if (y >= _destructableData.GetLength(1) - 1)
                {
                    break;
                }

                ex = 0;

                // Loop through all the y values
                for (int x = intX; x < intX + size - 1; x++)
                {
                    // If its outside the y area go to the next x
                    if (x >= _destructableData.GetLength(0) - 1)
                    {
                        break;
                    }
                    if (data[ex, ey] != 0 && _destructableData[x, y].A != 0 && _indestructableData[x, y].A == 0)
                    {
                        if (part >= maxP)
                        {
                            part = 0;
                            Color vCol = _destructableData[x, y];
                            pos = new Vector2(x, y);
                            positions.Add(pos);

                            vel = new Vector2(e._partVel[ex, ey].X + direction.X, e._partVel[ex, ey].Y + direction.Y);
                            velocities.Add(vel);

                            colors.Add(vCol);
                        }
                        _destructableData[x, y] = new Color();
                    }
                    ex++;
                    part++;
                }

                ey++;
            }

            PrimalDevistation.Instance.PhysicsParticles.SpawnParticles(positions, velocities, colors);
        }