# Frostbite2D 一个现代化的跨平台2D游戏引擎,使用C++17开发。 ## 特性 - **跨平台支持** - Windows、Linux、macOS、Nintendo Switch - **现代渲染** - OpenGL渲染器,支持批量渲染和着色器管理 - **完整的游戏开发框架** - 场景管理、精灵系统、资源管理 - **高效的工具集** - 二进制读取器、PVF归档格式、脚本解析器 - **智能指针系统** - 引用计数指针,避免内存泄漏 ## 构建 本项目使用 [XMake](https://xmake.io/) 作为构建系统。 ### 前置要求 - C++17 兼容编译器 - XMake - SDL2、SDL2_image、GLM、Glad ### 基本构建 ```bash xmake build ``` ### 调试构建 ```bash xmake build -m debug ``` ### 发布构建 ```bash xmake build -m release ``` ### 平台特定构建 ```bash xmake build -p windows xmake build -p linux xmake build -p switch ``` ## 快速开始 ```cpp #include #include #include #include #include using namespace frostbite2D; int main(int argc, char **argv) { AppConfig config = AppConfig::createDefault(); config.windowConfig.width = 1280; config.windowConfig.height = 720; config.windowConfig.title = "My Game"; Application& app = Application::get(); if (!app.init(config)) { return -1; } auto scene = MakePtr(); SceneManager::get().PushScene(scene); auto sprite = Sprite::createFromFile("assets/player.png"); if (sprite) { sprite->SetPosition(100, 100); scene->AddActor(sprite); } app.run(); app.shutdown(); return 0; } ``` ## 项目结构 ``` Frostbite2D/ ├── Frostbite2D/ # 引擎核心代码 │ ├── include/ # 公共头文件 │ │ └── frostbite2D/ │ │ ├── 2d/ # 2D图形组件 │ │ ├── core/ # 核心引擎类 │ │ ├── graphics/ # 图形渲染系统 │ │ ├── scene/ # 场景管理 │ │ ├── types/ # 类型定义 │ │ └── utils/ # 工具类 │ └── src/ # 实现文件 ├── Game/ # 游戏应用示例 │ ├── assets/ # 游戏资源 │ ├── include/ # 游戏头文件 │ └── src/ # 游戏源文件 ├── platform/ # 平台配置 └── xmake.lua # XMake构建配置 ``` ## 许可证 MIT License