MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / run

Method run

src/Core/Engine/Engine.cpp:247–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245 }
246
247 void Engine::run()
248 {
249 if (!m_initialized)
250 throw Exceptions::UnitializedEngine(EXC_INFO);
251
252 const std::string bootScript = "boot.lua"_fs;
253 if (bootScript.empty())
254 throw Exceptions::BootScriptMissing(
255 System::MountablePath::StringPaths(), EXC_INFO);
256 const sol::protected_function_result loadResult
257 = m_lua->safe_script_file(bootScript);
258
259 if (!loadResult.valid())
260 {
261 const auto errObj = loadResult.get<sol::error>();
262 throw Exceptions::BootScriptLoadingError(errObj.what(), EXC_INFO);
263 }
264 m_window->create();
265 const sol::protected_function bootFunction
266 = (*m_lua)["Game"]["Start"].get<sol::protected_function>();
267
268 const sol::protected_function_result bootResult = bootFunction.call();
269 if (!bootResult.valid())
270 {
271 const auto errObj = bootResult.get<sol::error>();
272 throw Exceptions::BootScriptExecutionError(
273 "Game.Start", errObj.what(), EXC_INFO);
274 }
275
276 while (m_window->isOpen())
277 {
278 m_framerate->update();
279
280 t_game->pushParameter("Update", "dt", m_framerate->getGameSpeed());
281 t_game->trigger("Update");
282
283 if (m_framerate->doRender())
284 t_game->trigger("Render");
285
286 this->update();
287 this->render();
288 }
289 }
290
291 Audio::AudioManager& Engine::getAudioManager()
292 {

Callers 1

startGameFunction · 0.45

Calls 15

updateMethod · 0.95
renderMethod · 0.95
UnitializedEngineClass · 0.85
BootScriptMissingClass · 0.85
safe_script_fileMethod · 0.80
getGameSpeedMethod · 0.80
doRenderMethod · 0.80
emptyMethod · 0.45
validMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected