feat(game): 添加基础游戏引擎和渲染模块
- 新增游戏引擎核心模块,包括初始化和运行逻辑 - 实现基本的渲染功能,支持控制台输出 - 添加物理引擎基础,包括碰撞检测 - 集成日志系统,用于调试和信息输出 - 创建窗口和输入管理模块
This commit is contained in:
31
game_engine/timer/ge_fps.h
Normal file
31
game_engine/timer/ge_fps.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef __GE_FPS_H__
|
||||
#define __GE_FPS_H__
|
||||
|
||||
#include <ge_common.h>
|
||||
struct ge_fps_controller;
|
||||
typedef struct ge_fps_controller ge_fps_controller_t;
|
||||
|
||||
typedef ge_u32_t (*ge_fps_get_ms_func_t)(void);
|
||||
typedef void (*ge_fps_sleep_ms_func_t)(ge_u32_t ms);
|
||||
|
||||
void ge_fps_init(ge_fps_controller_t* fps_ctrl, ge_u32_t target_fps,
|
||||
ge_fps_get_ms_func_t get_ms, ge_fps_sleep_ms_func_t sleep_ms);
|
||||
void ge_fps_begin_frame(ge_fps_controller_t* fps_ctrl);
|
||||
void ge_fps_end_frame(ge_fps_controller_t* fps_ctrl);
|
||||
|
||||
// FPS控制器结构体
|
||||
struct ge_fps_controller {
|
||||
ge_u32_t target_fps; // 目标帧率
|
||||
ge_u32_t frame_duration; // 目标每帧时长(毫秒)
|
||||
ge_u32_t last_frame_time; // 上一帧开始时间
|
||||
ge_u32_t frame_time; // 当前帧耗时
|
||||
ge_u32_t sleep_time; // 需要休眠的时间
|
||||
ge_u32_t frame_count; // 帧计数器
|
||||
ge_u32_t fps; // 实际帧率
|
||||
ge_u32_t last_fps_time; // 上次计算FPS的时间
|
||||
|
||||
ge_fps_get_ms_func_t call_get_ms;
|
||||
ge_fps_sleep_ms_func_t call_sleep_ms;
|
||||
};
|
||||
|
||||
#endif // __GE_FPS_H__
|
||||
Reference in New Issue
Block a user