Open jkomoros opened 7 years ago
Could have multiple pawn types- a basic little chip, a meeple, and a tall, ornate one. Can be hue-shifted.
An active, secondaryActive, highlighted property that different games would use for different things.
To start would just be mildly perspective-y SVGs. But as time goes on they'd be WebGL tokens that would animate a pick up, swing, put down animation as they go.
Having a specific token component would allow the animation logic to be factored reasonably.
For example, there's a boardgame-component element where most animation logic lives, with boardgame-card and boardgame-token subclasses. Components get their position from their container either directly or implicitly. Tokens would be contained within the game board, and it would set their position based on which region they were supposed to be in. Decks obviously set them based on existing postiion routines.
diableTrianguliarzation
? For cards it's not necesary. But look at stacks with many cards, it might be fine.The logic in boardgame-animator should defer more of the complicated calculations to the element being animated. that's the only way to scalably handle animating things. ele.beforeProperties(stack) result {}, ele.afterProperties(afterStack, beforeProperties{})
//ele is boardgame-component
//Called before the state change happens. Keep track of your before properties
ele.beforeStateChange();
//Called after the state cahnge happens. Keep trakc of your after properties.
ele.afterStateChange();
//Start the animation. Generally you set your values to the before properties
ele.prepareAnimation();
//Make the animation go. Generally you set your values back to the after properties.
ele.startAnimation();
... Wait, this doesn't work because the elements before and after might be different elements.
Also need a way to save content nodes if necessary, because those are just kept around as long as necessary
let beforeProps = ele.animatingProperties();
let afterProps = ele.animatingProperties();
//For elements that didn't have a before, generally stack.defaultForStack('propName') for each property
let defaultProps = ele.defaultAnimatingProperties();
//Consulted to see if we need to clone content. base class returns false. boardgame-card returns ture, but only if noContent is false (or whatever)
ele.cloneContent()
//Called for it to figure out if the before and after are rotated differently (and thus scale factor needs to change)
ele.animationRotates(beforeProps, afterProps) // bool
ele.prepareAnimation(beforeProps);
ele.startAnimation(afterProps);
Way to do trinagulation:
-------------------------
| /| |\ |
| / | | \ |
|/ | | \|
-------------------------
| |
| |
| |
-------------------------
to:
-------------------
/| |\
/ | | \
/ | | \
-------------------------
/| |\
/ | | \
/ | | \
------------------------------
That takes a few flavors with different SVG assets and hue/saturates them for color.