Пример #1
0
//***************************************************************
//	全更新
//***************************************************************
void	CScene::UpdateAll(void)
{
	//ポインタ宣言
	CScene	*pScene;

	for(int	nCount = 0 ; nCount < MAX_LIST ; nCount++)
	{
		pScene = m_apTop[nCount];
		while(pScene)
		{
			//次のオブジェクトへのポインタを保存
			CScene	*pSceneNext = pScene->m_pNext;

			//更新
			pScene->Update();

			//次のオブジェクトを代入
			pScene = pSceneNext;
		}
	}

	for(int	nCount = 0 ; nCount < MAX_LIST ; nCount++)
	{
		pScene = m_apTop[nCount];
		while(pScene)
		{
			//次のオブジェクトへのポインタを保存
			CScene	*pSceneNext = pScene->m_pNext;

			//死亡フラグが成立している場合
			if(pScene->m_bDelete)
			{
				//リストの先頭の場合
				if(pScene == m_apTop[pScene->m_nPriority])
				{
					//先頭にリリース対象の次のアドレスを入れる
					m_apTop[pScene->m_nPriority] = pScene->m_pNext;

					//リストの残りが複数の時
					if(pScene->m_pNext != NULL)
					{
						pScene->m_pNext->m_pPrev = NULL;
					}
				}
				//リストの最後の場合
				else	if(pScene == m_apCur[pScene->m_nPriority])
				{
					m_apCur[pScene->m_nPriority] = pScene->m_pPrev;
					pScene->m_pPrev->m_pNext = NULL;
				}
				//それ以外
				else
				{
					pScene->m_pPrev->m_pNext = pScene->m_pNext;
					pScene->m_pNext->m_pPrev = pScene->m_pPrev;
				}

				//解放処理
				pScene->Uninit();
				delete	pScene;
			}

			//次のオブジェクトを代入
			pScene = pSceneNext;
		}
	}
}
Пример #2
0
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPTSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

#ifdef _DEBUG // 디버그용 콘솔창
	CPrintLog pPrintLog;
	pPrintLog.Init();
	printf_s("CONSOLE WINDOW OPENED\n");
#endif // _DEBUG

	CMainWindow & window = CMainWindow::GetInstance();

	if ( ! window.Create( L"Meteor", WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX ) )
		return 0;

	window.ShowWindow( nCmdShow );

#ifdef _DEBUG	// TODO: Remove test code
	CD2DRenderer::GetInstance().Init();
	CScene * scene = new CScene();
	CD2DText * text = new CD2DText();
	text->SetFont( L"굴림", 12.f );

	// FPS Calculation
	DWORD startTime = timeGetTime();
	DWORD lastTime = startTime;

	DWORD elapsedTimeSum = 0;
	DWORD elapsedTimeSum1 = 0;
	DWORD frameCount = 0;
	DWORD frameCount1 = 0;
	double framePerSecond = 0;
#endif

	MSG msg = {};

	// Main message loop:
	while ( msg.message != WM_QUIT )
	{
		if ( msg.message == WM_DESTROY )
		{
			SafeDelete( text );
			SafeDelete( scene );
		}

		if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

#ifdef _DEBUG	// TODO: Remove test code
		DWORD currentTime = timeGetTime();
		DWORD elapsedTime = currentTime - lastTime;

		elapsedTimeSum += elapsedTime;
		frameCount++;
		if ( elapsedTimeSum >= 1000 )
		{
			framePerSecond = ( frameCount + frameCount1 ) * 1000.0f / ( elapsedTimeSum + elapsedTimeSum1 );
			elapsedTimeSum1 = elapsedTimeSum;
			elapsedTimeSum = 0;
			frameCount1 = frameCount;
			frameCount = 0;
		}

		//if ( elapsedTime > ( 1000 / 60 ) )
		{
			CInputManager::GetInstance().UpdateKeyState();
			scene->Update( static_cast<float>(currentTime - lastTime) );
			CD2DRenderer::GetInstance().Begin();
			CD2DRenderer::GetInstance().Clear();
			scene->Render();

			wchar_t wstrbuf[16];
			swprintf_s( wstrbuf, L"Fps: %.2f",  framePerSecond );
			text->SetText( std::wstring(wstrbuf) );
			text->Render();

			CD2DRenderer::GetInstance().End();
			lastTime = currentTime;
		}
#endif
	}

	return (int) msg.wParam;
}