diff options
| -rw-r--r-- | src/crepe/api/LoopManager.cpp | 4 | ||||
| -rw-r--r-- | src/crepe/manager/LoopTimerManager.cpp | 15 | ||||
| -rw-r--r-- | src/crepe/manager/LoopTimerManager.h | 3 | 
3 files changed, 10 insertions, 12 deletions
| diff --git a/src/crepe/api/LoopManager.cpp b/src/crepe/api/LoopManager.cpp index 6ebf280..46a7635 100644 --- a/src/crepe/api/LoopManager.cpp +++ b/src/crepe/api/LoopManager.cpp @@ -77,6 +77,4 @@ bool LoopManager::on_shutdown(const ShutDownEvent & e) {  	return false;  } -void LoopManager::frame_update() { -	this->scene_manager.load_next_scene(); -} +void LoopManager::frame_update() { this->scene_manager.load_next_scene(); } diff --git a/src/crepe/manager/LoopTimerManager.cpp b/src/crepe/manager/LoopTimerManager.cpp index 057a18e..e57ec6f 100644 --- a/src/crepe/manager/LoopTimerManager.cpp +++ b/src/crepe/manager/LoopTimerManager.cpp @@ -23,7 +23,8 @@ void LoopTimerManager::start() {  }  void LoopTimerManager::update() { -	std::chrono::steady_clock::time_point current_frame_time = std::chrono::steady_clock::now(); +	std::chrono::steady_clock::time_point current_frame_time +		= std::chrono::steady_clock::now();  	// Convert to duration in seconds for delta time  	this->delta_time = std::chrono::duration_cast<std::chrono::duration<double>>(  		current_frame_time - last_frame_time); @@ -54,7 +55,7 @@ void LoopTimerManager::advance_fixed_elapsed_time() {  void LoopTimerManager::set_target_fps(int fps) {  	this->target_fps = fps;  	//check if fps is lower or equals 0 -	if(fps <= 0){ +	if (fps <= 0) {  		return;  	}  	// target time per frame in seconds @@ -68,15 +69,15 @@ void LoopTimerManager::set_time_scale(double value) { this->time_scale = value;  double LoopTimerManager::get_time_scale() const { return this->time_scale; }  void LoopTimerManager::enforce_frame_rate() { -	std::chrono::steady_clock::time_point current_frame_time = std::chrono::steady_clock::now(); +	std::chrono::steady_clock::time_point current_frame_time +		= std::chrono::steady_clock::now();  	std::chrono::duration<double> frame_duration = current_frame_time - this->last_frame_time; -  	// Check if frame duration is less than the target frame time  	if (frame_duration < this->frame_target_time) { -		std::chrono::microseconds delay_time = std::chrono::duration_cast<std::chrono::microseconds>( -    	this->frame_target_time - frame_duration); - +		std::chrono::microseconds delay_time +			= std::chrono::duration_cast<std::chrono::microseconds>(this->frame_target_time +																	- frame_duration);  		if (delay_time.count() > 0) {  			std::this_thread::sleep_for(delay_time); diff --git a/src/crepe/manager/LoopTimerManager.h b/src/crepe/manager/LoopTimerManager.h index 9336520..ec44d52 100644 --- a/src/crepe/manager/LoopTimerManager.h +++ b/src/crepe/manager/LoopTimerManager.h @@ -19,7 +19,7 @@ public:  	/**  	 * \param mediator A reference to a Mediator object used for transfering managers.  	 */ -	LoopTimerManager(Mediator &mediator); +	LoopTimerManager(Mediator & mediator);  	/**  	 * \brief Get the current delta time for the current frame.  	 *	 @@ -146,7 +146,6 @@ private:  	 */  	void advance_fixed_elapsed_time(); -  private:  	//! Target frames per second  	int target_fps = 60; |