add off_map
This commit is contained in:
parent
c8391f34f2
commit
3226bbc411
|
@ -9,6 +9,7 @@ mod input;
|
||||||
mod camera;
|
mod camera;
|
||||||
mod map;
|
mod map;
|
||||||
mod player;
|
mod player;
|
||||||
|
mod off_map;
|
||||||
|
|
||||||
#[derive(PhysicsLayer)]
|
#[derive(PhysicsLayer)]
|
||||||
pub enum Layer {
|
pub enum Layer {
|
||||||
|
@ -33,6 +34,7 @@ fn main() {
|
||||||
.add_system(map::collide)
|
.add_system(map::collide)
|
||||||
.add_system(player::spawn_player)
|
.add_system(player::spawn_player)
|
||||||
.add_system(player::input.after("input"))
|
.add_system(player::input.after("input"))
|
||||||
|
.add_system(off_map::check)
|
||||||
.add_system(exit_on_escape)
|
.add_system(exit_on_escape)
|
||||||
// .add_system(log_collisions)
|
// .add_system(log_collisions)
|
||||||
.run();
|
.run();
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
pub struct CanFallOffMap;
|
||||||
|
|
||||||
|
const MIN_Y: f32 = -20.0;
|
||||||
|
|
||||||
|
pub fn check(
|
||||||
|
mut commands: Commands,
|
||||||
|
entities: Query<(Entity, &Transform), With<CanFallOffMap>>,
|
||||||
|
) {
|
||||||
|
for (entity, transform) in entities.iter() {
|
||||||
|
if transform.translation.y < MIN_Y {
|
||||||
|
commands.entity(entity).despawn_recursive();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ use rand::prelude::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
input::{InputState, Key, Source as InputSource},
|
input::{InputState, Key, Source as InputSource},
|
||||||
map::GroundContact,
|
map::GroundContact,
|
||||||
|
off_map::CanFallOffMap,
|
||||||
Layer,
|
Layer,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ pub fn spawn_player(
|
||||||
input_source: input_source.clone(),
|
input_source: input_source.clone(),
|
||||||
rotation: 0.0,
|
rotation: 0.0,
|
||||||
})
|
})
|
||||||
|
.insert(CanFallOffMap)
|
||||||
.insert(GroundContact::default())
|
.insert(GroundContact::default())
|
||||||
.insert(GlobalTransform::default())
|
.insert(GlobalTransform::default())
|
||||||
.insert(transform)
|
.insert(transform)
|
||||||
|
|
Loading…
Reference in New Issue