I'm trying to get my first moving projection (camera) and I'm having some troubles with moving left and right it seems to not be as easy as +90 degrees, Okay I'll jump into the details of what this means. The camera_angle contains the angles from -180 through to 180, moving the mouse a pixel to the left will cause the angle to decrease. the camera_position is the position which the camera is located. Simple really, probably didn't even need to explain.
Does anyone have a reason why adding 90 will not work? or as least correctly. Thank you for any help possible
if(GetAsyncKeyState(0x57)){
// W
camera_position.x += sin(camera_angle.x * PI / 180) * 2 - 1;
camera_position.z += cos(camera_angle.x * PI / 180) * 2 - 1;
}
if(GetAsyncKeyState(0x41)){
// A
camera_angle.x -= 90;
camera_position.x += sin(camera_angle.x * PI / 180) * 2 - 1;
camera_position.z += cos(camera_angle.x * PI / 180) * 2 - 1;
camera_angle.x += 90;
}
if(GetAsyncKeyState(0x53)){
// S
camera_position.x -= sin(camera_angle.x * PI / 180) * 2 - 1;
camera_position.z -= cos(camera_angle.x * PI / 180) * 2 - 1;
}
if(GetAsyncKeyState(0x44)){
// D
camera_angle.x += 90;
camera_position.x += sin(camera_angle.x * PI / 180) * 2 - 1;
camera_position.z += cos(camera_angle.x * PI / 180) * 2 - 1;
camera_angle.x -= 90;
}