rscenes-1.2.1 has been yanked.
rscenes
Rscene is a scene manager for Raylib.
Installation
cargo add rscenes
Sample
You don’t need to include raylib, the following line alone is enough:
use rscene.prelude::*
Then, in your function, instantiate the builder and the manager:
let mut builder = raylib::init();
builder.title("my-game"); let font: Option<Font> = None;
let mut manager = SceneManager::new(builder, font);
manager.config(|handle, thread, font| {
handle.set_window_title(thread, "My Game");
handle.set_target_fps(30);
font.insert(handle.load_font(thread, handle).unwrap());
});
manager.add_first_scene(Box::new(MyScene::default()));
manager.start()?;
The scene should be implemented like:
#[derive(Debug, Default)]
struct MyScene;
impl Scene<Option<Font>> for MyScene {
fn init(&mut self, handle: &mut RaylibHandle, thread: &RaylibThread) -> anyhow::Result<()> {
Ok(())
}
fn update(
&mut self,
(handle, thread): (&mut RaylibHandle, &RaylibThread),
dt: f32,
resources: &mut Option<Font>,
) -> anyhow::Result<State<Option<Font>>> {
Ok(State::Keep)
}
fn draw(
&mut self,
handle: &mut RaylibDrawHandle,
screen: Rectangle,
resources: &Option<Font>,
) -> anyhow::Result<()> {
Ok(())
}
}
The main resources are:
Everything else comes from
raylib::prelude.
License
License: BSD-3-Clause