完成帧率控制
This commit is contained in:
@@ -1,20 +1,25 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
// 前向声明, 减少头文件的依赖,增加编译速度
|
||||
struct SDL_Window;
|
||||
struct SDL_Renderer;
|
||||
|
||||
namespace engine::core {
|
||||
namespace engine::core { // 命名空间的最佳实践:与文件路径一致
|
||||
class Time;
|
||||
|
||||
/**
|
||||
* @brief 主游戏应用程序类,初始化SDL,管理游戏循环。
|
||||
*/
|
||||
class GameApp final {
|
||||
class GameApp final { // final 表示该类不能被继承
|
||||
private:
|
||||
SDL_Window* window_ = nullptr;
|
||||
SDL_Renderer* sdl_renderer_ = nullptr;
|
||||
bool is_running_ = false;
|
||||
|
||||
// 引擎组件
|
||||
std::unique_ptr<engine::core::Time> time_;
|
||||
|
||||
public:
|
||||
GameApp();
|
||||
~GameApp();
|
||||
@@ -31,7 +36,7 @@ public:
|
||||
GameApp& operator=(GameApp&&) = delete;
|
||||
|
||||
private:
|
||||
[[nodiscard]] bool init();
|
||||
[[nodiscard]] bool init(); // nodiscard 表示该函数返回值不应该被忽略
|
||||
void handleEvents();
|
||||
void update(float delta_time);
|
||||
void render();
|
||||
|
||||
Reference in New Issue
Block a user