acceleration module
This commit is contained in:
parent
4317ccf3a3
commit
d89666b3f0
2 changed files with 22 additions and 16 deletions
17
src/acceleration.rs
Normal file
17
src/acceleration.rs
Normal 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,
|
||||
}
|
21
src/main.rs
21
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<ColorMaterial>,
|
||||
|
|
Loading…
Reference in a new issue