Skip to content

Commit

Permalink
Players and enemies obstacles
Browse files Browse the repository at this point in the history
  • Loading branch information
martinstarman committed Dec 29, 2024
1 parent cb568bb commit 63df19e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/enemy.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use bevy::{math::bounding::Aabb2d, prelude::*};
use std::collections::HashMap;
use vleue_navigator::prelude::PrimitiveObstacle;

use crate::{
animation::{Animation, AnimationAtlasConfig},
Expand Down Expand Up @@ -155,6 +156,12 @@ pub fn enemy_setup(
},
Selectable::default(),
))
.with_children(|parent| {
parent.spawn((
Transform::from_translation(Vec3::new(0., -12., 0.)),
PrimitiveObstacle::Rectangle(Rectangle::new(16., 8.)),
));
})
.observe(enemy_select::<Pointer<Up>>());
}

Expand Down
1 change: 1 addition & 0 deletions src/navmesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub fn navmesh_setup(mut commands: Commands) {
));
}

// TODO: children are drawn twice
pub fn navmesh_draw(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
Expand Down
11 changes: 10 additions & 1 deletion src/player.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use bevy::{math::bounding::Aabb2d, prelude::*, window::PrimaryWindow};
use std::collections::HashMap;
use vleue_navigator::{prelude::ManagedNavMesh, NavMesh};
use vleue_navigator::{
prelude::{ManagedNavMesh, PrimitiveObstacle},
NavMesh,
};

use crate::{
animation::{Animation, AnimationAtlasConfig},
Expand Down Expand Up @@ -132,6 +135,12 @@ pub fn player_setup(
},
Selectable::default(),
))
.with_children(|parent| {
parent.spawn((
Transform::from_translation(Vec3::new(0., -12., 0.)),
PrimitiveObstacle::Rectangle(Rectangle::new(16., 8.)),
));
})
.observe(player_select::<Pointer<Up>>());
}

Expand Down

0 comments on commit 63df19e

Please sign in to comment.