int CDotWars::onExecute() { currentTime = SDL_GetTicks(); if(onInit() == false) { return -1; } a.setColor(0, 0, 0xff); a.setPosition(50, 100); a.velocity.x = 0; a.velocity.y = 0; b.color = 0x00FF00FF; a.gravity = false; gravityOverlord.playerDot = &a; //da_overlord.mouseDot = &b; SDL_Event Event; while(running) { while(SDL_PollEvent(&Event)) { onEvent(&Event); } onLoop(); onRender(); } onCleanup(); return 0; }
void App::onExecute() { // run the main loop while (running) { onEvent(); onLoop(); onRender(); } }
void Diabolical::onExecute() { while (!eventQueue.empty()) { onEvent(eventQueue.front()); eventQueue.pop_front(); } onLoop(); onRender(); }
int CApp::onExecute() { if(onInit() == false) { return -1; } SDL_Event Event; Uint32 waitTime = 1000.0f/FPS; Uint32 frameStartTime = 0; Sint32 delayTime; Uint32 idleTime = 0; // kill any cursors that may be waiting in the beginning tuioClient->lockCursorList(); map< int, GnmsCursor*>::iterator it; for (it=gnmsCursors.begin(); it!=gnmsCursors.end(); it++) { if (it->second != NULL) { it->second->killCursor(); } } tuioClient->unlockCursorList(); // polling loop... i know it's old fashioned, // but it's so easy to implement while(isRunning == true) { // get events, react accordingly while(SDL_PollEvent(&Event)) { onEvent(&Event); } delayTime = waitTime - (SDL_GetTicks() - frameStartTime); onLoop(); if(delayTime > 0) { SDL_Delay((Uint32)delayTime); } frameStartTime = SDL_GetTicks(); onRender(); } onCleanup(); return 0; }
int GApp::onExecute(void) { if (onInit() == false) { return -1; } SDL_Event event; while (isRunning) { while (SDL_PollEvent(&event)) { onEvent(&event); onLoop(); onRender(); } } onCleanup(); return 0; }
int BallGame::OnExecute() { if(onInit() == false) { return -1; } SDL_Event Event; while(running) { while(SDL_PollEvent(&Event)) { onEvent(&Event); } onLoop(); if (onRender() == false) { return -1; } } onCleanup(); return 0; }
Server::Server(int argc, char **argv) : QCoreApplication(argc, argv) { state = new ServerState(); state->init(); counter = new QElapsedTimer(); loop = new QTimer(); connect(loop, SIGNAL(timeout()), this, SLOT(onLoop())); TICKS_PER_SECOND = 20; std::cout << "TICKS PER SECOND = " << TICKS_PER_SECOND << std::endl; SKIP_TICKS = 1000 / TICKS_PER_SECOND; MAX_FRAMESKIP = 10; counter->start(); next_game_tick = counter->elapsed(); loop->start(0); //QVariantMap map; //map.insert("login", "kabanov"); //map.insert("password", ""); //map.insert("uids", "1,2"); //API::gi().request("users.getInfo", map); }
int App::onExecute() { if (onInit() == false) { return -1; } SDL_Event event; timespec start, end; double elapsed; long waitusec; while (m_running) { clock_gettime(CLOCK_MONOTONIC, &start); while(SDL_PollEvent(&event)) { onEvent(&event); } onLoop(); onRender(); clock_gettime(CLOCK_MONOTONIC, &end); elapsed = double(end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec)/double(1000000000); if (elapsed < double(1/m_targetFps)) { waitusec = (double(1/m_targetFps) - elapsed) * 1000000; usleep(waitusec); } } onCleanup(); return 0; }
int JoltApp::doExecute() { if(!doInit()) { return -1; } SDL_Event evt; JoltConsole::logInfo("App","Starting game loop."); while(running) { while(SDL_PollEvent(&evt)) { onEvent(&evt); } onLoop(); onRender(); //JoltConsole::logInfo("Main","Loop called at %i", SDL_GetTicks()); } doCleanup(); return 0; }