diff --git a/src/goal.rs b/src/goal.rs new file mode 100644 index 0000000..fc4d7ef --- /dev/null +++ b/src/goal.rs @@ -0,0 +1,35 @@ +use bevy::prelude::*; +use bevy_ecs_ldtk::prelude::*; + +use crate::player::Player; + +#[derive(Default, Component)] +pub struct Goal; + +#[derive(Default, Bundle, LdtkEntity)] +pub struct GoalBundle { + goal: Goal, + #[sprite_sheet_bundle] + sprite_sheet_bundle: LdtkSpriteSheetBundle, + #[grid_coords] + grid_coords: GridCoords, +} + +pub fn check_goal( + level_selection: ResMut, + players: Query<&GridCoords, (With, Changed)>, + goals: Query<&GridCoords, With>, +) { + if players + .iter() + .zip(goals.iter()) + .any(|(player_grid_coords, goal_grid_coords)| player_grid_coords == goal_grid_coords) + { + let indices = match level_selection.into_inner() { + LevelSelection::Indices(indices) => indices, + _ => panic!("level selection should always be Indices in this game"), + }; + + indices.level += 1; + } +} \ No newline at end of file diff --git a/src/level_structure.rs b/src/level_structure.rs new file mode 100644 index 0000000..9a4fba2 --- /dev/null +++ b/src/level_structure.rs @@ -0,0 +1,10 @@ +use bevy::prelude::*; +use bevy_ecs_ldtk::prelude::*; + +#[derive(Default, Component)] +pub struct Wall; + +#[derive(Default, Bundle, LdtkIntCell)] +pub struct WallBundle { + wall: Wall, +}