MCPcopy Create free account
hub / github.com/EasyRPG/Player / MainLoop

Method MainLoop

src/player.cpp:230–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230void Player::MainLoop() {
231 Instrumentation::FrameScope iframe;
232
233 const auto frame_time = Game_Clock::now();
234 Game_Clock::OnNextFrame(frame_time);
235
236 Player::UpdateInput();
237
238 if (!DisplayUi->ProcessEvents()) {
239 Scene::PopUntil(Scene::Null);
240 Player::Exit();
241 return;
242 }
243
244 int num_updates = 0;
245 while (Game_Clock::NextGameTimeStep()) {
246 if (num_updates > 0) {
247 Player::UpdateInput();
248
249 if (!DisplayUi->ProcessEvents()) {
250 Scene::PopUntil(Scene::Null);
251 Player::Exit();
252 return;
253 }
254 }
255
256 Scene::old_instances.clear();
257 Scene::instance->MainFunction();
258
259 Graphics::GetMessageOverlay().Update();
260
261 ++num_updates;
262 }
263 if (num_updates == 0) {
264 // If no logical frames ran, we need to update the system keys only.
265 Input::UpdateSystem();
266 }
267
268 Player::Draw();
269
270 Scene::old_instances.clear();
271
272 if (!Transition::instance().IsActive() && Scene::instance->type == Scene::Null) {
273 Exit();
274 return;
275 }
276
277 if (Player::player_config.automatic_screenshots.Get() && FileFinder::Game()) {
278 auto diff = std::chrono::duration_cast<std::chrono::seconds>(Game_Clock::now() - last_auto_screenshot);
279 if (diff.count() >= Player::player_config.automatic_screenshots_interval.Get()) {
280 last_auto_screenshot = Game_Clock::now();
281 Output::TakeScreenshot(true);
282 }
283 }
284
285 auto frame_limit = DisplayUi->GetFrameLimit();
286 if (frame_limit == Game_Clock::duration()) {
287 return;

Callers

nothing calls this directly

Calls 9

GameClass · 0.85
MainFunctionMethod · 0.80
GetFrameLimitMethod · 0.80
EndMethod · 0.80
ProcessEventsMethod · 0.45
clearMethod · 0.45
UpdateMethod · 0.45
IsActiveMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected