21个版本 (4个重大更新)
0.6.1 | 2022年11月27日 |
---|---|
0.6.0 | 2022年11月7日 |
0.4.6 | 2022年8月23日 |
0.4.5 | 2022年7月12日 |
0.1.1 | 2022年4月20日 |
#848 in 游戏开发
59 每月下载量
在 9 个包中使用(通过 srs2dge-core)
33KB
876 行
使用某些随机 Engine
的示例用法
struct App {
window: Window,
ws: WindowState,
update_loop: UpdateLoop,
}
impl App {
fn init(target: &EventLoopTarget) -> Self {
let window = WindowBuilder::new().build(target).unwrap();
let ws = WindowState::new(&window);
let update_loop = UpdateLoop::new(UpdateRate::PerSecond(60));
Self {
window,
ws,
update_loop,
}
}
fn event(&mut self, event: Event, _: &EventLoopTarget, control: &mut ControlFlow) {
self.ws.event(&event);
if self.ws.should_close {
*control = ControlFlow::Exit;
}
}
fn draw(&mut self) {
self.update_loop.update(|| {
// update();
});
// draw();
}
}
fn main() {
run_app!(App);
}
使用不同的初始化、事件和绘图函数的示例用法
use main_game_loop::prelude::*;
struct App {
// ...
}
async fn init(target: &EventLoopTarget) -> App {
// init
App {
// ..
}
}
impl App {
fn draw(&mut self) {
// draw
}
}
#[tokio::main]
async fn main() {
run_app!(
async init,
|_, _, _, _| {
// events
},
App::draw
);
}
依赖项
~6–19MB
~267K SLoC