SpiderPig Posted February 4, 2023 Posted February 4, 2023 Is there a need for something like this in Ultra or is the game loop frequency manged by the engine as indicated by world::Update()'s frequency parameter? uint64_t time_span = 1000;//ms uint64_t time_interval = 100;//ms uint64_t start_time = Millisecs(); float range = 90.0f; float inc = range / (float)(time_span / time_interval); //loop auto result = 0.0f; uint64_t current_time = Millisecs(); if (current_time >= start_time + time_interval) { start_time = current_time; result += inc;//Should be approx 90.0f after a second } Quote
Solution Josh Posted February 4, 2023 Solution Posted February 4, 2023 You can, but since the update step is fixed, unlike Leadwerks, you can rely on each iteration occurring in intervals of 16.667 milliseconds. Quote My job is to make tools you love, with the features you want, and performance you can't live without.
SpiderPig Posted February 4, 2023 Author Posted February 4, 2023 I wonder if we could get the current update frequency of the world? I could probably store a variable for this somewhere myself actually but just wondering. float convertRPM(float rpm) { auto frequency = (world->update_frequency * 60.0f) / rpm; return 360.0f / frequency; } Quote
Josh Posted February 4, 2023 Posted February 4, 2023 That is probably a good idea, especially for self-contained entity component code. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without.
SpiderPig Posted February 4, 2023 Author Posted February 4, 2023 That's pretty much what I'm doing now. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.