void SdlApp::OnUpdate() { static int tickCount = 0; tickCount = JGEGetTime(); int64_t dt = (tickCount - lastTickCount); lastTickCount = tickCount; if(g_engine->IsDone()) { SDL_Event event; event.user.type = SDL_QUIT; SDL_PushEvent(&event); } try { g_engine->SetDelta((float)dt / 1000.0f); g_engine->Update((float)dt / 1000.0f); } catch(out_of_range& oor) { cerr << oor.what(); } if(g_engine) g_engine->Render(); SDL_GL_SwapBuffers(); }
bool InitGame(void) { g_engine = JGE::GetInstance(); g_app = g_launcher->GetGameApp(); g_app->Create(); g_engine->SetApp(g_app); #ifdef ANDROID DebugTrace("Can I Set JNI Params ?"); if (mJNIEnv) DebugTrace("mJNIEnv is ok"); if (mJNIEnv && mJNIClass) { DebugTrace("Setting JNI Params"); g_engine->SetJNIEnv(mJNIEnv, *mJNIClass); } #endif JRenderer::GetInstance()->Enable2D(); lastTickCount = JGEGetTime(); return true; }
// returns number of milliseconds since game started int JGE::GetTime() { return JGEGetTime(); }