// Updates the game void Game::Update() { static int frameCount = 0; static float tickCount = 0.0f; static bool first = true; float elapsedTime = Time::GetElapsedTime(); tickCount += elapsedTime; ++frameCount; if ( tr ) { tr->SetText( std::to_string( elapsedTime ) + "ms\t" + std::to_string( tickCount ) + "ms\t" + std::to_string( frameCount ) ); } // counts Frames per second if ( tickCount >= 1.0f ) { std::string title = "Billy's 3D Billiards"; title += " | " + std::to_string( frameCount ) + " FPS"; _window->SetTitle( title ); frameCount = 0; tickCount -= 1.0f; } // Sets materials on Objects for (auto& object : _gameObjects) { if (object->GetActive()) { Material* material = object->GetComponentOfType<Material>(); if (material) { material->ApplyCamera(gameManager->GetActiveCamera()); } object->Update(); } } gameManager->Update(); // If escape is being pressed, then we should close the window if ( Input::WasKeyPressed( Key::Escape ) ) { _window->Close(); } if ( Input::WasKeyPressed( Key::T ) ) { Destroy( tr->GetGameObject() ); tr = nullptr; } }