are you sure your adding to the tanks forward correctly? i mean, if you want the tank to move forward (+z in tank space), and only add to the tanks z axis, it will move towards the +z in world space, no matter which way your tank is facing or how you rotated it. working with vectors for these kinds of things work well. so, when you rotate the tank, you should also rotate the tanks "forward" vector, then just add that forward vector to the tanks final position, something like this:
D3DXMATRIX matRot;
D3DXMATRIX matCenter;
D3DXMATRIX matScale;
D3DXMATRIX posZUnitVec;
D3DXVECTOR3 vecTankForward;
D3DXMatrixRotationYawPitchRoll(&matRot, D3DXToRadian(tankRotX), D3DXToRadian(0.0f), D3DXToRadian(0.0f));
D3DXMatrixTranslation(&posZUnitVec, 0.0f, 0.0f, 1.0f); // matrix holding position of vector pointing to positive z
D3DXMATRIX m = posZUinitVec * matRot;
vecTankForward = D3DXVECTOR3(m._41,m._42,m._43); // Get vector from the matrix
// move the tank forward (speed is the speed you want to move the tank every time this function is called)
tankPosX += speed * vecTankForward.x;
tankPosZ += speed * vecTankForward.z;
D3DXMatrixTranslation(&matCenter, 0.0f, 0.0f, 0.0f); // *** Rotation point ***
D3DXMatrixTranslation(&matPos, tankPosX, -240.0f, tankPosZ);
D3DXMatrixScaling(&matScale, 1.0f, 1.0f, 1.0f);
d3ddev->SetTransform(D3DTS_WORLD, &(matScale * matCenter * matRot * matPos));
Edited by iedoc, 06 May 2012 - 10:13 PM.