コード例 #1
0
ファイル: main.cpp プロジェクト: millvis/nxengine-libretro
static bool gameloop(void)
{
	//uint32_t gametimer;

	//gametimer = -GAME_WAIT*10;

	if(game.switchstage.mapno < 0)
	{
		run_tick();
		return true;
	}
	else
		return false;
}
コード例 #2
0
void gameloop(void)
{
int32_t nexttick = 0;

	game.switchstage.mapno = -1;
	
	while(game.running && game.switchstage.mapno < 0)
	{
		// get time until next tick
		int32_t curtime = SDL_GetTicks();
		int32_t timeRemaining = nexttick - curtime;
		
		if (timeRemaining <= 0 || game.ffwdtime)
		{
			run_tick();
			
			// try to "catch up" if something else on the system bogs us down for a moment.
			// but if we get really far behind, it's ok to start dropping frames
			if (game.ffwdtime)
				game.ffwdtime--;
			
			nexttick = curtime + GAME_WAIT;
/*			
			// pause game if window minimized
			if ((SDL_GetAppState() & VISFLAGS) != VISFLAGS)
			{
				AppMinimized();
				nexttick = 0;
			}
*/
		}
		else
		{
			// don't needlessly hog CPU, but don't sleep for entire
			// time left, some CPU's/kernels will fall asleep for
			// too long and cause us to run slower than we should
			timeRemaining /= 2;
			if (timeRemaining)
				SDL_Delay(timeRemaining);
		}
	}
}
コード例 #3
0
ファイル: main.cpp プロジェクト: binji/nacl-nxengine
void gameloop(void)
{
uint32_t gametimer;

	gametimer = -GAME_WAIT*10;
	game.switchstage.mapno = -1;
	
	while(game.running && game.switchstage.mapno < 0)
	{
		uint32_t curtime = SDL_GetTicks();
		
		if ((curtime - gametimer >= GAME_WAIT) || game.ffwdtime)
		{
			run_tick();
			
			// try to "catch up" if something else on the system bogs us down for a moment.
			// but if we get really far behind, it's ok to start dropping frames
			if (game.ffwdtime)
			{
				gametimer = curtime;
				game.ffwdtime--;
			}
			else if ((curtime - gametimer > (GAME_WAIT * 3)))
			{
				gametimer = curtime;
			}
			else
			{
				gametimer += GAME_WAIT;
			}
			
			// pause game if window minimized
			if ((SDL_GetAppState() & VISFLAGS) != VISFLAGS)
			{
				AppMinimized();
				gametimer = SDL_GetTicks();
			}
		}
	}
}