1 个不稳定版本
0.1.1 | 2022年6月5日 |
---|---|
0.1.0 |
|
#567 在 图形API
64KB
1.5K SLoC
⚠️ 免责声明:pufferfish处于非常早期的开发阶段。API可能会更改,许多基本功能缺失,本README中的一些内容可能无法反映crate的当前状态。建议不要将其用于项目,但对于那些勇敢的人,现在是提出建议和功能请求的时候了!
特性
- 最小和有观点的API
- 简单但灵活的回调系统
- 通过轮询轻松处理输入
- 高效的2D渲染器,支持精灵批处理,由
fugu
提供 - 支持自定义格式的资源加载器
入门指南
要将pufferfish添加到项目中,请在您的 Cargo.toml
的依赖关系部分添加以下内容
pufferfish = "0.1"
查看源中的 examples/
目录,以了解pufferfish API的工作方式。
一个基本的pufferfish程序看起来像这样
use pufferfish::graphics::{Color, Graphics};
use pufferfish::App;
struct State {
// Your game state...
}
fn main() {
App::new()
.with_title("Hello World")
.add_state(State::new()) // Add your state
.add_init_callback(init) // Add your callbacks
.add_frame_callback(update)
.add_frame_callback(draw)
.run();
}
fn init(state: &mut State) {
// Initialization code here...
}
fn update(state: &mut State) {
// Update code here...
}
// Request arbitrary state through the callback's type signature
fn draw(state: &State, g: &Graphics) {
g.clear(Color::BLACK);
g.begin();
// Draw code here...
g.end();
}
致谢
依赖关系
~22MB
~470K SLoC