cohesion scaffold
This commit is contained in:
parent
3cab0eecd5
commit
b2b59d68d5
1 changed files with 19 additions and 0 deletions
19
src/main.rs
19
src/main.rs
|
@ -19,13 +19,32 @@ struct Boid;
|
|||
#[derive(Component, Default)]
|
||||
struct Velocity(Vec2);
|
||||
|
||||
#[derive(Component, Default)]
|
||||
struct SeperationCache(Vec2);
|
||||
|
||||
#[derive(Component, Default)]
|
||||
struct CohesionCache(Vec2);
|
||||
|
||||
#[derive(Component, Default)]
|
||||
struct AlignmentCache(Vec2);
|
||||
|
||||
#[derive(Bundle, Default)]
|
||||
struct BoidCacheBundle {
|
||||
s_cache: SeperationCache,
|
||||
c_cache: CohesionCache,
|
||||
a_cache: AlignmentCache,
|
||||
}
|
||||
|
||||
#[derive(Bundle, Default)]
|
||||
struct BoidBundle {
|
||||
mesh: MaterialMesh2dBundle<ColorMaterial>,
|
||||
velocity: Velocity,
|
||||
boid: Boid,
|
||||
cache: BoidCacheBundle,
|
||||
}
|
||||
|
||||
fn seperation(mut boids: Query<(&Transform, &mut SeperationCache), With<Boid>>) {}
|
||||
|
||||
fn move_boids(mut boids: Query<(&mut Transform, &Velocity), With<Boid>>, time: Res<Time>) {
|
||||
for (mut transform, velocity) in &mut boids {
|
||||
transform.translation += velocity.0.extend(0.) * time.delta_seconds();
|
||||
|
|
Loading…
Reference in a new issue