#[cfg(feature = "animation")]
use blue_engine::{Engine, EngineSettings, ObjectSettings, primitive_shapes::cube};
#[cfg(feature = "animation")]
use blue_engine_utilities::{AnimationKeyframe, animation::Animation};
fn main() -> Result<(), blue_engine::error::Error> {
#[cfg(feature = "animation")]
{
let mut engine = Engine::new_config(EngineSettings {
width: 1280,
height: 720,
title: "Animation test",
..Default::default()
})?;
cube(
"cube",
ObjectSettings::default(),
&mut engine.renderer,
&mut engine.objects,
)?;
let mut animation = Animation::new("cube");
animation
.keyframes
.push((0.0, AnimationKeyframe::default()));
animation.keyframes.push((
5.0,
AnimationKeyframe {
position: (5f32, 0f32, 0f32).into(),
rotation: (45f32, 45f32, 0f32).into(),
size: (500f32, 100f32, 100f32).into(),
},
));
animation.keyframes.push((
8.0,
AnimationKeyframe {
position: (-3f32, -3f32, 0f32).into(),
rotation: (-45f32, -45f32, 0f32).into(),
size: (100f32, 50f32, 50f32).into(),
},
));
animation.keyframes.push((
10.0,
AnimationKeyframe {
position: (0f32, 0f32, 0f32).into(),
rotation: (0f32, 0f32, 0f32).into(),
..Default::default()
},
));
animation.start().expect("Couldn't compile the animation");
engine.update_loop(move |engine| {
animation.animate(&mut engine.objects);
})?;
}
Ok(())
}