From 00678bd2192c63ab7d681dcbcc0e678375639397 Mon Sep 17 00:00:00 2001 From: Sergei Surovtsev Date: Wed, 17 Jan 2024 10:25:58 +0300 Subject: [PATCH] rm examples --- examples/particles.rs | 47 -------------------------- examples/shaders.rs | 64 ----------------------------------- examples/sprites.rs | 77 ------------------------------------------- 3 files changed, 188 deletions(-) delete mode 100644 examples/particles.rs delete mode 100644 examples/shaders.rs delete mode 100644 examples/sprites.rs diff --git a/examples/particles.rs b/examples/particles.rs deleted file mode 100644 index 49c6db8..0000000 --- a/examples/particles.rs +++ /dev/null @@ -1,47 +0,0 @@ -//! Renders an animated sprite by loading all animation frames from a single image (a sprite sheet) -//! into a texture atlas, and changing the displayed image periodically. - -use bevy::prelude::*; -use bevy_particle_systems::*; - -fn main() { - App::new() - .add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) - .add_plugins(ParticleSystemPlugin) // prevents blurry sprites - .add_systems(Startup, spawn_particles) - .run(); -} - -fn spawn_particles(mut commands: Commands, asset_server: Res) { - commands.spawn(Camera2dBundle::default()); - - commands - .spawn(ParticleSystemBundle { - particle_system: ParticleSystem { - max_particles: 50_000, - texture: ParticleTexture::Sprite(asset_server.load("px.png")), - spawn_rate_per_second: 1000.0.into(), - initial_speed: JitteredValue::jittered(200.0, -50.0..50.0), - lifetime: JitteredValue::jittered(8.0, -2.0..2.0), - color: ColorOverTime::Gradient(Curve::new(vec![ - CurvePoint::new(Color::PURPLE, 0.0), - CurvePoint::new(Color::RED, 0.5), - CurvePoint::new(Color::rgba(0.0, 0.0, 1.0, 0.0), 1.0), - ])), - looping: true, - system_duration_seconds: 10.0, - max_distance: Some(300.0), - scale: 2.0.into(), - bursts: vec![ - ParticleBurst::new(0.0, 1000), - ParticleBurst::new(2.0, 1000), - ParticleBurst::new(4.0, 1000), - ParticleBurst::new(6.0, 1000), - ParticleBurst::new(8.0, 1000), - ], - ..ParticleSystem::default() - }, - ..ParticleSystemBundle::default() - }) - .insert(Playing); -} diff --git a/examples/shaders.rs b/examples/shaders.rs deleted file mode 100644 index bdc16db..0000000 --- a/examples/shaders.rs +++ /dev/null @@ -1,64 +0,0 @@ -//! A shader and a material that uses it. - -use bevy::{ - prelude::*, - reflect::{TypePath, TypeUuid}, - render::render_resource::{AsBindGroup, ShaderRef}, -}; - -fn main() { - App::new() - .add_plugins((DefaultPlugins, MaterialPlugin::::default())) - .add_systems(Startup, setup) - .run(); -} - -/// set up a simple 3D scene -fn setup( - mut commands: Commands, - mut meshes: ResMut>, - mut materials: ResMut>, - asset_server: Res, -) { - // cube - commands.spawn(MaterialMeshBundle { - mesh: meshes.add(Mesh::from(shape::Cube { size: 3.0 })), - transform: Transform::from_xyz(0.0, 0.5, 0.0), - material: materials.add(CustomMaterial { - color: Color::WHITE, - color_texture: Some(asset_server.load("textures/cabron.jpg")), - alpha_mode: AlphaMode::Blend, - }), - ..default() - }); - - // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); -} - -/// The Material trait is very configurable, but comes with sensible defaults for all methods. -/// You only need to implement functions for features that need non-default behavior. See the Material api docs for details! -impl Material for CustomMaterial { - fn fragment_shader() -> ShaderRef { - "shaders/custom_material.wgsl".into() - } - - fn alpha_mode(&self) -> AlphaMode { - self.alpha_mode - } -} - -// This is the struct that will be passed to your shader -#[derive(AsBindGroup, TypeUuid, TypePath, Debug, Clone)] -#[uuid = "f690fdae-d598-45ab-8225-97e2a3f056e0"] -pub struct CustomMaterial { - #[uniform(0)] - color: Color, - #[texture(1)] - #[sampler(2)] - color_texture: Option>, - alpha_mode: AlphaMode, -} diff --git a/examples/sprites.rs b/examples/sprites.rs deleted file mode 100644 index b7c512f..0000000 --- a/examples/sprites.rs +++ /dev/null @@ -1,77 +0,0 @@ -//! Renders an animated sprite by loading all animation frames from a single image (a sprite sheet) -//! into a texture atlas, and changing the displayed image periodically. - -use bevy::prelude::*; - -fn main() { - App::new() - .add_plugins(DefaultPlugins.set(ImagePlugin::default_nearest())) // prevents blurry sprites - .add_startup_system(setup) - .add_system(animate_sprite) - .run(); -} - -#[derive(Component)] -struct AnimationIndices { - first: usize, - last: usize, -} - -#[derive(Component, Deref, DerefMut)] -struct AnimationTimer(Timer); - -fn animate_sprite( - time: Res