How does one, if one does, handle an array of class identities with a pointer. Further more, how does one pass this to a function as a parameter.
I'd assuming that for the array I have to initialise the pointer, pass the data and then handle the new pointer with the function.
This is not what I'm looking to do however, as I simply want to pass the address of the array of classes to the function, and handle it's contents with a local pointer.
If this doesn't make sense, I cannot access the data of "Relatives" properly in the following code:
void Instance::Update(bool keyState[246], bool nodes[10][23], Instance (*Relatives)[250], int *pNextInstance)
{
if (type == Block)
{
if(fallTick < 15)
fallTick++;
else
{
for(int i = 0; i < 3; i++)
{
if (nodes[(int)Relatives[i]->x / 16][(int)Relatives[i]->y / 16 + 1] == false || y < 0)
{vObstruct = false; continue;}
else
{
ShowDebugMessages("Landed\n");
for (int j = 0; j < 4; j++)
{
int sizeArray[10][2];
sizeArray[sprite][1] = width;
sizeArray[sprite][2] = height;
*Relatives[*pNextInstance] = Instance(1, sprite, 0, 0, Relatives[j]->x, Relatives[j]->y, sizeArray, false);
nodes[(int)Relatives[j]->x / 16][(int)Relatives[j]->y / 16] = true;
Relatives[j]->y -= 160;
*pNextInstance++;
}
vObstruct = true;
break;
}
}
if (vObstruct == false)
{
Relatives[0]->y += 16;
Relatives[1]->y += 16;
Relatives[2]->y += 16;
Relatives[3]->y += 16;
fallTick = 0;
}
}
if(shiftTick < 4)
shiftTick++;
return;
}
}
Call to the function is as follows where Object is an 1D Array, size 250, of classes "Instance"
Object[1].Update(keyState, gridNodes, &Object, &nextInstance);
Regards,
Benson
If need be, I can repost the code commented out to show the workings of particular lines.

New Topic/Question
Reply



MultiQuote





|