mwg API
    Preparing search index...

    Function floatingTextAgeAtLeast

    • The age a pop-up should report, given the age it has, its lifetime, and the age it is forced to be at least.

      Java's rule as arithmetic. Java caps what is left, above.timeLeft = Math.min(above.timeLeft, LIFESPAN - numBelow / 5f), and a cap on what is left is a floor under the age. A floor and not a subtraction, on purpose: a line that has already lived longer than the floor keeps the age it has, where subtracting would shorten it a second time and cut a nearly-finished pop-up dead. A burst of numbers still cannot become a column that outlives the fight, which is what the rule is there for. Clamped to the lifetime as well, so a floor past the end finishes the pop-up on its next update instead of jumping through the rest of its rise.

      Pulled out of the class for the same reason floatingTextAlpha is: FloatingText needs a DOM to build, and a rule does not need one to be checked.

      Parameters

      • elapsed: number
      • duration: number
      • atLeast: number

      Returns number

      import { floatingTextAgeAtLeast } from '@datamoc/mw_games/two-d/ui';

      console.log(floatingTextAgeAtLeast(0, 1, 0.2)); // 0.2, a fresh line is pushed forward
      console.log(floatingTextAgeAtLeast(0.5, 1, 0.2)); // 0.5, an older line keeps the age it has