创建新工程
This commit is contained in:
132
SETUP.md
Normal file
132
SETUP.md
Normal file
@@ -0,0 +1,132 @@
|
||||
# 环境配置指南
|
||||
|
||||
## 环境要求
|
||||
|
||||
- **Godot 4.5.1+** - 游戏引擎
|
||||
- **Node.js 24.7.0+** - JavaScript 运行时
|
||||
- **Yarn 1.22.22+** - 包管理器
|
||||
|
||||
## 快速配置
|
||||
|
||||
### 1. 安装 Godot
|
||||
|
||||
1. 从 [Godot 官网](https://godotengine.org/download) 下载 Godot 4.5.1+
|
||||
2. 解压并运行 Godot 引擎
|
||||
|
||||
### 2. 打开项目
|
||||
|
||||
1. 启动 Godot 引擎
|
||||
2. 点击 "导入"
|
||||
3. 浏览到项目目录,选择 `project.godot` 文件
|
||||
4. 点击 "导入并编辑"
|
||||
|
||||
### 3. 安装服务器依赖
|
||||
|
||||
```bash
|
||||
cd server
|
||||
yarn install
|
||||
```
|
||||
|
||||
### 4. 启动开发环境
|
||||
|
||||
**启动服务器**:
|
||||
```bash
|
||||
cd server
|
||||
yarn dev
|
||||
```
|
||||
|
||||
**运行游戏**:
|
||||
在 Godot 编辑器中按 F5
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
ai_community/
|
||||
├── project.godot # Godot 项目配置
|
||||
├── scenes/ # 游戏场景
|
||||
├── scripts/ # GDScript 脚本
|
||||
├── assets/ # 游戏资源
|
||||
├── tests/ # 测试文件
|
||||
├── server/ # WebSocket 服务器
|
||||
│ ├── src/ # TypeScript 源码
|
||||
│ ├── data/ # 数据存储
|
||||
│ └── package.json # 服务器依赖
|
||||
└── .kiro/specs/ # 项目规范文档
|
||||
```
|
||||
|
||||
## 输入映射
|
||||
|
||||
项目已配置以下输入映射:
|
||||
|
||||
- **ui_left**: 左方向键 / A 键
|
||||
- **ui_right**: 右方向键 / D 键
|
||||
- **ui_up**: 上方向键 / W 键
|
||||
- **ui_down**: 下方向键 / S 键
|
||||
- **interact**: E 键
|
||||
|
||||
## 开发工作流
|
||||
|
||||
1. **启动服务器**: `cd server && yarn dev`
|
||||
2. **打开 Godot**: 导入并打开项目
|
||||
3. **编写代码**: 在 `scripts/` 目录创建 GDScript 文件
|
||||
4. **创建场景**: 在 `scenes/` 目录创建 .tscn 文件
|
||||
5. **测试**: 按 F5 运行游戏或 F6 运行当前场景
|
||||
6. **提交代码**: 使用 Git 提交更改
|
||||
|
||||
## 常见问题
|
||||
|
||||
### Q: 如何更改服务器端口?
|
||||
|
||||
A: 编辑 `server/src/server.ts`,修改端口号(默认 8080)
|
||||
|
||||
### Q: 如何添加新的依赖?
|
||||
|
||||
A: 在 `server/` 目录下运行:
|
||||
```bash
|
||||
yarn add <package-name>
|
||||
```
|
||||
|
||||
### Q: TypeScript 编译错误怎么办?
|
||||
|
||||
A: 运行以下命令检查错误:
|
||||
```bash
|
||||
cd server
|
||||
yarn build
|
||||
```
|
||||
|
||||
## 测试环境
|
||||
|
||||
### 运行测试
|
||||
|
||||
**所有测试**:
|
||||
1. 打开 `tests/RunAllTests.tscn`
|
||||
2. 按 F6 运行
|
||||
|
||||
**游戏测试**:
|
||||
1. 打开 `scenes/TestGameplay.tscn`
|
||||
2. 按 F6 运行
|
||||
3. 使用 WASD 移动角色
|
||||
|
||||
### 预期结果
|
||||
|
||||
- 所有单元测试通过
|
||||
- 角色可以在场景中移动
|
||||
- 相机跟随角色
|
||||
- 碰撞检测正常
|
||||
|
||||
## 下一步
|
||||
|
||||
环境配置完成后,你可以:
|
||||
|
||||
1. **运行测试**: 确保所有功能正常
|
||||
2. **查看场景**: 打开 `scenes/DatawhaleOffice.tscn` 查看办公室
|
||||
3. **开始开发**: 参考 `.kiro/specs/godot-ai-town-game/tasks.md` 继续开发
|
||||
|
||||
## 资源链接
|
||||
|
||||
- [Godot 官方文档](https://docs.godotengine.org/)
|
||||
- [GDScript 参考](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/index.html)
|
||||
- [WebSocket API](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)
|
||||
- [TypeScript 文档](https://www.typescriptlang.org/docs/)
|
||||
|
||||
配置完成!🚀
|
||||
Reference in New Issue
Block a user