I get a fatal error when the following lines are run. foe is an array of objects (representing monsters in a game I'm making), nummonsters is the number of monsters in that array. When they are destroyed, I run this loop to remove the dead monsters (by swapping their position with the last one, and reducing the scope of the array).
Does the following look ok?
I have never used the 'foe[i]=foe[nummonsters]' thing before. Must I manually assign each variable :Code:for (int i=0; i<nummonsters; i++){ if (foe[i]->hp<=0) {foe[i]=foe[nummonsters]; nummonsters--; return;} }
etc.Code:foe[i]->a=foe[nummonsters->a; foe[i]->b=foe[nummonsters->b; foe[i]->c=foe[nummonsters->c;



LinkBack URL
About LinkBacks



