1
General / Re: How to implement character control with the mouse
« on: September 17, 2017, 07:04:35 pm »If the freezes/jerks come from your variable frametime you should read this very well written articel on how to fix this "issue"
I have "sf::Clock clock" then i get time
float time = clock.getElapsedTime().asMicroseconds();
clock.restart();
time = time / 800;
and i pass the received time in method "animation()"clock.restart();
time = time / 800;
float frame = 0.f;
void animation(float &time, Vector2f &totalMovement, int scale)
{
frame += 0.005 * time;
if (frame > 8)
frame -= 8;
sprite.setTextureRect(IntRect(127 * int(frame), scale, width, height));
cout << totalMovement.x << " " << totalMovement.y << " " << time << " " << speed << endl;
sprite.move(totalMovement * time * speed); // time - getted early "time" , speed = 0.001f
}
void animation(float &time, Vector2f &totalMovement, int scale)
{
frame += 0.005 * time;
if (frame > 8)
frame -= 8;
sprite.setTextureRect(IntRect(127 * int(frame), scale, width, height));
cout << totalMovement.x << " " << totalMovement.y << " " << time << " " << speed << endl;
sprite.move(totalMovement * time * speed); // time - getted early "time" , speed = 0.001f
}
And, yeah, i prined my totalMovement vector, its values <= 1 (like (x)0.95151 (y)0.307619 or (x)1 (y)-0.000951649), no, i dont have framelimit. But my character dont move at all, he only spins on the spot, and the animation starts with freezes.