Skip to content

Instantly share code, notes, and snippets.

@boustrophedon
Last active June 11, 2016 20:07
Show Gist options
  • Save boustrophedon/c18403e67cf99d0e53fd2be9144b2681 to your computer and use it in GitHub Desktop.
Save boustrophedon/c18403e67cf99d0e53fd2be9144b2681 to your computer and use it in GitHub Desktop.
ecs ideas
fn main() {
let world = World::new(); // or builder pattern
let physics = PhysicsSystem::new(); // this would create the ncollide world inside
// world takes ownership of systems
world.add_system(physics);
// etc.
world.run();
}
struct PhysicsSystem {
ncollide_world: NcollideWorld; // or whatever it's called
}
impl PhysicsSystem {
fn new() {
// whatever
}
}
impl System for PhysicsSystem {
// whatever the System trait is
}
struct World {
//some stuff
systems: Vec<Box<System>>,
}
impl World {
//other stuff here ...
fn add_system<T: System>(self, system: T) { // or we could have the systems be passed in as boxes if this doesn't compile
self.systems.push(Box::new(system));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment