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 #4

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

Show how users can organize their code into plugins #4

janhohenheim opened this issue Jul 4, 2024 · 2 comments
Milestone

Comments

@janhohenheim
Copy link
Member

janhohenheim commented Jul 4, 2024

Migrated from bevyengine/bevy_github_ci_template#62

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(...);
}

I don't particularly care whether there's a top-level plugin, a plugin exported by a lib.rs or if everything is added in main as shown here. That's besides the point.

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.

@janhohenheim janhohenheim changed the title Show how users can organize their code into plugins #62 Show how users can organize their code into plugins Jul 4, 2024
@MiniaczQ
Copy link
Collaborator

MiniaczQ commented Jul 5, 2024

Do we consider this done with #16?

@janhohenheim
Copy link
Member Author

I'd say so

benfrankel added a commit that referenced this issue Jul 6, 2024
@benfrankel benfrankel added this to the Bevy Jam 5 milestone Jul 15, 2024
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

3 participants