ferravex_play/particles/
presets.rs

1//! Original procedural templates. Units are meters/seconds; scale the authored
2//! velocity, acceleration and size for pixel-coordinate games.
3use super::*;
4pub fn sparks(color: [f32; 4]) -> EmitterDesc {
5    EmitterDesc {
6        particle: ParticleDesc {
7            lifetime: 0.42,
8            acceleration: [0., -9., 0.],
9            start_color: color,
10            end_color: [color[0], color[1], color[2], 0.],
11            start_size: 0.07,
12            end_size: 0.01,
13            ..Default::default()
14        },
15        motion: ParticleMotion {
16            drag: 1.2,
17            angular_velocity: 7.,
18            ..Default::default()
19        },
20        shape: SpawnShape::Sphere { radius: 0.04 },
21        velocity_cone: Some(DirectionCone {
22            axis: [0., 1., 0.],
23            angle: 1.3,
24            speed: [1., 4.],
25        }),
26        lifetime_jitter: 0.3,
27        size_jitter: 0.4,
28        rotation_jitter: std::f32::consts::PI,
29        rate: 0.,
30        max_per_update: 64,
31        ..Default::default()
32    }
33}
34pub fn dust(color: [f32; 4]) -> EmitterDesc {
35    EmitterDesc {
36        particle: ParticleDesc {
37            lifetime: 0.7,
38            velocity: [0., 0.5, -0.5],
39            acceleration: [0., 0.2, 0.],
40            start_color: color,
41            end_color: [color[0], color[1], color[2], 0.],
42            start_size: 0.15,
43            end_size: 0.6,
44            ..Default::default()
45        },
46        motion: ParticleMotion {
47            drag: 1.5,
48            angular_velocity: 0.5,
49            ..Default::default()
50        },
51        shape: SpawnShape::Box {
52            half: [0.6, 0.03, 0.1],
53        },
54        velocity_jitter: [0.6, 0.2, 0.3],
55        lifetime_jitter: 0.2,
56        size_jitter: 0.3,
57        rotation_jitter: std::f32::consts::PI,
58        inherit_velocity: 0.05,
59        rate: 32.,
60        ..Default::default()
61    }
62}
63pub fn exhaust(color: [f32; 4]) -> EmitterDesc {
64    EmitterDesc {
65        particle: ParticleDesc {
66            lifetime: 0.5,
67            velocity: [0., 0., -2.],
68            acceleration: [0., 0.4, 0.],
69            start_color: color,
70            end_color: [color[0], color[1], color[2], 0.],
71            start_size: 0.08,
72            end_size: 0.32,
73            ..Default::default()
74        },
75        motion: ParticleMotion {
76            drag: 0.8,
77            ..Default::default()
78        },
79        shape: SpawnShape::Disc { radius: 0.07 },
80        velocity_jitter: [0.12, 0.12, 0.4],
81        size_jitter: 0.2,
82        rotation_jitter: std::f32::consts::PI,
83        rate: 24.,
84        ..Default::default()
85    }
86}