Esempio n. 1
0
void BBWin8Game::Run(){

	if( CFG_WIN8_SCREEN_ORIENTATION & 1 ){
		_deviceRotation=0;
	}else if( CFG_WIN8_SCREEN_ORIENTATION & 2 ){
		_deviceRotation=1;		
	}else if( CFG_WIN8_SCREEN_ORIENTATION & 4 ){
		_deviceRotation=2;		
	}else if( CFG_WIN8_SCREEN_ORIENTATION & 8 ){
		_deviceRotation=3;
	}else{
		_deviceRotation=0;
	}

	ValidateOrientation();

	StartGame();
	
	for(;;){
	
		if( _updateRate==60 ){
			PollEvents();
			UpdateGame();
			RenderGame();
			continue;
		}
	
		if( !_updateRate || _suspended ){
			RenderGame();
			WaitEvents();
			continue;
		}
		
		double time=GetTime();
		if( time<_nextUpdate ){
			Sleep( _nextUpdate-time );
			continue;
		}
		
		PollEvents();
				
		int updates=0;
		for(;;){
			_nextUpdate+=_updatePeriod;
			
			UpdateGame();
			if( !_updateRate ) break;
			
			if( _nextUpdate>GetTime() ){
				break;
			}
			
			if( ++updates==8 ) break;
		}
		RenderGame();
		if( updates==8 ) _nextUpdate=GetTime();
	}
}
Esempio n. 2
0
void BBWin8Game::Run(){

	DisplayOrientations prefs=DisplayOrientations::None;
	if( CFG_WIN8_SCREEN_ORIENTATION & 1 ) prefs=prefs|DisplayOrientations::Portrait;
	if( CFG_WIN8_SCREEN_ORIENTATION & 2 ) prefs=prefs|DisplayOrientations::Landscape;
	if( CFG_WIN8_SCREEN_ORIENTATION & 4 ) prefs=prefs|DisplayOrientations::PortraitFlipped;
	if( CFG_WIN8_SCREEN_ORIENTATION & 8 ) prefs=prefs|DisplayOrientations::LandscapeFlipped;
	if( prefs==DisplayOrientations::None ) prefs=DisplayProperties::CurrentOrientation;
	
	Windows::Graphics::Display::DisplayProperties::AutoRotationPreferences=prefs;

	int orientation;
	for( orientation=0;orientation<4 && !(CFG_WIN8_SCREEN_ORIENTATION & (1<<orientation));++orientation ) {}
	if( orientation==4 ) orientation=DeviceOrientation();

#if WINDOWS_8
	_deviceRotation=(orientation-1)&3;
#elif WINDOWS_PHONE_8
	_deviceRotation=orientation;
#endif	

	ValidateOrientation();
	
	StartGame();
	
	for(;;){
	
		if( _updateRate==60 ){
			PollEvents();
			UpdateGame();
			RenderGame();
			continue;
		}
	
		if( !_updateRate || _suspended ){
			RenderGame();
			WaitEvents();
			continue;
		}
		
		double time=GetTime();
		if( time<_nextUpdate ){
			Sleep( _nextUpdate-time );
			continue;
		}
		
		PollEvents();
				
		int updates=0;
		for(;;){
			_nextUpdate+=_updatePeriod;
			
			UpdateGame();
			if( !_updateRate ) break;
			
			if( _nextUpdate>GetTime() ){
				break;
			}
			
			if( ++updates==8 ) break;
		}
		RenderGame();
		if( updates==8 ) _nextUpdate=GetTime();
	}
}