void CGameFrameWork::FrameAdvance() { ProcessInput(); AnimateObjects(); Render(); }
void CGameFramework::FrameAdvance() { //타이머의 시간이 갱신되도록 하고 프레임 레이트를 계산한다. m_GameTimer.Tick(); ProcessInput(); AnimateObjects(); float fClearColor[4] = { 0.0f, 0.125f, 0.3f, 1.0f }; m_pd3dDeviceContext->ClearRenderTargetView(m_pd3dRenderTargetView, fClearColor); if (m_pPlayer) m_pPlayer->UpdateShaderVariables(m_pd3dDeviceContext); CCamera *pCamera = (m_pPlayer) ? m_pPlayer->GetCamera() : NULL; if (m_pScene) m_pScene->Render(m_pd3dDeviceContext, pCamera); m_pDXGISwapChain->Present(0, 0); m_GameTimer.GetFrameRate(m_pszBuffer + 12, 37); ::SetWindowText(m_hWnd, m_pszBuffer); }
void AnimationTimerProc(HWND hwnd, UINT timer) { Bool need_redraw = False; static DWORD last_animate_time = 0; DWORD dt, now; PingTimerProc(hwnd, 0, 0, 0); if (!(GameGetState() == GAME_PLAY || GameGetState() == GAME_SELECT)) return; if (last_animate_time == 0) { last_animate_time = timeGetTime(); return; } config.quickstart = FALSE; now = timeGetTime(); dt = now - last_animate_time; last_animate_time = now; timeLastFrame = dt; /* Send event to modules */ ModuleEvent(EVENT_ANIMATE, dt); /* Send event to non-module child windows */ if (config.animate) { Lagbox_Animate(dt); } /* Animate the first-person view elements */ if (config.animate && GetGameDataValid()) { // Avoid short-circuiting OR need_redraw |= ObjectsMove(dt); need_redraw |= ProjectilesMove(dt); need_redraw |= AnimateObjects(dt); need_redraw |= AnimateRoom(¤t_room, dt); need_redraw |= AnimateProjectiles(dt); need_redraw |= AnimatePlayerOverlays(dt); need_redraw |= AnimateBackgroundOverlays(dt); AnimateDescription(dt); need_redraw |= AnimateEffects(dt); if (need_redraw) RedrawAll(); } if (GetGameDataValid()) RedrawForce(); return; }
//----------------------------------------------------------------------------- // Name : FrameAdvance () (Private) // Desc : Called to signal that we are now rendering the next frame. //----------------------------------------------------------------------------- void CGameApp::FrameAdvance() { static TCHAR FrameRate[ 50 ]; static TCHAR TitleBuffer[ 255 ]; // Advance the timer m_Timer.Tick( 60 ); // Skip if app is inactive if ( !m_bActive ) return; // Get / Display the framerate if ( m_LastFrameRate != m_Timer.GetFrameRate() ) { m_LastFrameRate = m_Timer.GetFrameRate( FrameRate, 50 ); sprintf_s( TitleBuffer, _T("Game : %s"), FrameRate ); SetWindowText( m_hWnd, TitleBuffer ); } // End if Frame Rate Altered if(StartGame == true) { SetCursor( NULL ); // Poll & Process input devices ProcessInput(); // Collision detection between game objects BricksExist=false; CollisionDetection(); if(BricksExist == false) { Vec2 brickPos; brickPos.x = START_BRICK_POS_X; brickPos.y = START_BRICK_POS_Y; countBricks = 0; countGifts = 0; nrBricks = 0; // delete objects from previous level for(auto it = m_vGameObjects.begin(); it != m_vGameObjects.end(); ++it) { CGameObject * pGameObj = it->get(); if(pGameObj->GetObjectTypeSub() == GOT_BrickUnbreakable) { countBricks++; } } for(int cBricks = 0; cBricks <= countBricks; cBricks++) { for(auto it2 = m_vGameObjects.begin(); it2 != m_vGameObjects.end(); ++it2) { CGameObject * pGameObj = it2->get(); if(pGameObj->GetObjectTypeSub() == GOT_BrickUnbreakable) { m_vGameObjects.erase(it2); break; } } } for(auto it = m_vGameObjectsGift.begin(); it != m_vGameObjectsGift.end(); ++it) { CGameObject * pGameObj = it->get(); countGifts++; } for(int cGifts = 0; cGifts <= countGifts; cGifts++) { for(auto it2 = m_vGameObjectsGift.begin(); it2 != m_vGameObjectsGift.end(); ++it2) { CGameObject * pGameObj = it2->get(); m_vGameObjectsGift.erase(it2); break; } } // load new objects m_pBall.lock()->myVelocity.x = 0; m_pBall.lock()->myVelocity.y = 0; m_pBall.lock()->myPosition.x = m_pPlayer.lock()->myPosition.x; m_pBall.lock()->myPosition.y = m_nViewHeight - m_pBall.lock()->GetHeight() - m_pPlayer.lock()->GetHeight() - ONE; FollowPlayer = true; UnstoppableBall = false; StickyBar = false; MoveBall = false; SystemParametersInfo(SPI_SETMOUSESPEED, NULL, (void*)10, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE ); ballPos.x = 0; if(ShrinkBar == true) { ShrinkBar = false; m_pPlayer.lock()->Normal_Bar(); } nrLevel++; level.LoadBricks(nrLevel); level.RandomBricks("-ud"); string::iterator it; for(it = level.bricks.begin(); it < level.bricks.end(); it++) { if(*it == '-') { continue; } auto pBrick = std::make_shared<Brick>(*it); m_vGameObjects.push_back(pBrick); } for(auto it = m_vGameObjects.begin(); it != m_vGameObjects.end(); ++it) { CGameObject * pGameObj = it->get(); if(pGameObj->GetObjectType() == GOT_Brick) { for(std::size_t levelbricks = 0; levelbricks < level.bricks.size(); levelbricks++) { if(level.bricks[nrBricks] == '-') { brickPos.x += pGameObj->GetWidth(); if(brickPos.x >= m_nViewWidth - GET_MAX_BRICK_POS_X) { brickPos.x = START_BRICK_POS_X; brickPos.y += pGameObj->GetHeight(); } } else { nrBricks++; break; } nrBricks++; } pGameObj->Init(Vec2(brickPos.x, brickPos.y)); brickPos.x += pGameObj->GetWidth(); if(brickPos.x >= m_nViewWidth - GET_MAX_BRICK_POS_X) { brickPos.x = START_BRICK_POS_X; brickPos.y += pGameObj->GetHeight(); } } } if(level.Winner == true) { LevelChange = false; } else { LevelChange = true; } } // Animate the game objects AnimateObjects(); } // Drawing the game objects DrawObjects(); }