?
2012-08-19 15:38:57 UTC
(I have 2 vectors, one for objects, one for particles, I'll just show the particles since deleting is done in practically the same way)
What I have:
base.h:
class p_tem{
...
};
//par_sys is a pointer to the main vector that contains all of the particles
//oid is the index in the vector that the particle is
bool p_tem::onstep(vector
bool erased=false;
...
...
this->life--;
if(this->life==0){
par_sys->erase( par_sys->begin()+(oid-1) ) ;
erased=true;
};
return erased;
};
main.cpp:
int main(int argc, char** argv){
...
...
do{//Main loop
...
...
sti=0;
ishift=0;
if(psys.size()!=0){
do{
ishift=psys[sti].onstep(&psys, sti, map, mapwidth, mapheight);
sti++;
if(ishift==1){sti--;};
}while(sti
...
...
}while(brk==false);//End of main loop
...
...
return 0;
};
Also, I can't use anything that uses the algorithm header (like the remove/erase idiom) because it gives errors for unknown reasons when I try to use remove().