This should be something really simple but I can't wrap my head around it. I'm using an engine with Time::GetSpeed() function. It returns a float based on what fraction of 60fps the game is running at. So it returns 1.0 at 60fps, 2.0 at 30fps, 4.0 at 15fps, 60.0 at 1fps, etc. That means you can use the function to adjust movement to compensate for different fps.
I tried to use it to write a simple jump code but it doesn't work and I'm not sure why. Here are the relevant lines:
if(window->KeyHit(Key::Space)) vy=0.8; // Jump if Space is hit
...
vy-=0.05*Time::GetSpeed(); // Add gravity every frame
y+=vy*Time::GetSpeed(); // Add velocity to y every frame
...
Sleep(1);
I then increase the Sleep function parameter to slow the game down. The problem is that the lower the fps gets, the lower the jump becomes. I also tried removing *Time::GetSpeed from the gravity line (seems like it's redundant) but then the character jumps really high when the fps gets low.
What am I doing wrong?