How do I make sure that my game runs at the same speed on all computers? The problem occurred when i transferred my game project from my old laptop to my new one. The game runs too fast and is unplayable.
Game background: Its a small top-down car game with three ai's trying to shoot you down. Game ends when a bullet collides.
If any more information is required I'll be more than happy to share.
int main()
{
sf::Clock clock;
bool end_game= false;
initialize_cars();
initialize_bullets();
initialize_explosion_sprite();
while (window.isOpen())
{
sf::Event event;
if (window.pollEvent(event))
{
if (event.type== sf::Event::Closed || (event.type== sf::Event::KeyReleased) && (event.key.code== sf::Keyboard::Escape))
window.close();
}
move_cars();
set_bullet_timer(&clock);
move_bullets();
end_game= bullet_collision(&clock, &black_car, &blue_bullet);
if(end_game== true)
break;
end_game= bullet_collision(&clock, &black_car, &red_bullet);
if(end_game== true)
break;
for(int i=0; i<2; i++)
{
end_game= bullet_collision(&clock, &black_car, &green_bullet[i]);
if(end_game== true)
break;
}
if(end_game== true)
break;
window.clear(sf::Color::White);
display_cars();
display_bullets();
window.display();
}
return 0;
}