fix
This commit is contained in:
25
src/main.rs
25
src/main.rs
@@ -1,10 +1,16 @@
|
||||
use bevy::prelude::*;
|
||||
use asset_loading::ImageAssets;
|
||||
use bevy::{prelude::*, state::app::StatesPlugin};
|
||||
|
||||
mod asset_loading;
|
||||
|
||||
pub mod player;
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugins(DefaultPlugins)
|
||||
.add_plugins((DefaultPlugins, asset_loading::plugin))
|
||||
.init_state::<GameState>()
|
||||
// We need to register components to make them visible to Blenvy
|
||||
.add_systems(OnExit(GameState::Loading), debug_our_king)
|
||||
.add_systems(Startup, (setup, player::init_player))
|
||||
.add_systems(Update, player::move_camera)
|
||||
.add_systems(FixedUpdate, player::advance_physics)
|
||||
@@ -18,6 +24,21 @@ fn main() {
|
||||
.run();
|
||||
}
|
||||
|
||||
#[derive(States, Default, Clone, Eq, PartialEq, Debug, Hash)]
|
||||
enum GameState {
|
||||
/// During the loading State the loading_plugin will load our assets
|
||||
#[default]
|
||||
Loading,
|
||||
/// During this State the actual game logic is executed
|
||||
Playing,
|
||||
/// Here the menu is drawn and waiting for player interaction
|
||||
Menu,
|
||||
}
|
||||
|
||||
fn debug_our_king(mut commands: Commands, images: Res<ImageAssets>) {
|
||||
commands.spawn(Sprite::from_image(images.king.clone()));
|
||||
}
|
||||
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
|
||||
Reference in New Issue
Block a user