feat(engine): 重构游戏引擎核心逻辑

- 重新设计了引擎的初始化和运行流程
- 引入了实体组件系统(ECS)和物理系统
- 优化了渲染系统和输入系统
- 移除了不必要的资源管理系统
- 调整了日志系统的实现
This commit is contained in:
ZZY
2025-06-29 18:46:36 +08:00
parent 5ce660e3a6
commit 89bede93a9
37 changed files with 1294 additions and 350 deletions

View File

@@ -3,10 +3,10 @@
* @brief 模仿python标准库logger的日志系统核心模块支持多级日志、断言和异常处理
*/
#ifndef __PYTHONIC_LOG_H__
#define __PYTHONIC_LOG_H__
#ifndef __PYNIC_LOG_H__
#define __PYNIC_LOG_H__
#ifndef __NO_STDIO__
#ifndef __PYNIC_NO_STDIO__
#include <stdio.h>
#include <stdlib.h>
@@ -21,11 +21,11 @@
#endif
#endif
#ifndef __NO_PYNIC_COLOR__
#ifndef __PYNIC_NO_COLOR__
#include "pynic_color.h"
#else
#ifndef __LOG_NO_COLOR__
#define __LOG_NO_COLOR__
#ifndef __PYNIC_LOG_NO_COLOR__
#define __PYNIC_LOG_NO_COLOR__
#endif
#endif
@@ -50,7 +50,7 @@
#endif
#define _PYNIC_STR(str) #str
#define PYLIKE_STR(str) _PYNIC_STR(str)
#define PYNIC_STR(str) _PYNIC_STR(str)
/**
* @brief 日志级别枚举
@@ -199,7 +199,7 @@ void log_set_handler(logger_t* logger, pynic_log_handler handler);
#define AssertFmt(cond, format, ...) _Assert(cond, "Assertion Failure: " format, ## __VA_ARGS__) ///< 带格式的断言检查
#define PanicFmt(format, ...) _Assert(0, "Panic: " format, ## __VA_ARGS__) ///< 立即触发致命错误
#ifndef Assert
#define Assert(cond) AssertFmt(cond, "cond is `" PYLIKE_STR(cond) "`") ///< 基础断言检查
#define Assert(cond) AssertFmt(cond, "cond is `" PYNIC_STR(cond) "`") ///< 基础断言检查
#endif
#define Panic(...) PanicFmt(__VA_ARGS__) ///< 触发致命错误(带自定义消息)
#define TODO() PanicFmt("TODO please implement me") ///< 标记未实现代码(触发致命错误)
@@ -219,7 +219,7 @@ static inline const char* pynic_level_str(log_level_t level) {
return level_str;
}
#ifdef __PYTHONIC_TERMINAL_COLOR_H__
#ifdef __PYNIC_TERMINAL_COLOR_H__
static inline const char* pynic_level_color(log_level_t level) {
const char* color_code = ANSI_NONE;
switch (level) {
@@ -237,11 +237,11 @@ static inline const char* pynic_level_color(log_level_t level) {
#ifdef __PYNIC_LOG_IMPLIMENT__
static void default_handler(log_level_t level, const char* module, const char* file, int line, const char* message) {
static void __pynic_log_default_handler(log_level_t level, const char* module, const char* file, int line, const char* message) {
const char* level_str = pynic_level_str(level);
/// @note: 定义 __LOG_NO_COLOR__ 会取消颜色输出
#ifndef __LOG_NO_COLOR__
/// @note: 定义 __PYNIC_LOG_NO_COLOR__ 会取消颜色输出
#ifndef __PYNIC_LOG_NO_COLOR__
_pynic_logout_printf(ANSI_BOLD "%s[%s] - %s - %s:%d | %s" ANSI_NONE "\n",
pynic_level_color(level), level_str, module, file, line, message);
#else
@@ -256,7 +256,7 @@ static void default_handler(log_level_t level, const char* module, const char* f
static logger_t __pynic_root_logger = {
.name = "root",
.level = LOG_LEVEL_ALL,
.handler = default_handler,
.handler = __pynic_log_default_handler,
};
void init_logger(logger_t* logger, const char* name) {
@@ -265,7 +265,7 @@ void init_logger(logger_t* logger, const char* name) {
void init_logger_ex(logger_t* logger, const char* name, pynic_log_handler hander) {
logger->name = name;
logger->handler = hander ? hander : default_handler;
logger->handler = hander ? hander : __pynic_log_default_handler;
log_set_level(logger, LOG_LEVEL_ALL);
}
@@ -285,4 +285,4 @@ void log_set_handler(logger_t* logger, pynic_log_handler handler) {
}
#endif
#endif // __PYTHONIC_LOG_H__
#endif // __PYNIC_LOG_H__