Goodday,
this is my first post ever, i have looked for a solution for a while but cant find what I need to know. Here goes:
We are creating a 3d game. The question still is whether it will be an online game or an offline game.
I am using C#, and in the 3d world i now have a cube and a sphere. The cube is like a long wall (very thin and long, man height). The sphere has the diameter of a man. It starts on top of one end of the wall, end the moves to the other end of the wall. I use the following function which i call in my main loop.
public void Move(int __speedFactor)
{
TV_3DVECTOR __scalemin = new TV_3DVECTOR();
TV_3DVECTOR __scalemax = new TV_3DVECTOR();
TV_3DVECTOR __position = _GlobeMesh.GetPosition();
_CubeMesh.GetBoundingBox(ref __scalemin,ref __scalemax);
if (__globeDirection == 0)
if (__scalemax.x > __position.x)
_GlobeMesh.SetPosition(__position.x + __speedFactor * 0.01F * (float)_Tv.TimeElapsed(), __position.y, __position.z);
else __globeDirection = 1;
else
if (__scalemin.x < __position.x)
_GlobeMesh.SetPosition(__position.x - __speedFactor * 0.01F * (float)_Tv.TimeElapsed(), __position.y, __position.z);
else __globeDirection = 0;
}
When i use alt-tab to stop the focus, there is no more rendering, it sleeps for a few hundred milliseconds, and then checks again for focus. But when I come back, the program moves the sphere again. But, since now more time has elapsed, the sphere is moved WAY further than the bounds between i want it to move (the length of the cube).
The question:
How do I make it so that when there is no focus, and the focus comes back, it throws away the time elapsed, and starts moving again from where it was before focus? Would it be wise to stop counting the time elapsed when stopping focus? Or would that give other problems later (given it could become an online game)?