From ab7e91f3a92985e02649bf85164305e9d9e4d9fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barra=20=C3=93=20Cath=C3=A1in?= Date: Sat, 5 Aug 2023 01:24:43 +0100 Subject: [PATCH] Skip the linear interpolation when the movement is too dramatic. --- src/cspt-state.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cspt-state.c b/src/cspt-state.c index a45e1a4..8e219f4 100644 --- a/src/cspt-state.c +++ b/src/cspt-state.c @@ -33,6 +33,16 @@ void lerpStates (struct gameState * state, struct gameState * endState) (progress * (endState->clients[index].xPosition - startState->clients[index].xPosition)); state->clients[index].yPosition = startState->clients[index].yPosition + (progress * (endState->clients[index].yPosition - startState->clients[index].yPosition)); + + // If the movement is too dramatic, just go to the new position. Stops "zooming" when teleported: + if (fabs(startState->clients[index].xPosition - endState->clients[index].xPosition) >= 200) + { + state->clients[index].xPosition = endState->clients[index].xPosition; + } + if (fabs(startState->clients[index].yPosition - endState->clients[index].yPosition) >= 200) + { + state->clients[index].yPosition = endState->clients[index].yPosition; + } } usleep(100); }