Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// print.js

(function () {
  /*global adventurejs A*/
  "use strict";

  var p = adventurejs.Display.prototype;

  /**
   * Global method for printing text to game display.
   * @memberOf adventurejs.Display
   * @method adventurejs.Display#print
   * @param {String} msg An arbitrary string.
   * @param {String} classes Optional class(es) to apply to output.
   * @TODO add ability to pause at screen height so excess text doesn't scroll off screen
   */
  p.print = function Display_print(msg, classes) {
    this.outputEl.innerHTML =
      this.outputEl.innerHTML +
      '<span class="p ' +
      classes +
      '">' +
      msg +
      " </span>";
    this.outputWrapperEl.scrollTo({
      top: this.outputWrapperEl.scrollHeight,
      left: 0,
      behavior: "smooth",
    });
  };
})();