I am making a game like space invaders in C++ using the win32 api. I am a beginner. when I increase same speed across the screen no matter what the FPS is.
I use the and library to determine how many times the main apkqad games loops per second and use sleep_for() to add a delay to meet the desired FPS:
std::this_thread::sleep_for(std::chrono::milliseconds(targetFrameTime - elapsedTime));
I move objects in the main loop like this:
if (userInput.get_right_key_down()) {
rect_x = rect_x + 5;
}
I would rather not use thread if possible. I don’t really understand it and don’t know if I need it.