title: How to move relatively to the angle?
body: <p>I keep looking up on the internet how to move from point A to point B on an angle with a specified distance. When I tried to code it, however, the camera just gets messed up and I'm moving in random directions. I am using SDL/OpenGL with c++ and this is my player function. Right now, I'm trying to get the player to move forwards along the angle.</p>
  
  <pre><code>void player_action()
  {
  
      if (SDL_PollEvent(&amp;event))
      {
          switch (event.type)
          {
              case SDL_MOUSEMOTION:
                  {
                      player.rotxl = (screen-&gt;w)/2;
                      player.rotxd = event.motion.x - player.rotxl;
                      player.rotx = player.rotx + (player.rotxd/4);
                      if (player.rotx &lt; 0)
                      {
                          player.rotx = player.rotx + 360;
                      };
                      if (player.rotx &gt; 360)
                      {
                          player.rotx = player.rotx - 360;
                      }
                  };
              break;
  
              case SDL_KEYDOWN:
                  switch (event.key.keysym.sym)
                  {
                      case SDLK_w:
                          {player.zvel = 8.0f;}; break;
                      case SDLK_a:
                          {player.xvel = 8.0f;}; break;
                      case SDLK_s:
                          {player.zvel = -8.0f;}; break;
                      case SDLK_d:
                          {player.xvel = -8.0f;}; break;
                      case SDLK_ESCAPE:
                          {running = false;}; break;
                      default: break;
  
                  }; break;
  
              case SDL_KEYUP:
                  switch(event.key.keysym.sym)
                  {
                      case SDLK_w:
                          {player.zvel = 0.0f;}; break;
                      case SDLK_a:
                          {player.xvel = 0.0f;}; break;
                      case SDLK_s:
                          {player.zvel = 0.0f;}; break;
                      case SDLK_d:
                          {player.xvel = 0.0f;}; break;
                      default: break;
                  };
              break;
          };
  
      };
  
      player.x = player.x + float(player.zvel*cos((double)player.rotx));
      player.z = player.z + float(player.zvel*sin((double)player.rotx));
  
      glRotatef(player.rotx, 0.0f, 1.0f, 0.0f);
      glTranslatef(player.x, player.y, player.z);
  
      SDL_WarpMouse((screen-&gt;w/2), (screen-&gt;h/2));
  };
  </code></pre>