Hi All,
Since today I've added a strafing to my camera in my OpenGL engine,
when I use free mouselook and don't strafe, there's no problem, the other way around also.
But when I look with the mouselook and after that try to strafe, the strafing doesn't work anymore.
Here's code:
Strafe:
if(input->buffer[DIK_A] || input->buffer[DIK_LEFT] & 0x80)
{
scene->cam->xpos -= (float)sin(scene->cam->heading+(1*90)*piover180) * scene->cam->speed;
scene->cam->zpos -= (float)cos(scene->cam->heading+(1*90)*piover180) * scene->cam->speed;
}
if(input->buffer[DIK_D] || input->buffer[DIK_RIGHT] & 0x80)
{
scene->cam->xpos -= (float)sin(scene->cam->heading+(-1*90)*piover180) * scene->cam->speed;
scene->cam->zpos -= (float)cos(scene->cam->heading+(-1*90)*piover180) * scene->cam->speed;
}
And here's the free mouselook code:
GetCursorPos(&mpos);
SetCursorPos(screenwidth/2, screenheight/2);
*_camheading += (float)(screenwidth/2 - mpos.x) * _speed;
*_camyrot = *_camheading;
*_camxrot -= (float)(mpos.y - screenheight/2) * _speed;
If someone has some good advice, please tell me.
Thank you in advance.