1 /**
  2  * Copyright (C) 2009-2011 Klaus Reimer <k@ailis.de>
  3  * See LICENSE.txt for licensing information.
  4  * 
  5  * @use twodee/PolygonNode.js
  6  * @use twodee/BoundingBox.js
  7  * @use twodee/Matrix.js
  8  * @use twodee/Physics.js
  9  * @use twodee/Polygon.js
 10  * @use twodee/SceneNode.js
 11  * @use twodee/Vector.js
 12  */
 13 
 14 /** 
 15  * @license
 16  * TwoDee - JavaScript 2D scene graph engine
 17  * http://kayahr.github.com/twodee
 18  * 
 19  * Copyright (C) 2009-2011 Klaus Reimer <k@ailis.de>
 20  * 
 21  * This program is free software: you can redistribute it and/or modify
 22  * it under the terms of the GNU Lesser General Public License as published by
 23  * the Free Software Foundation, either version 3 of the License, or
 24  * (at your option) any later version.
 25  *
 26  * This program is distributed in the hope that it will be useful,
 27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 29  * GNU General Public License for more details.
 30  *
 31  * You should have received a copy of the GNU Lesser General Public License
 32  * along with this program.  If not, see <http://www.gnu.org/licenses/>
 33  * 
 34  */
 35 
 36 /** 
 37  * The twodee namespace
 38  * @type {Object} 
 39  */
 40 var twodee = {};
 41 
 42 /**
 43  * Debug info counter map.
 44  * 
 45  * @private
 46  * @type {?Object.<string, number>}
 47  */ 
 48 twodee.debugInfo = null;
 49 
 50 /**
 51  * Derives subClass from superClass.
 52  * 
 53  * @param {Function} subClass
 54  *            The sub class
 55  * @param {Function} superClass
 56  *            The super class
 57  */
 58 twodee.inherit = function(subClass, superClass)
 59 {
 60     var tmp = superClass.prototype;
 61     superClass = new Function();
 62     superClass.prototype = tmp;
 63     subClass.prototype = new superClass();
 64     subClass.prototype.constructor = subClass;
 65 };
 66 
 67 /**
 68  * Returns debugging info.
 69  * 
 70  * @return {string} The debugging info
 71  */
 72 twodee.getDebugInfo = function()
 73 {
 74     var boundingBox, matrix, physics, polygon, polygonNode,
 75         sceneNode, vector, info, d;
 76     
 77     d = twodee.debugInfo;
 78     boundingBox = twodee.BoundingBox.counter;
 79     matrix = twodee.Matrix.counter;
 80     physics = twodee.Physics.counter;
 81     polygon = twodee.Polygon.counter;
 82     polygonNode = twodee.PolygonNode.counter;
 83     sceneNode = twodee.SceneNode.counter;
 84     vector = twodee.Vector.counter;
 85     
 86     info = "Objects (since last call):\n" +
 87         "  BoundingBox: " + boundingBox + " (" + (boundingBox - (d ? d["boundingBox"] : 0)) + ")\n" +
 88         "  Matrix: " + matrix + " (" + (matrix - (d ? d["matrix"] : 0)) + ")\n" +
 89         "  Physics: " + physics + " (" + (physics - (d ? d["physics"] : 0)) + ")\n" +
 90         "  Polygon: " + polygon + " (" + (polygon - (d ? d["polygon"] : 0)) + ")\n" +
 91         "  PolygonNode: " + polygonNode + " (" + (polygonNode - (d ? d["polygonNode"] : 0)) + ")\n" +
 92         "  SceneNode: " + sceneNode + " (" + (sceneNode - (d ? d["sceneNode"] : 0)) + ")\n" +
 93         "  Vector: " + vector + " (" + (vector - (d ? d["vector"] : 0)) + ")\n";
 94 
 95     if (!d) d = twodee.debugInfo = {};
 96     d["boundingBox"] = boundingBox;
 97     d["matrix"] = matrix;
 98     d["physics"] = physics;
 99     d["polygon"] = polygon;
100     d["polygonNode"] = polygonNode;
101     d["sceneNode"] = sceneNode;
102     d["vector"] = vector;
103     
104     return info;
105 };
106