Hi!
I have a Windows (12 cores) machine and a Linux (1st gen i5 dual core) machine...
on windows my tick's deltatime tooks 0.0s, on Linux it tooks 0.045s
when i want to move a sprite i calculate the current position * speed * deltatime,... but deltatime on Windows is 0 (i don't know may be is really so fast in make inbetween operations...) the result is on Windows there is no movement at all..
This is my code:
void juego::tick(){
while (rw.isOpen()){
if (escena_actual){
std::clock_t clk = std::clock(); //clock starts (time is 0.0f)
rw.clear(sf::Color::White);
if (!escena_actual->hasFinished){
sf::Event e;
escena_actual->gameplay(e, dt(clk)); //n1
if (cortina->current_state == fader::eEstado::cerrada)
cortina->abrir(rw, dt(clk));
} else {
cortina->cerrar(rw, dt(clk));
if (cortina->current_state == fader::eEstado::cerrada)
cargar_escena();
}
for (basic_actor*& a : escena_actual->get_vbasic_actors())
rw.draw(a->get_spr());
rw.draw(cortina->get_spr());
rw.display();
}
}
}
n1 : the dt(clk) is a function that returns a const float which it is deltatime that is located on juego.h
inline const float dt(std::clock_t& _clk) {
//current second - second passed by argument
//on Windows this is 0, on Linux it is 0.045
return (std::clock() - _clk) / (float) CLOCKS_PER_SEC;
}
Then to move my sprites:
//_dt is a reference for returned dt(clk), as on windows is 0 then there is no movement.
clouds->get_spr().move(C_CLOUD_SPEED * _dt, 0);
May i'm calculating deltatime incorrectly ?
Windows compiler is msvc 2017 32bits
Linux compiler is GCC 64bits