HRESULT APPLICATION::Update(float deltaTime) { //Set World matrix D3DXMATRIX matWorld; D3DXMatrixIdentity(&matWorld); m_pDevice->SetTransform(D3DTS_WORLD, &matWorld); //Update m_mouse m_mouse.Update(); //Update m_camera m_camera.Update(m_mouse, deltaTime); //Change intersection test type if(KEYDOWN(VK_SPACE)) { Sleep(300); m_intersectType++; if(m_intersectType > 2)m_intersectType = 0; } if(KEYDOWN(VK_ESCAPE)) Quit(); return S_OK; }
HRESULT APPLICATION::Update(float deltaTime) { //Control camera D3DXMATRIX matWorld; D3DXMatrixIdentity(&matWorld); m_pDevice->SetTransform(D3DTS_WORLD, &matWorld); //Update mouse m_mouse.Update(); //Update camera m_camera.Update(m_mouse, deltaTime); if(KEYDOWN(VK_ESCAPE)) Quit(); return S_OK; }
void Update() { //cam.position.DebugPrint(); bool mainloop = false; //std::cout << "Mainloop" << std::endl; //if unpaused and getting a reasonable framerate //if (fps > MIN_FPS && timefactor != 0.0f) if (fps > 0.0f && timefactor != 0.0f) { double time_increment = timefactor / fps; //std::cout << "Time elapsed: " << execution_time << " + " << time_increment << std::endl; execution_time += time_increment; //int num_updates = (int) (execution_time / FRAME_TIME); // double this_frame = (double) num_updates * FRAME_TIME; mouse.Update(cam, SCREEN_WIDTH, SCREEN_HEIGHT, timefactor, fps); cam.dir = mouse.GetDir(); while (execution_time > FRAME_TIME) { //std::cout << "Frame start: " << execution_time << std::endl; #ifdef PERFORMANCE_PROFILE suseconds_t t1, t2; t1 = GetMicroSeconds(); t1 = GetMicroSeconds(); #endif //multiplay.Update(FRAME_TIME); //weather tick #ifdef PERFORMANCE_PROFILE t2 = GetMicroSeconds(); cout << "multiplay.Update() ticks: " << t2-t1 << endl; t1 = GetMicroSeconds(); #endif cam.Update(); //handle input //keyman.DoHeldKeys(timefactor, fps, cam); keyman.DoHeldKeys(1.0, 1.0/FRAME_TIME, cam); #ifdef PERFORMANCE_PROFILE t1 = GetMicroSeconds(); t1 = GetMicroSeconds(); #endif #ifdef PERFORMANCE_PROFILE t2 = GetMicroSeconds(); cout << "world update ticks: " << t2-t1 << endl; t1 = GetMicroSeconds(); #endif keyman.DoOneTimeKeys(cam); //particle.Update(timefactor, fps); //particle.Update(1.0, 1.0/FRAME_TIME); cam.ExtractFrustum(); //float timepassed = (timefactor/fps)/86400.0; float timepassed = (FRAME_TIME)/86400.0; /*if (keyman.keys[keyman.GetKey("AccelTimeVFast")]) timefactor = 10000.0; else if (keyman.keys[keyman.GetKey("AccelTimeFast")]) timefactor = 1000.0; else timefactor = 1.0;*/ //float timepassed = (timefactor/fps)/60.0; //float timepassed = (timefactor/fps)/10.0; abs_time += timepassed; day_time += timepassed; if (day_time > 1.0f) day_time -= 1.0f; #ifdef PERFORMANCE_PROFILE t2 = GetMicroSeconds(); cout << "Time increment ticks: " << t2-t1 << endl; t1 = GetMicroSeconds(); #endif mainloop = true; //terrain.Update(cam, timefactor, fps, day_time); //terrain.Update(cam, 1.0, 1.0/FRAME_TIME, day_time); execution_time -= FRAME_TIME; //num_updates++; //replay.IncrementFrame(); } } else { //print "paused" } if (pauserequest) { if (timefactor != 0.0f) timefactor = 0.0f; pauserequest = false; } if (unpauserequest) { if (timefactor == 0.0f) timefactor = 1.0f; unpauserequest = false; } /*if (!mainloop) multiplay.Update(0);*/ //don't need this anymore because we're stopping things from being paused in multiplayer mode }