本文整理汇总了C++中CScene::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ CScene::Update方法的具体用法?C++ CScene::Update怎么用?C++ CScene::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CScene
的用法示例。
在下文中一共展示了CScene::Update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//***************************************************************
// 全更新
//***************************************************************
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: _tWinMain
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;
}