From 3f410d65ddf9e00798dd18f1c9ad3741a9d182b7 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Thu, 15 Jul 2021 06:58:09 -0700 Subject: [PATCH] Add and use easing curves --- include/dawn/animation/easing.h | 18 ++++++++++++++---- src/poker/round/match.c | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/dawn/animation/easing.h b/include/dawn/animation/easing.h index 87dd7207..b5df18cf 100644 --- a/include/dawn/animation/easing.h +++ b/include/dawn/animation/easing.h @@ -16,11 +16,21 @@ */ #define easeTimeToEase(start, current, duration) ((current-start)/duration) +// Easing Functions, most were sourced from https://gist.github.com/gre/1650294 #define easeLinear(t) t -#define easeInQuad(t) t*t -#define easeOutQuad(t) t*(2-t) +#define easeInQuad(t) (t*t) +#define easeOutQuad(t) (t*(2-t)) #define easeInOutQuad(t) (t < .5 ? 2*t*t : -1+(4-2*t)*t) -#define easeInCubic(t) t*t*t -#define easeOutCubic(t) t*(t-1)*(t-1)+1 \ No newline at end of file +#define easeInCubic(t) (t*t*t) +#define easeOutCubic(t) ((t-1)*(t-1)*(t-1)+1) +#define easeInOutCubic(t) (t < .5 ? 4*t*t*t : (t-1)*(2*t-2)*(2*t-2)+1) + +#define easeInQuart(t) (t*t*t*t) +#define easeOutQuart(t) (1 - (t-1)*(t-1)*(t-1)*(t-1)) +#define easeInOutQuart(t) (t < .5 ? 8*t*t*t*t : 1-8*(t-1)*(t-1)*(t-1)*(t-1)) + +#define easeInQuint(t) (t*t*t*t*t) +#define easeOutQuint(t) (1 + (t-1)*(t-1)*(t-1)*(t-1)*(t-1)) +#define easeInOutQuint(t) (t<.5 ? 16*t*t*t*t*t : 1+16*(t-1)*(t-1)*(t-1)*(t-1)*(t-1)) \ No newline at end of file diff --git a/src/poker/round/match.c b/src/poker/round/match.c index 5e93f7b1..2923c2c9 100644 --- a/src/poker/round/match.c +++ b/src/poker/round/match.c @@ -27,8 +27,8 @@ void pokerMatchInit(poker_t *poker, engine_t *engine) { } void pokerMatchUpdate(poker_t *poker, engine_t *engine) { + float t = easeTimeToEase(poker->roundMatch.time, engine->time.current, 5); pokerLookAtPlayer( - &poker->cameraWorld, POKER_SEAT_PLAYER0, - easeOutCubic(easeTimeToEase(poker->roundMatch.time,engine->time.current,5)) + &poker->cameraWorld, POKER_SEAT_PLAYER0, 1 - easeOutQuint(t) ); } \ No newline at end of file