Skip to main content

particles_2/
particles_2.rs

1use sge::prelude::*;
2
3fn main() {
4    let opts = Opts::builder()
5        .title("Particles 2".to_string())
6        .swap_interval(SwapInterval::DontWait)
7        .build();
8    init_custom(opts).unwrap();
9
10    let mut ps = ParticleSystem::new();
11    let batch = ParticleOneshot::builder()
12        .shape(&Rect::new_square(Vec2::ZERO, 20.0, Color::GRAY))
13        .size_randomness(5.0)
14        .color_randomness(Color::GRAY)
15        .speed(15.0)
16        .speed_randomness(3.0)
17        .rotation_speed_randomness(0.5)
18        .acceleration(vec2(0.0, 1.0))
19        .direction_randomness(9.0)
20        .end_color(Color::BLACK)
21        .lifetime(1.1)
22        .quantity(100)
23        .build();
24
25    run_async(async move {
26        loop {
27            dont_clear_screen();
28
29            draw_fps_bg();
30
31            for pos in cursor_movements() {
32                ps.spawn_oneshot(&batch, pos);
33            }
34
35            ps.update();
36            ps.draw();
37
38            if should_quit() {
39                break;
40            }
41
42            next_frame().await;
43        }
44    });
45}