16 个版本 (10 个破坏性更新)
0.11.0 | 2023 年 3 月 30 日 |
---|---|
0.9.0 | 2023 年 1 月 12 日 |
0.8.2 | 2022 年 12 月 20 日 |
0.6.1 | 2022 年 11 月 23 日 |
#942 in 图形 API
每月 41 次下载
175KB
4.5K SLoC
Rhachis
Rhachis 是一个主要用于制作游戏的 Rust 框架。它旨在尽可能简单,同时仍然允许所有可能的定制。
框架的核心是它的 Game
特性和 GameData
结构体。The Game
特性是您项目的根。引擎会调用该特性上的函数来执行许多操作,如更新游戏逻辑或初始化游戏。这些函数会传递 GameData
结构体的引用以访问引擎的核心组件。这些核心组件都是线程安全的,必要时通过 RwLock
锁定。
基本用法
要开始使用 Rhachis,请运行 cargo add rhachis
将最新版本添加到您的 Cargo.toml
。
下面的代码显示了 Rhachis 项目的结构。
use rhachis::{graphics::EmptyRenderer, *};
// A procedural macro that starts the game from your struct.
#[run]
// The EmptyRenderer is a renderer that does nothing and acts as a placeholder.
struct Window(EmptyRenderer);
// The Game trait handles the core event loop.
impl Game for Window {
// Called to initialise the game state after core engine starts.
fn init() -> Self {
Self(EmptyRenderer)
}
// Used to get the current renderer. It is in this function so that
// renderers can be swapped on the fly.
fn get_renderer(&mut self) -> &mut dyn graphics::Renderer {
&mut self.0
}
}
更深入的示例可以在存储库的 示例目录 中找到。
致谢
- 来自 Google Fonts 的 Open Sans 字体
依赖关系
~27–61MB
~821K SLoC