Extremely Wierd Mouselook Problem!
Hey all,
Today, the leader of our project requested mouselook in the engine I'm creating. No problems, I said to myself. I'll just goto NeHe's site!
Anyways, I went to lesson 23 before, and read through it and tried it out (just the mouselook stuff, not DirectInput). The mouse works, looks up and down, left and right, etc. But there is a problem.
For some extremely wierd reason, my "walk forward" key will only walk in one direction. Even if I move the mouse, it will do anything to go in the direction. It's like there's a wall stopping it going the way I'm looking!
I've tried and tried, and can't get this to work!!! Maybe it's because I've implemented my own strafe function? I'll give you my code:
if (active)
{
if (keys[VK_PRIOR])
{
z-=0.02f;
}
if (keys[VK_NEXT])
{
z+=0.02f;
}
if (keys['W'])
{
xpos -= (float)sin(heading*piover180) * 0.20f;
zpos -= (float)cos(heading*piover180) * 0.20f;
if (walkbiasangle >= 359.0f)
{
walkbiasangle = 0.0f;
}
else
{
walkbiasangle+= 15;
}
walkbias = (float)sin(walkbiasangle * piover180)/20.0f;
}
if (keys['S'])
{
xpos += (float)sin(heading*piover180) * 0.10f;
zpos += (float)cos(heading*piover180) * 0.10f;
if (walkbiasangle <= 1.0f)
{
walkbiasangle = 359.0f;
}
else
{
walkbiasangle-= 10;
}
walkbias = (float)sin(walkbiasangle * piover180)/20.0f;
}
if (keys['D'])
{
strafeheading -= 0.10f;
strafe = strafeheading;
}
if (keys['A'])
{
strafeheading += 0.10f;
strafe = strafeheading;
}
if (keys[VK_PRIOR])
{
lookupdown-= 1.0f;
}
if (keys[VK_NEXT])
{
lookupdown+= 1.0f;
}
if (keys[VK_SPACE])
{
}
if (keys[VK_ESCAPE]) // does the user wanna exit?
{
done=TRUE;
}
else // they dont atm, continue rendering
{
RenderScene(); // Draw The Scene
SwapBuffers(hDC);
GetCursorPos(&mpos); // Get The Current Mouse Position ( Add )
SetCursorPos(320,240); // Set Mouse Position To Center Of The Window ( Add )
heading += (float)(320 - mpos.x)/100 * 5; // Update The Direction For Movement ( Add )
yrot = heading; // Update The Y Rotation ( Add )
lookupdown -= (float)(240 - mpos.y)/100 * 5; // Update The X Rotation ( Add )
}
}
Thanks in advance,
Luke.
[edited by - Luke Philpot on April 6, 2002 3:39:08 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement