add player to game

This commit is contained in:
TudbuT 2024-11-22 22:26:20 +01:00
parent c6f6415d8d
commit b72cfae04b
No known key found for this signature in database
GPG key ID: B3CF345217F202D3
4 changed files with 14 additions and 3 deletions

View file

@ -3,7 +3,8 @@ use bevy_rapier2d::prelude::*;
use player::player_plugin;
mod player;
mod set;
fn game_plugin(app: &mut App) {
app.add_plugins((player_plugin));
app.add_plugins(player_plugin);
}

View file

@ -1,14 +1,19 @@
use bevy::prelude::*;
use bevy_rapier2d::prelude::*;
use crate::AppState;
use super::set::IngameSet;
#[derive(Component)]
struct Player {}
pub(super) fn player_plugin(app: &mut App) {
//app.add_systems(OnEnter(AppState::InGame), add_player.in_set(GameplaySet));
app.add_systems(OnEnter(AppState::InGame), add_player.in_set(IngameSet));
}
pub fn add_player(mut commands: Commands) {
commands.spawn(Player {});
commands
.spawn(Player {})
.insert(ActiveEvents::COLLISION_EVENTS);
}

4
src/game/set.rs Normal file
View file

@ -0,0 +1,4 @@
use bevy::prelude::*;
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
pub struct IngameSet;

View file

@ -1,3 +1,4 @@
#![allow(unused)]
use bevy::prelude::*;
use bevy_rapier2d::prelude::*;