Skip to content

Commit

Permalink
Split stuff into lib and main
Browse files Browse the repository at this point in the history
  • Loading branch information
janhohenheim committed Jul 7, 2024
1 parent e98929e commit 94698d7
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
.cargo/config.toml
/wasm
32 changes: 0 additions & 32 deletions src/core/mod.rs

This file was deleted.

38 changes: 38 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Disable console on Windows for non-dev builds.
#![cfg_attr(not(feature = "dev"), windows_subsystem = "windows")]

mod loading;
mod ready;
mod ui;

use bevy::prelude::*;

pub struct GamePlugin;

impl Plugin for GamePlugin {
fn build(&self, app: &mut AppBuilder) {
// State setup
app.init_state::<AppState>();
// Add state scoped entities for UI cleanup
app.enable_state_scoped_entities::<AppState>();
// Print state transitions in dev builds
#[cfg(feature = "dev")]
app.add_systems(Update, bevy::dev_tools::states::log_transitions::<AppState>);

// Sub plugins
app.add_plugins((loading::plugin, ready::plugin));

// Other
app.add_plugins(ui::plugin);

// For a larger UI example visit: https://github.com/MiniaczQ/bevy-substate-project
}
}

/// Root state of the application.
#[derive(States, Debug, PartialEq, Eq, Hash, Clone, Default)]
enum AppState {
#[default]
Loading,
Ready,
}
File renamed without changes.
9 changes: 4 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Disable console on Windows for non-dev builds.
#![cfg_attr(not(feature = "dev"), windows_subsystem = "windows")]

mod core;
mod ui;

use bevy_template::GamePlugin;
use bevy::asset::AssetMetaCheck;
use bevy::prelude::*;

Expand All @@ -28,14 +26,15 @@ fn main() {
// The window will be made visible after a few frames.
// This is useful when you want to avoid the white window that shows up before the GPU is ready to render the app.
// Based on: <https://github.com/bevyengine/bevy/blob/v0.14.0/examples/window/window_settings.rs#L56>
visible: true, // TODO: Set to false when the freeze is fixed
// false on windows
visible: cfg!(not(windows)),
..default()
}
.into(),
..default()
}),
)
// We separate Bevy configuration from our game configuration.
.add_plugins(core::plugin)
.add_plugins(GamePlugin)
.run();
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 94698d7

Please sign in to comment.