Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show how users can organize their code into plugins #62

Closed
janhohenheim opened this issue Jul 4, 2024 · 0 comments
Closed

Show how users can organize their code into plugins #62

janhohenheim opened this issue Jul 4, 2024 · 0 comments

Comments

@janhohenheim
Copy link
Member

This might be a major bikeshed.

Over the years, I've experimented with many styles of organizing Bevy games, and I've landed at the following convention:

// main.rs

mod physics;
mod level;
mod camera;

fn main() {
    App::new().add_plugins((
        DefaultPlugins,
        physics::plugin,
        level::plugin,
        camera::plugin,
}
// camera.rs, level.rs, physics.rs

pub(super) fn plugin(app: &mut App) {
    app.add_systems(...);
}

Any of these plugins can (and probably will) have sub-plugins. I usually have about one plugin per file, which works out pretty well when using this terse plugin-function-syntax above. Please see the conversation here for a writeup I did about why I prefer to organize games this way.

This is the style used in Foxtrot, parts of Blenvy, and the unofficial best practices

This stuff is certainly opinionated, but I think we have to recognize the following things:

  • The template will be organized somehow
  • Users will generate a lot of nested modules while coding a game
  • Users will implicitly accept the organization presented in the template as a good starting point and try to follow it
  • The organization used for the empty template, which will only contain a few modules, will be stretched to serve users that have dozens upon dozens of modules

This means that we should take care to make the organization presented here conductive to development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants