haw-gj13-game/src/game/player.rs

25 lines
562 B
Rust
Raw Normal View History

use bevy::prelude::*;
2024-11-22 22:26:20 +01:00
use bevy_rapier2d::prelude::*;
2024-11-22 22:55:45 +01:00
use crate::{AppState, METER};
2024-11-22 22:26:20 +01:00
use super::set::IngameSet;
#[derive(Component)]
struct Player {}
pub(super) fn player_plugin(app: &mut App) {
2024-11-22 22:26:20 +01:00
app.add_systems(OnEnter(AppState::InGame), add_player.in_set(IngameSet));
}
pub fn add_player(mut commands: Commands) {
2024-11-22 22:26:20 +01:00
commands
.spawn(Player {})
2024-11-22 22:55:45 +01:00
.insert((
RigidBody::Dynamic,
Collider::cuboid(0.4 * METER, 0.9 * METER),
Velocity::default(),
))
2024-11-22 22:26:20 +01:00
.insert(ActiveEvents::COLLISION_EVENTS);
}