/** * while (true) { // main game loop * // ... * * for (each gameObject) { * gameObject.PreAnimUpdate(dt); * } * * g_animationEngine.CalculateIntermediatePoses(dt); * * for (each gameObject) { * gameObject.PostAnimUpdate(dt); * } * * g_ragdollSystem.ApplySkeletonsToRagDolls(); * * g_physicsEngine.Simulate(dt); // runs ragdolls too * * g_collisionEngine.DetectAndResolveCollisions(dt); * * g_ragdollSystem.ApplyRagDollsToSkeletons(); * * g_animationEngine.FinalizePoseAndMatrixPalette(); * * for (each gameObject) { * gameObject.FinalUpdate(dt); * } * } */ void Application::run(Game& game) { createApplication(); double time = 1.0 / 60.0; clock.start(- time * 1000000.0); running = true; game.create(*this); while(running) { if(!processMessages()) break; clock.tick(); GameTime gameTime(clock.getElapsedTimeInMicroSec(), clock.getFps()); eventManager->updateEvents(); controllerManager->update(gameTime); game.update(gameTime); game.render(); swapBuffers(); } game.destroy(); destroyApplication(); }
int Application::Start(void) { _screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_SWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER); SDL_WM_SetCaption("My Test Game (SDL/OpenGL)", NULL); Uint32 start; SDL_Event event; InitGL(); while (_running) { start = SDL_GetTicks(); while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { _running = false; } if (event.type == SDL_MOUSEBUTTONDOWN) { _mousein = true; } KeyHandler(); } Render(); Update(); if (1000/GAME_FPS > (SDL_GetTicks()-start)) SDL_Delay(1000/GAME_FPS > (SDL_GetTicks()-start)); } destroyApplication(); return 0; }
GameFrameworkAndroid::~GameFrameworkAndroid() { destroyApplication(); }