"git@weirdboi.dev:louis/big-brain.git" did not exist on "0d7e84e1ee638738741abc675e2c074aed9e4fc6"
Newer
Older
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use bevy::prelude::*;
use bevy_tweening::*;
use std::time::Duration;
fn main() -> Result<(), Box<dyn std::error::Error>> {
App::default()
.insert_resource(WindowDescriptor {
title: "Sequence".to_string(),
width: 600.,
height: 600.,
vsync: true,
..Default::default()
})
.add_plugins(DefaultPlugins)
.add_plugin(TweeningPlugin)
.add_startup_system(setup)
.run();
Ok(())
}
fn setup(mut commands: Commands) {
commands.spawn_bundle(OrthographicCameraBundle::new_2d());
let size = 25.;
let margin = 40.;
let screen_x = 600.;
let screen_y = 600.;
let center = Vec3::new(screen_x / 2., screen_y / 2., 0.);
let dests = &[
Vec3::new(margin, margin, 0.),
Vec3::new(screen_x - margin, margin, 0.),
Vec3::new(screen_x - margin, screen_y - margin, 0.),
Vec3::new(margin, screen_y - margin, 0.),
Vec3::new(margin, margin, 0.),
];
let tweens = dests
.windows(2)
.map(|pair| {
Tween::new(
EaseFunction::QuadraticInOut,
TweeningType::Once {
duration: Duration::from_secs(1),
},
TransformPositionLens {
start: pair[0] - center,
end: pair[1] - center,
},
)
})
.collect();
commands
.spawn_bundle(SpriteBundle {
sprite: Sprite {
color: Color::RED,
custom_size: Some(Vec2::new(size, size)),
..Default::default()
},
..Default::default()
})
.insert(Animator::new_seq(tweens));
}