How to make void UpDate in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

How to make void UpDate in c++

Clever people! pleas help me, how to make void UpDate (like in Unity) on c++ ?? Update- void who is updated every frame.

29th Aug 2018, 5:21 PM
Maslov Denis
Maslov Denis - avatar
8 Answers
+ 3
hinanawi Thanks for the help, I measured the incrementing method and from 0 to 1000 for 12.5 seconds = (+ -78) fps, okay, thanks for the answers, i will try find the answer )))
30th Aug 2018, 12:00 PM
Maslov Denis
Maslov Denis - avatar
+ 1
Maslov Denis I am sorry but I didn't get your point...could you please elaborate it?
30th Aug 2018, 1:28 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
Ketan Lalcheta Sure. I asked how to make a UpDate function in the language c ++. The UpDate function is a function that work again every frame. For example, if 60 fps, then the Update worked 60 times per second. That function works like infinity loop. Sorry about my English...
30th Aug 2018, 6:35 AM
Maslov Denis
Maslov Denis - avatar
+ 1
well you would just have a while(true) loop and use the wait() method at the start to help with the delay. however mind that different computers run at different speeds so the code won't be consistent. also it won't work on sololearn, just a heads-up.
30th Aug 2018, 11:31 AM
hinanawi
hinanawi - avatar
+ 1
hinanawi thank you for your answer, but I tested this with a loop for(;;) on different PCs. an average of 78 values per second. So I have two questions: how can I exit the endless loop by pressing Enter, for example. And the second, is how to tie a cycle to the deltaytime?
30th Aug 2018, 11:45 AM
Maslov Denis
Maslov Denis - avatar
+ 1
Maslov Denis well while the program is waiting, it won't take key-presses, so i don't exiting the loop that way is possible (afaik) as for the second question i'm not sure what you mean by cycle in this case, could you elaborate?
30th Aug 2018, 11:47 AM
hinanawi
hinanawi - avatar
+ 1
hinanawi sorry about my english, in second question I meant that on different computers the cycle speed was the same
30th Aug 2018, 11:53 AM
Maslov Denis
Maslov Denis - avatar
+ 1
Maslov Denis well i don't know if it's possible to detect the rate of the CPU clock on any given computer (you might wanna do research on that) so i recommend you use a program like unreal engine which possibly has something like UpDate from unity built in
30th Aug 2018, 11:55 AM
hinanawi
hinanawi - avatar