rscenes
Rscene
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 mut manager = SceneManager::new(builder);
manager.config(|handle, thread| {
handle.set_window_title(thread, "My Game");
});
manager.add_first_scene(Box::new(MyScene::default()));
manager.start()?;
The scene should be implemented like:
#[derive(Debug, Default)]
struct MyScene;
impl Scene 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,
audio: Option<Rc<&mut RaylibAudio>>,
) -> anyhow::Result<State> {
Ok(State::Keep)
}
fn draw(
&mut self,
handle: &mut RaylibDrawHandle,
screen: Rectangle,
font: Option<Rc<Font>>,
audio: Option<Rc<&mut RaylibAudio>>,
) -> anyhow::Result<()> {
Ok(())
}
}
The main resources are:
Everything else comes from raylib::prelude.
License
License: BSD-3-Clause