diff --git a/src/acceleration.rs b/src/acceleration.rs new file mode 100644 index 0000000..67da275 --- /dev/null +++ b/src/acceleration.rs @@ -0,0 +1,17 @@ +use bevy::prelude::*; + +#[derive(Component, Default)] +pub struct SeperationAcceleration(pub Vec2); + +#[derive(Component, Default)] +pub struct CohesionAcceleration(pub Vec2); + +#[derive(Component, Default)] +pub struct AlignmentAcceleration(pub Vec2); + +#[derive(Bundle, Default)] +pub struct BoidAccelerationBundle { + pub s_cache: SeperationAcceleration, + pub c_cache: CohesionAcceleration, + pub a_cache: AlignmentAcceleration, +} diff --git a/src/main.rs b/src/main.rs index f4bf072..86ea2f5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,13 @@ // #![allow(unused)] +mod acceleration; mod boid_mesh; mod boundary; +use acceleration::{ + AlignmentAcceleration, BoidAccelerationBundle, CohesionAcceleration, SeperationAcceleration, +}; + use bevy::{color::palettes::tailwind, prelude::*, sprite::MaterialMesh2dBundle}; use boid_mesh::BoidMesh; use rand::{Rng, SeedableRng}; @@ -32,22 +37,6 @@ struct Boid; #[derive(Component, Default)] struct Velocity(Vec2); -#[derive(Component, Default)] -struct SeperationAcceleration(Vec2); - -#[derive(Component, Default)] -struct CohesionAcceleration(Vec2); - -#[derive(Component, Default)] -struct AlignmentAcceleration(Vec2); - -#[derive(Bundle, Default)] -struct BoidAccelerationBundle { - s_cache: SeperationAcceleration, - c_cache: CohesionAcceleration, - a_cache: AlignmentAcceleration, -} - #[derive(Bundle, Default)] struct BoidBundle { mesh: MaterialMesh2dBundle,