goku
goku game engine_en
goku game engine_en
  • Chapter 1: Introduction to SDL2, Rust, and goku
  • Chapter2: The Base Structure: SpriteSheet
  • Chapter 3: Animated Textures
  • Chapter 4: Handling Textures: TextureManager
  • Chapter 5: Bringing Textures to Life: GameObject
  • Chapter 6: The Foundation: Tile System
  • Chapter 7: Moving the View: Camera
  • Chapter 8: Particle System
  • Chapter 9: The User Interface Layer
  • Chapter 10: The Button Element
  • Chapter 11: The Text Box Element
  • Chapter 12: The Checkbox Element
  • Chapter 13: The Slider Element
  • Chapter 14: The Audio System
  • Chapter 15: The AI System
  • Chapter 16: The Window System
  • Chapter 17: User Input Handling
  • Chapter 18: Rendering a Parallax Background
  • Chapter 19: Timing and Frame Rate Management
  • Chapter 20: Conclusion
Powered by GitBook
On this page

Chapter 19: Timing and Frame Rate Management

In this chapter, we delve into the details of managing time and frame rate in your game engine. It's critical to handle time correctly in your game, from managing frame rates to tracking elapsed time.

The Timer struct provides functionalities to measure the time between frames, calculate the average delta time (the time between frames), retrieve the time since the game started, get the frames per second (fps), and pause the execution of the program for a specified duration. It uses the std::time::Instant struct to measure time, and stores the times of the last 60 frames to calculate the average delta time and fps.

The step method updates the last_frame_time and delta_time, and manages the frame time history. The get_delta, get_average_delta, get_time, get_micro_time, and get_fps methods return the respective values. The sleep method pauses the execution for a specified duration.

PreviousChapter 18: Rendering a Parallax BackgroundNextChapter 20: Conclusion

Last updated 1 year ago