cargo-fmt
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
|
use bevy::{prelude::*, sprite::MaterialMesh2dBundle};
|
||||||
|
|
||||||
const BACKGROUND_COLOR: Color = Color::srgb(0.4, 0.4, 0.4);
|
const BACKGROUND_COLOR: Color = Color::srgb(0.4, 0.4, 0.4);
|
||||||
@@ -7,16 +6,11 @@ const TURN_FACTOR: f32 = 1.;
|
|||||||
|
|
||||||
pub struct BoidsPlugin;
|
pub struct BoidsPlugin;
|
||||||
|
|
||||||
impl Plugin for BoidsPlugin{
|
impl Plugin for BoidsPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app
|
app.insert_resource(ClearColor(BACKGROUND_COLOR))
|
||||||
.insert_resource(ClearColor(BACKGROUND_COLOR))
|
|
||||||
.add_systems(Startup, (spawn_camera, spawn_boids))
|
.add_systems(Startup, (spawn_camera, spawn_boids))
|
||||||
.add_systems(FixedUpdate, (
|
.add_systems(FixedUpdate, (apply_velocity, turn_if_edge, check_keyboard));
|
||||||
apply_velocity,
|
|
||||||
turn_if_edge,
|
|
||||||
check_keyboard,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,11 +52,7 @@ fn spawn_boids(
|
|||||||
let num_boids = 1000;
|
let num_boids = 1000;
|
||||||
for i in 0..num_boids {
|
for i in 0..num_boids {
|
||||||
let frac = 2.0 * std::f32::consts::PI / (num_boids as f32) * (i as f32);
|
let frac = 2.0 * std::f32::consts::PI / (num_boids as f32) * (i as f32);
|
||||||
let vel = Vec3::new(
|
let vel = Vec3::new(frac.cos() * 10.0, frac.sin() * 10.0, 0.0);
|
||||||
frac.cos() * 10.0,
|
|
||||||
frac.sin() * 10.0,
|
|
||||||
0.0,
|
|
||||||
);
|
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
BoidBundle::new(vel),
|
BoidBundle::new(vel),
|
||||||
MaterialMesh2dBundle {
|
MaterialMesh2dBundle {
|
||||||
@@ -80,7 +70,7 @@ fn spawn_boids(
|
|||||||
mesh: meshes.add(Triangle2d::default()).into(),
|
mesh: meshes.add(Triangle2d::default()).into(),
|
||||||
material: materials.add(PLAYERBOID_COLOR),
|
material: materials.add(PLAYERBOID_COLOR),
|
||||||
..default()
|
..default()
|
||||||
}
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
mod birdoids_plugin;
|
||||||
mod breakout_plugin;
|
mod breakout_plugin;
|
||||||
mod hello_world_plugin;
|
mod hello_world_plugin;
|
||||||
mod birdoids_plugin;
|
|
||||||
|
|
||||||
|
use birdoids_plugin::BoidsPlugin;
|
||||||
use breakout_plugin::BreakoutPlugin;
|
use breakout_plugin::BreakoutPlugin;
|
||||||
use hello_world_plugin::HelloPlugin;
|
use hello_world_plugin::HelloPlugin;
|
||||||
use birdoids_plugin::BoidsPlugin;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
|
|||||||
Reference in New Issue
Block a user