checs
An Entity-Component-System library.
Example
This is a very basic example of how to use checs.
You can find this example at examples/basic.rs. Run it with:
Define some components and a World to store them in.
Note: Components are just plain old Rust types.
;
;
impl_storage!;
let mut world = new;
Create entities with initial components.
// Either manually...
let player = world.spawn;
world.put;
world.put;
world.put;
// ...or by using the `spawn` macro.
let obstacle = spawn!;
let trap = spawn!;
let enemy = spawn!;
Find the entities that have some components.
use LendingIterator;
use IntoQuery;
let ps = &world.storage.positions;
let hs = &mut world.storage.healths;
let vs = &world.storage.visibles;
let query = .into_query;
query.for_each| );
// Entity(0) is Visible at (0, 0) with 63 HP.
// Entity(3) is Visible at (1, 4) with 83 HP.