App Builder (main function)

Relevant official examples: All of them ;)

In particular, check out the complete game examples: alien_cake_addict, breakout.


To enter the bevy runtime, you need to configure an App. The app is how you define the structure of all the things that make up your project: plugins, systems, event types, states, stages

Technically, the App contains the ECS World(s) (where all the data is stored) and Schedule(s) (where all the systems to run are stored). For advanced use-cases, Sub-apps are a way to have more than one ECS World and Schedule.

Local resources do not need to be registered. They are part of their respective systems.

Component types do not need to be registered.


Schedules cannot (yet) be modified at runtime; all systems you want to run must be added/configured in the App ahead of time.

The data in the ECS World can be modified at any time; create/destroy your entities and resources, from systems using Commands, or exclusive systems using direct World access.

Resources can also be initialized ahead of time, here in the App builder.


You also need to add the plugin group with Bevy's built-in functionality: either DefaultPlugins if you are making a full game/app, or MinimalPlugins for something like a headless server.

Note that there are some special configuration resources that must be added first, if you would like to use them, to take effect.


fn main() {
    App::new()
        // make sure to add any config resources first, before Bevy:
        .insert_resource(WindowDescriptor {
            // ...
            ..Default::default()
        }) // etc...

        // Bevy itself:
        .add_plugins(DefaultPlugins)

        // resources:
        .insert_resource(StartingLevel(3))
        // if it implements `Default` or `FromWorld`
        .init_resource::<MyFancyResource>()

        // events:
        .add_event::<LevelUpEvent>()

        // systems to run once at startup:
        .add_startup_system(spawn_player)

        // systems to run each frame:
        .add_system(player_level_up)
        .add_system(debug_levelups)
        .add_system(debug_stats_change)
        // ...

        // launch the app!
        .run();
}