Moving on the Z axis

I am creating a first-person shooter, and in my idle function I put:
xpos += speed*cos((Pi/180)xangle));
ypos += speed
They allow my pivitol point to “travel” with me, but I still need another equation for the z axis!

I believe its something like cos(n_angle)*sin(m_angle) where n_angle and m_angle are one of the 3 components of your orientation.

So n_angle and m_angle are theta and phi? But how would I convert it to the cartesian plane?