v2.3.0: added a cap of 5 floating texts at a time per tile

This commit is contained in:
Evan Debenham
2023-12-04 17:14:02 -05:00
parent 34b5035e75
commit 8884773783
@@ -91,7 +91,7 @@ public class FloatingText extends RenderedTextBlock {
public void update() { public void update() {
super.update(); super.update();
if (timeLeft > 0) { if (timeLeft >= 0) {
if ((timeLeft -= Game.elapsed) <= 0) { if ((timeLeft -= Game.elapsed) <= 0) {
kill(); kill();
} else { } else {
@@ -218,11 +218,17 @@ public class FloatingText extends RenderedTextBlock {
if (stack.size() > 0) { if (stack.size() > 0) {
FloatingText below = txt; FloatingText below = txt;
int aboveIndex = stack.size() - 1; int aboveIndex = stack.size() - 1;
int numBelow = 0;
while (aboveIndex >= 0) { while (aboveIndex >= 0) {
numBelow++;
FloatingText above = stack.get(aboveIndex); FloatingText above = stack.get(aboveIndex);
if (above.bottom() + 4 > below.top()) { if (above.bottom() + 4 > below.top()) {
above.setPos(above.left(), below.top() - above.height() - 4); above.setPos(above.left(), below.top() - above.height() - 4);
//reduce remaining time on texts being nudged up, to prevent spam
above.timeLeft = Math.min(above.timeLeft, LIFESPAN-(numBelow/5f));
above.timeLeft = Math.max(above.timeLeft, 0);
below = above; below = above;
aboveIndex--; aboveIndex--;
} else { } else {