I have a variable which is of type milliseconds and i want to set it equal to an equation. Here is what ive done so far. It compiles and runs but when it hits this line it stops entering the if statement below.
time = duration<int>(750-(lvl*50));
another thing to note is that i do have an if statement which may also be part of the issue that i'm comparing different data types. here is that if statement:
if(time_since_last >= time) {
the time since last variable is the difference in time of different 2 high_resolution_clock::now()
You can try something like this. For converting an integer value to chrono in milliseconds use std::chrono::milliseconds(value);
auto old_time = std::chrono::high_resolution_clock::now();
this_thread::sleep_for(chrono::milliseconds(500));
auto new_time = std::chrono::high_resolution_clock::now();
auto time_since_last = std::chrono::duration_cast<chrono::milliseconds>(new_time - old_time);
cout << time_since_last.count();
int value = 1000;
auto time = std::chrono::milliseconds(value);
cout << " " <<time.count();
if (time_since_last >= time) {
/* do something */
}