1. ## Time Dependent Movement?

Hi I got my little paddle object and player working together to move around, and it does what I want it to except it does it at whatever frame rate the window is going at, (alot I assume). So when I tell my paddle to move up it flies off the screen, how do I make the movement updates time dependent?

My project is based off of Nehe's Lesson 1

Player.h
Code:
```#include "vector2.h"
class Player
{
public:
vector2 location;

const vector2 & get_position() const { return location; }

Player()
{
location.x = 0;
location.y = 0;
}
{
}
{
location += direction;
}
};

Player player;```

Code:
```#include "vector2.h"
{
public:

void draw(vector2 vec)
{
glTranslatef(vec.x,vec.y,-100.0f);
glVertex3f(-1.0f, -5.0f,  1.0f);	// Bottom Left Of The Texture and Quad
glVertex3f( 1.0f, -5.0f,  1.0f);	// Bottom Right Of The Texture and Quad
glVertex3f( 1.0f,  5.0f,  1.0f);	// Top Right Of The Texture and Quad
glVertex3f(-1.0f,  5.0f,  1.0f);	// Top Left Of The Texture and Quad
glEnd();
}
};```

2. So don't make direction so big, or multiply it by the time-step involved.

3. You will need a time delta:

Code:
```LARGE_INTEGER freq;
LARGE_INTEGER lastTime;
LARGE_INTEGER nowTime;

QueryPerformanceFrequency(&freq);
...
...
QueryPerformanceCounter(&lastTime);
while (inGame)
{
QueryPerformanceCounter(&nowTime);

Render();
Update(timeDelta);

lastTime = nowTime;
}```
Now multiply all movements by the timeDelta passed to Update(). I would imagine something like this:

Code:
```GameApp::Update(float timeDelta)
{
m_pScene->Update(timeDelta);
...
}```

4. Thanks bubba I'll use the information you gave me in conjunction with this tidbit I found on google: Precise (and simple!) timer using time.h - C++ - Source Code | DreamInCode.net

5. First question, is this what you meant? Second off am I doing this right? I'm getting an error
binary '*' : 'vector2' does not define this operator or a conversion to a type acceptable to the predefined operator

Code:
```#include "vector2.h"
#include "time.h"
time_t timer;
class Player
{
public:
vector2 location;

const vector2 & get_position() const { return location; }

Player()
{
location.x = 0;
location.y = 0;
}
{
}
{
location += direction * time(&timer) * 1;

}
};

Player player;```

6. Around this time I will also note a bit of an oddity.

Only when I move in the right direction it flies off screen now, it appears as up down and left are working.

That is when I remove the extra silliness from the move function i just added.

7. Code:
```void move_paddle(vector2 direction)
{
location += direction * time(&timer) * 1;
}```
What is this? Are you going to recompute your delta for every object? If you do your system will fail 100% because each delta will be slightly different. Compute your delta once before calling update and then use that delta for ALL objects.

It's as simple as this:

Code:
```...
m_vecPosition += m_vecVelocity * timeDelta;```
Or:

Code:
```...
ComputeForces();
RigidBody.Accel = RigidBody.Force / RigidBody.Mass;
RigidBody.Velocity += RigidBody.Accel * timeDelta;
RigidBody.Position += RigidBody.Velocity * timeDelta;
...```
This does not take into account friction or drag which 'normally' act in the exact opposite direction of velocity.

But regardless if you are simulating physics or just moving things across the screen arbitrarily you will always multiply by the timeDelta which is expressed in seconds.

8. Bubba thank you yet again for pointing out the obvious (in all seriousness)