Giter Club home page Giter Club logo

bevy_particle_systems's Introduction

bevy_particle_systems

Crates.io docs MIT

A native and WASM-compatible 2D particle system plugin for bevy

Note: This crate is still under development and its API may change between releases.

Example

The above was captured running a release build of the basic example, cargo run --example basic --release, and ran at 190-200 FPS on a 2019 Intel i9 MacBook Pro, rendering about 10k particles.

INFO bevy diagnostic: frame_time                      :    5.125810ms (avg 5.211673ms)
INFO bevy diagnostic: fps                             :  206.027150   (avg 204.176718)
INFO bevy diagnostic: entity_count                    : 11358.713999   (avg 11341.450000)

Usage

  1. Add the [ParticleSystemPlugin] plugin.
use bevy::prelude::*;
use bevy_particle_systems::ParticleSystemPlugin;

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, ParticleSystemPlugin::default())) // <-- Add the plugin
        // ...
        .add_systems(Startup, spawn_particle_system)
        .run();
}

fn spawn_particle_system() { /* ... */ }
  1. Spawn a particle system whenever necessary.
use bevy::prelude::*;
use bevy_particle_systems::*;

fn spawn_particle_system(mut commands: Commands, asset_server: Res<AssetServer>) {
    commands
    // Add the bundle specifying the particle system itself.
    .spawn(ParticleSystemBundle {
        particle_system: ParticleSystem {
            max_particles: 10_000,
            texture: ParticleTexture::Sprite(asset_server.load("my_particle.png")),
            spawn_rate_per_second: 25.0.into(),
            initial_speed: JitteredValue::jittered(3.0, -1.0..1.0),
            lifetime: JitteredValue::jittered(8.0, -2.0..2.0),
            color: ColorOverTime::Gradient(Gradient::new(vec![
                ColorPoint::new(Color::WHITE, 0.0),
                ColorPoint::new(Color::rgba(0.0, 0.0, 1.0, 0.0), 1.0),
            ])),
            looping: true,
            system_duration_seconds: 10.0,
            ..ParticleSystem::default()
        },
        ..ParticleSystemBundle::default()
    })
    // Add the playing component so it starts playing. This can be added later as well.
    .insert(Playing);
}

Bevy Versions

bevy_particle_systems bevy
0.11 0.12
0.10 0.11
0.9 0.10
0.6 - 0.8 0.9
0.5 0.8
0.4 0.7

bevy_particle_systems's People

Contributors

abnormalbrain avatar johanhelsing avatar cbournhonesque avatar rayoule avatar monamayrhofer avatar theanti9 avatar zuqini avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.