Ok let's start analysing the code, i found some issues im wondering about.
in the main program loop we find this
times = timeGetTime()*0.001f;//get current time in seconds
++frames; // update the frame rate 1ce per second
if (times-last_time>1.0f)
{
fps = frames/(times-last_time);
last_time = times;
frames = 0L;
}
Ok this is fine, but this should really be done once per frame like this.
First add a float called frametime
times = timeGetTime()*0.001f;//get current time in seconds
frametime= times-last_time;
fps = 1/frametime;
last_time = times;
next in update there is another mad thing your doing.
MoveDistance = 1.75f/(times*0.005f);
Now that we got this nice global called frame time we could at least use it.
MoveDistance = 1.75f/frametime);
I cant tell if 1.75 is the right speed, normaly i use a speed of 30-90, but i guess it depends on your scale.
Ok about the sliding, i think i found the bug in the main program loop.
the thing is that you only do disspatch one message per frame, you should do all of them per frame.
IT should be done something like this.
while (PeekMessage (&msg, window.hWnd, 0, 0, PM_REMOVE) != 0)
{
if (msg.message != WM_QUIT)
{
DispatchMessage (&msg);
}
else
{
ProgramLooping = false;
done = true;
}
}
Natuarly you should remove the DispatchMessage func after SwapBuffers (Win.hDC);
This will effectivly remove the escape key function, so add this in the update func.
if (KeyPressed[VK_ESCAPE] == TRUE)
{
TerminateApplication (g_window);
}
So why does this happen.
Well, it's simple realy, you can only disspach one message per frame, but at the same time create a message per frame while holding the key down, so the number of messages remain constant. But every now and then another message is created so the messages start's to stack up and it will take some time to get to the key up message.
(In theory atleast).
I hope this will help
[edited by - lc_overlord on September 28, 2003 5:30:07 PM]
"Skidding"
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement