2 releases

new 0.1.1 Jun 24, 2024
0.1.0 Jun 1, 2024

#4 in #raylib

Download history 191/week @ 2024-05-27 27/week @ 2024-06-03 7/week @ 2024-06-10

225 downloads per month

MIT license

13KB
250 lines

lifers-raylib

Raylib frontend for lifers.

Usage

To use this frontend, simply create a cell type:

// Simple Game of Life-like cell
struct Cell {
    is_alive: bool
}

Your cells don't have to be this simple, they can have many attributes (type, group, etc.).

Now just implement RenderCell<Color> for it:

use raylib::color::Color;
use lifers::frontend::RenderCell;

impl RenderCell<Color> for Cell {
    fn render_cell(&self) -> Color {
        if cell.is_alive {
            Color::WHITE
        } else {
            Color::BLACK
        }
    }
}

Then you can use it to create an Automaton and pass it to RaylibFrontend (or use FrontendBuilder).

Also, see examples and docs.


lib.rs:

Raylib frontend for [lifers].

Provides RaylibFrontend that does all the displaying and rendering work. It's recommended to use FrontendBuilder for convenience.

The frontend can be used in an event loop, similar to a typical Raylib application:

# use lifers::engine::Automaton;
# use lifers_raylib::FrontendBuilder;
let game = /* Automaton */;
let mut frontend = FrontendBuilder::new((480, 480))
    .finish(game);

while !frontend.window_should_close() {
    frontend.display_grid();
    frontend.tick();
}

Dependencies

~8–15MB
~203K SLoC