-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrandom_sequence.rs
38 lines (33 loc) · 903 Bytes
/
random_sequence.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
mod shared;
use bevy::{prelude::*, window::PrimaryWindow};
use bevy_scroller::*;
use shared::get_app;
fn main() {
get_app("random sequence".into())
.add_systems(Startup, start)
.run();
}
pub fn start(mut commands: Commands, windows: Query<&Window, With<PrimaryWindow>>) {
commands.spawn(Camera2dBundle::default());
let primary_window = windows.get_single().expect("no primary window");
let items = (1..=7)
.map(|i| SpriteScrollerItem {
path: format!("gems/{i}.png"),
size: Vec2 { x: 128., y: 128. },
})
.collect::<Vec<SpriteScrollerItem>>();
commands.spawn((
ScrollerSize {
size: Vec2::new(primary_window.width(), 128.),
},
ScrollerBundle {
scroller: Scroller {
speed: 5.,
render_layer: Some(1),
..default()
},
generator: RandomSequenceSpriteGenerator { items },
..default()
},
));
}