checs
An Entity-Component-System library.
Disclaimer
This is a work in progress.
Example
This is a very basic example of how to use checs.
Note: 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.
;
;
use ComponentVec;
use Storage;
let mut world = new;
Create entities with initial components.
// Either manually...
let player = world.spawn;
world.insert;
world.insert;
world.insert;
// ...or by using the `spawn` macro...
let obstacle = spawn!;
let trap = spawn!;
// ...or by using `spawn_with`.
let enemy = world.spawn_with;
Create a query to find the entities that share 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) at (0, 0) has 63 HP.
// Entity(3) at (1, 4) has 83 HP.