   std::list problem
  Can anyone tell me why this is crashing?, all i want todo is create boxes each time space is pressed and move away in the direction i tell it...  struct VecStruct{D3DXMATRIX Pos;D3DXVECTOR3 Dir;D3DXVECTOR3 FPos;float BulletTime;LPD3DXMESH Bullet;};if(fire){MessageBox(NULL,"Fire","",0);VecStruct vs;vs.Dir = RotToDir;vs.FPos = FinalPos; //position of shipLPD3DXMESH Bullet; D3DXCreateBox(d3ddev,0.05f,0.05f,0.05f,&Bullet,NULL);vs.Bullet = Bullet;vs.BulletTime = gTimeDelta;Vs.push_back(vs);fire = false;}std::list<VecStruct>::iterator i = Vs.begin();while( i != Vs.end() ){D3DXMatrixTranslation(&i->Pos,   i->Dir.x*(gTimeDelta-i->BulletTime)*1.0f,    i->Dir.y*(gTimeDelta-i->BulletTime)*1.0f,  i->Dir.z*(gTimeDelta-i->BulletTime)*1.0f);d3ddev->SetTransform(D3DTS_WORLD,&i->Pos);//D3DXVECTOR3 BPos(Vs.Pos._41,Vs.Pos._42,Vs.Pos._43);i->Bullet->DrawSubset(0);}
  Do you increment i somewhere?   ;  that was it thanks   ;  ive got another problem, now i want to delete the boxes so reading from my previous source codes it should be this but seems to be crashing..while( i != Vs.end() ){i->life += gTimeDelta;if(i->life >= 5.0f){i = Vs.erase(i);}D3DXMatrixTranslation(&i->Pos,   i->Dir.x*(gTimeDelta-i->BulletTime)*1.0f,    i->Dir.y*(gTimeDelta-i->BulletTime)*1.0f,  i->Dir.z*(gTimeDelta-i->BulletTime)*1.0f);d3ddev->SetTransform(D3DTS_WORLD,&i->Pos);//D3DXVECTOR3 BPos(Vs.Pos._41,Vs.Pos._42,Vs.Pos._43);i->Bullet->DrawSubset(0);i++;};  Since you erase the iterator if this was the last one in the list you could end up with Vs.end() after erase. In itself not incorrect but after that you dereference it without checking and also increment itSolution check for Vs.end() after the erase.   ;  Yeh thanks got it working , made a little video of the bullets collison :)http://www.youtube.com/user/Anddos25   ;  I actually didn't check what the code was doing. But now I see you store the bullets in a list and then update them every time. Very nice.   ;  It would be more idiomatic to move the rest of the loop body into an "else" statement, which means that you only test for the terminating condition once per iteration, and you also don't draw dead bullets:while( i != Vs.end() ){    i->life += gTimeDelta;    if(i->life >= 5.0f)    {   i = Vs.erase(i);    }    else    {   D3DXMatrixTranslation(&i->Pos,   i->Dir.x*(gTimeDelta-i->BulletTime)*1.0f,   i->Dir.y*(gTimeDelta-i->BulletTime)*1.0f,   i->Dir.z*(gTimeDelta-i->BulletTime)*1.0f);   d3ddev->SetTransform(D3DTS_WORLD,&i->Pos);   //D3DXVECTOR3 BPos(Vs.Pos._41,Vs.Pos._42,Vs.Pos._43);   i->Bullet->DrawSubset(0);   i++;    }};Quote:if(i->life >= 5.0f)Rather than increasing and testing against value, decrease it. At some point, one will want to either change value of maximum life, or use individual values for each item.i->life = 25f; // let it live for 25 frames....i->life -= dt;  // decrement it...if (i->life < 0.0f) {  // erase it}This solves bunch of problems down the road and allows more flexibility.   