Skip to main content
added 856 characters in body
Source Link

Your pixelOffset calculations are inconsistent...

int pixelOffset = y + normX * 51;

is different than...

int j = x + normX;
int i = y + normY;
int pixelOffset = j + i * 51;

One uses x * 51 + y and the other uses y * 51 + x.

EDIT You are also reusing variable i and y.
I think you want your blast circle to be based on your outer y value in addition to the inner. Notice y + yy + normY below.

            // blast a circle around that bullet hit position
            int radius = 9;
            for (int yy = -radius; yy <= radius; yy++)
            {
                for (int xx = -radius; xx <= radius; xx++)
                {
                    if (xx*xx + yy*yy <= radius*radius)
                    {
                        int jj = xx + normX;
                        int ii = y + yy + normY;
                        int pixelOffset = jj + ii * 51;
                        ptr[pixelOffset] = 0xff000000;
                    }
                }
            }

Your pixelOffset calculations are inconsistent...

int pixelOffset = y + normX * 51;

is different than...

int j = x + normX;
int i = y + normY;
int pixelOffset = j + i * 51;

One uses x * 51 + y and the other uses y * 51 + x.

Your pixelOffset calculations are inconsistent...

int pixelOffset = y + normX * 51;

is different than...

int j = x + normX;
int i = y + normY;
int pixelOffset = j + i * 51;

One uses x * 51 + y and the other uses y * 51 + x.

EDIT You are also reusing variable i and y.
I think you want your blast circle to be based on your outer y value in addition to the inner. Notice y + yy + normY below.

            // blast a circle around that bullet hit position
            int radius = 9;
            for (int yy = -radius; yy <= radius; yy++)
            {
                for (int xx = -radius; xx <= radius; xx++)
                {
                    if (xx*xx + yy*yy <= radius*radius)
                    {
                        int jj = xx + normX;
                        int ii = y + yy + normY;
                        int pixelOffset = jj + ii * 51;
                        ptr[pixelOffset] = 0xff000000;
                    }
                }
            }
Source Link

Your pixelOffset calculations are inconsistent...

int pixelOffset = y + normX * 51;

is different than...

int j = x + normX;
int i = y + normY;
int pixelOffset = j + i * 51;

One uses x * 51 + y and the other uses y * 51 + x.