2个版本
0.1.1 | 2022年3月8日 |
---|---|
0.1.0 | 2021年11月18日 |
651 in 游戏开发
2.5MB
10K SLoC
Rust RPG Toolkit
请注意
该项目已停止开发,因为其中大部分已包含在我们为Fish Fight项目使用的内部引擎中。随着我们接近Fish Fight的1.0版本,今年夏天,我们将发布一个基于此的引擎核心库(尚未命名)。它遵循与本项目相同的原理,但在游戏类型方面将更加通用。它还将支持多个渲染后端
此库允许您使用Rust和JSON创建基于图块的2D动作RPG。它最初是一个游戏项目,但随着范围的扩大而分离成自己的项目。它使用JSON文件来指定大部分游戏数据和资源,这样就可以用很少的Rust代码与游戏交互。这有利于使最终产品非常容易修改,无论是参与开发过程的非开发者,还是最终用户。可以通过直接修改游戏的数据文件或创建用户模块来完成修改,这些模块是默认支持的。
目前,正如其名所示,它非常侧重于RPG,但我正在努力使其更加灵活。截至撰写本文时,尚未实现“胜利条件”等功能,进展只能通过任务/任务开发实现,但我计划以这种方式设计,允许框架用于非RPG类型。
我还计划添加创建其他视角(除俯视外)游戏的可能性。例如,实现侧滚动视图非常容易,因为我已经(或多或少)具有与Tiled地图功能平齐,以及完全兼容性。实现侧滚动物理只需添加几个物理属性——主要是重力——就足够了...
功能
- 无需触摸源代码或重新编译项目即可轻松定义和修改游戏数据和资源
- 默认支持模组,可以扩展或替换游戏的数据和资源
- RPG机制,如角色属性、物品和库存系统
- 从Tiled地图转换,并从地图属性实例化演员和物品
- 灵活的AI行为
- 对话系统
- 任务和奖励系统
- 通过JSON构建和主题化的UI和菜单
- 支持WebAssembly,使用wasm-bindgen
当前里程碑
- 重新设计演员行为系统
- 定义基本、默认的AI行为
- 重构碰撞检测
- 完善路径查找
- 扩展角色创建,包括外观选项
- 实现演员能力(当前能力仅在物品上实现)
- 重构UI系统
- 最终确定WASM构建过程
使用库
要开始,请将以下内容添加到您的Cargo.toml
文件中
[dependencies]
rust-rpg-toolkit = "0.1.0"
包功能
collision-between-actors
如果启用,演员将与其他演员发生碰撞,而不仅仅是地图。在此阶段不建议这样做,因为导航不考虑其他演员。
示例
use rust_rpg_toolkit::prelude::*;
const GAME_NAME: &str = "My Awesome Game";
const GAME_VERSION: &str = "0.1.0";
const CONFIG_PATH: &str = "config.json";
fn get_window_conf() -> WindowConf {
let config = Config::load(CONFIG_PATH);
WindowConf {
window_title: GAME_NAME.to_owned(),
high_dpi: false,
window_width: config.resolution.x as i32,
window_height: config.resolution.y as i32,
fullscreen: config.fullscreen,
..Default::default()
}
}
#[macroquad::main(get_window_conf)]
async fn main() -> Result<()> {
let params = GameParams {
name: GAME_NAME.to_string(),
version: GAME_VERSION.to_string(),
..Default::default()
};
// Load game resources, apply modules and dispatch an event that opens the main menu when the game loop starts.
// This puts a Resources struct, holding all the games assets and data files, including everything from modules,
// into storage, so any code that requires access to such data, must be called after this.
init(params).await?;
/* Begin optional stuff */
// This defines the builder used when loading scenes and it is the best way to inject your own Macroquad
// scene node implementations into the scene tree and have them drawn when you want them to.
// The DrawBuffers require a type that implements BufferedDraw, so implementation of Macroquad's Node trait is,
// strictly speaking, not required. This is what it was meant to be used for, however.
// If you don't define your own scene builder, the default one will be used.
SceneBuilder::new()
.with_draw_buffer::<MyBufferedDrawImpl>(DrawStage::Actors)
.make_default();
// This is also where you want to define anything else that you reference in your game data, like custom ActorBehaviors,
// custom ButtonBuilders that are referenced in your customized GUI theme(s), etc.
/* End optional stuff */
// Handle event queue until encountering a Quit event
while handle_queued_events().await? {
// Begin frame
begin_frame();
// ...
// End frame
end_frame().await;
}
Ok(())
}
您创建的任何游戏都应该有一个资源文件夹。将示例项目中的资源文件夹作为起点进行复制...
可以使用以下cargo命令构建和运行示例项目
cargorun --exampleexample-project
命令行界面
CLI包目前仅包含一个tiled地图转换工具,但随着我们的进展,它将被扩展
更多文档
请参阅文档文件夹以获取更多文档。
贡献
我们非常欢迎贡献。请随意创建PR或问题。
鸣谢
- Wenrexa Minimal UI Kit(UI主题)
- Free UI Kit #4(UI主题)
- Neo Zero Cyberpunk City Tileset(地图贴图和道具)
- Cyberpunk Top Down Game Asset Pack(目前未使用但包含在存储库中)
- Cyberpunk Items 16x16(目前用于所有物品图形)
- M4A1 Single声音由Kibblesbob提供(Creative Commons Attribution 3.0)
- 9mm Glock 17声音由JKirsch提供(Creative Commons Attribution 3.0)
- 其他声音来自SciFi Weapons Pro,这是一个付费资源包。这意味着您无法重新分发这些声音。
许可证:MIT(不包括外部来源的资源)
版权所有 2021 Ole A. Sjo Fasting 和 Magus
依赖项
~27MB
~380K SLoC