Extract entities
This commit is contained in:
parent
b7780b8862
commit
cef21f4a00
4 changed files with 24 additions and 20 deletions
1
src/game/mod.rs
Normal file
1
src/game/mod.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod objects;
|
18
src/game/objects.rs
Normal file
18
src/game/objects.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
use avian2d::prelude::*;
|
||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Component, Default)]
|
||||||
|
#[require(Collider, Mesh2d, MeshMaterial2d<ColorMaterial>, Restitution = Restitution::new(1.0), RigidBody, TransformInterpolation, Transform)]
|
||||||
|
struct GameObject;
|
||||||
|
|
||||||
|
#[derive(Component, Default)]
|
||||||
|
#[require(GameObject, RigidBody = RigidBody::Dynamic)]
|
||||||
|
pub struct Ball;
|
||||||
|
|
||||||
|
#[derive(Component, Default)]
|
||||||
|
#[require(Ball)]
|
||||||
|
pub struct Player;
|
||||||
|
|
||||||
|
#[derive(Component, Default)]
|
||||||
|
#[require(GameObject, RigidBody = RigidBody::Static)]
|
||||||
|
pub struct Wall;
|
23
src/lib.rs
23
src/lib.rs
|
@ -13,9 +13,10 @@ use bevy_rand::prelude::{EntropyPlugin, GlobalEntropy, WyRand};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use wyrand::WyRand as LocalRng;
|
use wyrand::WyRand as LocalRng;
|
||||||
|
|
||||||
pub mod utils;
|
mod game;
|
||||||
|
use game::objects::{Ball, Player, Wall};
|
||||||
use utils::AppSettings;
|
mod utils;
|
||||||
|
pub use utils::AppSettings;
|
||||||
|
|
||||||
const BALL_COUNT: u8 = 32;
|
const BALL_COUNT: u8 = 32;
|
||||||
const BALL_SIZES: Range<f32> = 10.0..25.0;
|
const BALL_SIZES: Range<f32> = 10.0..25.0;
|
||||||
|
@ -72,18 +73,6 @@ fn setup_ui(mut commands: Commands) {
|
||||||
commands.spawn((Name::new("Camera"), Camera2d, IsDefaultUiCamera));
|
commands.spawn((Name::new("Camera"), Camera2d, IsDefaultUiCamera));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Default)]
|
|
||||||
#[require(Collider, Mesh2d, MeshMaterial2d<ColorMaterial>, Restitution = Restitution::new(1.0), RigidBody, TransformInterpolation, Transform)]
|
|
||||||
struct GameObject;
|
|
||||||
|
|
||||||
#[derive(Component, Default)]
|
|
||||||
#[require(GameObject, RigidBody = RigidBody::Dynamic)]
|
|
||||||
struct Ball;
|
|
||||||
|
|
||||||
#[derive(Component, Default)]
|
|
||||||
#[require(Ball)]
|
|
||||||
struct Player;
|
|
||||||
|
|
||||||
fn setup_player(
|
fn setup_player(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||||
|
@ -126,10 +115,6 @@ fn setup_balls(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Component, Default)]
|
|
||||||
#[require(GameObject, RigidBody = RigidBody::Static)]
|
|
||||||
struct Wall;
|
|
||||||
|
|
||||||
fn setup_walls(
|
fn setup_walls(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use bevy::prelude::AppExit;
|
use bevy::prelude::AppExit;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
use distributed_physics_test::{run_app, utils::AppSettings};
|
use distributed_physics_test::{AppSettings, run_app};
|
||||||
|
|
||||||
fn main() -> AppExit {
|
fn main() -> AppExit {
|
||||||
run_app(AppSettings::parse())
|
run_app(AppSettings::parse())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue