Animations stubbed out, now to use them...

main
Elijah Voigt 1 year ago
parent efc7353532
commit 9aa028e2c4

@ -1,4 +1,4 @@
use std::f32::consts::PI; use std::{f32::consts::PI, ops::RangeInclusive};
use crate::{deck::*, *}; use crate::{deck::*, *};
use bevy::{ use bevy::{
@ -120,30 +120,57 @@ fn setup_animations(
} }
{ {
// Pre-req: requires deck location and helper function for each spot's placement
// For each spot on board // For each spot on board
// Move from deck location (TBD) to spot RangeInclusive::<u8>::new(0, 3).for_each(|x| {
// For each card RangeInclusive::<u8>::new(0, 3).for_each(|y| {
// Assign this curve to the target let a = Vec3::new(-100.0, 0.0, 0.0);
// todo!("Setup deal animations"); let b = play::card_placement(&play::PlayLocation { x, y });
} let c = Vec3::new(100.0, 0.0, 0.0);
{ // Serve Deck -> Spot Animation
// Pre-req: requires discard location and helper function for each spot's placement {
// For each spot on board let mut animation = AnimationClip::default();
// Move from spot location to discard pile (location TBD) targets.iter().for_each(|target| {
// For each card let curve = AnimatableCurve::new(
// Assign this curve to the target animated_field!(Transform::translation),
// todo!("Setup discard animations"); AnimatableKeyframeCurve::new([0.0, 1.0].into_iter().zip([a, b]))
.expect("Serve Card animation"),
);
animation.add_curve_to_target(*target, curve);
});
let animation_handle = clips.add(animation);
let (graph, animation_index) = AnimationGraph::from_clip(animation_handle);
let graph_handle = AnimationGraphHandle(graphs.add(graph));
animation_store.store.insert(
format!("deck->{:?}", (x, y)),
(graph_handle, animation_index),
);
}
// Spot -> Discard Animation
{
let mut animation = AnimationClip::default();
targets.iter().for_each(|target| {
let curve = AnimatableCurve::new(
animated_field!(Transform::translation),
AnimatableKeyframeCurve::new([0.0, 1.0].into_iter().zip([b, c]))
.expect("Serve Card animation"),
);
animation.add_curve_to_target(*target, curve);
});
let animation_handle = clips.add(animation);
let (graph, animation_index) = AnimationGraph::from_clip(animation_handle);
let graph_handle = AnimationGraphHandle(graphs.add(graph));
animation_store.store.insert(
format!("{:?}->discard", (x, y)),
(graph_handle, animation_index),
);
}
});
});
} }
commands.insert_resource(animation_store); commands.insert_resource(animation_store);
// Card Animations:
// active_card_animation = AnimationClip::default() // simple rotation
// for each (X, Y) in board:
// deck_to_X_Y = AnimationClip::default() // Move from deck to X Y position
// X_Y_to_sets = AnimationClip::default() // Move from X Y position to sets pile
// All need AnimationTarget, AnimationGraphHandle, and AnimationPlayer
// TODO: (example: https://bevyengine.org/examples/animation/animated-transform/) // TODO: (example: https://bevyengine.org/examples/animation/animated-transform/)
// Button Animations: // Button Animations:
// active_button_animation = AnimationClip::default() // color and size // active_button_animation = AnimationClip::default() // color and size

@ -1,8 +1,9 @@
TODO: TODO:
* Better shuffling * BUG: Help does not animate rotating cards
* Make "set" button visually interesting when 3 cards selected * Make "set" button visually interesting when 3 cards selected
* Animate cards deck -> board * Animate cards deck -> board
* Animate cards deck -> set-pile * Animate cards deck -> set-pile
* Better shuffling
Later: Later:
* View all cards with some indication of in-set * View all cards with some indication of in-set

Loading…
Cancel
Save