Skip to content

Creating a world

Ethan Almloff edited this page Apr 7, 2024 · 2 revisions

Here's how you create a world in

fn main(){
    let mut engine = World::new();

    // Add an Entity and Components:
    let entities_and_components = &mut engine.entities_and_components;
    let entity = entities_and_components.add_entity();

    // Add components like Position and Velocity;
    entities_and_components.add_component_to(entity, Position { x: 0.0, y: 0.0 });
    entities_and_components.add_component_to(entity, Velocity { x: 1.0, y: 1.0 });

    // or you can do it all in one step:
    let entity = entities_and_components
        .add_entity_with((Position { x: 0.0, y: 0.0 }, Velocity { x: 1.0, y: 1.0 }));
}

For how to add and define system look at creating systems

Clone this wiki locally