补充文档和各类运行说明 文件
This commit is contained in:
@@ -40,6 +40,69 @@ sudo apt install cmake pkg-config g++ libraylib-dev libpugixml-dev
|
||||
|
||||
仓库中也包含 `vcpkg.json`,声明了 `raylib` 和 `pugixml` 依赖;如果你使用 vcpkg,请确保 CMake 能通过 pkg-config 找到对应库。
|
||||
|
||||
### Windows 构建和运行
|
||||
|
||||
下面给出两种 Windows 运行方式:**PowerShell + VS Code** 和 **Visual Studio 2022**。两种方式都使用 vcpkg 安装依赖。当前 CMake 配置通过 `pkg-config` 查找 `raylib` 和 `pugixml`,所以除了游戏依赖本身,还需要安装 `pkgconf`。
|
||||
|
||||
先准备通用依赖。下面假设 vcpkg 安装在 `C:\src\vcpkg`:
|
||||
|
||||
```powershell
|
||||
git clone https://github.com/microsoft/vcpkg C:\src\vcpkg
|
||||
C:\src\vcpkg\bootstrap-vcpkg.bat
|
||||
C:\src\vcpkg\vcpkg.exe install raylib pugixml pkgconf --triplet x64-windows
|
||||
```
|
||||
|
||||
#### 方式一:PowerShell + VS Code
|
||||
|
||||
1. 安装 Visual Studio Code。
|
||||
2. 安装 VS Code 扩展:**C/C++** 和 **CMake Tools**。
|
||||
3. 安装 Visual Studio 2022 或 Build Tools for Visual Studio 2022,并勾选 **Desktop development with C++** 工作负载。
|
||||
4. 用 VS Code 打开项目根目录,在 VS Code 终端中选择 PowerShell,然后运行:
|
||||
|
||||
```powershell
|
||||
$env:VCPKG_ROOT = "C:\src\vcpkg"
|
||||
$env:PKG_CONFIG_PATH = "$env:VCPKG_ROOT\installed\x64-windows\lib\pkgconfig;$env:VCPKG_ROOT\installed\x64-windows\share\pkgconfig"
|
||||
|
||||
cmake -S . -B build -G "Visual Studio 17 2022" -A x64 `
|
||||
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake" `
|
||||
-DPKG_CONFIG_EXECUTABLE="$env:VCPKG_ROOT\installed\x64-windows\tools\pkgconf\pkgconf.exe"
|
||||
|
||||
cmake --build build --config Release --target mana_pet_world
|
||||
```
|
||||
|
||||
5. 从项目根目录启动游戏,并把 `.` 作为资源根目录传给程序:
|
||||
|
||||
```powershell
|
||||
.\build\Release\mana_pet_world.exe .
|
||||
```
|
||||
|
||||
#### 方式二:Visual Studio 2022
|
||||
|
||||
1. 安装 Visual Studio 2022,并勾选 **Desktop development with C++** 和 CMake 支持。
|
||||
2. 双击项目根目录下的 `setup_vs2022.bat`。脚本会安装 vcpkg 依赖、生成 `build\vs2022\ManaPetWorld.sln`、编译 `mana_pet_world`,然后打开 Visual Studio。
|
||||
3. 在 Visual Studio 中点击运行按钮即可启动游戏。CMake 已经把 `mana_pet_world` 设为启动项目,并把调试工作目录和启动参数设置为项目根目录。
|
||||
|
||||
如果你想手动执行,也可以打开 **Developer PowerShell for VS 2022**,进入项目根目录,运行:
|
||||
|
||||
```powershell
|
||||
$env:VCPKG_ROOT = "C:\src\vcpkg"
|
||||
$env:PKG_CONFIG_PATH = "$env:VCPKG_ROOT\installed\x64-windows\lib\pkgconfig;$env:VCPKG_ROOT\installed\x64-windows\share\pkgconfig"
|
||||
|
||||
cmake -S . -B build\vs2022 -G "Visual Studio 17 2022" -A x64 `
|
||||
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake" `
|
||||
-DPKG_CONFIG_EXECUTABLE="$env:VCPKG_ROOT\installed\x64-windows\tools\pkgconf\pkgconf.exe"
|
||||
|
||||
cmake --build build\vs2022 --config Release --target mana_pet_world
|
||||
```
|
||||
|
||||
然后打开 `build\vs2022\ManaPetWorld.sln`,点击运行按钮;或者直接从命令行运行:
|
||||
|
||||
```powershell
|
||||
.\build\vs2022\Release\mana_pet_world.exe .
|
||||
```
|
||||
|
||||
如果 CMake 报告找不到 `raylib`、`pugixml` 或 `pkg-config`,请先确认上面的 `VCPKG_ROOT`、`PKG_CONFIG_PATH` 和 `PKG_CONFIG_EXECUTABLE` 路径与本机 vcpkg 安装位置一致。
|
||||
|
||||
## 快速启动
|
||||
|
||||
在项目根目录运行:
|
||||
|
||||
Reference in New Issue
Block a user