From 075bcd869c21083390c2b7fb9f02ab1fc3d75302 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 27 Jan 2017 15:35:34 +0100 Subject: [PATCH] Change cell vanishing timing --- .../io/github/lonamiwebs/klooni/game/Cell.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/core/src/io/github/lonamiwebs/klooni/game/Cell.java b/core/src/io/github/lonamiwebs/klooni/game/Cell.java index 58d05ae..5c77232 100644 --- a/core/src/io/github/lonamiwebs/klooni/game/Cell.java +++ b/core/src/io/github/lonamiwebs/klooni/game/Cell.java @@ -76,17 +76,18 @@ class Cell { vanishSize = size; vanishColor = color.cpy(); - vanishLifetime = 1.5f; + vanishLifetime = 1f; - // Square the size when calculating the vanish distance - // because it will be used as delay, and without squaring, - // the delay would be too large + // The vanish distance is this measure (distanceĀ² + sizeĀ³ * 20% size) + // because it seems good enough. The more the distance, the more the + // delay, but we decrease the delay depending on the cell size too or + // it would be way too high Vector2 center = new Vector2(pos.x + size * 0.5f, pos.y + 0.5f); - float vanishDist = Vector2.dst( - vanishFrom.x, vanishFrom.y, center.x, center.y) / (size * size); + float vanishDist = Vector2.dst2( + vanishFrom.x, vanishFrom.y, center.x, center.y) / (size * size * size * size * 0.2f); - // Negative time indicates delay, + half lifetime because elastic has that delay - vanishElapsed = vanishLifetime * 0.5f - vanishDist; + // Negative time = delay, + 0.4*lifetime because elastic interpolation has that delay + vanishElapsed = vanishLifetime * 0.4f - vanishDist; color = Color.WHITE; }