Newer
Older
pub struct State {
splash: Splash,
}
pub struct Splash {
fg: Sprite,
bg: Sprite,
scale: Animation<f32>,
rot: Animation<f32>,
}
impl State {
pub async fn new(queue: &Queue, device: &Device) -> Result<State> {
Ok(State {
splash: Splash {
fg: Sprite::new("splash_fg.png", queue, device, true).await?,
bg: Sprite::new("splash_bg.png", queue, device, true).await?,
scale: Animation::new(vec![0.0, 0.1, 0.25], Duration::from_secs(1)),
rot: Animation::new(vec![PI, PI, 0.0], Duration::from_secs(3)),
},
})
}
pub fn update<'a, 'b: 'a>(
&'b mut self,
queue: &Queue,
device: &Device,
pass: &mut RenderPass<'a>,
format: TextureFormat,
aspect: f32,
) {
if !self.splash.rot.complete() {
self.splash.bg.transforms =
Mat4::from_2d(Vec2::ZERO, self.splash.scale.get(), self.splash.rot.get());
self.splash.fg.transforms = Mat4::from_2d(Vec2::ZERO, 0.25, 0.0);
self.splash.bg.record(queue, device, pass, format, aspect);
if self.splash.scale.complete() {
self.splash.fg.record(queue, device, pass, format, aspect)