Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
//createImageLookup.js
(function() {
  /*global adventurejs A*/ 
  "use strict";

	var p = adventurejs.Game.prototype;

  /**
   * <strong>createImageLookup()</strong> is a method 
   * used to create an image lookup. Generally used for
   * setting room background images.
   * The function takes one parameter: a generic 
   * object containing an array of image id/url pairs.
   * 
   * <pre class="display"><code class="language-javascript">MyGame.createImageLookup({
   *   images: [
   *     { id: "desert", image: "images/backgrounds/desert.jpg" },
   *     { id: "sea", image: "images/backgrounds/sea.jpg" },
   *     { id: "mountains", image: "images/backgrounds/mountains.jpg" },
   *     { id: "dungeon", image: "images/backgrounds/dungeon.jpg" },
   *     { id: "throneroom", image: "images/backgrounds/throneroom.jpg" },
   *   ],
   * });
   * </code></pre>
   * 
   * The image library is accessible at game.image_lookup.
   * @memberOf adventurejs.Game
   * @method adventurejs.Game#createImageLookup
   * @kind function
   * @param {Object} asset A generic object with properties to copy into the image library.
   * @returns {Object} A reference to the image lookup.
   */
	p.createImageLookup = function Game_createImageLookup( properties )
  {
    if(properties.images){
      for(var item in properties.images)
      {
        this.image_lookup[ properties.images[item].id ] = properties.images[item].image;
      }
    }
    return this.image_lookup;
	}  
}());