Files
Frostbite2D/README.md
Lenheart 7fc056496b docs: 添加项目README文件
添加项目README文件,包含项目介绍、特性、构建说明、快速开始示例和项目结构等信息
2026-03-18 04:23:15 +08:00

112 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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 <frostbite2D/core/application.h>
#include <frostbite2D/core/window.h>
#include <frostbite2D/2d/sprite.h>
#include <frostbite2D/scene/scene.h>
#include <frostbite2D/scene/scene_manager.h>
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<Scene>();
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