Last active
June 11, 2016 20:07
-
-
Save boustrophedon/c18403e67cf99d0e53fd2be9144b2681 to your computer and use it in GitHub Desktop.
ecs ideas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct PhysicsSystem { | |
ncollide_world: NcollideWorld; // or whatever it's called | |
} | |
impl PhysicsSystem { | |
fn new() { | |
// whatever | |
} | |
} | |
impl System for PhysicsSystem { | |
// whatever the System trait is | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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