# Thread: looking up and down (opengl)

1. ## looking up and down (opengl)

i am writing a camera class in opengl. ive done the x and z axis, but i cant seem to be able to get the y axis working correctly. here is what i have:
Code:
```#define FORWARD  0
#define BACKWARD 1
#define LEFT     2
#define RIGHT    3
#define UP       4
#define DOWN     5

class Camera{
public:
GLfloat angle;      //the angle to use for turning the camera
GLfloat x, y, z;    //camera position
GLfloat lx, ly, lz; //line of sight
GLfloat pitch;      //angle of the y axis

Camera(){
angle = 0.0f;
x = 0.0f; y = 0.0f; z = 0.0f;
lx = 0.0f; ly = 0.0f; lz = -1.0f;
pitch = 0.0f;
}

void Move( int direction ){
x = x + direction * lx * 0.1f;
z = z + direction * lz * 0.1f;
}

void Orient(){
lx = sin( angle );
lz = -cos( angle );
}

void ChangePitch(){
ly = sin( pitch ) * lz;
lz = cos( pitch ) * lz;
}

void move( int direction ){
switch( direction ){
case FORWARD:
Move( 1 );
break;
case BACKWARD:
Move( -1 );
break;
case LEFT:
angle -= 0.01f;
Orient();
break;
case RIGHT:
angle += 0.01f;
Orient();
break;
case UP:
if( pitch <= -1.0f ) break;
pitch -= 0.01f;
ChangePitch();
break;
case DOWN:
if( pitch >= 1.0f ) break;
pitch += 0.01f;
ChangePitch();
break;
default:
break;
}
}

void View(){