addNewlyVisibleEntities method

void addNewlyVisibleEntities ()

Adds all Entity's that became visible since the last update.

Implementation

void addNewlyVisibleEntities() async {
  double scrolled = this.viewHeight * this.laneSpeed * (this.initialTimeLimit - this.timeLimit) / 1000;

  List<Entity> remEnt = List.from(remainingEntities);

  double lastY;
  int lastH;

  remEnt.forEach((e) {
    if (lastY != null && e.y < lastY && e.y + e.height < lastY + lastH) {
      return;
    }

    lastY = e.y;
    lastH = e.height;

    if (e.y + e.height + scrolled >= 0) {
      e.y = e.y + scrolled.floor();
      visibleEntities.putIfAbsent(e.id, () => e);
      remainingEntities.remove(e);
    }
  });
}