Exemplo n.º 1
0
bool Game::Run()
{
	
	SplashScreen();

	LoadScreen();
	

	Initialize();
	_currentState=_pMenu;
	//_currentState = new Level1(_rWindow,_rSfmlDebugDraw,_pWorld,score);
	
	LoadContent();

	Clock timeElapsed;

	while ( _rWindow.isOpen() )
	{
		
		_rWindow.pollEvent(e);

		if ( e.type == Event::Closed )
		{
			_rWindow.close();
			UnloadContent();
			break;
		}

		if(e.type==Event::KeyPressed)
		{
			if(Keyboard::isKeyPressed(Keyboard::LAlt) && Keyboard::isKeyPressed(Keyboard::F4))
			{
				_rWindow.close();
				UnloadContent();
				break;
			}

			
		}
		
		HandleInput( e );

		//Time lastUpdateCall = timeElapsed.restart();

		if ( timeElapsed.getElapsedTime().asMilliseconds() >= timeStep)
		{
			Update( e, oldEvent, timeElapsed.restart() );
		}
	
		Time lastDrawCall = /*lastUpdateCall +*/ timeElapsed.getElapsedTime(); //.restart();

		Draw( _rWindow, lastDrawCall );

		oldEvent = e;
	}
	
	return true;
}
Exemplo n.º 2
0
Vehicle::~Vehicle()
{
	if (!m_shutdown)
	{
		UnloadContent();
	}
}
Exemplo n.º 3
0
//Releasing the main DirectX11 object
void Dx11DemoBase::Shutdown()
{
	UnloadContent();

	if( backBufferTarget_ ) backBufferTarget_->Release();
	if( swapChain_ ) swapChain_->Release();
	if( d3dContext_ ) d3dContext_->Release();
	if( d3dDevice_ ) d3dDevice_->Release();

	if( keyboardDevice_ )
	{
		keyboardDevice_ ->Unacquire();
		keyboardDevice_ ->Release();
	}


	if( mouseDevice_ )
	{
		mouseDevice_ ->Unacquire();
		mouseDevice_ ->Release();
	}


	if( directInput_ )directInput_ ->Release();

	d3dDevice_ = 0;
	d3dContext_ = 0;
	swapChain_ = 0;
	backBufferTarget_ = 0;
	keyboardDevice_ = 0;
	mouseDevice_ = 0;
	directInput_ = 0;
}
Exemplo n.º 4
0
void Game::Run()
{
	//if the game object fail to load then return before the loop is entered
	if(!LoadContent())
	{
		MessageBoxA(NULL, "Failed to load game objects", "ERROR!", MB_OK | MB_ICONERROR);
		return;
	}

	//Initalise the game timer
	m_system.GetGameTimer()->Reset();

	//The game loop is open until the system gets a WM_QUIT msg
	while(!m_system.Done() && !m_escape)
	{
		//starts the game timer
		m_system.GetGameTimer()->Tick();

		//Detect input
		m_system.GetDirectInput()->DetectInput();

		//Update the game
		Update(m_system.GetGameTimer()->GetDeltaTime());

		//change wireframe mode
		m_system.GetDX()->SetWireframeMode(m_wireframe);

		Render();
	}

	//Unload all the objects after the loop has closed
	UnloadContent();
}
Exemplo n.º 5
0
void Game::ExitScreen()
{
	//Exit Screen coding

	_rWindow.close();
	UnloadContent();
	
	exit(0);

}
Exemplo n.º 6
0
void ConsoleGame::Run()
{
	Initialize();

	while(!exitRequested)
	{
		Tick();
	}

	UnloadContent();
}
Exemplo n.º 7
0
// Called by destructor to unload and release allocated memory
void Dx11DemoBase::Shutdown()
{
    UnloadContent();
    if (backBufferTarget_) backBufferTarget_->Release();
    if (swapChain_) swapChain_->Release();
    if (d3dContext_) d3dContext_->Release();
    if (d3dDevice_) d3dDevice_->Release();
    backBufferTarget_ = 0;
    swapChain_ = 0;
    d3dContext_ = 0;
    d3dDevice_ = 0;
}
	//=============================================================================================================
	void CGodRayRenderer9::onlostdevice()
	{
		UnloadContent();

		memset(rendertargets, 0, sizeof(rendertargets));
		memset(surfaces, 0, sizeof(surfaces));

		Color = NULL;
		Occluders = NULL;

		CEffectRenderer9::onlostdevice();
	}
	//=============================================================================================================
	void CCausticsRenderer9::onlostdevice()
	{
		UnloadContent();
        
		for( size_t i = 0; i < distancemaps.size(); ++i )
			distancemaps[i].colors = distancemaps[i].distances = NULL;

		PhotonHits = NULL;
		Caustics = NULL;
		ShadowMap = NULL;
		
		CEffectRenderer9::onlostdevice();
	}
Exemplo n.º 10
0
//Releasing the main DirectX11 object
void Dx11DemoBase::Shutdown()
{
	UnloadContent();

	if( depthTexture_ ) depthTexture_ ->Release();
	if( depthStencilView_ ) depthStencilView_ ->Release();
	if( backBufferTarget_ ) backBufferTarget_->Release();
	if( swapChain_ ) swapChain_->Release();
	if( d3dContext_ ) d3dContext_->Release();
	if( d3dDevice_ ) d3dDevice_->Release();

	d3dDevice_ = 0;
	d3dContext_ = 0;
	swapChain_ = 0;
	backBufferTarget_ = 0;
	depthStencilView_ = 0;
	depthTexture_ = 0;
}
Exemplo n.º 11
0
	//=============================================================================================================
	void CGame10::Run()
	{
		bool success = Initialize();
		dassert(, "CGame10::Run(): Initialization failed", success);

		success = LoadContent();
		dassert(, "CGame10::Run(): Content creation failed", success);

		dsad("Most of the features are not yet implemented");
		ResetRenderStates();

		Sync.Timer().Start();
		Application.Show();

		valid = false;

		while( Application.Run() )
		{
			if( Application.Active() )
			{
				if( !valid )
				{
					valid = Validate();
				}
				else
				{
					if( fixedtimestep )
						Sync.Update();
					else
						Update();

					Draw();
				}
			}
			else
			{
				valid = false;
				Sleep(100);
			}
		}

		UnloadContent();
	}
ErrorPopUpScreen::~ErrorPopUpScreen(void)
{
    UnloadContent();
}
Exemplo n.º 13
0
GameSpriteDemo::~GameSpriteDemo(void)
{
  UnloadContent();
}