acceleration module

main
Zynh Ludwig 2024-09-04 02:06:31 -07:00
parent 4317ccf3a3
commit d89666b3f0
2 changed files with 22 additions and 16 deletions

17
src/acceleration.rs Normal file
View File

@ -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,
}

View File

@ -1,8 +1,13 @@
// #![allow(unused)] // #![allow(unused)]
mod acceleration;
mod boid_mesh; mod boid_mesh;
mod boundary; mod boundary;
use acceleration::{
AlignmentAcceleration, BoidAccelerationBundle, CohesionAcceleration, SeperationAcceleration,
};
use bevy::{color::palettes::tailwind, prelude::*, sprite::MaterialMesh2dBundle}; use bevy::{color::palettes::tailwind, prelude::*, sprite::MaterialMesh2dBundle};
use boid_mesh::BoidMesh; use boid_mesh::BoidMesh;
use rand::{Rng, SeedableRng}; use rand::{Rng, SeedableRng};
@ -32,22 +37,6 @@ struct Boid;
#[derive(Component, Default)] #[derive(Component, Default)]
struct Velocity(Vec2); 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)] #[derive(Bundle, Default)]
struct BoidBundle { struct BoidBundle {
mesh: MaterialMesh2dBundle<ColorMaterial>, mesh: MaterialMesh2dBundle<ColorMaterial>,