/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 11);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* unused harmony export isObject */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return isCommonArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return isTypedArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return isArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return isEqual; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return removeFromArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return parametrizeString; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return noop; });
var isObject = function (obj) {
    return obj === Object(obj);
};
var isCommonArray = function (a) {
    return !!(a.splice);
};
var isTypedArray = function (a) {
    return !!(a.buffer);
};
var isArray = function (a) {
    return isCommonArray(a) || isTypedArray(a);
};
var isEqualArray = function (a, b) {
    for (var i = 0, max = a.length; i < max; i++) {
        if (a[i] !== b[i])
            return false;
    }
    return true;
};
var isEqualObject = function (a, b) {
    throw new Error('not implemented');
};
var isEqual = function (a, b) {
    if (a === null || a === undefined)
        return false;
    if (isArray(a) && isArray(b))
        return isEqualArray(a, b);
    else if (isObject(a) && isObject(b))
        return isEqualObject(a, b);
    return a === b;
};
var removeFromArray = function (arr, predicate) {
    var i = arr.length;
    var cnt = 0;
    while (i--) {
        if (predicate(arr[i])) {
            arr.splice(i, 1);
            cnt++;
        }
    }
    return cnt;
};
var parametrizeString = function (source, args) {
    Object.keys(args).forEach(function (key) {
        source = source.split(key).join('' + args[key]);
    });
    return source;
};
var noop = function (arg) { };


/***/ }),
/* 1 */
/***/ (function(module, exports) {

module.exports = [
    "#define HALF                            .5",
    "#define ZERO                            .0",
    "#define ONE                             1.",
    "#define PI                              __PI__",
    "#define TWO_PI                          (__PI__*2.)",
    "#define ERROR_COLOR                     vec4(ONE,ZERO,ZERO,ONE)",
    "#define STRETCH_MODE_STRETCH            __STRETCH_MODE_STRETCH__",
    "#define STRETCH_MODE_REPEAT             __STRETCH_MODE_REPEAT__",
    "#define FILL_TYPE_COLOR                 __FILL_TYPE_COLOR__",
    "#define FILL_TYPE_TEXTURE               __FILL_TYPE_TEXTURE__",
    "#define FILL_TYPE_LINEAR_GRADIENT       __FILL_TYPE_LINEAR_GRADIENT__",
    "#define SHAPE_TYPE_ELLIPSE              __SHAPE_TYPE_ELLIPSE__",
    "#define SHAPE_TYPE_RECT                 __SHAPE_TYPE_RECT__",
    "vec4 getStretchedImage(float tx,float ty){",
    "    vec2 txVec = vec2(tx,ty);",
    "    txVec += fract(u_texOffset);",
    "    txVec = mod(txVec,u_texRect.zw);",
    "    txVec += u_texRect.xy;",
    "    return texture2D(texture, txVec);",
    "}",
    "vec4 getRepeatedImage(float tx,float ty){",
    "    vec2 txVec = vec2(tx,ty)*u_repeatFactor;",
    "    txVec += fract(u_texOffset);",
    "    txVec = mod(txVec,u_texRect.zw);",
    "    txVec += u_texRect.xy;",
    "    return texture2D(texture, txVec);",
    "}",
    "vec4 getFillColor(){",
    "    if (u_fillType==FILL_TYPE_COLOR) return u_fillColor;",
    "    else if (u_fillType==FILL_TYPE_LINEAR_GRADIENT) {",
    "        vec2 polarCoords = vec2(length(v_position.xy),atan(v_position.y/v_position.x));",
    "        polarCoords.y+=u_fillLinearGradient[2].x;",
    "        vec2 rectCoords = vec2(polarCoords.x*cos(polarCoords.y),polarCoords.x*sin(polarCoords.y));",
    "        return mix(u_fillLinearGradient[0],u_fillLinearGradient[1],rectCoords.x);",
    "    }",
    "    else if (u_fillType==FILL_TYPE_TEXTURE) {",
    "        float tx = (v_position.x-u_rectOffsetLeft)/u_width*u_texRect[2];",
    "        float ty = (v_position.y-u_rectOffsetTop)/u_height*u_texRect[3];",
    "        vec4 txVec;",
    "        if (u_stretchMode==STRETCH_MODE_STRETCH) txVec = getStretchedImage(tx,ty);",
    "        else if (u_stretchMode==STRETCH_MODE_REPEAT) txVec = getRepeatedImage(tx,ty);",
    "        else txVec = ERROR_COLOR;",
    "        return txVec;",
    "    }",
    "    else return ERROR_COLOR;",
    "}",
    "float calcRadiusAtPosition(float x,float y) {",
    "    float a = atan(y-HALF,x-HALF);",
    "    float cosA = cos(a);",
    "    float sinA = sin(a);",
    "    return u_rx*u_ry/sqrt(u_rx*u_rx*sinA*sinA+u_ry*u_ry*cosA*cosA);",
    "}",
    "void _drawElliplse(float dist,float rAtCurrAngle){",
    "    if (dist < rAtCurrAngle) {",
    "        if (dist > rAtCurrAngle - u_lineWidth) gl_FragColor = u_color;",
    "        else gl_FragColor = getFillColor();",
    "    } else discard;",
    "}",
    "void drawEllipse(){",
    "    float dist = distance(vec2(HALF, HALF), v_position.xy);",
    "    float rAtCurrAngle = calcRadiusAtPosition(v_position.x, v_position.y);",
    "    bool isArcNotUsed = u_arcAngleFrom==u_arcAngleTo;",
    "    if (dist > rAtCurrAngle) discard;",
    "    if (isArcNotUsed) {",
    "        _drawElliplse(dist,rAtCurrAngle);",
    "    } else {",
    "        float angle = atan(v_position.y-HALF, v_position.x-HALF);",
    "        float angleFrom = u_arcAngleFrom;",
    "        float angleTo =  u_arcAngleTo;",
    "        if (angleFrom<ZERO) angleFrom = TWO_PI + angleFrom;",
    "        if (angleTo<ZERO) angleTo = TWO_PI + angleTo;",
    "        if (angle<ZERO) angle = TWO_PI + angle;",
    "        bool anticlockwise = u_anticlockwise;",
    "        if (angleFrom>angleTo) {",
    "            anticlockwise=!anticlockwise;",
    "            float tmp = angleFrom;",
    "            angleFrom = angleTo;",
    "            angleTo = tmp;",
    "        }",
    "        bool withinArc = (angleFrom<=angle) && (angle<=angleTo);",
    "        if (withinArc) {",
    "            if (anticlockwise) discard;",
    "            else _drawElliplse(dist,rAtCurrAngle);",
    "        }",
    "        else {",
    "            if (!anticlockwise) discard;",
    "            else _drawElliplse(dist,rAtCurrAngle);",
    "        }",
    "    }",
    "}",
    "void drawRect(){",
    "    float x = v_position.x - HALF;",
    "    float y = v_position.y - HALF;",
    "    float distX = abs(x);",
    "    float distY = abs(y);",
    "    float halfW = u_width  * HALF;",
    "    float halfH = u_height * HALF;",
    "    if (distX < halfW && distY < halfH) {",
    "        if (distX>halfW - u_borderRadius && distY>halfH - u_borderRadius) {",
    "            vec2 borderCenter = vec2(ZERO,ZERO);",
    "            float posX = v_position.x, posY = v_position.y;",
    "            if (posX<HALF && posY<HALF) { // top left",
    "                borderCenter = vec2(HALF - halfW + u_borderRadius,HALF - halfH + u_borderRadius);",
    "            }",
    "            else if (posX>HALF && posY<HALF) { // top right",
    "                borderCenter = vec2(HALF + halfW - u_borderRadius,HALF - halfH + u_borderRadius);",
    "            }",
    "            else if (posX<HALF && posY>HALF) { // bottom left",
    "                borderCenter = vec2(HALF - halfW + u_borderRadius,HALF + halfH - u_borderRadius);",
    "            }",
    "            else {  // bottom right",
    "                borderCenter = vec2(HALF + halfW - u_borderRadius,HALF + halfH - u_borderRadius);",
    "            }",
    "            float distToBorderCenter = distance(v_position.xy,borderCenter);",
    "            if (distToBorderCenter>u_borderRadius) discard;",
    "            else if (distToBorderCenter>u_borderRadius-u_lineWidth) gl_FragColor = u_color;",
    "            else gl_FragColor = getFillColor();",
    "        }",
    "        else if (distX > halfW - u_lineWidth || distY > halfH - u_lineWidth) gl_FragColor = u_color;",
    "        else gl_FragColor = getFillColor();",
    "    }",
    "    else discard;",
    "}",
    "void main(){",
    "    if (u_shapeType==SHAPE_TYPE_ELLIPSE) drawEllipse();",
    "    else if (u_shapeType==SHAPE_TYPE_RECT) drawRect();",
    "    else gl_FragColor = ERROR_COLOR;",
    "    gl_FragColor*=u_alpha;",
    "}"
].join('\n');

/***/ }),
/* 2 */
/***/ (function(module, exports) {

module.exports = [
    "precision mediump float;",
    "attribute vec4 a_position;",
    "attribute vec2 a_texCoord;",
    "attribute vec3 a_normal;",
    "uniform mat4 u_modelMatrix;",
    "uniform mat4 u_inverseTransposeModelMatrix;",
    "uniform mat4 u_projectionMatrix;",
    "uniform mat4 u_textureMatrix;",
    "uniform sampler2D u_heightMapTexture;",
    "uniform bool  u_heightMapTextureUsed;",
    "uniform float u_heightMapFactor;",
    "varying vec2 v_texCoord;",
    "varying vec3 v_normal;",
    "varying vec4 v_position;",
    "varying vec3 v_surfaceToLight;",
    "varying vec3 v_surfaceToView;",
    "void main() {",
    "    vec4 position = a_position;",
    "    v_texCoord = (u_textureMatrix * vec4(a_texCoord,1.,1.)).xy;",
    "    v_normal = mat3(u_inverseTransposeModelMatrix) * a_normal;",
    "    if (u_heightMapTextureUsed) {",
    "        vec4 bumpData = texture2D(u_heightMapTexture, v_texCoord);",
    "        position = position + vec4(a_normal,0) * bumpData.r * u_heightMapFactor;",
    "    }",
    "    v_position = u_projectionMatrix * u_modelMatrix * position;",
    "    // compute the vector of the surface to the light",
    "    // and pass it to the fragment shader",
    "    v_surfaceToLight = vec3(600,200,1000) - vec3(u_modelMatrix * position);",
    "    // compute the vector of the surface to the view/camera",
    "    // and pass it to the fragment shader",
    "    v_surfaceToView = normalize(vec3(500,300,1000) - vec3(u_modelMatrix * position));",
    "    gl_Position = v_position;",
    "}"
].join('\n');

/***/ }),
/* 3 */
/***/ (function(module, exports) {

module.exports = [
    "precision mediump float;",
    "varying vec2 v_texCoord;",
    "varying vec3 v_normal;",
    "varying vec4 v_position;",
    "varying vec3 v_surfaceToLight;",
    "varying vec3 v_surfaceToView;",
    "uniform sampler2D u_texture;",
    "uniform sampler2D u_normalsTexture;",
    "uniform samplerCube u_cubeMapTexture;",
    "uniform bool  u_textureUsed;",
    "uniform bool  u_normalsTextureUsed;",
    "uniform bool  u_cubeMapTextureUsed;",
    "uniform float u_alpha;",
    "uniform float u_reflectivity;",
    "uniform bool  u_lightUsed;",
    "uniform vec4  u_color;",
    "uniform float u_color_mix;",
    "uniform mat4  u_modelMatrix;",
    "void main() {",
    "    if (u_textureUsed) gl_FragColor = mix(texture2D(u_texture, v_texCoord),u_color,u_color_mix);",
    "    else gl_FragColor = u_color;",
    "    if (u_lightUsed) {",
    "        vec3 normal = normalize(v_normal);",
    "        vec3 surfaceToLightDirection = normalize(v_surfaceToLight);",
    "        vec3 surfaceToViewDirection = normalize(v_surfaceToView);",
    "        vec3 halfVector = normalize(surfaceToLightDirection + surfaceToViewDirection);",
    "        if (u_normalsTextureUsed) {",
    "            vec4 bumpNormal = texture2D(u_normalsTexture, v_texCoord) * 2. - 1.;",
    "            normal+= bumpNormal.rgb;",
    "            normal = normalize(normal);",
    "        }",
    "        vec3 directionLightPos = vec3(0,0,-100);",
    "        vec3 lightDirection = normalize(directionLightPos);",
    "        float light = max(0.,dot(normal, lightDirection));",
    "        light += max(0.,dot(normal, surfaceToLightDirection));",
    "        float specular = pow(max(dot(normal, halfVector), 0.0), 2.);",
    "        light = clamp(light,.5,1.0);",
    "        //gl_FragColor = vec4(normalize(v_normal)*0.5+0.5,1.0); // to debug normals",
    "        gl_FragColor.rgb *= light;",
    "        gl_FragColor.rgb+=specular;",
    "    }",
    "    if (u_cubeMapTextureUsed) {",
    "        vec3 I = normalize(vec3(v_position));",
    "        vec3 R = reflect(I, normalize(v_normal));",
    "        vec4 reflectionColor = textureCube(u_cubeMapTexture, R);",
    "        gl_FragColor = mix(gl_FragColor,reflectionColor,u_reflectivity);",
    "    }",
    "    gl_FragColor*=u_alpha;",
    "}"
].join('\n');

/***/ }),
/* 4 */
/***/ (function(module) {

module.exports = JSON.parse("{\"compressionlevel\":-1,\"editorsettings\":{\"export\":{\"target\":\".\"}},\"height\":15,\"infinite\":false,\"layers\":[{\"draworder\":\"topdown\",\"id\":2,\"name\":\"objects\",\"objects\":[{\"height\":26.4282485354491,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":707.884065993204,\"x\":-1.06576256592396,\"y\":449.513446192168},{\"height\":431.533557820933,\"id\":4,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":24,\"x\":12.7152543936528,\"y\":70.9050847978843},{\"height\":18.6666666666667,\"id\":5,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":236,\"x\":194.364746221381,\"y\":407.037286467703},{\"height\":28,\"id\":10,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":613.414456386365,\"x\":76.0919784122884,\"y\":45.6106216461399},{\"height\":28,\"id\":12,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":437.698756092685,\"y\":408.97965773329},{\"height\":28,\"id\":13,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":479.440902870673,\"y\":389.057398096468},{\"height\":28,\"id\":14,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":517.202484739456,\"y\":358.945308055414},{\"height\":28,\"id\":15,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":558.516382981995,\"y\":325.728585266848},{\"gid\":1,\"height\":64,\"id\":25,\"name\":\"\",\"rotation\":0,\"type\":\"hero\",\"visible\":true,\"width\":64,\"x\":82.2558236080999,\"y\":411.982594523118},{\"gid\":418,\"height\":24,\"id\":78,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":195.687685471347,\"y\":401.646324399957},{\"gid\":418,\"height\":24,\"id\":79,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":555.009486907453,\"y\":436.741916140043},{\"gid\":419,\"height\":157,\"id\":90,\"name\":\"\",\"rotation\":0,\"type\":\"tree\",\"visible\":true,\"width\":100,\"x\":588.553438811754,\"y\":477.428017897504},{\"height\":461.082706766917,\"id\":91,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":35.0847412703536,\"x\":689.648920476037,\"y\":8.14124267724526},{\"gid\":420,\"height\":40,\"id\":92,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":614.125190276304,\"y\":162.443839660501},{\"height\":28,\"id\":97,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":137.820563679137,\"x\":551.044513123299,\"y\":197.670279994465},{\"height\":104.165874809724,\"id\":98,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":542.188016052401,\"y\":86.0784169011486}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}],\"nextlayerid\":3,\"nextobjectid\":100,\"orientation\":\"orthogonal\",\"renderorder\":\"right-down\",\"tiledversion\":\"1.3.3\",\"tileheight\":32,\"tilesets\":[{\"columns\":16,\"firstgid\":1,\"image\":\"../res/sprite/cat.png\",\"imageheight\":1024,\"imagewidth\":1024,\"margin\":0,\"name\":\"cat\",\"spacing\":0,\"tilecount\":256,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":28.7640449438202,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":16,\"x\":23.6546422235364,\"y\":25.357776463631}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":257,\"image\":\"../res/sprite/monster1.png\",\"imageheight\":512,\"imagewidth\":512,\"margin\":0,\"name\":\"monster1\",\"spacing\":0,\"tilecount\":64,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":24.6008279124778,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":22.5192193968066,\"x\":19.3021880544057,\"y\":29.3317563571851}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":321,\"image\":\"../res/sprite/zombie.png\",\"imageheight\":512,\"imagewidth\":512,\"margin\":0,\"name\":\"skeleton\",\"spacing\":0,\"tilecount\":64,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":40.4967474866943,\"id\":2,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":20.4376108811354,\"x\":21.9515079834418,\"y\":19.8698994677706}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":385,\"image\":\"../res/sprite/monster2.png\",\"imageheight\":256,\"imagewidth\":512,\"margin\":0,\"name\":\"monster2\",\"spacing\":0,\"tilecount\":32,\"tileheight\":64,\"tiles\":[{\"id\":9,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":37.4689532820816,\"id\":3,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":26.8716735659373,\"x\":18.3560023654642,\"y\":18.5452395032525}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":1,\"firstgid\":417,\"image\":\"../res/sprite/bloodDrop.png\",\"imageheight\":16,\"imagewidth\":16,\"margin\":0,\"name\":\"bloodDrop\",\"spacing\":0,\"tilecount\":1,\"tileheight\":16,\"tilewidth\":16},{\"columns\":1,\"firstgid\":418,\"image\":\"../res/sprite/testTube.png\",\"imageheight\":24,\"imagewidth\":24,\"margin\":0,\"name\":\"testTube\",\"spacing\":0,\"tilecount\":1,\"tileheight\":24,\"tilewidth\":24},{\"columns\":1,\"firstgid\":419,\"image\":\"../res/sprite/tree.png\",\"imageheight\":157,\"imagewidth\":100,\"margin\":0,\"name\":\"tree\",\"spacing\":0,\"tilecount\":1,\"tileheight\":157,\"tilewidth\":100},{\"columns\":1,\"firstgid\":420,\"image\":\"../res/sprite/virus.png\",\"imageheight\":40,\"imagewidth\":40,\"margin\":0,\"name\":\"virus\",\"spacing\":0,\"tilecount\":1,\"tileheight\":40,\"tilewidth\":40},{\"columns\":1,\"firstgid\":421,\"image\":\"../res/sprite/ironCar.png\",\"imageheight\":46,\"imagewidth\":100,\"margin\":0,\"name\":\"ironCar\",\"spacing\":0,\"tilecount\":1,\"tileheight\":46,\"tilewidth\":100}],\"tilewidth\":32,\"type\":\"map\",\"version\":1.2,\"width\":23}");

/***/ }),
/* 5 */
/***/ (function(module) {

module.exports = JSON.parse("{\"compressionlevel\":-1,\"editorsettings\":{\"export\":{\"target\":\".\"}},\"height\":20,\"infinite\":false,\"layers\":[{\"draworder\":\"topdown\",\"id\":2,\"name\":\"objects\",\"objects\":[{\"gid\":420,\"height\":64,\"id\":100,\"name\":\"\",\"rotation\":0,\"type\":\"fan\",\"visible\":true,\"width\":64,\"x\":761.54213755247,\"y\":637.78439964943},{\"height\":28,\"id\":80,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":871.300336731399,\"x\":-1.37220351492238,\"y\":612.467118717038},{\"height\":22,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":148.153451112444,\"x\":11.3333333333334,\"y\":598},{\"height\":420.020111628765,\"id\":4,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":24,\"x\":7.40135615111398,\"y\":162.710057351969},{\"height\":18.6666666666667,\"id\":5,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":236,\"x\":150.082260866891,\"y\":413.819887141165},{\"height\":38.598643848886,\"id\":6,\"name\":\"\",\"properties\":[{\"name\":\"toY\",\"type\":\"int\",\"value\":70}],\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":45.3333333333334,\"x\":328.213109460768,\"y\":523.659209373126},{\"height\":55.7550317511566,\"id\":7,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":424.313667604594,\"x\":40.6684810184966,\"y\":142.48203330412},{\"height\":28,\"id\":12,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":355.333333333333,\"y\":290},{\"height\":28,\"id\":13,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":387.333333333333,\"y\":291.333333333333},{\"height\":28,\"id\":14,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":420.666666666667,\"y\":291.333333333333},{\"height\":28,\"id\":15,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":456.666666666667,\"y\":290},{\"height\":58.9977397481434,\"id\":20,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":48.3699432630656,\"x\":232.567461598782,\"y\":498.349831634301},{\"height\":65.197287697772,\"id\":21,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":55.4551409197841,\"x\":440.695142764888,\"y\":515.050847978842},{\"height\":28,\"id\":22,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":563.050847978843,\"y\":553.494011101373},{\"gid\":1,\"height\":64,\"id\":25,\"name\":\"\",\"rotation\":0,\"type\":\"hero\",\"visible\":true,\"width\":64,\"x\":84.0271230222795,\"y\":367.397512185372},{\"gid\":321,\"height\":64,\"id\":60,\"name\":\"\",\"rotation\":0,\"type\":\"zombie\",\"visible\":true,\"width\":64,\"x\":386.666666666667,\"y\":541.333333333333},{\"gid\":418,\"height\":24,\"id\":78,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":605.743499853929,\"y\":600.614911511909},{\"gid\":418,\"height\":24,\"id\":79,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":556.780786321633,\"y\":544.488583421745},{\"height\":510.813106385596,\"id\":84,\"name\":\"\",\"rotation\":0,\"type\":\"lava\",\"visible\":true,\"width\":32,\"x\":855.376724018636,\"y\":124.325876039793},{\"gid\":419,\"height\":157,\"id\":90,\"name\":\"\",\"rotation\":0,\"type\":\"tree\",\"visible\":true,\"width\":100,\"x\":-29.6300567369348,\"y\":629.457170533697},{\"gid\":418,\"height\":24,\"id\":91,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":443.223949444163,\"y\":486.318188108308},{\"gid\":419,\"height\":157,\"id\":93,\"name\":\"\",\"rotation\":0,\"type\":\"tree\",\"visible\":true,\"width\":100,\"x\":3.13898242538865,\"y\":629.717168688593},{\"gid\":419,\"height\":157,\"id\":94,\"name\":\"\",\"rotation\":0,\"type\":\"tree\",\"visible\":true,\"width\":100,\"x\":19.0806771530052,\"y\":630.602818395683},{\"gid\":321,\"height\":64,\"id\":95,\"name\":\"\",\"rotation\":0,\"type\":\"zombie\",\"visible\":true,\"width\":64,\"x\":166.385534388118,\"y\":602.708243000139},{\"gid\":321,\"height\":64,\"id\":96,\"name\":\"\",\"rotation\":0,\"type\":\"zombie\",\"visible\":true,\"width\":64,\"x\":359.457170533696,\"y\":277.674800498178},{\"height\":18.6667,\"id\":97,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":57.9844088749481,\"x\":1211.36021034181,\"y\":193.480432923567},{\"height\":18.6667,\"id\":98,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":91.6390977443607,\"x\":1084.71230222796,\"y\":525.599073082246},{\"gid\":418,\"height\":24,\"id\":99,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":1103.03298122607,\"y\":429.939203837815},{\"gid\":420,\"height\":64,\"id\":102,\"name\":\"\",\"rotation\":0,\"type\":\"fan\",\"visible\":true,\"width\":64,\"x\":674.748466257669,\"y\":416.138751787444},{\"gid\":420,\"height\":64,\"id\":103,\"name\":\"\",\"rotation\":0,\"type\":\"fan\",\"visible\":true,\"width\":64,\"x\":767.741685502099,\"y\":208.896720328429}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}],\"nextlayerid\":3,\"nextobjectid\":104,\"orientation\":\"orthogonal\",\"renderorder\":\"right-down\",\"tiledversion\":\"1.3.3\",\"tileheight\":32,\"tilesets\":[{\"columns\":16,\"firstgid\":1,\"image\":\"../res/sprite/cat.png\",\"imageheight\":1024,\"imagewidth\":1024,\"margin\":0,\"name\":\"cat\",\"spacing\":0,\"tilecount\":256,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":28.7640449438202,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":16,\"x\":23.6546422235364,\"y\":25.357776463631}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":257,\"image\":\"../res/sprite/monster1.png\",\"imageheight\":512,\"imagewidth\":512,\"margin\":0,\"name\":\"monster1\",\"spacing\":0,\"tilecount\":64,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":24.6008279124778,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":22.5192193968066,\"x\":19.3021880544057,\"y\":29.3317563571851}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":321,\"image\":\"../res/sprite/zombie.png\",\"imageheight\":512,\"imagewidth\":512,\"margin\":0,\"name\":\"skeleton\",\"spacing\":0,\"tilecount\":64,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":40.4967474866943,\"id\":2,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":20.4376108811354,\"x\":21.9515079834418,\"y\":19.8698994677706}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":385,\"image\":\"../res/sprite/monster2.png\",\"imageheight\":256,\"imagewidth\":512,\"margin\":0,\"name\":\"monster2\",\"spacing\":0,\"tilecount\":32,\"tileheight\":64,\"tiles\":[{\"id\":9,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":37.4689532820816,\"id\":3,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":26.8716735659373,\"x\":18.3560023654642,\"y\":18.5452395032525}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":1,\"firstgid\":417,\"image\":\"../res/sprite/bloodDrop.png\",\"imageheight\":16,\"imagewidth\":16,\"margin\":0,\"name\":\"bloodDrop\",\"spacing\":0,\"tilecount\":1,\"tileheight\":16,\"tilewidth\":16},{\"columns\":1,\"firstgid\":418,\"image\":\"../res/sprite/testTube.png\",\"imageheight\":24,\"imagewidth\":24,\"margin\":0,\"name\":\"testTube\",\"spacing\":0,\"tilecount\":1,\"tileheight\":24,\"tilewidth\":24},{\"columns\":1,\"firstgid\":419,\"image\":\"../res/sprite/tree.png\",\"imageheight\":157,\"imagewidth\":100,\"margin\":0,\"name\":\"tree\",\"spacing\":0,\"tilecount\":1,\"tileheight\":157,\"tilewidth\":100},{\"columns\":1,\"firstgid\":420,\"image\":\"../res/sprite/fan.png\",\"imageheight\":64,\"imagewidth\":64,\"margin\":0,\"name\":\"fan\",\"spacing\":0,\"tilecount\":1,\"tileheight\":64,\"tilewidth\":64}],\"tilewidth\":32,\"type\":\"map\",\"version\":1.2,\"width\":40}");

/***/ }),
/* 6 */
/***/ (function(module) {

module.exports = JSON.parse("{\"compressionlevel\":-1,\"editorsettings\":{\"export\":{\"target\":\".\"}},\"height\":15,\"infinite\":false,\"layers\":[{\"draworder\":\"topdown\",\"id\":2,\"name\":\"objects\",\"objects\":[{\"gid\":422,\"height\":46,\"id\":106,\"name\":\"\",\"rotation\":0,\"type\":\"ironCar\",\"visible\":true,\"width\":100,\"x\":710.773098390147,\"y\":465.878638313575},{\"height\":41.2847456063471,\"id\":80,\"name\":\"\",\"rotation\":0,\"type\":\"lava\",\"visible\":true,\"width\":672.029152636192,\"x\":-9.34305087873071,\"y\":451.581469009949},{\"height\":22,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":102.985316050864,\"x\":16.6472315758723,\"y\":397.260113473869},{\"height\":420.020111628765,\"id\":4,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":24,\"x\":7.40135615111398,\"y\":2.71005735196884},{\"height\":18.6666666666667,\"id\":5,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":236,\"x\":233.333333333333,\"y\":265.333333333333},{\"height\":353.333333333333,\"id\":7,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":24,\"x\":572.058305272383,\"y\":-181.363162507496},{\"height\":28,\"id\":12,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":355.333333333333,\"y\":130},{\"height\":28,\"id\":13,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":393.532881282962,\"y\":211.041806971416},{\"height\":28,\"id\":14,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":155.857404246814,\"y\":60.4813567661482},{\"height\":28,\"id\":15,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":465.523163737565,\"y\":15.7511877854144},{\"height\":28,\"id\":20,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":284.820794317081,\"y\":384.403616402971},{\"height\":47.4842935559759,\"id\":21,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":40.3990958992573,\"x\":472.578532220121,\"y\":351.508249150483},{\"height\":28,\"id\":22,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":563.050847978843,\"y\":393.494011101373},{\"gid\":1,\"height\":64,\"id\":25,\"name\":\"\",\"rotation\":0,\"type\":\"hero\",\"visible\":true,\"width\":64,\"x\":84.0271230222795,\"y\":207.397512185372},{\"gid\":321,\"height\":64,\"id\":60,\"name\":\"\",\"rotation\":0,\"type\":\"zombie\",\"visible\":true,\"width\":64,\"x\":386.666666666667,\"y\":381.333333333333},{\"gid\":418,\"height\":24,\"id\":78,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":605.743499853929,\"y\":440.614911511909},{\"gid\":418,\"height\":24,\"id\":79,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":556.780786321633,\"y\":384.488583421745},{\"height\":510.813106385596,\"id\":84,\"name\":\"\",\"rotation\":0,\"type\":\"lava\",\"visible\":true,\"width\":32,\"x\":673.818534065224,\"y\":59.9760444054922},{\"gid\":418,\"height\":24,\"id\":91,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":443.223949444163,\"y\":326.318188108308},{\"gid\":321,\"height\":64,\"id\":95,\"name\":\"\",\"rotation\":0,\"type\":\"zombie\",\"visible\":true,\"width\":64,\"x\":166.385534388118,\"y\":442.708243000139},{\"gid\":321,\"height\":64,\"id\":96,\"name\":\"\",\"rotation\":0,\"type\":\"zombie\",\"visible\":true,\"width\":64,\"x\":359.457170533696,\"y\":117.674800498178},{\"gid\":418,\"height\":24,\"id\":97,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":676.149822408783,\"y\":41.1389824253886},{\"gid\":418,\"height\":24,\"id\":98,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":1041.92315143687,\"y\":348.459430785553},{\"height\":25.3430573227548,\"id\":99,\"name\":\"\",\"properties\":[{\"name\":\"toY\",\"type\":\"int\",\"value\":63}],\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":40.3991,\"x\":622.782137347202,\"y\":344.688128149361},{\"gid\":420,\"height\":40,\"id\":100,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":279.349600996356,\"y\":257.354121500069},{\"gid\":420,\"height\":40,\"id\":101,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":608.811292033766,\"y\":144.730845518705},{\"gid\":420,\"height\":40,\"id\":102,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":781.512984916279,\"y\":434.338299737073},{\"gid\":420,\"height\":40,\"id\":103,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":785.055583744638,\"y\":362.600673462798},{\"gid\":421,\"height\":89,\"id\":104,\"name\":\"\",\"rotation\":0,\"type\":\"table\",\"visible\":true,\"width\":83,\"x\":213.181465934776,\"y\":269.840675307902},{\"height\":28,\"id\":107,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":1040.80880114396,\"y\":386.313667604594},{\"height\":41.2847,\"id\":109,\"name\":\"\",\"rotation\":0,\"type\":\"lava\",\"visible\":true,\"width\":221.233299091286,\"x\":934.007179966789,\"y\":447.86634505051},{\"height\":35.0851976567185,\"id\":110,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":162.618755477651,\"x\":709.575810692375,\"y\":463.365192121408}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}],\"nextlayerid\":3,\"nextobjectid\":111,\"orientation\":\"orthogonal\",\"renderorder\":\"right-down\",\"tiledversion\":\"1.3.3\",\"tileheight\":32,\"tilesets\":[{\"columns\":16,\"firstgid\":1,\"image\":\"../res/sprite/cat.png\",\"imageheight\":1024,\"imagewidth\":1024,\"margin\":0,\"name\":\"cat\",\"spacing\":0,\"tilecount\":256,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":28.7640449438202,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":16,\"x\":23.6546422235364,\"y\":25.357776463631}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":257,\"image\":\"../res/sprite/monster1.png\",\"imageheight\":512,\"imagewidth\":512,\"margin\":0,\"name\":\"monster1\",\"spacing\":0,\"tilecount\":64,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":24.6008279124778,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":22.5192193968066,\"x\":19.3021880544057,\"y\":29.3317563571851}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":321,\"image\":\"../res/sprite/zombie.png\",\"imageheight\":512,\"imagewidth\":512,\"margin\":0,\"name\":\"skeleton\",\"spacing\":0,\"tilecount\":64,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":40.4967474866943,\"id\":2,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":20.4376108811354,\"x\":21.9515079834418,\"y\":19.8698994677706}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":385,\"image\":\"../res/sprite/monster2.png\",\"imageheight\":256,\"imagewidth\":512,\"margin\":0,\"name\":\"monster2\",\"spacing\":0,\"tilecount\":32,\"tileheight\":64,\"tiles\":[{\"id\":9,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":37.4689532820816,\"id\":3,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":26.8716735659373,\"x\":18.3560023654642,\"y\":18.5452395032525}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":1,\"firstgid\":417,\"image\":\"../res/sprite/bloodDrop.png\",\"imageheight\":16,\"imagewidth\":16,\"margin\":0,\"name\":\"bloodDrop\",\"spacing\":0,\"tilecount\":1,\"tileheight\":16,\"tilewidth\":16},{\"columns\":1,\"firstgid\":418,\"image\":\"../res/sprite/testTube.png\",\"imageheight\":24,\"imagewidth\":24,\"margin\":0,\"name\":\"testTube\",\"spacing\":0,\"tilecount\":1,\"tileheight\":24,\"tilewidth\":24},{\"columns\":1,\"firstgid\":419,\"image\":\"../res/sprite/tree.png\",\"imageheight\":157,\"imagewidth\":100,\"margin\":0,\"name\":\"tree\",\"spacing\":0,\"tilecount\":1,\"tileheight\":157,\"tilewidth\":100},{\"columns\":1,\"firstgid\":420,\"image\":\"../res/sprite/virus.png\",\"imageheight\":40,\"imagewidth\":40,\"margin\":0,\"name\":\"virus\",\"spacing\":0,\"tilecount\":1,\"tileheight\":40,\"tilewidth\":40},{\"columns\":1,\"firstgid\":421,\"image\":\"../res/sprite/table.png\",\"imageheight\":89,\"imagewidth\":83,\"margin\":0,\"name\":\"table\",\"spacing\":0,\"tilecount\":1,\"tileheight\":89,\"tilewidth\":83},{\"columns\":1,\"firstgid\":422,\"image\":\"../res/sprite/ironCar.png\",\"imageheight\":46,\"imagewidth\":100,\"margin\":0,\"name\":\"ironCar\",\"spacing\":0,\"tilecount\":1,\"tileheight\":46,\"tilewidth\":100}],\"tilewidth\":32,\"type\":\"map\",\"version\":1.2,\"width\":35}");

/***/ }),
/* 7 */
/***/ (function(module) {

module.exports = JSON.parse("{\"compressionlevel\":-1,\"editorsettings\":{\"export\":{\"target\":\".\"}},\"height\":18,\"infinite\":false,\"layers\":[{\"draworder\":\"topdown\",\"id\":2,\"name\":\"objects\",\"objects\":[{\"height\":22,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":947.895136614542,\"x\":-2.83706198010358,\"y\":562.340790626874},{\"height\":383.708473638083,\"id\":4,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":24,\"x\":10.0583052723834,\"y\":104.909605301597},{\"height\":18.6666666666667,\"id\":5,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":236,\"x\":233.333333333333,\"y\":361.333333333333},{\"height\":20,\"id\":6,\"name\":\"\",\"properties\":[{\"name\":\"toY\",\"type\":\"int\",\"value\":32}],\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":45.3333333333334,\"x\":503.571751464551,\"y\":414.491074311546},{\"height\":36.2707381951808,\"id\":7,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":940.647446837954,\"x\":-2.72835462890376,\"y\":68.7398865261313},{\"height\":28,\"id\":12,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":355.333333333333,\"y\":226},{\"height\":28,\"id\":13,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":387.333333333333,\"y\":227.333333333333},{\"height\":28,\"id\":14,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":420.666666666667,\"y\":227.333333333333},{\"height\":28,\"id\":15,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":456.666666666667,\"y\":226},{\"height\":28,\"id\":20,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":570,\"y\":530},{\"height\":28,\"id\":21,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":570,\"y\":495.333333333333},{\"height\":28,\"id\":22,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":569.250395928471,\"y\":449.639774282332},{\"gid\":1,\"height\":64,\"id\":25,\"name\":\"\",\"rotation\":0,\"type\":\"hero\",\"visible\":true,\"width\":64,\"x\":856.313667604594,\"y\":360.07909343912},{\"height\":28,\"id\":50,\"name\":\"\",\"properties\":[{\"name\":\"toX\",\"type\":\"int\",\"value\":144}],\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":116,\"x\":67.3333333333333,\"y\":195.333333333333},{\"gid\":257,\"height\":64,\"id\":55,\"name\":\"\",\"rotation\":0,\"type\":\"monster1\",\"visible\":true,\"width\":64,\"x\":208.331749619447,\"y\":217.995479496287},{\"gid\":257,\"height\":64,\"id\":56,\"name\":\"\",\"rotation\":0,\"type\":\"monster1\",\"visible\":true,\"width\":64,\"x\":347.220566754309,\"y\":325.712994141796},{\"gid\":321,\"height\":64,\"id\":60,\"name\":\"\",\"rotation\":0,\"type\":\"zombie\",\"visible\":true,\"width\":64,\"x\":386.666666666667,\"y\":477.333333333333},{\"gid\":418,\"height\":24,\"id\":78,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":162.918646309024,\"y\":299.26079001184},{\"gid\":418,\"height\":24,\"id\":79,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":51.0748035733509,\"y\":360.92587296462},{\"height\":63.4842935559758,\"id\":82,\"name\":\"\",\"rotation\":0,\"type\":\"water\",\"visible\":true,\"width\":995.118409520737,\"x\":-48.87027384412,\"y\":498.277288312806},{\"height\":355.824407644879,\"id\":84,\"name\":\"\",\"rotation\":0,\"type\":\"lava\",\"visible\":true,\"width\":32,\"x\":916.486553807832,\"y\":89.5523163737564},{\"gid\":321,\"height\":64,\"id\":91,\"name\":\"\",\"rotation\":0,\"type\":\"zombie\",\"visible\":true,\"width\":64,\"x\":750.028691360303,\"y\":366.892199824715},{\"gid\":321,\"height\":64,\"id\":92,\"name\":\"\",\"rotation\":0,\"type\":\"zombie\",\"visible\":true,\"width\":64,\"x\":613.638636468472,\"y\":163.192767194059},{\"gid\":418,\"height\":24,\"id\":93,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":160.701692882513,\"y\":156.623275981364},{\"gid\":418,\"height\":24,\"id\":94,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":265.208358319111,\"y\":339.952765348955},{\"gid\":418,\"height\":24,\"id\":95,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":556.587111951658,\"y\":358.551409197841},{\"height\":75.7959315466581,\"id\":96,\"name\":\"\",\"properties\":[{\"name\":\"toY\",\"type\":\"int\",\"value\":32}],\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":20.5351082014853,\"x\":443.18509592924,\"y\":274.64338761013},{\"height\":98.8228239309931,\"id\":97,\"name\":\"\",\"properties\":[{\"name\":\"toY\",\"type\":\"int\",\"value\":32}],\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":19.6494584943955,\"x\":231.514815934776,\"y\":254.273444347064},{\"gid\":420,\"height\":40,\"id\":98,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":491.905530697911,\"y\":360.293555975829},{\"gid\":420,\"height\":40,\"id\":99,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":571.614004335994,\"y\":401.91909220905},{\"gid\":420,\"height\":40,\"id\":100,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":408.654458231468,\"y\":173.421467779879},{\"gid\":420,\"height\":40,\"id\":101,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":57.0515245168135,\"y\":151.280225102634},{\"gid\":420,\"height\":40,\"id\":102,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":81.8497163153282,\"y\":142.423728031736},{\"gid\":420,\"height\":40,\"id\":103,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":110.190506942202,\"y\":143.309377738826},{\"gid\":422,\"height\":42,\"id\":105,\"name\":\"\",\"rotation\":0,\"type\":\"car\",\"visible\":true,\"width\":100,\"x\":486.703722496425,\"y\":69.1749158171502},{\"gid\":418,\"height\":24,\"id\":106,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":244.838415056045,\"y\":22.8901702108031},{\"gid\":423,\"height\":64,\"id\":107,\"name\":\"\",\"rotation\":0,\"type\":\"fan\",\"visible\":true,\"width\":64,\"x\":1149.45670925781,\"y\":393.111859403109},{\"gid\":423,\"height\":64,\"id\":108,\"name\":\"\",\"rotation\":0,\"type\":\"fan\",\"visible\":true,\"width\":64,\"x\":975.869366668205,\"y\":300.118640158679},{\"gid\":423,\"height\":64,\"id\":109,\"name\":\"\",\"rotation\":0,\"type\":\"fan\",\"visible\":true,\"width\":64,\"x\":973.212417546935,\"y\":147.786890539232},{\"gid\":418,\"height\":24,\"id\":110,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":3.0560450205268,\"y\":34.0537847686701},{\"height\":28,\"id\":112,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":237.898980580285,\"x\":1109.88947829697,\"y\":586.470501406891},{\"gid\":422,\"height\":42,\"id\":113,\"name\":\"\",\"rotation\":0,\"type\":\"car\",\"visible\":true,\"width\":100,\"x\":1145.62710457124,\"y\":589.21264818488}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}],\"nextlayerid\":3,\"nextobjectid\":114,\"orientation\":\"orthogonal\",\"renderorder\":\"right-down\",\"tiledversion\":\"1.3.3\",\"tileheight\":32,\"tilesets\":[{\"columns\":16,\"firstgid\":1,\"image\":\"../res/sprite/cat.png\",\"imageheight\":1024,\"imagewidth\":1024,\"margin\":0,\"name\":\"cat\",\"spacing\":0,\"tilecount\":256,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":28.7640449438202,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":16,\"x\":23.6546422235364,\"y\":25.357776463631}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":257,\"image\":\"../res/sprite/monster1.png\",\"imageheight\":512,\"imagewidth\":512,\"margin\":0,\"name\":\"monster1\",\"spacing\":0,\"tilecount\":64,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":24.6008279124778,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":22.5192193968066,\"x\":19.3021880544057,\"y\":29.3317563571851}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":321,\"image\":\"../res/sprite/zombie.png\",\"imageheight\":512,\"imagewidth\":512,\"margin\":0,\"name\":\"skeleton\",\"spacing\":0,\"tilecount\":64,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":40.4967474866943,\"id\":2,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":20.4376108811354,\"x\":21.9515079834418,\"y\":19.8698994677706}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":385,\"image\":\"../res/sprite/monster2.png\",\"imageheight\":256,\"imagewidth\":512,\"margin\":0,\"name\":\"monster2\",\"spacing\":0,\"tilecount\":32,\"tileheight\":64,\"tiles\":[{\"id\":9,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":37.4689532820816,\"id\":3,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":26.8716735659373,\"x\":18.3560023654642,\"y\":18.5452395032525}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":1,\"firstgid\":417,\"image\":\"../res/sprite/bloodDrop.png\",\"imageheight\":16,\"imagewidth\":16,\"margin\":0,\"name\":\"bloodDrop\",\"spacing\":0,\"tilecount\":1,\"tileheight\":16,\"tilewidth\":16},{\"columns\":1,\"firstgid\":418,\"image\":\"../res/sprite/testTube.png\",\"imageheight\":24,\"imagewidth\":24,\"margin\":0,\"name\":\"testTube\",\"spacing\":0,\"tilecount\":1,\"tileheight\":24,\"tilewidth\":24},{\"columns\":1,\"firstgid\":419,\"image\":\"../res/sprite/tree.png\",\"imageheight\":157,\"imagewidth\":100,\"margin\":0,\"name\":\"tree\",\"spacing\":0,\"tilecount\":1,\"tileheight\":157,\"tilewidth\":100},{\"columns\":1,\"firstgid\":420,\"image\":\"../res/sprite/virus.png\",\"imageheight\":40,\"imagewidth\":40,\"margin\":0,\"name\":\"virus\",\"spacing\":0,\"tilecount\":1,\"tileheight\":40,\"tilewidth\":40},{\"columns\":1,\"firstgid\":421,\"image\":\"../res/sprite/ironCar.png\",\"imageheight\":46,\"imagewidth\":100,\"margin\":0,\"name\":\"ironCar\",\"spacing\":0,\"tilecount\":1,\"tileheight\":46,\"tilewidth\":100},{\"columns\":1,\"firstgid\":422,\"image\":\"../res/sprite/car.png\",\"imageheight\":42,\"imagewidth\":100,\"margin\":0,\"name\":\"car\",\"spacing\":0,\"tilecount\":1,\"tileheight\":42,\"tilewidth\":100},{\"columns\":1,\"firstgid\":423,\"image\":\"../res/sprite/fan.png\",\"imageheight\":64,\"imagewidth\":64,\"margin\":0,\"name\":\"fan\",\"spacing\":0,\"tilecount\":1,\"tileheight\":64,\"tilewidth\":64}],\"tilewidth\":32,\"type\":\"map\",\"version\":1.2,\"width\":33}");

/***/ }),
/* 8 */
/***/ (function(module) {

module.exports = JSON.parse("{\"compressionlevel\":-1,\"editorsettings\":{\"export\":{\"target\":\".\"}},\"height\":25,\"infinite\":false,\"layers\":[{\"draworder\":\"topdown\",\"id\":2,\"name\":\"objects\",\"objects\":[{\"height\":28,\"id\":80,\"name\":\"\",\"rotation\":0,\"type\":\"lava\",\"visible\":true,\"width\":680,\"x\":-12,\"y\":778.666666666667},{\"height\":22,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":554.666666666667,\"x\":11.3333333333334,\"y\":758},{\"height\":304,\"id\":4,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":24,\"x\":26,\"y\":395.333333333333},{\"height\":18.6666666666667,\"id\":5,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":236,\"x\":233.333333333333,\"y\":585.333333333333},{\"height\":20,\"id\":6,\"name\":\"\",\"properties\":[{\"name\":\"toY\",\"type\":\"int\",\"value\":32}],\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":45.3333333333334,\"x\":508,\"y\":712},{\"height\":353.333333333333,\"id\":7,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":24,\"x\":588,\"y\":252},{\"height\":28,\"id\":10,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":162,\"y\":380.666666666667},{\"height\":28,\"id\":11,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":288.666666666667,\"y\":388.666666666667},{\"height\":28,\"id\":12,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":355.333333333333,\"y\":450},{\"height\":28,\"id\":13,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":387.333333333333,\"y\":451.333333333333},{\"height\":28,\"id\":14,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":420.666666666667,\"y\":451.333333333333},{\"height\":28,\"id\":15,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":456.666666666667,\"y\":450},{\"height\":28,\"id\":20,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":570,\"y\":754},{\"height\":28,\"id\":21,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":570,\"y\":719.333333333333},{\"height\":28,\"id\":22,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":607.333333333333,\"y\":696.666666666667},{\"gid\":1,\"height\":64,\"id\":25,\"name\":\"\",\"rotation\":0,\"type\":\"hero\",\"visible\":true,\"width\":64,\"x\":82.2558236080999,\"y\":731.982594523118},{\"height\":28,\"id\":50,\"name\":\"\",\"properties\":[{\"name\":\"toX\",\"type\":\"int\",\"value\":144}],\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":116,\"x\":67.3333333333333,\"y\":419.333333333333},{\"gid\":257,\"height\":64,\"id\":51,\"name\":\"\",\"rotation\":0,\"type\":\"monster1\",\"visible\":true,\"width\":64,\"x\":386.666666666667,\"y\":414.666666666667},{\"gid\":257,\"height\":64,\"id\":55,\"name\":\"\",\"rotation\":0,\"type\":\"monster1\",\"visible\":true,\"width\":64,\"x\":56,\"y\":380},{\"gid\":257,\"height\":64,\"id\":56,\"name\":\"\",\"rotation\":0,\"type\":\"monster1\",\"visible\":true,\"width\":64,\"x\":498.666666666667,\"y\":534.656949121269},{\"gid\":321,\"height\":64,\"id\":60,\"name\":\"\",\"rotation\":0,\"type\":\"zombie\",\"visible\":true,\"width\":64,\"x\":386.666666666667,\"y\":701.333333333333},{\"gid\":385,\"height\":64,\"id\":63,\"name\":\"\",\"rotation\":0,\"type\":\"monster2\",\"visible\":true,\"width\":64,\"x\":216,\"y\":508},{\"gid\":417,\"height\":16,\"id\":76,\"name\":\"\",\"rotation\":0,\"type\":\"bloodDrop\",\"visible\":true,\"width\":16,\"x\":292,\"y\":354.666666666667},{\"gid\":418,\"height\":24,\"id\":78,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":353.333333333333,\"y\":442.666666666667},{\"gid\":418,\"height\":24,\"id\":79,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":162.666666666667,\"y\":352},{\"height\":43.9999999999999,\"id\":82,\"name\":\"\",\"rotation\":0,\"type\":\"water\",\"visible\":true,\"width\":268,\"x\":685.333333333333,\"y\":737.333333333333},{\"height\":18.6667,\"id\":83,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":495.611974722081,\"x\":687.333333333333,\"y\":775.999983333333},{\"height\":429.333333333333,\"id\":84,\"name\":\"\",\"rotation\":0,\"type\":\"lava\",\"visible\":true,\"width\":32,\"x\":928,\"y\":312.666666666667},{\"gid\":419,\"height\":157,\"id\":90,\"name\":\"\",\"rotation\":0,\"type\":\"tree\",\"visible\":true,\"width\":100,\"x\":172.298076479542,\"y\":787.685871119517},{\"height\":28,\"id\":91,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":1438.46551962729,\"y\":450.360902255639},{\"gid\":418,\"height\":24,\"id\":92,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":1438.69422021311,\"y\":407.192767194059},{\"gid\":420,\"height\":64,\"id\":93,\"name\":\"\",\"rotation\":0,\"type\":\"fan\",\"visible\":true,\"width\":64,\"x\":1120.23026892384,\"y\":700.712763503852},{\"gid\":420,\"height\":64,\"id\":94,\"name\":\"\",\"rotation\":0,\"type\":\"fan\",\"visible\":true,\"width\":64,\"x\":974.983716961115,\"y\":557.237510955302},{\"gid\":420,\"height\":64,\"id\":95,\"name\":\"\",\"rotation\":0,\"type\":\"fan\",\"visible\":true,\"width\":64,\"x\":1204.36699109738,\"y\":557.237510955302},{\"gid\":420,\"height\":64,\"id\":96,\"name\":\"\",\"rotation\":0,\"type\":\"fan\",\"visible\":true,\"width\":64,\"x\":1091.00382858988,\"y\":410.219659578394},{\"gid\":420,\"height\":64,\"id\":97,\"name\":\"\",\"rotation\":0,\"type\":\"fan\",\"visible\":true,\"width\":64,\"x\":740.286544582315,\"y\":444.479542414318},{\"gid\":421,\"height\":89,\"id\":98,\"name\":\"\",\"rotation\":0,\"type\":\"table\",\"visible\":true,\"width\":83,\"x\":1001.5,\"y\":780.5}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}],\"nextlayerid\":3,\"nextobjectid\":100,\"orientation\":\"orthogonal\",\"renderorder\":\"right-down\",\"tiledversion\":\"1.3.3\",\"tileheight\":32,\"tilesets\":[{\"columns\":16,\"firstgid\":1,\"image\":\"../res/sprite/cat.png\",\"imageheight\":1024,\"imagewidth\":1024,\"margin\":0,\"name\":\"cat\",\"spacing\":0,\"tilecount\":256,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":28.7640449438202,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":16,\"x\":23.6546422235364,\"y\":25.357776463631}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":257,\"image\":\"../res/sprite/monster1.png\",\"imageheight\":512,\"imagewidth\":512,\"margin\":0,\"name\":\"monster1\",\"spacing\":0,\"tilecount\":64,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":24.6008279124778,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":22.5192193968066,\"x\":19.3021880544057,\"y\":29.3317563571851}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":321,\"image\":\"../res/sprite/zombie.png\",\"imageheight\":512,\"imagewidth\":512,\"margin\":0,\"name\":\"skeleton\",\"spacing\":0,\"tilecount\":64,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":40.4967474866943,\"id\":2,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":20.4376108811354,\"x\":21.9515079834418,\"y\":19.8698994677706}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":385,\"image\":\"../res/sprite/monster2.png\",\"imageheight\":256,\"imagewidth\":512,\"margin\":0,\"name\":\"monster2\",\"spacing\":0,\"tilecount\":32,\"tileheight\":64,\"tiles\":[{\"id\":9,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":37.4689532820816,\"id\":3,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":26.8716735659373,\"x\":18.3560023654642,\"y\":18.5452395032525}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":1,\"firstgid\":417,\"image\":\"../res/sprite/bloodDrop.png\",\"imageheight\":16,\"imagewidth\":16,\"margin\":0,\"name\":\"bloodDrop\",\"spacing\":0,\"tilecount\":1,\"tileheight\":16,\"tilewidth\":16},{\"columns\":1,\"firstgid\":418,\"image\":\"../res/sprite/testTube.png\",\"imageheight\":24,\"imagewidth\":24,\"margin\":0,\"name\":\"testTube\",\"spacing\":0,\"tilecount\":1,\"tileheight\":24,\"tilewidth\":24},{\"columns\":1,\"firstgid\":419,\"image\":\"../res/sprite/tree.png\",\"imageheight\":157,\"imagewidth\":100,\"margin\":0,\"name\":\"tree\",\"spacing\":0,\"tilecount\":1,\"tileheight\":157,\"tilewidth\":100},{\"columns\":1,\"firstgid\":420,\"image\":\"../res/sprite/fan.png\",\"imageheight\":64,\"imagewidth\":64,\"margin\":0,\"name\":\"fan\",\"spacing\":0,\"tilecount\":1,\"tileheight\":64,\"tilewidth\":64},{\"columns\":1,\"firstgid\":421,\"image\":\"../res/sprite/table.png\",\"imageheight\":89,\"imagewidth\":83,\"margin\":0,\"name\":\"table\",\"spacing\":0,\"tilecount\":1,\"tileheight\":89,\"tilewidth\":83},{\"columns\":1,\"firstgid\":422,\"image\":\"../res/sprite/ironCar.png\",\"imageheight\":46,\"imagewidth\":100,\"margin\":0,\"name\":\"ironCar\",\"spacing\":0,\"tilecount\":1,\"tileheight\":46,\"tilewidth\":100}],\"tilewidth\":32,\"type\":\"map\",\"version\":1.2,\"width\":55}");

/***/ }),
/* 9 */
/***/ (function(module) {

module.exports = JSON.parse("{\"compressionlevel\":-1,\"editorsettings\":{\"export\":{\"format\":\"json\"}},\"height\":40,\"infinite\":false,\"layers\":[{\"draworder\":\"topdown\",\"id\":2,\"name\":\"objects\",\"objects\":[{\"height\":28,\"id\":80,\"name\":\"\",\"rotation\":0,\"type\":\"lava\",\"visible\":true,\"width\":680,\"x\":32.8564970708981,\"y\":1245.15275919861},{\"height\":22,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":166.666666666667,\"x\":152.189830404232,\"y\":1190.48609253194},{\"height\":304,\"id\":4,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":24,\"x\":34.8564970708981,\"y\":853.819425865277},{\"height\":18.6666666666667,\"id\":5,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":236,\"x\":242.189830404231,\"y\":1043.81942586528},{\"height\":20,\"id\":6,\"name\":\"\",\"properties\":[{\"name\":\"toY\",\"type\":\"int\",\"value\":32}],\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":45.3333333333334,\"x\":516.856497070898,\"y\":1170.48609253194},{\"height\":353.333333333333,\"id\":7,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":24,\"x\":596.856497070898,\"y\":710.486092531944},{\"height\":28,\"id\":10,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":170.856497070898,\"y\":839.15275919861},{\"height\":28,\"id\":11,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":297.523163737565,\"y\":847.15275919861},{\"height\":28,\"id\":12,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":364.189830404231,\"y\":908.486092531944},{\"height\":28,\"id\":13,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":396.189830404231,\"y\":909.819425865277},{\"height\":28,\"id\":20,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":578.856497070898,\"y\":1212.48609253194},{\"height\":28,\"id\":21,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":578.856497070898,\"y\":1177.81942586528},{\"height\":28,\"id\":22,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":616.189830404231,\"y\":1155.15275919861},{\"gid\":1,\"height\":64,\"id\":25,\"name\":\"\",\"rotation\":0,\"type\":\"hero\",\"visible\":true,\"width\":64,\"x\":287.112320678998,\"y\":228.468687055062},{\"height\":28,\"id\":50,\"name\":\"\",\"properties\":[{\"name\":\"toX\",\"type\":\"int\",\"value\":144}],\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":116,\"x\":76.1898304042314,\"y\":877.819425865277},{\"gid\":257,\"height\":64,\"id\":51,\"name\":\"\",\"rotation\":0,\"type\":\"monster1\",\"visible\":true,\"width\":64,\"x\":395.523163737565,\"y\":873.15275919861},{\"gid\":257,\"height\":64,\"id\":55,\"name\":\"\",\"rotation\":0,\"type\":\"monster1\",\"visible\":true,\"width\":64,\"x\":64.8564970708981,\"y\":838.486092531944},{\"gid\":257,\"height\":64,\"id\":56,\"name\":\"\",\"rotation\":0,\"type\":\"monster1\",\"visible\":true,\"width\":64,\"x\":507.523163737565,\"y\":993.143041653213},{\"gid\":321,\"height\":64,\"id\":60,\"name\":\"\",\"rotation\":0,\"type\":\"zombie\",\"visible\":true,\"width\":64,\"x\":395.523163737565,\"y\":1159.81942586528},{\"gid\":385,\"height\":64,\"id\":63,\"name\":\"\",\"rotation\":0,\"type\":\"monster2\",\"visible\":true,\"width\":64,\"x\":224.856497070898,\"y\":966.486092531944},{\"gid\":417,\"height\":16,\"id\":76,\"name\":\"\",\"rotation\":0,\"type\":\"bloodDrop\",\"visible\":true,\"width\":16,\"x\":300.856497070898,\"y\":813.15275919861},{\"gid\":418,\"height\":24,\"id\":78,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":362.189830404231,\"y\":901.152759198611},{\"gid\":418,\"height\":24,\"id\":79,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":171.523163737565,\"y\":810.486092531944},{\"height\":222,\"id\":82,\"name\":\"\",\"rotation\":0,\"type\":\"water\",\"visible\":true,\"width\":692,\"x\":0.189830404231088,\"y\":361.819425865277},{\"height\":429.333333333333,\"id\":84,\"name\":\"\",\"rotation\":0,\"type\":\"lava\",\"visible\":true,\"width\":32,\"x\":936.856497070898,\"y\":771.15275919861},{\"height\":28,\"id\":91,\"name\":\"\",\"rotation\":0,\"type\":\"lava\",\"visible\":true,\"width\":680,\"x\":32,\"y\":586},{\"height\":28,\"id\":92,\"name\":\"\",\"rotation\":0,\"type\":\"lava\",\"visible\":true,\"width\":680,\"x\":256,\"y\":134},{\"height\":28,\"id\":93,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":424,\"y\":242},{\"height\":28,\"id\":94,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":304,\"y\":242},{\"height\":28,\"id\":95,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":134,\"y\":228},{\"height\":28,\"id\":96,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":60,\"y\":38},{\"height\":68,\"id\":97,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":286,\"y\":42},{\"height\":28,\"id\":98,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":686,\"y\":68},{\"height\":28,\"id\":99,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":742,\"y\":1040},{\"height\":28,\"id\":100,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":856,\"y\":876},{\"height\":28,\"id\":101,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":756,\"y\":718},{\"height\":28,\"id\":102,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":830,\"y\":602},{\"height\":28,\"id\":103,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":780,\"y\":418},{\"height\":28,\"id\":104,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":842,\"y\":240},{\"gid\":418,\"height\":24,\"id\":105,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":484,\"y\":80},{\"gid\":418,\"height\":24,\"id\":106,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":614,\"y\":50},{\"gid\":418,\"height\":24,\"id\":107,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":822,\"y\":52},{\"gid\":418,\"height\":24,\"id\":108,\"name\":\"\",\"rotation\":0,\"type\":\"testTube\",\"visible\":true,\"width\":24,\"x\":122,\"y\":174},{\"gid\":385,\"height\":64,\"id\":111,\"name\":\"\",\"rotation\":0,\"type\":\"monster2\",\"visible\":true,\"width\":64,\"x\":330,\"y\":20},{\"gid\":385,\"height\":64,\"id\":112,\"name\":\"\",\"rotation\":0,\"type\":\"monster2\",\"visible\":true,\"width\":64,\"x\":418,\"y\":56},{\"gid\":385,\"height\":64,\"id\":113,\"name\":\"\",\"rotation\":0,\"type\":\"monster2\",\"visible\":true,\"width\":64,\"x\":534,\"y\":70},{\"gid\":385,\"height\":64,\"id\":114,\"name\":\"\",\"rotation\":0,\"type\":\"monster2\",\"visible\":true,\"width\":64,\"x\":736,\"y\":58},{\"gid\":385,\"height\":64,\"id\":115,\"name\":\"\",\"rotation\":0,\"type\":\"monster2\",\"visible\":true,\"width\":64,\"x\":842,\"y\":52},{\"height\":28,\"id\":116,\"name\":\"\",\"rotation\":0,\"type\":\"lava\",\"visible\":true,\"width\":44,\"x\":774,\"y\":1240},{\"height\":28,\"id\":117,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":12,\"y\":154},{\"gid\":420,\"height\":40,\"id\":121,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":174,\"y\":1182},{\"gid\":420,\"height\":40,\"id\":123,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":590,\"y\":680},{\"gid\":420,\"height\":40,\"id\":124,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":418,\"y\":228},{\"gid\":420,\"height\":40,\"id\":125,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":772,\"y\":342},{\"gid\":420,\"height\":40,\"id\":126,\"name\":\"\",\"rotation\":0,\"type\":\"virus\",\"visible\":true,\"width\":40,\"x\":930,\"y\":738}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}],\"nextlayerid\":3,\"nextobjectid\":127,\"orientation\":\"orthogonal\",\"renderorder\":\"right-down\",\"tiledversion\":\"1.3.3\",\"tileheight\":32,\"tilesets\":[{\"columns\":16,\"firstgid\":1,\"image\":\"../res/sprite/cat.png\",\"imageheight\":1024,\"imagewidth\":1024,\"margin\":0,\"name\":\"cat\",\"spacing\":0,\"tilecount\":256,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":28.7640449438202,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":16,\"x\":23.6546422235364,\"y\":25.357776463631}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":257,\"image\":\"../res/sprite/monster1.png\",\"imageheight\":512,\"imagewidth\":512,\"margin\":0,\"name\":\"monster1\",\"spacing\":0,\"tilecount\":64,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":24.6008279124778,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":22.5192193968066,\"x\":19.3021880544057,\"y\":29.3317563571851}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":321,\"image\":\"../res/sprite/zombie.png\",\"imageheight\":512,\"imagewidth\":512,\"margin\":0,\"name\":\"skeleton\",\"spacing\":0,\"tilecount\":64,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":40.4967474866943,\"id\":2,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":20.4376108811354,\"x\":21.9515079834418,\"y\":19.8698994677706}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":385,\"image\":\"../res/sprite/monster2.png\",\"imageheight\":256,\"imagewidth\":512,\"margin\":0,\"name\":\"monster2\",\"spacing\":0,\"tilecount\":32,\"tileheight\":64,\"tiles\":[{\"id\":9,\"objectgroup\":{\"draworder\":\"index\",\"name\":\"\",\"objects\":[{\"height\":37.4689532820816,\"id\":3,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":26.8716735659373,\"x\":18.3560023654642,\"y\":18.5452395032525}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":1,\"firstgid\":417,\"image\":\"../res/sprite/bloodDrop.png\",\"imageheight\":16,\"imagewidth\":16,\"margin\":0,\"name\":\"bloodDrop\",\"spacing\":0,\"tilecount\":1,\"tileheight\":16,\"tilewidth\":16},{\"columns\":1,\"firstgid\":418,\"image\":\"../res/sprite/testTube.png\",\"imageheight\":24,\"imagewidth\":24,\"margin\":0,\"name\":\"testTube\",\"spacing\":0,\"tilecount\":1,\"tileheight\":24,\"tilewidth\":24},{\"columns\":1,\"firstgid\":419,\"image\":\"../res/sprite/tree.png\",\"imageheight\":157,\"imagewidth\":100,\"margin\":0,\"name\":\"tree\",\"spacing\":0,\"tilecount\":1,\"tileheight\":157,\"tilewidth\":100},{\"columns\":1,\"firstgid\":420,\"image\":\"../res/sprite/virus.png\",\"imageheight\":40,\"imagewidth\":40,\"margin\":0,\"name\":\"virus\",\"spacing\":0,\"tilecount\":1,\"tileheight\":40,\"tilewidth\":40}],\"tilewidth\":32,\"type\":\"map\",\"version\":1.2,\"width\":30}");

/***/ }),
/* 10 */
/***/ (function(module) {

module.exports = JSON.parse("{\"compressionlevel\":-1,\"height\":15,\"infinite\":false,\"layers\":[{\"draworder\":\"topdown\",\"id\":2,\"name\":\"objects\",\"objects\":[{\"height\":304,\"id\":4,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":53.3333333333333,\"x\":54,\"y\":23.3333333333333},{\"height\":18.6666666666667,\"id\":5,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":236,\"x\":10.6666666666664,\"y\":409.333333333333},{\"height\":28,\"id\":10,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":162,\"y\":60.6666666666667},{\"height\":28,\"id\":11,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":288.666666666667,\"y\":68.6666666666666},{\"height\":28,\"id\":12,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":444.666666666666,\"y\":179.333333333333},{\"height\":28,\"id\":13,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":386,\"y\":162},{\"height\":53.3333333333333,\"id\":14,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":68,\"x\":287.333333333334,\"y\":124.666666666666},{\"height\":28,\"id\":15,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":456.666666666667,\"y\":130},{\"height\":28,\"id\":20,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":137.333333333333,\"x\":460.666666666667,\"y\":434},{\"height\":28,\"id\":21,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":570,\"y\":399.333333333333},{\"height\":28,\"id\":22,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":28,\"x\":495.333333333333,\"y\":163.333333333334},{\"height\":154.6667,\"id\":85,\"name\":\"\",\"rotation\":0,\"type\":\"wall\",\"visible\":true,\"width\":186.666666666667,\"x\":307.333333333333,\"y\":235.999983333333}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}],\"nextlayerid\":3,\"nextobjectid\":86,\"orientation\":\"orthogonal\",\"renderorder\":\"right-down\",\"tiledversion\":\"1.3.3\",\"tileheight\":32,\"tilesets\":[{\"columns\":16,\"firstgid\":1,\"image\":\"D:/git/vEngine2/demo/catGame/res/sprite/cat.png\",\"imageheight\":1024,\"imagewidth\":1024,\"margin\":0,\"name\":\"cat\",\"spacing\":0,\"tilecount\":256,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"id\":2,\"name\":\"\",\"objects\":[{\"height\":28.7640449438202,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":16,\"x\":23.6546422235364,\"y\":25.357776463631}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":257,\"image\":\"D:/git/vEngine2/demo/catGame/res/sprite/monster1.png\",\"imageheight\":512,\"imagewidth\":512,\"margin\":0,\"name\":\"monster1\",\"spacing\":0,\"tilecount\":64,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"id\":2,\"name\":\"\",\"objects\":[{\"height\":24.6008279124778,\"id\":1,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":22.5192193968066,\"x\":19.3021880544057,\"y\":29.3317563571851}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":321,\"image\":\"D:/git/vEngine2/demo/catGame/res/sprite/zombie.png\",\"imageheight\":512,\"imagewidth\":512,\"margin\":0,\"name\":\"skeleton\",\"spacing\":0,\"tilecount\":64,\"tileheight\":64,\"tiles\":[{\"id\":0,\"objectgroup\":{\"draworder\":\"index\",\"id\":3,\"name\":\"\",\"objects\":[{\"height\":40.4967474866943,\"id\":2,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":20.4376108811354,\"x\":21.9515079834418,\"y\":19.8698994677706}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":8,\"firstgid\":385,\"image\":\"D:/git/vEngine2/demo/catGame/res/sprite/monster2.png\",\"imageheight\":256,\"imagewidth\":512,\"margin\":0,\"name\":\"monster2\",\"spacing\":0,\"tilecount\":32,\"tileheight\":64,\"tiles\":[{\"id\":9,\"objectgroup\":{\"draworder\":\"index\",\"id\":4,\"name\":\"\",\"objects\":[{\"height\":37.4689532820816,\"id\":3,\"name\":\"\",\"rotation\":0,\"type\":\"\",\"visible\":true,\"width\":26.8716735659373,\"x\":18.3560023654642,\"y\":18.5452395032525}],\"opacity\":1,\"type\":\"objectgroup\",\"visible\":true,\"x\":0,\"y\":0}}],\"tilewidth\":64},{\"columns\":1,\"firstgid\":417,\"image\":\"D:/git/vEngine2/demo/catGame/res/sprite/bloodDrop.png\",\"imageheight\":16,\"imagewidth\":16,\"margin\":0,\"name\":\"bloodDrop\",\"spacing\":0,\"tilecount\":1,\"tileheight\":16,\"tilewidth\":16},{\"columns\":1,\"firstgid\":418,\"image\":\"D:/git/vEngine2/demo/catGame/res/sprite/testTube.png\",\"imageheight\":24,\"imagewidth\":24,\"margin\":0,\"name\":\"testTube\",\"spacing\":0,\"tilecount\":1,\"tileheight\":24,\"tilewidth\":24}],\"tilewidth\":32,\"type\":\"map\",\"version\":1.2,\"width\":30}");

/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(14);


/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

if (true) {
    window.__POLYFILLS_INCLUDED__ = true;
}
if (typeof globalThis === 'undefined')
    window.globalThis = window;
var rafPolyfill = function (f) {
    return setTimeout(f, 17);
};
globalThis.requestAnimationFrame =
    globalThis.requestAnimationFrame ||
        globalThis.webkitRequestAnimationFrame ||
        rafPolyfill;
if (!globalThis.cancelAnimationFrame) {
    globalThis.cancelAnimationFrame = function (id) { return clearTimeout(id); };
}
if (!Array.prototype.find) {
    Array.prototype.find = function (predicate) {
        if (!this && true) {
            throw new TypeError('Array.prototype.find called on null or undefined');
        }
        if (typeof predicate !== 'function' && true) {
            throw new TypeError('predicate must be a function');
        }
        var list = Object(this);
        var length = list.length >>> 0;
        var thisArg = arguments[1];
        var value;
        for (var i = 0; i < length; i++) {
            value = list[i];
            if (predicate.call(thisArg, value, i, list)) {
                return value;
            }
        }
        return undefined;
    };
}


/***/ }),
/* 13 */,
/* 14 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);

// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.js
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */

var extendStatics = function(d, b) {
    extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return extendStatics(d, b);
};

function __extends(d, b) {
    extendStatics(d, b);
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}

var __assign = function() {
    __assign = Object.assign || function __assign(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
        }
        return t;
    }
    return __assign.apply(this, arguments);
}

function __rest(s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
}

function __decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
}

function __param(paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
}

function __metadata(metadataKey, metadataValue) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}

function __awaiter(thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
}

function __generator(thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
}

function __exportStar(m, exports) {
    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}

function __values(o) {
    var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
    if (m) return m.call(o);
    return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
}

function __read(o, n) {
    var m = typeof Symbol === "function" && o[Symbol.iterator];
    if (!m) return o;
    var i = m.call(o), r, ar = [], e;
    try {
        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
    }
    catch (error) { e = { error: error }; }
    finally {
        try {
            if (r && !r.done && (m = i["return"])) m.call(i);
        }
        finally { if (e) throw e.error; }
    }
    return ar;
}

function __spread() {
    for (var ar = [], i = 0; i < arguments.length; i++)
        ar = ar.concat(__read(arguments[i]));
    return ar;
}

function __spreadArrays() {
    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
    for (var r = Array(s), k = 0, i = 0; i < il; i++)
        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
            r[k] = a[j];
    return r;
};

function __await(v) {
    return this instanceof __await ? (this.v = v, this) : new __await(v);
}

function __asyncGenerator(thisArg, _arguments, generator) {
    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
    var g = generator.apply(thisArg, _arguments || []), i, q = [];
    return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
    function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
    function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
    function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
    function fulfill(value) { resume("next", value); }
    function reject(value) { resume("throw", value); }
    function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}

function __asyncDelegator(o) {
    var i, p;
    return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
    function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}

function __asyncValues(o) {
    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
    var m = o[Symbol.asyncIterator], i;
    return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
    function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
    function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}

function __makeTemplateObject(cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};

function __importStar(mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result.default = mod;
    return result;
}

function __importDefault(mod) {
    return (mod && mod.__esModule) ? mod : { default: mod };
}

// EXTERNAL MODULE: ./engine/misc/object.ts
var object = __webpack_require__(0);

// CONCATENATED MODULE: ./engine/misc/releaseableEntity.ts
var ReleaseableEntity = (function () {
    function ReleaseableEntity() {
        this._captured = false;
    }
    ReleaseableEntity.prototype.isCaptured = function () {
        return this._captured;
    };
    ReleaseableEntity.prototype.capture = function () {
        this._captured = true;
        return this;
    };
    ReleaseableEntity.prototype.release = function () {
        this._captured = false;
        return this;
    };
    return ReleaseableEntity;
}());


// CONCATENATED MODULE: ./engine/geometry/abstract/observableEntity.ts



var observableEntity_ObservableEntity = (function (_super) {
    __extends(ObservableEntity, _super);
    function ObservableEntity() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this._onChanged = [];
        return _this;
    }
    ObservableEntity.prototype.forceTriggerChange = function () {
        for (var _i = 0, _a = this._onChanged; _i < _a.length; _i++) {
            var fn = _a[_i];
            fn();
        }
    };
    ObservableEntity.prototype.addOnChangeListener = function (f) {
        this._onChanged.push(f);
    };
    ObservableEntity.prototype.removeOnChangeListener = function (f) {
        Object(object["g" /* removeFromArray */])(this._onChanged, function (it) { return it === f; });
    };
    ObservableEntity.prototype.observe = function (onChangedFn) {
        this.addOnChangeListener(onChangedFn);
    };
    ObservableEntity.prototype.triggerObservable = function () {
        for (var _i = 0, _a = this._onChanged; _i < _a.length; _i++) {
            var fn = _a[_i];
            fn();
        }
    };
    return ObservableEntity;
}(ReleaseableEntity));


// CONCATENATED MODULE: ./engine/debug/debugError.ts

var debugError_DebugError = (function (_super) {
    __extends(DebugError, _super);
    function DebugError(message) {
        var _this = _super.call(this, message) || this;
        if (Error.captureStackTrace) {
            Error.captureStackTrace(_this, _this.constructor);
        }
        else {
            _this.stack = (new Error()).stack;
        }
        _this.name = 'DebugError';
        _this.errorMessage = message;
        return _this;
    }
    DebugError.prototype.toString = function () {
        return this.errorMessage;
    };
    return DebugError;
}(Error));


// CONCATENATED MODULE: ./engine/control/abstract/abstractKeypad.ts



var KEY_STATE;
(function (KEY_STATE) {
    KEY_STATE[KEY_STATE["KEY_JUST_PRESSED"] = 2] = "KEY_JUST_PRESSED";
    KEY_STATE[KEY_STATE["KEY_PRESSED"] = 1] = "KEY_PRESSED";
    KEY_STATE[KEY_STATE["KEY_JUST_RELEASED"] = 0] = "KEY_JUST_RELEASED";
    KEY_STATE[KEY_STATE["KEY_RELEASED"] = -1] = "KEY_RELEASED";
})(KEY_STATE || (KEY_STATE = {}));
var abstractKeypad_KeyPadEvent = (function (_super) {
    __extends(KeyPadEvent, _super);
    function KeyPadEvent() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return KeyPadEvent;
}(observableEntity_ObservableEntity));

var abstractKeypad_AbstractKeypad = (function () {
    function AbstractKeypad(game) {
        this.buffer = [];
        this.game = game;
    }
    AbstractKeypad.prototype.press = function (event) {
        event.keyState = KEY_STATE.KEY_PRESSED;
        this.buffer.push(event);
        this.notify(this.keyPressed, event);
    };
    AbstractKeypad.prototype.release = function (event) {
        event.keyState = KEY_STATE.KEY_JUST_RELEASED;
        this.notify(this.keyReleased, event);
    };
    AbstractKeypad.prototype.update = function () {
        for (var _i = 0, _a = this.buffer; _i < _a.length; _i++) {
            var event_1 = _a[_i];
            if (!event_1.isCaptured())
                continue;
            var keyVal = event_1.keyState;
            switch (keyVal) {
                case KEY_STATE.KEY_RELEASED:
                    this.buffer.splice(this.buffer.indexOf(event_1), 1);
                    event_1.release();
                    break;
                case KEY_STATE.KEY_JUST_RELEASED:
                    event_1.keyState = KEY_STATE.KEY_RELEASED;
                    break;
                case KEY_STATE.KEY_JUST_PRESSED:
                    event_1.keyState = KEY_STATE.KEY_PRESSED;
                    break;
                case KEY_STATE.KEY_PRESSED:
                    this.notify(this.keyHold, event_1);
                    break;
                default:
                    if (true)
                        throw new debugError_DebugError("unknown button state: " + keyVal);
                    break;
            }
        }
    };
    AbstractKeypad.prototype.notify = function (eventName, e) {
        this.game.getCurrScene().trigger(eventName, e);
    };
    return AbstractKeypad;
}());


// CONCATENATED MODULE: ./engine/misc/objectPool.ts

var objectPool_ObjectPool = (function () {
    function ObjectPool(Class, numberOfInstances) {
        if (numberOfInstances === void 0) { numberOfInstances = 16; }
        this.Class = Class;
        this.numberOfInstances = numberOfInstances;
        this._pool = [];
        if ( true && !Class)
            throw new debugError_DebugError("can not instantiate ObjectPool: class not provided in constructor");
    }
    ObjectPool.prototype.getFreeObject = function (silently) {
        if (silently === void 0) { silently = false; }
        for (var i = 0; i < this.numberOfInstances; i++) {
            var current = this._pool[i];
            if (current === undefined) {
                current = this._pool[i] = new this.Class();
                current.capture();
                return current;
            }
            else if (!current.isCaptured()) {
                current.capture();
                return current;
            }
        }
        if ( true && !silently)
            throw new debugError_DebugError("can not get free object: no free object in pool");
        return undefined;
    };
    ObjectPool.prototype.releaseObject = function (obj) {
        var indexOf = this._pool.indexOf(obj);
        if ( true && indexOf === -1) {
            console.error(obj);
            throw new debugError_DebugError("can not release the object: it does not belong to the pool");
        }
        this._pool[indexOf].release();
    };
    ObjectPool.prototype.releaseAll = function () {
        for (var i = 0; i < this.numberOfInstances; i++) {
            var current = this._pool[i];
            if (current !== undefined) {
                current.release();
            }
        }
    };
    return ObjectPool;
}());


// CONCATENATED MODULE: ./engine/control/keyboard/keyboardEvents.ts



var KEYBOARD_EVENTS;
(function (KEYBOARD_EVENTS) {
    KEYBOARD_EVENTS["keyPressed"] = "keyPressed";
    KEYBOARD_EVENTS["keyReleased"] = "keyReleased";
    KEYBOARD_EVENTS["keyHold"] = "keyHold";
})(KEYBOARD_EVENTS || (KEYBOARD_EVENTS = {}));
var keyboardEvents_KeyBoardEvent = (function (_super) {
    __extends(KeyBoardEvent, _super);
    function KeyBoardEvent() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    KeyBoardEvent.fromPool = function () {
        return KeyBoardEvent.pool.getFreeObject();
    };
    KeyBoardEvent.pool = new objectPool_ObjectPool(KeyBoardEvent);
    return KeyBoardEvent;
}(abstractKeypad_KeyPadEvent));


// CONCATENATED MODULE: ./engine/control/keyboard/keyboardControl.ts



var keyboardControl_KeyboardControl = (function (_super) {
    __extends(KeyboardControl, _super);
    function KeyboardControl() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.type = 'KeyboardControl';
        _this.keyPressed = KEYBOARD_EVENTS.keyPressed;
        _this.keyHold = KEYBOARD_EVENTS.keyHold;
        _this.keyReleased = KEYBOARD_EVENTS.keyReleased;
        return _this;
    }
    KeyboardControl.prototype.isJustPressed = function (key) {
        var event = this.findEvent(key);
        if (event === undefined)
            return false;
        return event.keyState === KEY_STATE.KEY_JUST_PRESSED;
    };
    KeyboardControl.prototype.isReleased = function (key) {
        var event = this.findEvent(key);
        if (event === undefined)
            return false;
        return event.keyState <= KEY_STATE.KEY_JUST_RELEASED;
    };
    KeyboardControl.prototype.isJustReleased = function (key) {
        var event = this.findEvent(key);
        if (event === undefined)
            return false;
        return event.keyState === KEY_STATE.KEY_JUST_RELEASED;
    };
    KeyboardControl.prototype.listenTo = function () {
        var _this = this;
        this.keyDownListener = function (e) {
            e.preventDefault();
            e.stopPropagation();
            var code = e.keyCode;
            _this.triggerKeyPress(code);
        };
        this.keyUpListener = function (e) {
            var code = e.keyCode;
            _this.triggerKeyRelease(code);
        };
        globalThis.addEventListener('keydown', this.keyDownListener);
        globalThis.addEventListener('keyup', this.keyUpListener);
    };
    KeyboardControl.prototype.triggerKeyPress = function (code) {
        if (this.isPressed(code))
            return;
        var eventFromBuffer = keyboardEvents_KeyBoardEvent.fromPool();
        if (eventFromBuffer === undefined) {
            if (true)
                console.warn('keyboard pool is full');
            return;
        }
        eventFromBuffer.key = code;
        this.press(eventFromBuffer);
    };
    KeyboardControl.prototype.triggerKeyRelease = function (code) {
        var eventFromBuffer = this.findEvent(code);
        if (eventFromBuffer === undefined)
            return;
        this.release(eventFromBuffer);
    };
    KeyboardControl.prototype.destroy = function () {
        globalThis.removeEventListener('keydown', this.keyDownListener);
        globalThis.removeEventListener('keyup', this.keyUpListener);
    };
    KeyboardControl.prototype.isPressed = function (key) {
        var event = this.findEvent(key);
        if (event === undefined)
            return false;
        return event.keyState >= KEY_STATE.KEY_PRESSED;
    };
    KeyboardControl.prototype.findEvent = function (key) {
        for (var _i = 0, _a = this.buffer; _i < _a.length; _i++) {
            var event_1 = _a[_i];
            if (event_1.key === key)
                return event_1;
        }
        return undefined;
    };
    return KeyboardControl;
}(abstractKeypad_AbstractKeypad));


// EXTERNAL MODULE: ./engine/misc/polyfills.ts
var polyfills = __webpack_require__(12);

// CONCATENATED MODULE: ./engine/misc/easing/functions/linear.ts
var EasingLinear = function (t, b, c, d) { return c * t / d + b; };

// CONCATENATED MODULE: ./engine/animation/tween.ts



var tween_Tween = (function () {
    function Tween(tweenDesc) {
        this._propsToChange = [];
        this._startedTime = 0;
        this._currTime = 0;
        this._completed = false;
        this._delayBeforeStart = 0;
        this._target = tweenDesc.target;
        this._progressFn = tweenDesc.progress;
        this._completeFn = tweenDesc.complete;
        this._easeFn = tweenDesc.ease || EasingLinear;
        this._delayBeforeStart = tweenDesc.delayBeforeStart || 0;
        this._tweenTime = (tweenDesc.time || 1000) + this._delayBeforeStart;
        this._loop = tweenDesc.loop || false;
        this._desc = this.normalizeDesc(tweenDesc);
    }
    Tween.prototype.reuse = function (newTweenDesc) {
        var _this = this;
        this._startedTime = this._currTime;
        this._completed = false;
        Object.keys(newTweenDesc).forEach(function (key) {
            _this._desc[key] = newTweenDesc[key];
        });
        this._desc = this.normalizeDesc(newTweenDesc);
    };
    Tween.prototype.update = function () {
        if (this._completed)
            return;
        var currTime = game_Game.getInstance().getCurrentTime();
        this._currTime = currTime;
        if (this._startedTime === 0)
            this._startedTime = currTime;
        var curTweenTime = currTime - this._startedTime;
        if (curTweenTime < 0)
            curTweenTime = currTime;
        if (curTweenTime < this._delayBeforeStart)
            return;
        if (curTweenTime > this._tweenTime) {
            if (this._loop) {
                this._startedTime = currTime + (curTweenTime - this._tweenTime);
            }
            else {
                this.complete();
                return;
            }
        }
        var l = this._propsToChange.length;
        while (l--) {
            var prp = this._propsToChange[l];
            var valFrom = this._desc.from[prp];
            var valTo = this._desc.to[prp];
            var fn = this._easeFn;
            this._target[prp] = fn(curTweenTime, valFrom, valTo - valFrom, this._tweenTime);
        }
        if (this._progressFn)
            this._progressFn(this._target);
    };
    Tween.prototype.reset = function () {
        this._startedTime = 0;
        this._completed = false;
    };
    Tween.prototype.complete = function () {
        if (this._completed)
            return;
        for (var _i = 0, _a = this._propsToChange; _i < _a.length; _i++) {
            var k = _a[_i];
            this._target[k] = this._desc.to[k];
        }
        if (this._progressFn)
            this._progressFn(this._target);
        if (this._completeFn)
            this._completeFn(this._target);
        this._completed = true;
    };
    Tween.prototype.isCompleted = function () {
        return this._completed;
    };
    Tween.prototype.getTarget = function () {
        return this._target;
    };
    Tween.prototype.getTweenTime = function () {
        return this._tweenTime;
    };
    Tween.prototype.normalizeDesc = function (tweenDesc) {
        var _this = this;
        var normalized = tweenDesc;
        normalized.from = normalized.from || {};
        normalized.to = normalized.to || {};
        var allPropsMap = {};
        Object.keys(normalized.from).forEach(function (keyFrom) {
            allPropsMap[keyFrom] = true;
        });
        Object.keys(normalized.to).forEach(function (keyTo) {
            allPropsMap[keyTo] = true;
        });
        this._propsToChange = Object.keys(allPropsMap);
        if (true) {
            this._propsToChange.forEach(function (key) {
                if (!(key in _this._target)) {
                    console.error('target', _this._target);
                    throw new debugError_DebugError("Can not create tween animation: property \"" + key + "\" does not belong to target object");
                }
            });
        }
        this._propsToChange.forEach(function (prp) {
            if (normalized.from[prp] === undefined)
                normalized.from[prp] = _this._target[prp];
            if (normalized.to[prp] === undefined)
                normalized.to[prp] = _this._target[prp];
        });
        return normalized;
    };
    Tween.prototype.progress = function (_progressFn) {
        this._progressFn = _progressFn;
    };
    return Tween;
}());


// CONCATENATED MODULE: ./engine/geometry/point2d.ts




var point2d_Point2d = (function (_super) {
    __extends(Point2d, _super);
    function Point2d(x, y, onChangedFn) {
        if (x === void 0) { x = 0; }
        if (y === void 0) { y = x; }
        var _this = _super.call(this) || this;
        _this._x = 0;
        _this._y = 0;
        if (onChangedFn)
            _this.addOnChangeListener(onChangedFn);
        _this.setXY(x, y);
        return _this;
    }
    Object.defineProperty(Point2d.prototype, "x", {
        get: function () {
            return this._x;
        },
        set: function (value) {
            this.setX(value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Point2d.prototype, "y", {
        get: function () {
            return this._y;
        },
        set: function (value) {
            this.setY(value);
        },
        enumerable: true,
        configurable: true
    });
    Point2d.fromPool = function () {
        return Point2d.pool.getFreeObject();
    };
    Point2d.prototype.setXY = function (x, y) {
        if (y === void 0) { y = x; }
        if ( true && (Number.isNaN(x) || Number.isNaN(y)))
            throw new debugError_DebugError("Point2d: wrong numeric arguments " + x + "," + y);
        var changed = this._x !== x || this._y !== y;
        if (changed) {
            this._x = x;
            this._y = y;
            this.triggerObservable();
        }
        return this;
    };
    Point2d.prototype.setX = function (x) {
        this.setXY(x, this._y);
        return this;
    };
    Point2d.prototype.setY = function (y) {
        this.setXY(this._x, y);
        return this;
    };
    Point2d.prototype.set = function (another) {
        this.setXY(another.x, another.y);
        return this;
    };
    Point2d.prototype.add = function (another) {
        this.addXY(another.x, another.y);
        return this;
    };
    Point2d.prototype.substract = function (another) {
        this.addXY(-another.x, -another.y);
        return this;
    };
    Point2d.prototype.multiply = function (n) {
        this.setXY(this._x * n, this._y * n);
        return this;
    };
    Point2d.prototype.addXY = function (x, y) {
        this.setXY(this._x + x, this._y + y);
        return this;
    };
    Point2d.prototype.addX = function (x) {
        this.addXY(x, 0);
        return this;
    };
    Point2d.prototype.addY = function (y) {
        this.addXY(0, y);
        return this;
    };
    Point2d.prototype.negative = function () {
        this.setXY(-this._x, -this._y);
        return this;
    };
    Point2d.prototype.equal = function (x, y) {
        if (y === void 0) { y = x; }
        return this._x === x && this._y === y;
    };
    Point2d.prototype.equalPoint = function (point) {
        return this.equal(point.x, point.y);
    };
    Point2d.prototype.clone = function () {
        return new Point2d(this._x, this._y);
    };
    Point2d.prototype.fromJSON = function (json) {
        this.setXY(json.x, json.y);
    };
    Point2d.prototype.toJSON = function () {
        return { x: this._x, y: this._y };
    };
    Point2d.prototype.toArray = function () {
        if (this._arr === undefined)
            this._arr = [this._x, this._y];
        else {
            this._arr[0] = this._x;
            this._arr[1] = this._y;
        }
        return this._arr;
    };
    Point2d.pool = new objectPool_ObjectPool(Point2d, 4);
    return Point2d;
}(observableEntity_ObservableEntity));


// CONCATENATED MODULE: ./engine/geometry/mat4.ts




var mat4_mat4;
(function (mat4) {
    var Mat16Holder = (function (_super) {
        __extends(Mat16Holder, _super);
        function Mat16Holder() {
            var _this = _super.call(this) || this;
            _this.mat16 = new Float32Array(16);
            _this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
            return _this;
        }
        Mat16Holder.fromPool = function () {
            return Mat16Holder.m16hPool.getFreeObject();
        };
        Mat16Holder.create = function () {
            return new Mat16Holder();
        };
        Mat16Holder.prototype.set = function (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) {
            var mat16 = this.mat16;
            mat16[0] = v0;
            mat16[1] = v1;
            mat16[2] = v2;
            mat16[3] = v3;
            mat16[4] = v4;
            mat16[5] = v5;
            mat16[6] = v6;
            mat16[7] = v7;
            mat16[8] = v8;
            mat16[9] = v9;
            mat16[10] = v10;
            mat16[11] = v11;
            mat16[12] = v12;
            mat16[13] = v13;
            mat16[14] = v14;
            mat16[15] = v15;
        };
        Mat16Holder.prototype.fromMat16 = function (mat16) {
            this.set(mat16[0], mat16[1], mat16[2], mat16[3], mat16[4], mat16[5], mat16[6], mat16[7], mat16[8], mat16[9], mat16[10], mat16[11], mat16[12], mat16[13], mat16[14], mat16[15]);
        };
        Mat16Holder.prototype.clone = function () {
            var m = new Mat16Holder();
            for (var i = 0; i < this.mat16.length; i++) {
                m.mat16[i] = this.mat16[i];
            }
            return m;
        };
        Mat16Holder.m16hPool = new objectPool_ObjectPool(Mat16Holder, 256);
        return Mat16Holder;
    }(ReleaseableEntity));
    mat4.Mat16Holder = Mat16Holder;
    mat4.makeIdentity = function (out) {
        out.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    };
    mat4.makeZToWMatrix = function (out, fudgeFactor) {
        out.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, fudgeFactor, 0, 0, 0, 1);
    };
    mat4.make2DProjection = function (out, width, height, depth) {
        out.set(2 / width, 0, 0, 0, 0, -2 / height, 0, 0, 0, 0, 2 / depth, 0, -1, 1, 0, 1);
    };
    mat4.ortho = function (out, left, right, bottom, top, near, far) {
        if (true) {
            if (left === right || bottom === top || near === far) {
                console.error({ left: left, right: right, bottom: bottom, top: top, near: near, far: far });
                throw new debugError_DebugError("Can not create ortho matrix with wrong parameters");
            }
        }
        var lr = 1 / (left - right), bt = 1 / (bottom - top), nf = 1 / (near - far);
        var outMat16 = out.mat16;
        outMat16[0] = -2 * lr;
        outMat16[1] = 0;
        outMat16[2] = 0;
        outMat16[3] = 0;
        outMat16[4] = 0;
        outMat16[5] = -2 * bt;
        outMat16[6] = 0;
        outMat16[7] = 0;
        outMat16[8] = 0;
        outMat16[9] = 0;
        outMat16[10] = 2 * nf;
        outMat16[11] = 0;
        outMat16[12] = (left + right) * lr;
        outMat16[13] = (top + bottom) * bt;
        outMat16[14] = (far + near) * nf;
        outMat16[15] = 1;
    };
    mat4.perspective = function (out, fovy, aspect, near, far) {
        var f = 1.0 / Math.tan(fovy / 2), nf = 1 / (near - far);
        var outMat16 = out.mat16;
        outMat16[0] = f / aspect;
        outMat16[1] = 0;
        outMat16[2] = 0;
        outMat16[3] = 0;
        outMat16[4] = 0;
        outMat16[5] = f;
        outMat16[6] = 0;
        outMat16[7] = 0;
        outMat16[8] = 0;
        outMat16[9] = 0;
        outMat16[10] = (far + near) * nf;
        outMat16[11] = -1;
        outMat16[12] = 0;
        outMat16[13] = 0;
        outMat16[14] = (2 * far * near) * nf;
        outMat16[15] = 0;
    };
    mat4.makeTranslation = function (out, tx, ty, tz) {
        out.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, tx, ty, tz, 1);
    };
    mat4.makeXSkew = function (out, angle) {
        out.set(1, 0, 0, 0, Math.tan(angle), 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    };
    mat4.makeYSkew = function (out, angle) {
        out.set(1, Math.tan(angle), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    };
    mat4.makeXRotation = function (out, angleInRadians) {
        var c = Math.cos(angleInRadians);
        var s = Math.sin(angleInRadians);
        out.set(1, 0, 0, 0, 0, c, s, 0, 0, -s, c, 0, 0, 0, 0, 1);
    };
    mat4.makeYRotation = function (out, angleInRadians) {
        var c = Math.cos(angleInRadians);
        var s = Math.sin(angleInRadians);
        out.set(c, 0, -s, 0, 0, 1, 0, 0, s, 0, c, 0, 0, 0, 0, 1);
    };
    mat4.makeZRotation = function (out, angleInRadians) {
        var c = Math.cos(angleInRadians);
        var s = Math.sin(angleInRadians);
        out.set(c, s, 0, 0, -s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    };
    mat4.makeRotationReset = function (out) {
        var matrix = out.mat16;
        var d = Math.sqrt(matrix[0] * matrix[0] + matrix[1] * matrix[1] + matrix[2] * matrix[2]);
        matrix[0] = d;
        matrix[4] = 0;
        matrix[8] = 0;
        matrix[1] = 0;
        matrix[5] = d;
        matrix[9] = 0;
        matrix[2] = 0;
        matrix[6] = 0;
        matrix[10] = d;
        matrix[3] = 0;
        matrix[7] = 0;
        matrix[11] = 0;
        matrix[15] = 1;
    };
    mat4.makeScale = function (out, sx, sy, sz) {
        out.set(sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1);
    };
    mat4.matrixMultiply = function (out, aHolder, bHolder) {
        var r = out.mat16;
        var a = aHolder.mat16;
        var b = bHolder.mat16;
        r[0] = a[0] * b[0] + a[1] * b[4] + a[2] * b[8] + a[3] * b[12];
        r[1] = a[0] * b[1] + a[1] * b[5] + a[2] * b[9] + a[3] * b[13];
        r[2] = a[0] * b[2] + a[1] * b[6] + a[2] * b[10] + a[3] * b[14];
        r[3] = a[0] * b[3] + a[1] * b[7] + a[2] * b[11] + a[3] * b[15];
        r[4] = a[4] * b[0] + a[5] * b[4] + a[6] * b[8] + a[7] * b[12];
        r[5] = a[4] * b[1] + a[5] * b[5] + a[6] * b[9] + a[7] * b[13];
        r[6] = a[4] * b[2] + a[5] * b[6] + a[6] * b[10] + a[7] * b[14];
        r[7] = a[4] * b[3] + a[5] * b[7] + a[6] * b[11] + a[7] * b[15];
        r[8] = a[8] * b[0] + a[9] * b[4] + a[10] * b[8] + a[11] * b[12];
        r[9] = a[8] * b[1] + a[9] * b[5] + a[10] * b[9] + a[11] * b[13];
        r[10] = a[8] * b[2] + a[9] * b[6] + a[10] * b[10] + a[11] * b[14];
        r[11] = a[8] * b[3] + a[9] * b[7] + a[10] * b[11] + a[11] * b[15];
        r[12] = a[12] * b[0] + a[13] * b[4] + a[14] * b[8] + a[15] * b[12];
        r[13] = a[12] * b[1] + a[13] * b[5] + a[14] * b[9] + a[15] * b[13];
        r[14] = a[12] * b[2] + a[13] * b[6] + a[14] * b[10] + a[15] * b[14];
        r[15] = a[12] * b[3] + a[13] * b[7] + a[14] * b[11] + a[15] * b[15];
    };
    mat4.multVecByMatrix = function (out, matrix, vec4Arr) {
        for (var i = 0; i < 4; i++) {
            out.vec4[i] =
                vec4Arr.vec4[0] * matrix.mat16[0 * 4 + i] +
                    vec4Arr.vec4[1] * matrix.mat16[1 * 4 + i] +
                    vec4Arr.vec4[2] * matrix.mat16[2 * 4 + i] +
                    vec4Arr.vec4[3] * matrix.mat16[3 * 4 + i];
        }
    };
    mat4.inverse = function (out, mHolder) {
        var r = out.mat16;
        var m = mHolder.mat16;
        r[0] = m[5] * m[10] * m[15] - m[5] * m[14] * m[11] - m[6] * m[9] * m[15] + m[6] * m[13] * m[11] + m[7] * m[9] * m[14] - m[7] * m[13] * m[10];
        r[1] = -m[1] * m[10] * m[15] + m[1] * m[14] * m[11] + m[2] * m[9] * m[15] - m[2] * m[13] * m[11] - m[3] * m[9] * m[14] + m[3] * m[13] * m[10];
        r[2] = m[1] * m[6] * m[15] - m[1] * m[14] * m[7] - m[2] * m[5] * m[15] + m[2] * m[13] * m[7] + m[3] * m[5] * m[14] - m[3] * m[13] * m[6];
        r[3] = -m[1] * m[6] * m[11] + m[1] * m[10] * m[7] + m[2] * m[5] * m[11] - m[2] * m[9] * m[7] - m[3] * m[5] * m[10] + m[3] * m[9] * m[6];
        r[4] = -m[4] * m[10] * m[15] + m[4] * m[14] * m[11] + m[6] * m[8] * m[15] - m[6] * m[12] * m[11] - m[7] * m[8] * m[14] + m[7] * m[12] * m[10];
        r[5] = m[0] * m[10] * m[15] - m[0] * m[14] * m[11] - m[2] * m[8] * m[15] + m[2] * m[12] * m[11] + m[3] * m[8] * m[14] - m[3] * m[12] * m[10];
        r[6] = -m[0] * m[6] * m[15] + m[0] * m[14] * m[7] + m[2] * m[4] * m[15] - m[2] * m[12] * m[7] - m[3] * m[4] * m[14] + m[3] * m[12] * m[6];
        r[7] = m[0] * m[6] * m[11] - m[0] * m[10] * m[7] - m[2] * m[4] * m[11] + m[2] * m[8] * m[7] + m[3] * m[4] * m[10] - m[3] * m[8] * m[6];
        r[8] = m[4] * m[9] * m[15] - m[4] * m[13] * m[11] - m[5] * m[8] * m[15] + m[5] * m[12] * m[11] + m[7] * m[8] * m[13] - m[7] * m[12] * m[9];
        r[9] = -m[0] * m[9] * m[15] + m[0] * m[13] * m[11] + m[1] * m[8] * m[15] - m[1] * m[12] * m[11] - m[3] * m[8] * m[13] + m[3] * m[12] * m[9];
        r[10] = m[0] * m[5] * m[15] - m[0] * m[13] * m[7] - m[1] * m[4] * m[15] + m[1] * m[12] * m[7] + m[3] * m[4] * m[13] - m[3] * m[12] * m[5];
        r[11] = -m[0] * m[5] * m[11] + m[0] * m[9] * m[7] + m[1] * m[4] * m[11] - m[1] * m[8] * m[7] - m[3] * m[4] * m[9] + m[3] * m[8] * m[5];
        r[12] = -m[4] * m[9] * m[14] + m[4] * m[13] * m[10] + m[5] * m[8] * m[14] - m[5] * m[12] * m[10] - m[6] * m[8] * m[13] + m[6] * m[12] * m[9];
        r[13] = m[0] * m[9] * m[14] - m[0] * m[13] * m[10] - m[1] * m[8] * m[14] + m[1] * m[12] * m[10] + m[2] * m[8] * m[13] - m[2] * m[12] * m[9];
        r[14] = -m[0] * m[5] * m[14] + m[0] * m[13] * m[6] + m[1] * m[4] * m[14] - m[1] * m[12] * m[6] - m[2] * m[4] * m[13] + m[2] * m[12] * m[5];
        r[15] = m[0] * m[5] * m[10] - m[0] * m[9] * m[6] - m[1] * m[4] * m[10] + m[1] * m[8] * m[6] + m[2] * m[4] * m[9] - m[2] * m[8] * m[5];
        var det = m[0] * r[0] + m[1] * r[4] + m[2] * r[8] + m[3] * r[12];
        if ( true && det === 0) {
            console.error(m);
            throw new debugError_DebugError("can not invert matrix with zero determinant");
        }
        for (var i = 0; i < 16; i++)
            r[i] /= det;
    };
    mat4.transpose = function (out, mHolder) {
        var m = mHolder.mat16;
        out.set(m[0], m[4], m[8], m[12], m[1], m[5], m[9], m[13], m[2], m[6], m[10], m[14], m[3], m[7], m[11], m[15]);
    };
    var m16h = Mat16Holder.create();
    mat4.makeIdentity(m16h);
    mat4.IDENTITY = m16h.mat16;
    mat4.IDENTITY_HOLDER = new Mat16Holder();
    mat4.IDENTITY_HOLDER.set.apply(mat4.IDENTITY_HOLDER, mat4.IDENTITY);
})(mat4_mat4 || (mat4_mat4 = {}));

// CONCATENATED MODULE: ./engine/geometry/vec4.ts



var vec4_vec4;
(function (vec4) {
    var Vec4Holder = (function (_super) {
        __extends(Vec4Holder, _super);
        function Vec4Holder() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.vec4 = new Float32Array(4);
            return _this;
        }
        Vec4Holder.fromPool = function () {
            return Vec4Holder.pool.getFreeObject();
        };
        Vec4Holder.prototype.set = function (x, y, z, w) {
            var v = this.vec4;
            v[0] = x;
            v[1] = y;
            v[2] = z;
            v[3] = w;
        };
        Object.defineProperty(Vec4Holder.prototype, "x", {
            get: function () {
                return this.vec4[0];
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(Vec4Holder.prototype, "y", {
            get: function () {
                return this.vec4[1];
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(Vec4Holder.prototype, "z", {
            get: function () {
                return this.vec4[2];
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(Vec4Holder.prototype, "w", {
            get: function () {
                return this.vec4[3];
            },
            enumerable: true,
            configurable: true
        });
        Vec4Holder.pool = new objectPool_ObjectPool(Vec4Holder, 32);
        return Vec4Holder;
    }(ReleaseableEntity));
    vec4.Vec4Holder = Vec4Holder;
})(vec4_vec4 || (vec4_vec4 = {}));

// CONCATENATED MODULE: ./engine/misc/mathEx.ts



var mathEx_MathEx;
(function (MathEx) {
    var Mat16Holder = mat4_mat4.Mat16Holder;
    var Vec4Holder = vec4_vec4.Vec4Holder;
    MathEx.isPointInRect = function (point, rect, angle) {
        return point.x > rect.x &&
            point.x < (rect.x + rect.width) &&
            point.y > rect.y &&
            point.y < (rect.y + rect.height);
    };
    MathEx.clamp = function (val, min, max) {
        if (val < min)
            val = min;
        if (val > max)
            val = max;
        return val;
    };
    MathEx.overlapTest = function (a, b) {
        return (a.x < b.x + b.width) &&
            (a.x + a.width > b.x) &&
            (a.y < b.y + b.height) &&
            (a.y + a.height > b.y);
    };
    MathEx.radToDeg = function (rad) {
        return rad * 180 / Math.PI;
    };
    MathEx.degToRad = function (deg) {
        return deg * Math.PI / 180;
    };
    MathEx.rectToPolar = function (point, center) {
        var radius = Math.sqrt(point.x * point.x + center.y * center.y);
        var angle = Math.atan2(center.y - point.y, center.x - point.x);
        return { radius: radius, angle: angle };
    };
    MathEx.polarToRect = function (radius, angle, center) {
        var x = radius * Math.cos(angle);
        var y = radius * Math.sin(angle);
        return new point2d_Point2d(center.x - x, center.y - y);
    };
    MathEx.getDistanceSquared = function (p1, p2) {
        return Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2);
    };
    MathEx.closeTo = function (a, b, epsilon) {
        if (epsilon === void 0) { epsilon = 0.01; }
        return Math.abs(a - b) <= epsilon;
    };
    MathEx.getDistance = function (p1, p2) {
        return Math.sqrt(MathEx.getDistanceSquared(p1, p2));
    };
    MathEx.getAngle = function (p1, p2) {
        var dx = p1.x - p2.x;
        var dy = p1.y - p2.y;
        return Math.atan2(dy, dx);
    };
    MathEx.random = function (min, max) {
        if (min > max) {
            var tmp = min;
            min = max;
            max = tmp;
        }
        return Math.random() * (max - min) + min;
    };
    MathEx.randomInt = function (min, max) {
        return ~~MathEx.random(min, max);
    };
    MathEx.randomByte = function (min, max) {
        return MathEx.randomInt(min, max);
    };
    MathEx.unProject = function (winPoint, width, height, viewProjectionMatrix) {
        var x = 2.0 * winPoint.x / width - 1;
        var y = 2.0 * winPoint.y / height - 1;
        var viewProjectionInverse = Mat16Holder.fromPool();
        mat4_mat4.inverse(viewProjectionInverse, viewProjectionMatrix);
        var point3D = Vec4Holder.fromPool();
        point3D.set(x, y, 0, 1);
        var res = Vec4Holder.fromPool();
        mat4_mat4.multVecByMatrix(res, viewProjectionInverse, point3D);
        var resultX = (res.x / 2 + 0.5) * width;
        var resultY = (res.y / 2 + 0.5) * height;
        var result = point2d_Point2d.fromPool();
        result.setXY(resultX, resultY);
        point3D.release();
        res.release();
        viewProjectionInverse.release();
        return result;
    };
})(mathEx_MathEx || (mathEx_MathEx = {}));

// CONCATENATED MODULE: ./engine/geometry/rect.ts




var rect_Rect = (function (_super) {
    __extends(Rect, _super);
    function Rect(x, y, width, height, onChangedFn) {
        if (x === void 0) { x = 0; }
        if (y === void 0) { y = 0; }
        if (width === void 0) { width = 0; }
        if (height === void 0) { height = 0; }
        var _this = _super.call(this) || this;
        _this._x = 0;
        _this._y = 0;
        _this._width = 0;
        _this._height = 0;
        _this._arr = [0, 0, 0, 0];
        if (onChangedFn)
            _this.addOnChangeListener(onChangedFn);
        _this.setXYWH(x, y, width, height);
        return _this;
    }
    Rect.fromPool = function () {
        return Rect.rectPool.getFreeObject();
    };
    Rect.prototype.setXYWH = function (x, y, width, height) {
        if ( true &&
            (Number.isNaN(x) ||
                Number.isNaN(y) ||
                Number.isNaN(width) ||
                Number.isNaN(height)))
            throw new debugError_DebugError("Rect: wrong numeric arguments " + x + "," + y + "," + width + "," + height);
        var oldX = this._x;
        var oldY = this._y;
        var oldW = this._width;
        var oldH = this._height;
        var changed = oldX !== x || oldY !== y || oldW !== width || oldH !== height;
        if (changed) {
            this._x = x;
            this._y = y;
            this._width = width;
            this._height = height;
            this._right = this._x + this._width;
            this._bottom = this._y + this._height;
            this.triggerObservable();
        }
        return this;
    };
    Object.defineProperty(Rect.prototype, "x", {
        get: function () {
            return this._x;
        },
        set: function (x) {
            this.setXY(x, this.y);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Rect.prototype, "y", {
        get: function () {
            return this._y;
        },
        set: function (y) {
            this.setXY(this.x, y);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Rect.prototype, "width", {
        get: function () {
            return this._width;
        },
        set: function (width) {
            this.setWH(width, this.height);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Rect.prototype, "height", {
        get: function () {
            return this._height;
        },
        set: function (height) {
            this.setWH(this.width, height);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Rect.prototype, "right", {
        get: function () {
            return this._right;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Rect.prototype, "bottom", {
        get: function () {
            return this._bottom;
        },
        enumerable: true,
        configurable: true
    });
    Rect.prototype.setXY = function (x, y) {
        this.setXYWH(x, y, this._width, this._height);
        return this;
    };
    Rect.prototype.setWH = function (width, height) {
        this.setXYWH(this._x, this._y, width, height);
        return this;
    };
    Rect.prototype.set = function (another) {
        this.setXYWH(another.x, another.y, another.width, another.height);
        return this;
    };
    Rect.prototype.setSize = function (s) {
        this.setWH(s.width, s.height);
        return this;
    };
    Rect.prototype.setPoint = function (p) {
        this.setXY(p.x, p.y);
        return this;
    };
    Rect.prototype.setPointAndSize = function (p, size) {
        this.setPoint(p);
        this.setSize(size);
        return this;
    };
    Rect.prototype.addXY = function (x, y) {
        this.setXY(this._x + x, this._y + y);
        return this;
    };
    Rect.prototype.addWH = function (width, height) {
        this.setWH(this._width + width, this._height + height);
        return this;
    };
    Rect.prototype.addPoint = function (another) {
        this.addXY(another.x, another.y);
        return this;
    };
    Rect.prototype.isZeroSize = function () {
        return this._width === 0 || this._height === 0;
    };
    Rect.prototype.clone = function () {
        return new Rect(this._x, this._y, this._width, this._height);
    };
    Rect.prototype.toJSON = function () {
        return {
            x: this._x,
            y: this._y,
            width: this._width,
            height: this._height
        };
    };
    Rect.prototype.toArray = function () {
        this._arr[0] = this._x;
        this._arr[1] = this._y;
        this._arr[2] = this._width;
        this._arr[3] = this._height;
        return this._arr;
    };
    Rect.prototype.fromJSON = function (jsonObj) {
        this.setXYWH(jsonObj.x, jsonObj.y, jsonObj.width, jsonObj.height);
    };
    Rect.rectPool = new objectPool_ObjectPool(Rect);
    return Rect;
}(observableEntity_ObservableEntity));


// CONCATENATED MODULE: ./engine/renderer/camera.ts





var camera_Mat16Holder = mat4_mat4.Mat16Holder;
var camera_Camera = (function () {
    function Camera(game) {
        var _this = this;
        this.game = game;
        this.pos = new point2d_Point2d(0, 0);
        this.posZ = 0;
        this.scale = new point2d_Point2d(1, 1);
        this.worldTransformDirty = true;
        this.worldTransformMatrix = new camera_Mat16Holder();
        this._rect = new rect_Rect();
        this.cameraPosCorrection = {
            current: new point2d_Point2d(),
            max: new point2d_Point2d()
        };
        var observer = function () { return _this.worldTransformDirty = true; };
        this.pos.observe(observer);
        this.scale.observe(observer);
        this._rect.observe(observer);
    }
    Camera.prototype.revalidate = function () {
        this._rect.setSize(this.game.size);
        this.worldTransformDirty = true;
    };
    Camera.prototype.followTo = function (gameObject) {
        if (gameObject === undefined) {
            this.objFollowTo = undefined;
            return;
        }
        this.objFollowTo = gameObject;
        this.objFollowToPrevPos = new point2d_Point2d();
        this.objFollowToPrevPos.set(this.objFollowTo.pos);
        this.revalidate();
    };
    Camera.prototype.update = function () {
        var gameObject = this.objFollowTo;
        if (gameObject !== undefined) {
            if ((gameObject.pos.x - this.objFollowToPrevPos.x) > 0)
                this.directionCorrection = 0;
            else if ((gameObject.pos.x - this.objFollowToPrevPos.x) < 0)
                this.directionCorrection = 1;
            if ((gameObject.pos.y - this.objFollowToPrevPos.y) > 0)
                this.directionCorrection = 3;
            else if ((gameObject.pos.y - this.objFollowToPrevPos.y) < 0)
                this.directionCorrection = 2;
            this.objFollowToPrevPos.set(gameObject.pos);
            var _a = this.getRect(), width = _a.width, height = _a.height;
            if (this.directionCorrection === 0)
                this.cameraPosCorrection.max.x = width / 3;
            else if (this.directionCorrection === 1)
                this.cameraPosCorrection.max.x = -width / 3;
            else if (this.directionCorrection === 3)
                this.cameraPosCorrection.max.y = height / 3;
            else if (this.directionCorrection === 2)
                this.cameraPosCorrection.max.y = -height / 3;
            var currCorrection = this.cameraPosCorrection.max.
                substract(this.cameraPosCorrection.current).
                multiply(0.05);
            this.cameraPosCorrection.current.add(currCorrection);
            var newPos = point2d_Point2d.fromPool();
            var pointToFollow = point2d_Point2d.fromPool();
            var scene = this.game.getCurrScene();
            var w = this.game.size.width;
            var h = this.game.size.height;
            var wDiv2 = w / 2;
            var hDiv2 = h / 2;
            pointToFollow.set(gameObject.pos);
            pointToFollow.addXY(-wDiv2, -hDiv2);
            newPos.x = this.pos.x + (pointToFollow.x + this.cameraPosCorrection.current.x - this.pos.x) * Camera.FOLLOW_FACTOR.x;
            newPos.y = this.pos.y + (pointToFollow.y + this.cameraPosCorrection.current.y - this.pos.y) * Camera.FOLLOW_FACTOR.y;
            if (newPos.x < 0) {
                newPos.x = 0;
            }
            if (newPos.y < 0) {
                newPos.y = 0;
            }
            if (newPos.x > scene.size.width - w) {
                newPos.x = scene.size.width - w;
            }
            if (newPos.y > scene.size.height - h) {
                newPos.y = scene.size.height - h;
            }
            this.pos.set(newPos);
            newPos.release();
            pointToFollow.release();
        }
        if (this.cameraShakeTween !== undefined)
            this.cameraShakeTween.update();
    };
    Camera.prototype.shake = function (amplitude, time) {
        var _this = this;
        var tweenTarget = { time: 0, point: new point2d_Point2d(0, 0) };
        this.cameraShakeTween = new tween_Tween({
            target: tweenTarget,
            time: time,
            to: { time: time },
            progress: function () {
                var r1 = mathEx_MathEx.random(-amplitude / 2, amplitude / 2);
                var r2 = mathEx_MathEx.random(-amplitude / 2, amplitude / 2);
                tweenTarget.point.setXY(r1, r2);
            },
            complete: function () { return _this.cameraShakeTween = undefined; }
        });
    };
    Camera.prototype.translate = function () {
        var renderer = this.game.getRenderer();
        renderer.transformTranslate(-this.pos.x, -this.pos.y, 0);
    };
    Camera.prototype.transform = function () {
        var renderer = this.game.getRenderer();
        if (!this.scale.equal(1)) {
            renderer.transformTranslate(this.game.size.width / 2, this.game.size.height / 2, 0);
            renderer.transformScale(this.scale.x, this.scale.y);
            renderer.transformTranslate(-this.game.size.width / 2, -this.game.size.height / 2);
        }
        if (this.cameraShakeTween !== undefined)
            renderer.transformTranslate(this.cameraShakeTween.getTarget().point.x, this.cameraShakeTween.getTarget().point.y);
    };
    Camera.prototype.screenToWorld = function (p, transformType) {
        var mScale = camera_Mat16Holder.fromPool();
        var scaleX = transformType === 0 ? this.scale.x : 1;
        var scaleY = transformType === 0 ? this.scale.y : 1;
        var posX = transformType === 0 ? this.pos.x : 0;
        var posY = transformType === 0 ? this.pos.y : 0;
        mat4_mat4.makeScale(mScale, scaleX, scaleY, 1);
        var point2d = mathEx_MathEx.unProject(p, this.game.size.width, this.game.size.height, mScale);
        point2d.addXY(posX / scaleX, posY / scaleY);
        mScale.release();
        return point2d;
    };
    Camera.prototype.getRect = function () {
        this._rect.setXY(this.pos.x, this.pos.y);
        return this._rect;
    };
    Camera.FOLLOW_FACTOR = new point2d_Point2d(0.1, 0.1);
    return Camera;
}());


// CONCATENATED MODULE: ./engine/misc/collection/stack.ts

var stack_Stack = (function () {
    function Stack() {
        this._array = new Array(16);
        this.stackPointer = 0;
    }
    Stack.prototype.push = function (obj) {
        this._array[this.stackPointer++] = obj;
    };
    Stack.prototype.pop = function () {
        if ( true && this.stackPointer === 0)
            throw new debugError_DebugError("empty stack");
        this.stackPointer--;
        var res = this._array[this.stackPointer];
        this._array[this.stackPointer] = undefined;
        return res;
    };
    Stack.prototype.replaceLast = function (obj) {
        if (!this._array.length)
            this.push(obj);
        else
            this._array[this.stackPointer - 1] = obj;
    };
    Stack.prototype.getLast = function () {
        if (!this._array)
            return undefined;
        else
            return this._array[this.stackPointer - 1];
    };
    Stack.prototype.getAt = function (i) {
        return this._array[i];
    };
    Stack.prototype.size = function () {
        return this.stackPointer;
    };
    Stack.prototype.isEmpty = function () {
        return this.stackPointer === 0;
    };
    return Stack;
}());


// CONCATENATED MODULE: ./engine/geometry/size.ts




var size_Size = (function (_super) {
    __extends(Size, _super);
    function Size(width, height, onChangedFn) {
        if (width === void 0) { width = 0; }
        if (height === void 0) { height = 0; }
        var _this = _super.call(this) || this;
        _this._arr = [_this._width, _this._height];
        if (onChangedFn)
            _this.addOnChangeListener(onChangedFn);
        _this.setWH(width, height);
        return _this;
    }
    Object.defineProperty(Size.prototype, "width", {
        get: function () {
            return this._width;
        },
        set: function (val) {
            if ( true && Number.isNaN(val))
                throw new debugError_DebugError("Size: wrong numeric argument  " + val);
            var changed = this._width !== val;
            if (changed) {
                this._width = val;
                this.triggerObservable();
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Size.prototype, "height", {
        get: function () {
            return this._height;
        },
        set: function (val) {
            var changed = this._height !== val;
            if (changed) {
                this._height = val;
                this.triggerObservable();
            }
        },
        enumerable: true,
        configurable: true
    });
    Size.fromPool = function () {
        return Size.rectPool.getFreeObject();
    };
    Size.prototype.setW = function (width) {
        this.setWH(width, this._height);
        return this;
    };
    Size.prototype.setH = function (height) {
        this.setWH(this._width, height);
        return this;
    };
    Size.prototype.setWH = function (width, height) {
        if (height === void 0) { height = width; }
        var changed = this._width !== width || this._height !== height;
        if (changed) {
            this._width = width;
            this._height = height;
            this.triggerObservable();
        }
        return this;
    };
    Size.prototype.addWH = function (width, height) {
        if (height === void 0) { height = width; }
        this.setWH(this.width + width, this.height + height);
        return this;
    };
    Size.prototype.set = function (another) {
        this.setWH(another.width, another.height);
        return this;
    };
    Size.prototype.equal = function (w, h) {
        return this._width === w && this._height === h;
    };
    Size.prototype.clone = function () {
        return new Size(this.width, this.height);
    };
    Size.prototype.isZero = function () {
        return this.equal(0, 0);
    };
    Size.prototype.toArray = function () {
        this._arr[0] = this._width;
        this._arr[1] = this._height;
        return this._arr;
    };
    Size.prototype.toJSON = function () {
        return {
            width: this.width,
            height: this.height
        };
    };
    Size.rectPool = new objectPool_ObjectPool(Size);
    return Size;
}(observableEntity_ObservableEntity));


// CONCATENATED MODULE: ./engine/core/game.ts






var game_Game = (function () {
    function Game(_a) {
        var _b = _a === void 0 ? {} : _a, _c = _b.width, width = _c === void 0 ? 320 : _c, _d = _b.height, height = _d === void 0 ? 240 : _d, _e = _b.scaleStrategy, scaleStrategy = _e === void 0 ? 1 : _e;
        this.size = new size_Size();
        this.scale = new point2d_Point2d(1, 1);
        this.pos = new point2d_Point2d(0, 0);
        this.camera = new camera_Camera(this);
        this.fps = 0;
        this._scaleStrategy = 1;
        this._startedTime = 0;
        this._lastTime = 0;
        this._currTime = 0;
        this._deltaTime = 0;
        this._sceneStack = new stack_Stack();
        this._running = false;
        this._destroyed = false;
        this._controls = [];
        this.mainLoop = new MainLoop(this);
        Game.instance = this;
        if (true)
            window.game = this;
        this.size.setWH(width, height);
        this._scaleStrategy = scaleStrategy;
        this._startedTime = Date.now();
    }
    Game.getInstance = function () {
        return Game.instance;
    };
    Object.defineProperty(Game.prototype, "scaleStrategy", {
        get: function () {
            return this._scaleStrategy;
        },
        enumerable: true,
        configurable: true
    });
    Game.prototype.addControl = function (C) {
        var instance = new C(this);
        if (true) {
            for (var _i = 0, _a = this._controls; _i < _a.length; _i++) {
                var c = _a[_i];
                if (c.type === instance.type) {
                    throw new debugError_DebugError("control with type \"" + c.type + "\" added already");
                }
            }
        }
        this._controls.push(instance);
        instance.listenTo();
    };
    Game.prototype.hasControl = function (type) {
        return this.getControl(type) !== undefined;
    };
    Game.prototype.getControl = function (type) {
        for (var _i = 0, _a = this._controls; _i < _a.length; _i++) {
            var c = _a[_i];
            if (c.type === type) {
                return c;
            }
        }
        return undefined;
    };
    Game.prototype.setPhysicsSystem = function (s) {
        this.physicsSystem = new s(this);
    };
    Game.prototype.getPhysicsSystem = function () {
        if ( true && this.physicsSystem === undefined)
            throw new debugError_DebugError("Physics system is not initialized.");
        return this.physicsSystem;
    };
    Game.prototype.setAudioPLayer = function (p) {
        this.audioPlayer = new p(this);
    };
    Game.prototype.getAudioPlayer = function () {
        if ( true && !this.audioPlayer) {
            throw new debugError_DebugError('audio player is not set');
        }
        return this.audioPlayer;
    };
    Game.prototype.getCurrentTime = function () {
        return this._lastTime;
    };
    Game.prototype.getDeltaTime = function () {
        return this._deltaTime;
    };
    Game.prototype.getElapsedTime = function () {
        return this._lastTime - this._startedTime;
    };
    Game.prototype.log = function () {
        var _a;
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        if (true)
            (_a = this._renderer).log.apply(_a, args);
    };
    Game.prototype.clearLog = function () {
        if (true)
            this._renderer.clearLog();
    };
    Game.prototype.setRenderer = function (Renderer) {
        this._renderer = new Renderer(this);
    };
    Game.prototype.getRenderer = function () {
        return this._renderer;
    };
    Game.prototype.runScene = function (scene, transition, replaceStack) {
        var _this = this;
        if (replaceStack === void 0) { replaceStack = true; }
        var _a;
        if (replaceStack)
            this._sceneStack.replaceLast({ scene: scene, transition: transition });
        this._prevScene = this._currScene;
        if (this._prevScene !== undefined) {
            this._prevScene.trigger("inactivated", undefined);
            this._prevScene.onInactivated();
            this._currScene.lifeCycleState = 3;
        }
        this._currScene = scene;
        if (this._currSceneTransition !== undefined) {
            this._currSceneTransition.complete();
            this._currSceneTransition = undefined;
        }
        if (transition !== undefined) {
            this._currSceneTransition = transition;
            transition.start(this._prevScene, this._currScene);
            transition.onComplete(function () { return _this._currSceneTransition = undefined; });
        }
        this.revalidate();
        if (!scene.resourceLoader.isCompleted()) {
            this._currScene.trigger("preloading");
            (_a = scene === null || scene === void 0 ? void 0 : scene.preloadingTaskFromDecorators) === null || _a === void 0 ? void 0 : _a.forEach(function (cb) { return cb(scene); });
            scene.onPreloading();
            scene.resourceLoader.onProgress(function () {
                _this._currScene.trigger("progress");
                scene.onProgress(scene.resourceLoader.getProgress());
                _this._currScene.lifeCycleState = 1;
            });
            scene.resourceLoader.onCompleted(function () {
                _this._currScene.onReady();
                _this._currScene.onContinue();
                _this._currScene.trigger("completed");
                _this._currScene.lifeCycleState = 2;
            });
            scene.resourceLoader.startLoading();
        }
        else {
            this._currScene.trigger("continue");
            this._currScene.onContinue();
        }
        if (!this._running) {
            this.mainLoop.start();
            this._running = true;
        }
    };
    Game.prototype.pushScene = function (scene, transition) {
        this.runScene(scene, transition, false);
        this._sceneStack.push({ scene: scene, transition: transition });
    };
    Game.prototype.popScene = function () {
        var last = this._sceneStack.pop();
        if ( true && !last)
            throw new debugError_DebugError("can not pop scene: no scene in stack");
        var transition = last.transition ? last.transition.getOppositeTransition() : undefined;
        this.runScene(this._sceneStack.getLast().scene, transition);
    };
    Game.prototype.getCurrScene = function () {
        if ( true && !this._currScene)
            throw new debugError_DebugError("current scene is not set yet");
        return this._currScene;
    };
    Game.prototype.update = function () {
        if (this._destroyed)
            return;
        this._lastTime = this._currTime;
        this._currTime = Date.now();
        var currTimeCopy = this._currTime;
        if (!this._lastTime)
            this._lastTime = this._currTime;
        this._deltaTime = this._currTime - this._lastTime;
        if (true) {
            this.fps = ~~(1000 / this._deltaTime);
            var renderError = this._renderer.getError();
            if (renderError !== undefined) {
                throw new debugError_DebugError("rendering error with code " + renderError.code + " (" + renderError.desc + ")");
            }
        }
        var numOfLoops = (~~(this._deltaTime / Game.UPDATE_TIME_RATE)) || 1;
        this._currTime = this._currTime - numOfLoops * Game.UPDATE_TIME_RATE;
        var currentScene = this._currScene;
        var loopCnt = 0;
        do {
            this._lastTime = this._currTime;
            this._currTime += Game.UPDATE_TIME_RATE;
            this._deltaTime = this._currTime - this._lastTime;
            if (this._currSceneTransition !== undefined)
                this._currSceneTransition.update();
            else
                currentScene.update();
            for (var _i = 0, _a = this._controls; _i < _a.length; _i++) {
                var c = _a[_i];
                c.update();
            }
            loopCnt++;
            if (loopCnt > 10) {
                this._lastTime = this._currTime = currTimeCopy;
                break;
            }
        } while (loopCnt < numOfLoops);
        if (this._currSceneTransition !== undefined)
            this._currSceneTransition.render();
        else
            currentScene.render();
        this.camera.worldTransformDirty = false;
    };
    Game.prototype.destroy = function () {
        this.mainLoop.stop();
        this._destroyed = true;
        for (var _i = 0, _a = this._controls; _i < _a.length; _i++) {
            var c = _a[_i];
            c.destroy();
        }
        if (this._renderer) {
            this._renderer.cancelFullScreen();
            this._renderer.destroy();
        }
        if (this.getAudioPlayer())
            this.getAudioPlayer().stopAll();
    };
    Game.prototype.revalidate = function () {
        if ( true && !this._renderer)
            throw new debugError_DebugError("game renderer is not set");
        this.camera.revalidate();
    };
    Game.UPDATE_TIME_RATE = 20;
    return Game;
}());

if (true) {
    var _cnt_1 = 0;
    game_Game.prototype.debug2 = function () {
        var val = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            val[_i] = arguments[_i];
        }
        console.log(val);
        _cnt_1++;
        if (_cnt_1 > 16)
            throw new debugError_DebugError('too many logs');
    };
    if (!window.__POLYFILLS_INCLUDED__)
        throw new debugError_DebugError("polyfills module is not included!");
}
if (true) {
    var now = Date.now();
    var passed = now - 1589043569287;
    console.log("last compiled " + passed / 1000 + " sec ago");
}
var MainLoop = (function () {
    function MainLoop(game) {
        this.game = game;
    }
    MainLoop.prototype.start = function () {
        var _this = this;
        var game = this.game;
        var updateFn = game.update.bind(game);
        var loopFn = function () {
            updateFn();
            _this.timerId = requestAnimationFrame(loopFn);
        };
        this.timerId = requestAnimationFrame(loopFn);
    };
    MainLoop.prototype.stop = function () {
        cancelAnimationFrame(this.timerId);
    };
    return MainLoop;
}());

// CONCATENATED MODULE: ./engine/renderer/webGl/base/shaderProgramUtils.ts


var parseErrors = function (log) {
    if (false)
        {}
    var logs = [];
    var result;
    while (!!(result = log.match(/ERROR\:([^\n]+)/))) {
        if (result.index !== undefined)
            log = log.slice((result.index + 1));
        var line = result[1].trim();
        var seps = line.split(':');
        var message = seps.slice(2).join(':').trim();
        var lineNum = +seps[1];
        logs.push({ message: message, lineNum: lineNum });
    }
    return logs;
};
var compileShader = function (gl, shaderSource, shaderType) {
    if (true) {
        if (!shaderSource)
            throw new debugError_DebugError("can not compile shader: shader source not specified for type " + shaderType);
    }
    var shader = gl.createShader(shaderType);
    if ( true && !shader)
        throw new debugError_DebugError("can not allocate memory for shader: gl.createShader(shaderType)");
    gl.shaderSource(shader, shaderSource);
    gl.compileShader(shader);
    var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
    if (!compiled) {
        var lastError = gl.getShaderInfoLog(shader);
        gl.deleteShader(shader);
        if (lastError !== null) {
            if (true) {
                var parsedLogs = parseErrors(lastError);
                var lines_1 = shaderSource.split('\n');
                var errorMsg_1 = '';
                var arrow_1 = '----->';
                parsedLogs.forEach(function (inf) {
                    var i = inf.lineNum - 1;
                    if (lines_1[i].indexOf(arrow_1) === -1)
                        lines_1[i] = arrow_1 + " " + lines_1[i];
                    errorMsg_1 += lines_1[i] + " <----" + inf.message + "\n";
                });
                console.log(lines_1.join('\n'));
                throw new debugError_DebugError("Error compiling shader: " + (errorMsg_1 ? errorMsg_1 : lastError));
            }
            else {}
        }
        else {
            throw new Error( true ? 'unknown compilation error' : undefined);
        }
    }
    return shader || undefined;
};
var createProgram = function (gl, vertexShader, fragmentShader) {
    var program = gl.createProgram();
    if ( true && !program)
        throw new debugError_DebugError("can not allocate memory for gl.createProgram()");
    gl.attachShader(program, vertexShader);
    gl.attachShader(program, fragmentShader);
    gl.linkProgram(program);
    var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
    if (!linked) {
        var lastError = gl.getProgramInfoLog(program);
        if (lastError) {
            if (true) {
                var status_1 = gl.getProgramParameter(program, gl.VALIDATE_STATUS);
                console.error('VALIDATE_STATUS', status_1);
                var vertexSource = gl.getShaderSource(vertexShader);
                var fragmentSource = gl.getShaderSource(fragmentShader);
                console.log(vertexSource);
                console.log('\n\n');
                console.log(fragmentSource);
                gl.deleteProgram(program);
                throw new debugError_DebugError("Error in program linking. Last error \"" + lastError + "\", status: " + status_1);
            }
            else {}
        }
        else {
            throw new Error( true ? 'unknown linking error' : undefined);
        }
    }
    return program;
};
var GL_TABLE;
var GL_TYPE;
(function (GL_TYPE) {
    GL_TYPE["FLOAT"] = "float";
    GL_TYPE["FLOAT_VEC2"] = "vec2";
    GL_TYPE["FLOAT_VEC3"] = "vec3";
    GL_TYPE["FLOAT_VEC4"] = "vec4";
    GL_TYPE["INT"] = "int";
    GL_TYPE["INT_VEC2"] = "ivec2";
    GL_TYPE["INT_VEC3"] = "ivec3";
    GL_TYPE["INT_VEC4"] = "ivec4";
    GL_TYPE["BOOL"] = "bool";
    GL_TYPE["BOOL_VEC2"] = "bvec2";
    GL_TYPE["BOOL_VEC3"] = "bvec3";
    GL_TYPE["BOOL_VEC4"] = "bvec4";
    GL_TYPE["FLOAT_MAT2"] = "mat2";
    GL_TYPE["FLOAT_MAT3"] = "mat3";
    GL_TYPE["FLOAT_MAT4"] = "mat4";
    GL_TYPE["SAMPLER_2D"] = "sampler2D";
    GL_TYPE["SAMPLER_CUBE"] = "samplerCube";
})(GL_TYPE || (GL_TYPE = {}));
var mapType = function (gl, type) {
    if (GL_TABLE === undefined) {
        var typeNames = Object.keys(GL_TYPE);
        GL_TABLE = {};
        for (var i = 0; i < typeNames.length; ++i) {
            var tn = typeNames[i];
            GL_TABLE[gl[tn]] = GL_TYPE[tn];
        }
    }
    return GL_TABLE[type];
};
var normalizeUniformName = function (s) {
    if ( true && s.indexOf(' ') > -1)
        throw new debugError_DebugError("bad uniform name: \"" + s + "\", check spaces!");
    else
        return s;
};
var extractUniformsFromShaderBin = function (gl, program) {
    var glProgram = program.getProgram();
    var activeUniforms = gl.getProgramParameter(glProgram, gl.ACTIVE_UNIFORMS);
    var uniforms = {};
    for (var i = 0; i < activeUniforms; i++) {
        var uniformData = gl.getActiveUniform(glProgram, i);
        if ( true && !uniformData)
            throw new debugError_DebugError("can not receive active uniforms info: gl.getActiveUniform()");
        var type = mapType(gl, uniformData.type);
        var name_1 = normalizeUniformName(uniformData.name);
        var location_1 = gl.getUniformLocation(glProgram, name_1);
        if ( true && location_1 === null) {
            console.log(program);
            throw new debugError_DebugError("error finding uniform location: " + uniformData.name);
        }
        uniforms[name_1] = {
            type: type,
            size: uniformData.size,
            location: location_1,
            setter: getUniformSetter(uniformData.size, type)
        };
        if (name_1.indexOf('[') > -1) {
            var arrayName = name_1.split(/\[/)[0];
            uniforms[arrayName] = uniforms[name_1];
        }
    }
    return uniforms;
};
var extractUniformsAndAttributesFromShaderSource = function (vertexSource, fragmentSource) {
    var uniforms = [];
    var attributes = [];
    var allTokens = (vertexSource + " " + fragmentSource).split(/[\s;]/).filter(function (it) { return !!it; });
    allTokens.forEach(function (it, i) {
        var possibleUniformName = allTokens[i + 2];
        if (it === 'uniform' && possibleUniformName !== undefined && uniforms.indexOf(possibleUniformName) === -1) {
            uniforms.push(possibleUniformName);
        }
        else {
            var possibleAttributeName = allTokens[i + 2];
            if (it === 'attribute' && possibleAttributeName !== undefined && attributes.indexOf(possibleAttributeName) === -1) {
                attributes.push(possibleAttributeName);
            }
        }
    });
    return { uniforms: uniforms, attributes: attributes };
};
var extractAttributes = function (gl, program) {
    var glProgram = program.getProgram();
    var activeAttributes = gl.getProgramParameter(glProgram, gl.ACTIVE_ATTRIBUTES);
    var attrMap = {};
    for (var i = 0; i < activeAttributes; i++) {
        var attrData = gl.getActiveAttrib(glProgram, i);
        if ( true && !attrData)
            throw new debugError_DebugError("can not receive active attribute info: gl.getActiveAttrib()");
        var location_2 = gl.getAttribLocation(glProgram, attrData.name);
        if ( true && location_2 < 0) {
            console.log(program);
            throw new debugError_DebugError("error finding attribute location: " + attrData.name);
        }
        attrMap[attrData.name] = location_2;
    }
    return attrMap;
};
var isNumber = function (val) {
    if (false)
        {}
    if (isNaN(parseFloat(String(val))) || !isFinite(Number(val)))
        throw new debugError_DebugError("can not set uniform with value " + val + ": expected argument of type number");
    else
        return true;
};
var isInteger = function (val) {
    if (false)
        {}
    isNumber(val);
    if (val !== ~~val)
        throw new debugError_DebugError("can not set uniform with value " + val + ": expected argument of integer type, but " + val + " found");
    else
        return true;
};
var isBoolean = function (val) {
    if (false)
        {}
    if (!(val === true || val === false))
        throw new debugError_DebugError("can not set uniform with value " + val + ": expected argument of boolean type, but " + val + " found");
    else
        return true;
};
var isArrayOfType = function (val, checker, size) {
    if (false)
        {}
    if (!val)
        throw new debugError_DebugError("can not set uniform  value: " + val);
    if (Object(object["b" /* isCommonArray */])(val)) {
        console.error(val);
        throw new debugError_DebugError("can not use primitive array as uniform value. Use Float32Array of Int32Array instead");
    }
    if (!Object(object["d" /* isTypedArray */])(val)) {
        console.error('Can not set uniform value', val);
        throw new debugError_DebugError("can not set uniform with value [" + val + "]: expected argument of type Array");
    }
    if (size !== undefined && val.length !== size)
        throw new debugError_DebugError("can not set uniform with value [" + val + "]: expected array with size " + size + ", but " + val.length + " found");
    for (var i = 0; i < val.length; i++) {
        try {
            checker(val[i]);
        }
        catch (e) {
            console.error('Can not set uniform array item', val);
            throw new debugError_DebugError("can not set uniform array item with value [" + val + "]: unexpected array element type: " + val[i]);
        }
    }
    return true;
};
var getUniformSetter = function (size, type) {
    if (size === 1) {
        switch (type) {
            case GL_TYPE.FLOAT: return function (gl, location, value) {
                if (isNumber(value))
                    gl.uniform1f(location, value);
            };
            case GL_TYPE.FLOAT_VEC2: return function (gl, location, value) {
                if (isArrayOfType(value, isNumber, 2))
                    gl.uniform2f(location, value[0], value[1]);
            };
            case GL_TYPE.FLOAT_VEC3: return function (gl, location, value) {
                if (isArrayOfType(value, isNumber, 3))
                    gl.uniform3f(location, value[0], value[1], value[2]);
            };
            case GL_TYPE.FLOAT_VEC4: return function (gl, location, value) {
                if (isArrayOfType(value, isNumber, 4))
                    gl.uniform4f(location, value[0], value[1], value[2], value[3]);
            };
            case GL_TYPE.INT: return function (gl, location, value) {
                if (isInteger(value))
                    gl.uniform1i(location, value);
            };
            case GL_TYPE.INT_VEC2: return function (gl, location, value) {
                if (isArrayOfType(value, isInteger, 2))
                    gl.uniform2i(location, value[0], value[1]);
            };
            case GL_TYPE.INT_VEC3: return function (gl, location, value) {
                if (isArrayOfType(value, isInteger, 3))
                    gl.uniform3i(location, value[0], value[1], value[2]);
            };
            case GL_TYPE.INT_VEC4: return function (gl, location, value) {
                if (isArrayOfType(value, isInteger, 4))
                    gl.uniform4i(location, value[0], value[1], value[2], value[3]);
            };
            case GL_TYPE.BOOL: return function (gl, location, value) {
                if (isBoolean(value))
                    gl.uniform1i(location, value ? 1 : 0);
            };
            case GL_TYPE.BOOL_VEC2: return function (gl, location, value) {
                if (isArrayOfType(value, isBoolean, 2))
                    gl.uniform2i(location, value[0], value[1]);
            };
            case GL_TYPE.BOOL_VEC3: return function (gl, location, value) {
                if (isArrayOfType(value, isBoolean, 3))
                    gl.uniform3i(location, value[0], value[1], value[2]);
            };
            case GL_TYPE.BOOL_VEC4: return function (gl, location, value) {
                if (isArrayOfType(value, isBoolean, 4))
                    gl.uniform4i(location, value[0], value[1], value[2], value[3]);
            };
            case GL_TYPE.FLOAT_MAT2: return function (gl, location, value) {
                if (isArrayOfType(value, isNumber, 2 * 2))
                    gl.uniformMatrix2fv(location, false, value);
            };
            case GL_TYPE.FLOAT_MAT3: return function (gl, location, value) {
                if (isArrayOfType(value, isNumber, 3 * 3))
                    gl.uniformMatrix3fv(location, false, value);
            };
            case GL_TYPE.FLOAT_MAT4: return function (gl, location, value) {
                if (isArrayOfType(value, isNumber, 4 * 4))
                    gl.uniformMatrix4fv(location, false, value);
            };
            case GL_TYPE.SAMPLER_2D: return function (gl, location, value) {
                if (isNumber(value))
                    gl.uniform1i(location, value);
            };
            case GL_TYPE.SAMPLER_CUBE: return function (gl, location, value) {
                if (isNumber(value))
                    gl.uniform1i(location, value);
            };
            default:
                if (true)
                    throw new debugError_DebugError("can not set uniform for type " + type + " and size " + size);
                break;
        }
    }
    else {
        switch (type) {
            case GL_TYPE.FLOAT: return function (gl, location, value) {
                if (isArrayOfType(value, isNumber, size))
                    gl.uniform1fv(location, value);
            };
            case GL_TYPE.FLOAT_VEC2: return function (gl, location, value) {
                if (isArrayOfType(value, isNumber, size * 2))
                    gl.uniform2fv(location, value);
            };
            case GL_TYPE.FLOAT_VEC3: return function (gl, location, value) {
                if (isArrayOfType(value, isNumber, size * 3))
                    gl.uniform3fv(location, value);
            };
            case GL_TYPE.FLOAT_VEC4: return function (gl, location, value) {
                if (isArrayOfType(value, isNumber, size * 4))
                    gl.uniform4fv(location, value);
            };
            case GL_TYPE.INT: return function (gl, location, value) {
                if (isArrayOfType(value, isInteger, size))
                    gl.uniform1iv(location, value);
            };
            case GL_TYPE.INT_VEC2: return function (gl, location, value) {
                if (isArrayOfType(value, isInteger, size * 2))
                    gl.uniform2iv(location, value);
            };
            case GL_TYPE.INT_VEC3: return function (gl, location, value) {
                if (isArrayOfType(value, isInteger, size * 3))
                    gl.uniform3iv(location, value);
            };
            case GL_TYPE.INT_VEC4: return function (gl, location, value) {
                if (isArrayOfType(value, isInteger, size * 4))
                    gl.uniform4iv(location, value);
            };
            case GL_TYPE.BOOL: return function (gl, location, value) {
                if (isArrayOfType(value, isBoolean, size))
                    gl.uniform1iv(location, value);
            };
            case GL_TYPE.BOOL_VEC2: return function (gl, location, value) {
                if (isArrayOfType(value, isBoolean, size * 2))
                    gl.uniform2iv(location, value);
            };
            case GL_TYPE.BOOL_VEC3: return function (gl, location, value) {
                if (isArrayOfType(value, isBoolean, size * 3))
                    gl.uniform3iv(location, value);
            };
            case GL_TYPE.BOOL_VEC4: return function (gl, location, value) {
                if (isArrayOfType(value, isBoolean, size * 4))
                    gl.uniform4iv(location, value);
            };
            case GL_TYPE.SAMPLER_2D: return function (gl, location, value) {
                if (isArrayOfType(value, isInteger, size))
                    gl.uniform1iv(location, value);
            };
            case GL_TYPE.SAMPLER_CUBE: return function (gl, location, value) {
                if (isArrayOfType(value, isInteger, size))
                    gl.uniform1iv(location, value);
            };
            default:
                if (true)
                    throw new debugError_DebugError("can not set uniform for type " + type + " and size " + size);
                break;
        }
    }
    throw new Error();
};

// CONCATENATED MODULE: ./engine/renderer/webGl/base/shaderProgram.ts


var shaderProgram_ShaderProgram = (function () {
    function ShaderProgram(gl, vertexSource, fragmentSource) {
        this.attributeSourceNames = [];
        var vShader = compileShader(gl, vertexSource, gl.VERTEX_SHADER);
        var fShader = compileShader(gl, fragmentSource, gl.FRAGMENT_SHADER);
        this.program = createProgram(gl, vShader, fShader);
        gl.deleteShader(vShader);
        gl.deleteShader(fShader);
        this.uniforms = extractUniformsFromShaderBin(gl, this);
        this.attributes = extractAttributes(gl, this);
        var sourceExtracted = extractUniformsAndAttributesFromShaderSource(vertexSource, fragmentSource);
        this.attributeSourceNames = sourceExtracted.attributes;
        this.uniformSourceNames = sourceExtracted.uniforms;
        this.gl = gl;
    }
    ShaderProgram.prototype.getProgram = function () {
        return this.program;
    };
    ShaderProgram.prototype.bind = function () {
        if (ShaderProgram.currentProgram === this)
            return;
        this.gl.useProgram(this.program);
        ShaderProgram.currentProgram = this;
    };
    ShaderProgram.prototype.unbind = function () {
        this.gl.useProgram(null);
        ShaderProgram.currentProgram = undefined;
    };
    ShaderProgram.prototype.setUniform = function (name, value) {
        if ( true && !name) {
            throw new debugError_DebugError("no uniform name was provided!");
        }
        var uniformWrapper = this.uniforms[name];
        if ( true && !uniformWrapper) {
            if (this.uniformSourceNames.indexOf(name) > -1) {
                return;
            }
            console.error('shader program failed', this);
            console.error('uniforms', this.uniforms);
            throw new debugError_DebugError("no uniform with name " + name + " found!");
        }
        if (true) {
            if (ShaderProgram.currentProgram !== this) {
                console.error(this);
                throw new debugError_DebugError("can not set uniform: target program is inactive");
            }
        }
        uniformWrapper.setter(this.gl, uniformWrapper.location, value);
    };
    ShaderProgram.prototype.bindBuffer = function (buffer, attrName) {
        if (true) {
            if (!attrName)
                throw new debugError_DebugError("can not find attribute location: attrName not defined");
            if (this.attributes[attrName] === undefined) {
                if (this.attributeSourceNames.indexOf(attrName) > -1) {
                    return;
                }
                console.log(this);
                throw new debugError_DebugError("can not find attribute location for  " + attrName);
            }
        }
        this.gl.bindBuffer(this.gl.ARRAY_BUFFER, buffer.getGlBuffer());
        this.enableAttribute(attrName);
        var attrLocation = this.attributes[attrName];
        this.gl.vertexAttribPointer(attrLocation, buffer.getItemSize(), buffer.getItemType(), false, 0, 0);
    };
    ShaderProgram.prototype.disableAttribute = function (attrName) {
        this.toggleAttribute(attrName, false);
    };
    ShaderProgram.prototype.enableAttribute = function (attrName) {
        this.toggleAttribute(attrName, true);
    };
    ShaderProgram.prototype.destroy = function () {
        this.gl.deleteProgram(this.program);
    };
    ShaderProgram.prototype.toggleAttribute = function (attrName, on) {
        if (this.attributes[attrName] === undefined) {
            console.log(this);
            throw new debugError_DebugError("unbind error: can not find attribute location for  " + attrName);
        }
        var attrLocation = this.attributes[attrName];
        if (on)
            this.gl.enableVertexAttribArray(attrLocation);
        else
            this.gl.disableVertexAttribArray(attrLocation);
    };
    return ShaderProgram;
}());


// CONCATENATED MODULE: ./engine/misc/collection/fastMap.ts
var FastMap = (function () {
    function FastMap() {
        this.keys = [];
        this.values = [];
    }
    FastMap.prototype.put = function (key, value) {
        var index = this.keys.indexOf(key);
        if (index === -1) {
            this.keys.push(key);
            this.values.push(value);
        }
        else {
            this.values[index] = value;
        }
    };
    FastMap.prototype.get = function (key) {
        var index = this.keys.indexOf(key);
        if (index === -1)
            return undefined;
        return this.values[index];
    };
    FastMap.prototype.has = function (key) {
        var index = this.keys.indexOf(key);
        return index > -1;
    };
    FastMap.prototype.remove = function (key) {
        var index = this.keys.indexOf(key);
        if (index === -1)
            return;
        this.keys.splice(index, 1);
        this.values.splice(index, 1);
    };
    FastMap.prototype.getKeys = function () {
        return this.keys;
    };
    FastMap.prototype.getValues = function () {
        return this.values;
    };
    FastMap.prototype.size = function () {
        return this.keys.length;
    };
    return FastMap;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/programs/abstract/abstractDrawer.ts



var abstractDrawer_AbstractDrawer = (function () {
    function AbstractDrawer(gl) {
        this.uniformCache = new FastMap();
        this.texturesToBind = { length: 0, texturesInfo: [] };
        this.gl = gl;
    }
    AbstractDrawer.prototype.destroy = function () {
        if (this.bufferInfo)
            this.bufferInfo.destroy();
        if (this.program !== undefined)
            this.program.destroy();
    };
    AbstractDrawer.prototype.setUniform = function (name, value) {
        if ( true && !name) {
            console.trace();
            throw new debugError_DebugError("can not set uniform with value " + value + ": name is not provided");
        }
        if ( true && value === null || value === undefined) {
            console.trace();
            throw new debugError_DebugError("can not set uniform with name " + name + " and value " + value);
        }
        if (this.uniformCache.has(name) && Object(object["c" /* isEqual */])(this.uniformCache.get(name).value, value))
            return;
        if (Object(object["a" /* isArray */])(value)) {
            if (!this.uniformCache.has(name)) {
                this.uniformCache.put(name, { value: new Float32Array(value.length), dirty: true });
            }
            var uniformInCache = this.uniformCache.get(name);
            var arr = uniformInCache.value;
            arr.set(value);
            uniformInCache.dirty = true;
        }
        else {
            this.uniformCache.put(name, { value: value, dirty: true });
        }
    };
    AbstractDrawer.prototype.attachTexture = function (uniformName, texture) {
        this.texturesToBind.texturesInfo[this.texturesToBind.length] =
            this.texturesToBind.texturesInfo[this.texturesToBind.length] || { uniformName: undefined, texture: undefined };
        this.texturesToBind.texturesInfo[this.texturesToBind.length].uniformName = uniformName;
        this.texturesToBind.texturesInfo[this.texturesToBind.length].texture = texture;
        this.texturesToBind.length++;
    };
    AbstractDrawer.prototype.getAttachedTextureAt = function (i) {
        if ( true && i > this.texturesToBind.length - 1)
            throw new debugError_DebugError("can not find bound texture: out of range: index:" + i + ", length:" + this.texturesToBind.length);
        return this.texturesToBind.texturesInfo[i].texture;
    };
    AbstractDrawer.prototype.setUniformsFromMap = function (batch) {
        var keys = batch.getKeys();
        var values = batch.getValues();
        for (var i = 0; i < keys.length; i++) {
            this.setUniform(keys[i], values[i]);
        }
    };
    AbstractDrawer.prototype.draw = function () {
        this.bind();
        var keys = this.uniformCache.getKeys();
        var values = this.uniformCache.getValues();
        for (var i = 0; i < keys.length; i++) {
            if (!values[i].dirty)
                continue;
            this._setUniform(keys[i], values[i].value);
            values[i].dirty = false;
        }
        for (var i = 0, max = this.texturesToBind.length; i < max; i++) {
            var t = this.texturesToBind.texturesInfo[i];
            t.texture.bind(t.uniformName, i, this.program);
        }
        this.texturesToBind.length = 0;
        this.drawElements();
        this.unbind();
    };
    AbstractDrawer.prototype.bind = function () {
        var _a;
        if ( true && this.program === undefined) {
            console.error(this);
            throw new debugError_DebugError("can not init drawer: initProgram method must be invoked!");
        }
        if (AbstractDrawer.currentInstance === this)
            return;
        (_a = AbstractDrawer.currentInstance) === null || _a === void 0 ? void 0 : _a.unbind();
        AbstractDrawer.currentInstance = this;
        this.bufferInfo.bind(this.program);
    };
    AbstractDrawer.prototype.unbind = function () {
        this.bufferInfo.unbind(this.program);
        AbstractDrawer.currentInstance = undefined;
    };
    AbstractDrawer.prototype.drawElements = function () {
        this.bufferInfo.draw();
    };
    AbstractDrawer.prototype._setUniform = function (name, value) {
        this.program.setUniform(name, value);
    };
    return AbstractDrawer;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/base/vertexBuffer.ts

var vertexBuffer_VertexBuffer = (function () {
    function VertexBuffer(gl) {
        this.bufferItemSize = 0;
        this.bufferItemType = 0;
        this.dataLength = 0;
        if ( true && !gl)
            throw new debugError_DebugError("can not create VertexBuffer, gl context not passed to constructor, expected: VertexBuffer(gl)");
        this.gl = gl;
        this.buffer = gl.createBuffer();
        if ( true && !this.buffer)
            throw new debugError_DebugError("can not allocate memory for vertex buffer");
    }
    VertexBuffer.prototype.setData = function (bufferData, itemType, itemSize) {
        if (true) {
            if (!bufferData)
                throw new debugError_DebugError('can not set data to vertex buffer: bufferData is not specified');
            if (!itemType)
                throw new debugError_DebugError('can not set data to vertex buffer: itemType is not specified');
            if (!itemSize)
                throw new debugError_DebugError('can not set data to vertex buffer: itemSize is not specified');
        }
        var gl = this.gl;
        gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
        gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(bufferData), gl.STATIC_DRAW);
        gl.bindBuffer(gl.ARRAY_BUFFER, null);
        this.bufferItemSize = itemSize;
        this.bufferItemType = itemType;
        this.dataLength = bufferData.length;
    };
    VertexBuffer.prototype.setAttrName = function (attrName) {
        if ( true && !attrName)
            throw new debugError_DebugError("attrName not provided");
        this.attrName = attrName;
    };
    VertexBuffer.prototype.bind = function (program) {
        if ( true && !program)
            throw new debugError_DebugError("can not bind VertexBuffer, program is not specified");
        if ( true && !this.attrName)
            throw new debugError_DebugError("can not bind VertexBuffer, attribute name is not specified");
        program.bindBuffer(this, this.attrName);
    };
    VertexBuffer.prototype.unbind = function () {
        this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null);
    };
    VertexBuffer.prototype.destroy = function () {
        this.gl.deleteBuffer(this.buffer);
    };
    VertexBuffer.prototype.getGlBuffer = function () {
        return this.buffer;
    };
    VertexBuffer.prototype.getItemSize = function () {
        return this.bufferItemSize;
    };
    VertexBuffer.prototype.getItemType = function () {
        return this.bufferItemType;
    };
    VertexBuffer.prototype.getBufferLength = function () {
        return this.dataLength;
    };
    return VertexBuffer;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/base/indexBuffer.ts

var indexBuffer_IndexBuffer = (function () {
    function IndexBuffer(gl) {
        if ( true && !gl)
            throw new debugError_DebugError("can not create IndexBuffer, gl context not passed to constructor, expected: IndexBuffer(gl)");
        this.gl = gl;
        this.buffer = gl.createBuffer();
        if ( true && !this.buffer)
            throw new debugError_DebugError("can not allocate memory for index buffer");
    }
    IndexBuffer.prototype.setData = function (bufferData) {
        if (true) {
            if (!bufferData)
                throw new debugError_DebugError('can not set data to buffer: bufferData not specified');
        }
        var gl = this.gl;
        this.dataLength = bufferData.length;
        gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.buffer);
        gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(bufferData), gl.STATIC_DRAW);
        gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
    };
    IndexBuffer.prototype.getGlBuffer = function () {
        return this.buffer;
    };
    IndexBuffer.prototype.bind = function () {
        this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.buffer);
    };
    IndexBuffer.prototype.unbind = function () {
        this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, null);
    };
    IndexBuffer.prototype.destroy = function () {
        this.gl.deleteBuffer(this.buffer);
    };
    IndexBuffer.prototype.getBufferLength = function () {
        return this.dataLength;
    };
    return IndexBuffer;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/debug/debugUtil.ts
var debugUtil;
(function (debugUtil) {
    var map;
    debugUtil.glEnumToString = function (gl, glEnum) {
        if (!map && true) {
            map = {};
            var keymap = gl;
            for (var k in keymap) {
                if (isFinite(keymap[k]))
                    map[keymap[k]] = k;
            }
        }
        return map[glEnum];
    };
})(debugUtil || (debugUtil = {}));

// CONCATENATED MODULE: ./engine/renderer/webGl/base/bufferInfo.ts




var glEnumToString = debugUtil.glEnumToString;
var drawMethodToGlEnum = function (gl, m) {
    switch (m) {
        case 0:
            return gl.LINE_STRIP;
        case 1:
            return gl.TRIANGLE_FAN;
        case 2:
            return gl.TRIANGLE_STRIP;
        case 3:
            return gl.TRIANGLES;
        case 4:
            return gl.LINES;
        case 5:
            return gl.LINE_LOOP;
    }
    if (true) {
        throw new debugError_DebugError("unknown drawMethod enum value: " + m);
    }
};
var bufferInfo_BufferInfo = (function () {
    function BufferInfo(gl, description) {
        this.numOfElementsToDraw = 0;
        this.gl = gl;
        if ( true && description.drawMethod === undefined)
            throw new debugError_DebugError("can not create BufferInfo: drawMethod not defined");
        this.drawMethod = drawMethodToGlEnum(gl, description.drawMethod);
        if ( true && !description.posVertexInfo)
            throw new debugError_DebugError("can not create BufferInfo: posVertexInfo is mandatory");
        this.posVertexBuffer = new vertexBuffer_VertexBuffer(gl);
        this.posVertexBuffer.setData(description.posVertexInfo.array, description.posVertexInfo.type, description.posVertexInfo.size);
        this.posVertexBuffer.setAttrName(description.posVertexInfo.attrName);
        if (description.posIndexInfo) {
            this.posIndexBuffer = new indexBuffer_IndexBuffer(gl);
            this.posIndexBuffer.setData(description.posIndexInfo.array);
        }
        else
            this.numOfElementsToDraw = this._getNumOfElementsToDraw(this.drawMethod);
        if (description.texVertexInfo) {
            this.texVertexBuffer = new vertexBuffer_VertexBuffer(gl);
            this.texVertexBuffer.setData(description.texVertexInfo.array, description.texVertexInfo.type, description.texVertexInfo.size);
            this.texVertexBuffer.setAttrName(description.texVertexInfo.attrName);
        }
        if (description.normalInfo) {
            this.normalBuffer = new vertexBuffer_VertexBuffer(gl);
            this.normalBuffer.setData(description.normalInfo.array, description.normalInfo.type, description.normalInfo.size);
            this.normalBuffer.setAttrName(description.normalInfo.attrName);
        }
    }
    BufferInfo.prototype.bind = function (program) {
        program.bind();
        if (this.posIndexBuffer !== undefined)
            this.posIndexBuffer.bind();
        if (this.posVertexBuffer !== undefined)
            this.posVertexBuffer.bind(program);
        if (this.texVertexBuffer !== undefined)
            this.texVertexBuffer.bind(program);
        if (this.normalBuffer !== undefined)
            this.normalBuffer.bind(program);
    };
    BufferInfo.prototype.unbind = function (program) {
        program.unbind();
        if (this.posIndexBuffer !== undefined)
            this.posIndexBuffer.unbind();
        if (this.posVertexBuffer !== undefined)
            this.posVertexBuffer.unbind();
        if (this.texVertexBuffer !== undefined)
            this.texVertexBuffer.unbind();
        if (this.normalBuffer !== undefined)
            this.normalBuffer.unbind();
    };
    BufferInfo.prototype.destroy = function () {
        if (this.posVertexBuffer !== undefined)
            this.posVertexBuffer.destroy();
        if (this.posIndexBuffer !== undefined)
            this.posIndexBuffer.destroy();
        if (this.texVertexBuffer !== undefined)
            this.texVertexBuffer.destroy();
        if (this.normalBuffer !== undefined)
            this.normalBuffer.destroy();
    };
    BufferInfo.prototype.draw = function () {
        if (this.posIndexBuffer !== undefined) {
            this.gl.drawElements(this.drawMethod, this.posIndexBuffer.getBufferLength(), this.gl.UNSIGNED_SHORT, 0);
        }
        else {
            this.gl.drawArrays(this.drawMethod, 0, this.numOfElementsToDraw);
        }
    };
    BufferInfo.prototype._getNumOfElementsToDraw = function (drawMethod) {
        switch (drawMethod) {
            case this.gl.LINE_STRIP:
            case this.gl.TRIANGLE_FAN:
                return this.posVertexBuffer.getBufferLength() / 2;
            case this.gl.TRIANGLE_STRIP:
                return this.posVertexBuffer.getBufferLength() / 3;
            case this.gl.TRIANGLES:
                return this.posVertexBuffer.getBufferLength() / this.posVertexBuffer.getItemSize();
            default:
                throw new debugError_DebugError("unknown draw method: " + drawMethod + " (" + glEnumToString(this.gl, drawMethod) + ")");
        }
    };
    return BufferInfo;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/primitives/abstractPrimitive.ts
var AbstractPrimitive = (function () {
    function AbstractPrimitive() {
    }
    return AbstractPrimitive;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/primitives/plane.ts


var plane_Plane = (function (_super) {
    __extends(Plane, _super);
    function Plane() {
        var _this = _super.call(this) || this;
        _this.vertexArr = [
            0, 0,
            0, 1,
            1, 0,
            1, 1
        ];
        _this.indexArr = [0, 1, 2, 3];
        _this.texCoordArr = [
            0, 0,
            0, 1,
            1, 0,
            1, 1
        ];
        return _this;
    }
    return Plane;
}(AbstractPrimitive));


// CONCATENATED MODULE: ./engine/renderer/webGl/shaders/generators/shaderGenerator.ts

var shaderGenerator_ShaderGenerator = (function () {
    function ShaderGenerator() {
        this.vertexUniforms = [];
        this.fragmentUniforms = [];
        this.attributes = [];
        this.varyings = [];
        this.appendedFragCodeBlocks = [];
        this.appendedVertexCodeBlocks = [];
        this.prependedVertexCodeBlocks = [];
        this.prependedFragCodeBlocks = [];
        this.vertexMainFn = '';
        this.fragmentMainFn = '';
    }
    ShaderGenerator.prototype.addVertexUniform = function (type, name) {
        this.vertexUniforms.push({ type: type, name: name });
        return normalizeUniformName(name);
    };
    ShaderGenerator.prototype.addScalarFragmentUniform = function (type, name, extractArrayName) {
        if (extractArrayName === void 0) { extractArrayName = false; }
        return this._addFragmentUniform(type, name, extractArrayName);
    };
    ShaderGenerator.prototype.addStructFragmentUniform = function (strucName, uniformName, extractArrayName) {
        if (extractArrayName === void 0) { extractArrayName = false; }
        return this._addFragmentUniform(strucName, uniformName, extractArrayName);
    };
    ShaderGenerator.prototype.addAttribute = function (type, name) {
        this.attributes.push({ type: type, name: name });
        return normalizeUniformName(name);
    };
    ShaderGenerator.prototype.addVarying = function (type, name) {
        this.varyings.push({ type: type, name: name });
    };
    ShaderGenerator.prototype.appendVertexCodeBlock = function (code) {
        this.appendedVertexCodeBlocks.push(code);
    };
    ShaderGenerator.prototype.appendFragmentCodeBlock = function (code) {
        this.appendedFragCodeBlocks.push(code);
    };
    ShaderGenerator.prototype.prependVertexCodeBlock = function (code) {
        this.prependedVertexCodeBlocks.push(code);
    };
    ShaderGenerator.prototype.prependFragmentCodeBlock = function (code) {
        this.prependedFragCodeBlocks.push(code);
    };
    ShaderGenerator.prototype.setVertexMainFn = function (fnCode) {
        this.vertexMainFn = fnCode;
    };
    ShaderGenerator.prototype.setFragmentMainFn = function (fnCode) {
        this.fragmentMainFn = fnCode;
    };
    ShaderGenerator.prototype.getVertexSource = function () {
        return ("\nprecision mediump float;\n\n" + this.prependedVertexCodeBlocks.map(function (v) { return "" + v; }).join('\n') + "\n\n" + this.vertexUniforms.map(function (u) { return "uniform   " + u.type + " " + u.name + ";"; }).join('\n') + "\n" + this.attributes.map(function (u) { return "attribute " + u.type + " " + u.name + ";"; }).join('\n') + "\n" + this.varyings.map(function (u) { return "varying   " + u.type + " " + u.name + ";"; }).join('\n') + "\n" + this.appendedVertexCodeBlocks.map(function (v) { return "" + v; }).join('\n') + "\n\n" + this.vertexMainFn);
    };
    ShaderGenerator.prototype.getFragmentSource = function () {
        return ("\nprecision mediump float;\n\n" + this.prependedFragCodeBlocks.map(function (v) { return "" + v; }).join('\n') + "\n\n" + this.fragmentUniforms.map(function (u) { return "uniform " + u.type + " " + u.name + ";"; }).join('\n') + "\n" + this.varyings.map(function (u) { return "varying " + u.type + " " + u.name + ";"; }).join('\n') + "\n" + this.appendedFragCodeBlocks.map(function (v) { return "" + v; }).join('\n') + "\n\n" + this.fragmentMainFn + "\n");
    };
    ShaderGenerator.prototype.debug = function () {
        if (false)
            {}
        console.log('// *** vertex shader source ***');
        console.log(this.getVertexSource());
        console.log('// *** fragment shader source ***');
        console.log(this.getFragmentSource());
    };
    ShaderGenerator.prototype._addFragmentUniform = function (type, name, extractArrayName) {
        if (extractArrayName === void 0) { extractArrayName = false; }
        this.fragmentUniforms.push({ type: type, name: name });
        name = normalizeUniformName(name);
        if (extractArrayName)
            name = name.split('[')[0];
        return name;
    };
    return ShaderGenerator;
}());


// EXTERNAL MODULE: ./engine/renderer/webGl/programs/impl/base/shape/shape.fragment.glsl
var shape_fragment = __webpack_require__(1);

// CONCATENATED MODULE: ./engine/renderer/webGl/programs/impl/base/shape/shapeDrawer.ts









var shapeDrawer_ShapeDrawer = (function (_super) {
    __extends(ShapeDrawer, _super);
    function ShapeDrawer(gl) {
        var _this = _super.call(this, gl) || this;
        var gen = new shaderGenerator_ShaderGenerator();
        gen.setVertexMainFn("void main(){\nv_position = a_position;\ngl_Position = u_vertexMatrix * a_position;\n}");
        _this.u_vertexMatrix = gen.addVertexUniform(GL_TYPE.FLOAT_MAT4, 'u_vertexMatrix');
        _this.a_position = gen.addAttribute(GL_TYPE.FLOAT_VEC4, 'a_position');
        gen.addVarying(GL_TYPE.FLOAT_VEC4, 'v_position');
        _this.u_lineWidth = gen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'u_lineWidth');
        _this.u_rx = gen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'u_rx');
        _this.u_ry = gen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'u_ry');
        _this.u_width = gen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'u_width');
        _this.u_height = gen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'u_height');
        _this.u_rectOffsetTop = gen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'u_rectOffsetTop');
        _this.u_rectOffsetLeft = gen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'u_rectOffsetLeft');
        _this.u_borderRadius = gen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'u_borderRadius');
        _this.u_color = gen.addScalarFragmentUniform(GL_TYPE.FLOAT_VEC4, 'u_color');
        _this.u_alpha = gen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'u_alpha');
        _this.u_fillColor = gen.addScalarFragmentUniform(GL_TYPE.FLOAT_VEC4, 'u_fillColor');
        _this.u_fillLinearGradient = gen.addScalarFragmentUniform(GL_TYPE.FLOAT_VEC4, 'u_fillLinearGradient[3]', true);
        _this.u_texRect = gen.addScalarFragmentUniform(GL_TYPE.FLOAT_VEC4, 'u_texRect');
        _this.u_texOffset = gen.addScalarFragmentUniform(GL_TYPE.FLOAT_VEC2, 'u_texOffset');
        gen.addScalarFragmentUniform(GL_TYPE.SAMPLER_2D, 'texture');
        _this.u_shapeType = gen.addScalarFragmentUniform(GL_TYPE.INT, 'u_shapeType');
        _this.u_fillType = gen.addScalarFragmentUniform(GL_TYPE.INT, 'u_fillType');
        _this.u_arcAngleFrom = gen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'u_arcAngleFrom');
        _this.u_arcAngleTo = gen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'u_arcAngleTo');
        _this.u_repeatFactor = gen.addScalarFragmentUniform(GL_TYPE.FLOAT_VEC2, 'u_repeatFactor');
        _this.u_stretchMode = gen.addScalarFragmentUniform(GL_TYPE.INT, 'u_stretchMode');
        _this.u_anticlockwise = gen.addScalarFragmentUniform(GL_TYPE.BOOL, 'u_anticlockwise');
        gen.setFragmentMainFn(Object(object["f" /* parametrizeString */])(shape_fragment, {
            __STRETCH_MODE_STRETCH__: 0,
            __STRETCH_MODE_REPEAT__: 1,
            __FILL_TYPE_COLOR__: 0,
            __FILL_TYPE_TEXTURE__: 1,
            __FILL_TYPE_LINEAR_GRADIENT__: 2,
            __SHAPE_TYPE_ELLIPSE__: 0,
            __SHAPE_TYPE_RECT__: 1,
            __PI__: Math.PI,
        }));
        _this.program = new shaderProgram_ShaderProgram(gl, gen.getVertexSource(), gen.getFragmentSource());
        _this.primitive = new plane_Plane();
        _this.bufferInfo = new bufferInfo_BufferInfo(gl, {
            posVertexInfo: { array: _this.primitive.vertexArr, type: gl.FLOAT, size: 2, attrName: _this.a_position },
            posIndexInfo: { array: _this.primitive.indexArr },
            drawMethod: 2,
        });
        return _this;
    }
    return ShapeDrawer;
}(abstractDrawer_AbstractDrawer));


// CONCATENATED MODULE: ./engine/renderer/webGl/base/matrixStack.ts

var matrixStack_Mat16Holder = mat4_mat4.Mat16Holder;

var matrixStack_MatrixStack = (function () {
    function MatrixStack() {
        this.stack = new stack_Stack();
        this.restore();
    }
    MatrixStack.prototype.restore = function () {
        if (this.stack.isEmpty())
            this.setIdentity();
        else {
            var last = this.stack.pop();
            last.release();
        }
    };
    MatrixStack.prototype.save = function () {
        var copy = matrixStack_Mat16Holder.fromPool();
        copy.fromMat16(this.getCurrentValue().mat16);
        this.stack.push(copy);
    };
    MatrixStack.prototype.getCurrentValue = function () {
        return this.stack.getLast();
    };
    MatrixStack.prototype.setCurrentValue = function (m) {
        return this.stack.replaceLast(m);
    };
    MatrixStack.prototype.translate = function (x, y, z) {
        if (z === void 0) { z = 0; }
        var t = matrixStack_Mat16Holder.fromPool();
        mat4_mat4.makeTranslation(t, x, y, z);
        var m = this.getCurrentValue();
        var result = matrixStack_Mat16Holder.fromPool();
        mat4_mat4.matrixMultiply(result, t, m);
        this.setCurrentValue(result);
        t.release();
        m.release();
        return this;
    };
    MatrixStack.prototype.setMatrixValues = function (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) {
        this.getCurrentValue().set(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15);
        return this;
    };
    MatrixStack.prototype.skewX = function (angle) {
        var t = matrixStack_Mat16Holder.fromPool();
        mat4_mat4.makeXSkew(t, angle);
        var m = this.getCurrentValue();
        var result = matrixStack_Mat16Holder.fromPool();
        mat4_mat4.matrixMultiply(result, t, m);
        this.setCurrentValue(result);
        t.release();
        m.release();
        return this;
    };
    MatrixStack.prototype.skewY = function (angle) {
        var t = matrixStack_Mat16Holder.fromPool();
        mat4_mat4.makeYSkew(t, angle);
        var m = this.getCurrentValue();
        var result = matrixStack_Mat16Holder.fromPool();
        mat4_mat4.matrixMultiply(result, t, m);
        this.setCurrentValue(result);
        t.release();
        m.release();
        return this;
    };
    MatrixStack.prototype.rotateX = function (angleInRadians) {
        var t = matrixStack_Mat16Holder.fromPool();
        mat4_mat4.makeXRotation(t, angleInRadians);
        this._rotate(t);
        t.release();
        return this;
    };
    MatrixStack.prototype.rotateY = function (angleInRadians) {
        var t = matrixStack_Mat16Holder.fromPool();
        mat4_mat4.makeYRotation(t, angleInRadians);
        this._rotate(t);
        t.release();
        return this;
    };
    MatrixStack.prototype.rotateZ = function (angleInRadians) {
        var t = matrixStack_Mat16Holder.fromPool();
        mat4_mat4.makeZRotation(t, angleInRadians);
        this._rotate(t);
        t.release();
        return this;
    };
    MatrixStack.prototype.scale = function (x, y, z) {
        if (z === void 0) { z = 1; }
        var t = matrixStack_Mat16Holder.fromPool();
        mat4_mat4.makeScale(t, x, y, z);
        var m = this.getCurrentValue();
        var result = matrixStack_Mat16Holder.fromPool();
        mat4_mat4.matrixMultiply(result, t, m);
        this.setCurrentValue(result);
        t.release();
        m.release();
        return this;
    };
    MatrixStack.prototype.resetTransform = function () {
        this.getCurrentValue().release();
        var identity = matrixStack_Mat16Holder.fromPool();
        mat4_mat4.makeIdentity(identity);
        this.setCurrentValue(identity);
        return this;
    };
    MatrixStack.prototype.rotationReset = function () {
        var m = this.getCurrentValue();
        mat4_mat4.makeRotationReset(m);
    };
    MatrixStack.prototype.release = function () {
        for (var i = 0, max = this.stack.size(); i < max; i++) {
            this.stack.getAt(i).release();
        }
        return this;
    };
    MatrixStack.prototype.setIdentity = function () {
        var ident = matrixStack_Mat16Holder.fromPool();
        mat4_mat4.makeIdentity(ident);
        this.stack.push(ident);
    };
    MatrixStack.prototype._rotate = function (rotMat) {
        var m = this.getCurrentValue();
        var result = matrixStack_Mat16Holder.fromPool();
        mat4_mat4.matrixMultiply(result, rotMat, m);
        this.setCurrentValue(result);
        m.release();
    };
    return MatrixStack;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/base/abstract/abstractTexture.ts


var isPowerOf2 = function (value) {
    return (value & (value - 1)) === 0;
};
var abstractTexture_AbstractTexture = (function () {
    function AbstractTexture(gl) {
        this.gl = gl;
        this.size = new size_Size(0, 0);
        this.destroyed = false;
        if (true) {
            if (!gl)
                throw new debugError_DebugError("can not create Texture, gl context not passed to constructor, expected: Texture(gl)");
            if (!AbstractTexture.MAX_TEXTURE_IMAGE_UNITS) {
                AbstractTexture.MAX_TEXTURE_IMAGE_UNITS = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS);
                if ( true && !AbstractTexture.MAX_TEXTURE_IMAGE_UNITS)
                    throw new debugError_DebugError("Can not obtain MAX_TEXTURE_IMAGE_UNITS value");
            }
        }
        this.tex = gl.createTexture();
        if ( true && !this.tex)
            throw new debugError_DebugError("can not allocate memory for texture");
    }
    AbstractTexture.destroyAll = function () {
        for (var i = 0; i < AbstractTexture.instances.length; i++) {
            AbstractTexture.instances[i].destroy();
        }
        AbstractTexture.currentBindTextureAt = {};
    };
    AbstractTexture.prototype.bind = function (name, i, program) {
        if (true) {
            if (!name) {
                console.error(this);
                throw new debugError_DebugError("can not bind texture: uniform name was not provided");
            }
            if (i > AbstractTexture.MAX_TEXTURE_IMAGE_UNITS - 1) {
                console.error(this);
                throw new debugError_DebugError("can not bind texture with index " + i + ". Max supported value by device is " + AbstractTexture.MAX_TEXTURE_IMAGE_UNITS);
            }
            if (this.destroyed) {
                console.error(this);
                throw new debugError_DebugError("can not bind destroyed texture");
            }
        }
        program.setUniform(name, i);
        if (AbstractTexture.currentBindTextureAt[i] === this)
            return;
        var gl = this.gl;
        gl.activeTexture(gl.TEXTURE0 + i);
        gl.bindTexture(this.samplerType, this.tex);
        AbstractTexture.currentBindTextureAt[i] = this;
    };
    AbstractTexture.prototype.unbind = function (i) {
        if (i === void 0) { i = 0; }
        var gl = this.gl;
        gl.activeTexture(gl.TEXTURE0 + i);
        gl.bindTexture(gl.TEXTURE_2D, null);
        delete AbstractTexture.currentBindTextureAt[i];
    };
    AbstractTexture.prototype.destroy = function () {
        this.gl.deleteTexture(this.tex);
        AbstractTexture.instances.splice(AbstractTexture.instances.indexOf(this), 1);
        this.destroyed = true;
    };
    AbstractTexture.prototype.getGlTexture = function () {
        return this.tex;
    };
    AbstractTexture.prototype.setInterpolationMode = function (mode) {
        if (mode === this.interpolationMode)
            return;
        this.beforeOperation();
        var gl = this.gl;
        var glMode;
        switch (mode) {
            case 1:
                glMode = gl.LINEAR;
                break;
            case 0:
                glMode = gl.NEAREST;
                break;
            default:
                if (true)
                    throw new debugError_DebugError("unknown interpolation mode " + mode);
                break;
        }
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, glMode);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, glMode);
        this.interpolationMode = mode;
        this.afterOperation();
    };
    AbstractTexture.prototype.beforeOperation = function () {
        if (this._currentTextureAt0 !== undefined)
            return;
        this._currentTextureAt0 = AbstractTexture.currentBindTextureAt[0];
        this.gl.bindTexture(this.gl.TEXTURE_2D, this.tex);
    };
    AbstractTexture.prototype.afterOperation = function () {
        if (this._currentTextureAt0)
            this.gl.bindTexture(this.gl.TEXTURE_2D, this._currentTextureAt0.tex);
        else
            this.gl.bindTexture(this.gl.TEXTURE_2D, null);
        this._currentTextureAt0 = undefined;
    };
    AbstractTexture.prototype.setFilters = function () {
        var gl = this.gl;
        var isPowerOfTwo = isPowerOf2(this.size.width) && isPowerOf2(this.size.height);
        if (isPowerOfTwo) {
            gl.generateMipmap(gl.TEXTURE_2D);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
        }
        else {
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
        }
    };
    AbstractTexture.currentBindTextureAt = {};
    AbstractTexture.MAX_TEXTURE_IMAGE_UNITS = 0;
    AbstractTexture.instances = [];
    return AbstractTexture;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/base/texture.ts




var texture_Texture = (function (_super) {
    __extends(Texture, _super);
    function Texture(gl) {
        var _this = _super.call(this, gl) || this;
        _this.gl = gl;
        _this.samplerType = _this.gl.TEXTURE_2D;
        _this.setRawData(new Uint8Array([0, 255, 0, 255]), 1, 1);
        return _this;
    }
    Texture.prototype.setImage = function (img, size) {
        if (size === void 0) { size = new size_Size(0, 0); }
        var gl = this.gl;
        if (true) {
            if (!(img || size.width || size.height))
                throw new debugError_DebugError("texture.setImage: if image is undefined, width and height must be specified: tex.setImage(null,w,h)");
            var maxSupportedSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
            if ( true && !maxSupportedSize)
                throw new debugError_DebugError("Can not obtain MAX_TEXTURE_SIZE value");
            if (size.width > maxSupportedSize || size.height > maxSupportedSize) {
                throw new debugError_DebugError("can not create texture with size " + size.width + "x" + size.height + ", max supported size is " + maxSupportedSize);
            }
        }
        if (img !== undefined)
            this.size.setWH(img.width, img.height);
        else
            this.size.set(size);
        this.beforeOperation();
        gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
        if (img) {
            gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, img);
        }
        else {
            gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, size.width, size.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
        }
        this.setFilters();
        this.setInterpolationMode(1);
        this.afterOperation();
    };
    Texture.prototype.toDataArray = function () {
        var gl = this.gl;
        var wxh = this.size.width * this.size.height;
        var fb = gl.createFramebuffer();
        gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.tex, 0);
        if ( true && gl.checkFramebufferStatus(gl.FRAMEBUFFER) !== gl.FRAMEBUFFER_COMPLETE)
            throw new debugError_DebugError("wrong framebuffer state!");
        var pixels = new Uint8Array(wxh * 4);
        gl.readPixels(0, 0, this.size.width, this.size.height, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
        gl.bindFramebuffer(gl.FRAMEBUFFER, null);
        return pixels;
    };
    Texture.prototype.toDataUrl = function () {
        var canvas = document.createElement('canvas');
        var ctx = canvas.getContext('2d');
        canvas.width = this.size.width;
        canvas.height = this.size.height;
        var imgData = ctx.createImageData(this.size.width, this.size.height);
        imgData.data.set(this.toDataArray());
        ctx.putImageData(imgData, 0, 0);
        return canvas.toDataURL();
    };
    Texture.prototype.setRawData = function (data, width, height, mode) {
        if (mode === void 0) { mode = 1; }
        if (true) {
            var numOfBytes = width * height * 4;
            if (data.length !== numOfBytes) {
                throw new debugError_DebugError("unexpected Uint8Array length, expected width*height*4 (" + width + "*" + height + "*4=" + numOfBytes + "), but is found " + data.length);
            }
        }
        var gl = this.gl;
        this.beforeOperation();
        this.size.setWH(width, height);
        gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, data);
        this.setFilters();
        this.setInterpolationMode(mode);
        this.afterOperation();
    };
    return Texture;
}(abstractTexture_AbstractTexture));


// CONCATENATED MODULE: ./engine/delegates/tweenableDelegate.ts

var tweenableDelegate_TweenableDelegate = (function () {
    function TweenableDelegate() {
        this._tweens = [];
        this._tweenMovies = [];
    }
    TweenableDelegate.prototype.tween = function (desc) {
        var t = new tween_Tween(desc);
        if (!this._tweens)
            this._tweens = [];
        this._tweens.push(t);
        return t;
    };
    TweenableDelegate.prototype.addTween = function (t) {
        if (!this._tweens)
            this._tweens = [];
        this._tweens.push(t);
    };
    TweenableDelegate.prototype.addTweenMovie = function (tm) {
        if (!this._tweenMovies)
            this._tweenMovies = [];
        this._tweenMovies.push(tm);
    };
    TweenableDelegate.prototype.update = function () {
        for (var i = 0, l = this._tweens.length; i < l; i++) {
            var t = this._tweens[i];
            t.update();
            if (t.isCompleted()) {
                this._tweens.splice(i, 1);
                l--;
            }
        }
        for (var i = 0, l = this._tweenMovies.length; i < l; i++) {
            var t = this._tweenMovies[i];
            t.update();
            if (t.isCompleted()) {
                this._tweenMovies.splice(i, 1);
                l--;
            }
        }
    };
    return TweenableDelegate;
}());


// CONCATENATED MODULE: ./engine/misc/timer.ts


var timer_Timer = (function () {
    function Timer(parent, callback, interval, once) {
        this.parent = parent;
        this.once = once;
        this.lastTime = 0;
        this.interval = interval;
        this.callback = callback;
    }
    Timer.prototype.onUpdate = function () {
        var time = game_Game.getInstance().getCurrentTime();
        if (!this.lastTime)
            this.lastTime = time;
        var delta = time - this.lastTime;
        if (delta !== 0 && delta > this.interval) {
            this.lastTime = time;
            this.callback();
            if (this.once)
                this.kill();
        }
    };
    Timer.prototype.kill = function () {
        var _this = this;
        Object(object["g" /* removeFromArray */])(this.parent.getTimers(), function (it) { return it === _this; });
    };
    return Timer;
}());


// CONCATENATED MODULE: ./engine/delegates/timerDelegate.ts

var timerDelegate_TimerDelegate = (function () {
    function TimerDelegate() {
    }
    TimerDelegate.prototype.setInterval = function (callback, interval) {
        return this._addTimer(callback, interval, false);
    };
    TimerDelegate.prototype.setTimeout = function (callback, interval) {
        return this._addTimer(callback, interval, true);
    };
    TimerDelegate.prototype.getTimers = function () {
        return this._timers;
    };
    TimerDelegate.prototype.update = function () {
        if (!this._timers)
            return;
        for (var _i = 0, _a = this._timers; _i < _a.length; _i++) {
            var t = _a[_i];
            t.onUpdate();
        }
    };
    TimerDelegate.prototype._addTimer = function (callback, interval, once) {
        var t = new timer_Timer(this, callback, interval, once);
        if (!this._timers)
            this._timers = [];
        this._timers.push(t);
        return t;
    };
    return TimerDelegate;
}());


// CONCATENATED MODULE: ./engine/control/mouse/mouseEvents.ts
var MOUSE_EVENTS;
(function (MOUSE_EVENTS) {
    MOUSE_EVENTS["click"] = "click";
    MOUSE_EVENTS["mousePressed"] = "mousePressed";
    MOUSE_EVENTS["mouseDown"] = "mouseDown";
    MOUSE_EVENTS["mouseMove"] = "mouseMove";
    MOUSE_EVENTS["mouseLeave"] = "mouseLeave";
    MOUSE_EVENTS["mouseEnter"] = "mouseEnter";
    MOUSE_EVENTS["mouseUp"] = "mouseUp";
    MOUSE_EVENTS["doubleClick"] = "doubleClick";
    MOUSE_EVENTS["scroll"] = "scroll";
    MOUSE_EVENTS["dragStart"] = "dragStart";
    MOUSE_EVENTS["dragMove"] = "dragMove";
    MOUSE_EVENTS["dragStop"] = "dragStop";
})(MOUSE_EVENTS || (MOUSE_EVENTS = {}));

// CONCATENATED MODULE: ./engine/misc/eventEmitter.ts

var eventEmitter_EventEmitter = (function () {
    function EventEmitter() {
        this.events = {};
    }
    EventEmitter.prototype.on = function (eventNameOrList, callBack) {
        var _this = this;
        if (typeof eventNameOrList === 'string') {
            this._on(eventNameOrList, callBack);
        }
        else if (eventNameOrList.splice !== undefined) {
            eventNameOrList.forEach(function (eventName) {
                _this._on(eventName, callBack);
            });
        }
    };
    EventEmitter.prototype.off = function (eventName, callback) {
        var es = this.events[eventName];
        if (!es)
            return;
        var index = es.indexOf(callback);
        if ( true && index === -1) {
            console.error(callback);
            throw new debugError_DebugError("can not remove event listener " + eventName);
        }
        es.splice(index, 1);
    };
    EventEmitter.prototype.trigger = function (eventName, data) {
        var evnts = this.events[eventName];
        if (!evnts)
            return;
        var l = evnts.length;
        while (l--) {
            if (evnts[l] !== undefined)
                evnts[l](data);
        }
    };
    EventEmitter.prototype._on = function (name, callBack) {
        this.events[name] = this.events[name] || [];
        this.events[name].push(callBack);
    };
    return EventEmitter;
}());


// CONCATENATED MODULE: ./engine/control/gamepad/gamePadEvents.ts



var GAME_PAD_EVENTS;
(function (GAME_PAD_EVENTS) {
    GAME_PAD_EVENTS["buttonPressed"] = "buttonPressed";
    GAME_PAD_EVENTS["buttonReleased"] = "buttonReleased";
    GAME_PAD_EVENTS["buttonHold"] = "buttonHold";
})(GAME_PAD_EVENTS || (GAME_PAD_EVENTS = {}));
var gamePadEvents_GamePadEvent = (function (_super) {
    __extends(GamePadEvent, _super);
    function GamePadEvent() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    GamePadEvent.fromPool = function () {
        return GamePadEvent.pool.getFreeObject(true);
    };
    GamePadEvent.pool = new objectPool_ObjectPool(GamePadEvent);
    return GamePadEvent;
}(abstractKeypad_KeyPadEvent));


// CONCATENATED MODULE: ./engine/delegates/eventEmitterDelegate.ts






var getControlErrorMessage = function (controlName, controlClassName) {
    if (false)
        {}
    return "can not listen " + controlName + " events: " + controlName + " control is not added;\ninvoke \"game.addControl(" + controlClassName + ");\"";
};
var eventEmitterDelegate_EventEmitterDelegate = (function () {
    function EventEmitterDelegate() {
    }
    EventEmitterDelegate.prototype.on = function (eventName, callBack) {
        if ( true && eventName in MOUSE_EVENTS) {
            if (!game_Game.getInstance().hasControl('MouseControl'))
                throw new debugError_DebugError(getControlErrorMessage('mouse', 'MouseControl'));
        }
        if ( true && eventName in GAME_PAD_EVENTS) {
            if (!game_Game.getInstance().hasControl('GamePadControl'))
                throw new debugError_DebugError(getControlErrorMessage('gamepad', 'GamePadControl'));
        }
        if ( true && eventName in KEYBOARD_EVENTS) {
            if (!game_Game.getInstance().hasControl('KeyboardControl'))
                throw new debugError_DebugError(getControlErrorMessage('keyboard', 'KeyboardControl'));
        }
        if (this._emitter === undefined)
            this._emitter = new eventEmitter_EventEmitter();
        this._emitter.on(eventName, callBack);
        return callBack;
    };
    EventEmitterDelegate.prototype.once = function (eventName, callBack) {
        var _this = this;
        var cb = this.on(eventName, function (_args) {
            _this.off(eventName, cb);
            callBack(_args);
        });
    };
    EventEmitterDelegate.prototype.off = function (eventName, callBack) {
        if (this._emitter !== undefined)
            this._emitter.off(eventName, callBack);
    };
    EventEmitterDelegate.prototype.trigger = function (eventName, data) {
        if (this._emitter !== undefined)
            this._emitter.trigger(eventName, data);
    };
    return EventEmitterDelegate;
}());


// CONCATENATED MODULE: ./engine/resources/incrementer.ts
var incrementer_val = 0;
var Incrementer = (function () {
    function Incrementer() {
    }
    Incrementer.getValue = function () {
        return incrementer_val++;
    };
    return Incrementer;
}());


// CONCATENATED MODULE: ./engine/delegates/parentChildDelegate.ts

var parentChildDelegate_ParentChildDelegate = (function () {
    function ParentChildDelegate(model) {
        this.model = model;
    }
    ParentChildDelegate.prototype.appendChild = function (c, afterAppended) {
        if (true) {
            if (c === this.model)
                throw new debugError_DebugError("parent and child objects are the same");
            if (this.model.children.find(function (it) { return it === c; })) {
                console.error(c);
                throw new debugError_DebugError("this children is already added");
            }
        }
        c.parent = this.model;
        this.model.children.push(c);
        if (afterAppended !== undefined)
            afterAppended(c);
    };
    ParentChildDelegate.prototype.appendChildAt = function (c, index, afterAppended) {
        if (true) {
            if (index > this.model.children.length - 1)
                throw new debugError_DebugError("can not insert element: index is out of range (" + index + "," + (this.model.children.length - 1) + ")");
        }
        c.parent = this.model;
        this.model.children.splice(index, 0, c);
        if (afterAppended !== undefined)
            afterAppended(c);
    };
    ParentChildDelegate.prototype.appendChildAfter = function (modelAfter, newChild, afterAppended) {
        var afterIndex = this.model.children.indexOf(modelAfter);
        if (true) {
            if (afterIndex === -1)
                throw new debugError_DebugError("can not insert element: object is detached");
        }
        if (afterIndex === this.model.children.length - 1)
            this.appendChild(newChild, afterAppended);
        else
            this.appendChildAt(newChild, afterIndex + 1, afterAppended);
    };
    ParentChildDelegate.prototype.appendChildBefore = function (modelBefore, newChild, afterAppended) {
        var beforeIndex = this.model.children.indexOf(modelBefore);
        if (true) {
            if (beforeIndex === -1)
                throw new debugError_DebugError("can not insert element: object is detached");
        }
        if (beforeIndex === 0)
            this.prependChild(newChild, afterAppended);
        else
            this.appendChildAt(newChild, beforeIndex - 1, afterAppended);
    };
    ParentChildDelegate.prototype.prependChild = function (c, afterAppended) {
        c.parent = this.model;
        this.model.children.unshift(c);
        if (afterAppended !== undefined)
            afterAppended(c);
    };
    ParentChildDelegate.prototype.removeChildAt = function (i, afterRemoved) {
        var c = this.model.children[i];
        if ( true && !c)
            throw new debugError_DebugError("can not remove children with index " + i);
        if ( true && c.parent === undefined)
            throw new debugError_DebugError("can not remove children with index " + i + ": it is already detached");
        c.parent.children.splice(i, 1);
        c.parent = undefined;
        if (afterRemoved !== undefined)
            afterRemoved(c);
    };
    ParentChildDelegate.prototype.removeChild = function (child, afterRemoved) {
        var parent = child.getParent();
        var i = parent.children.indexOf(child);
        if ( true && i === -1)
            throw new debugError_DebugError("can not remove child: it doesn't belong to parent");
        parent.children.splice(i, 1);
        child.parent = undefined;
        if (afterRemoved !== undefined)
            afterRemoved(child);
    };
    ParentChildDelegate.prototype.removeSelf = function (afterRemoved) {
        var parent = this.model.getParent();
        if ( true && parent === undefined)
            throw new debugError_DebugError("can not remove child: it is already detached");
        var i = parent.children.indexOf(this.model);
        if ( true && i === -1)
            throw new debugError_DebugError("can not remove child: it doesn't belong to parent");
        parent.children.splice(i, 1);
        this.model.parent = undefined;
        if (afterRemoved !== undefined)
            afterRemoved(this.model);
    };
    ParentChildDelegate.prototype.removeChildren = function (afterRemoved) {
        for (var i = this.model.children.length - 1; i >= 0; i--) {
            var c = this.model.children[i];
            this.removeChildAt(i, afterRemoved);
        }
    };
    ParentChildDelegate.prototype.moveToFront = function () {
        var parent = this.model.getParent();
        if ( true && !parent)
            throw new debugError_DebugError("can not move to front: object is detached");
        var parentArray = parent.children;
        var index = parentArray.indexOf(this.model);
        if ( true && index === -1)
            throw new debugError_DebugError("can not move to front: object is not belong to current scene");
        parentArray.splice(index, 1);
        parentArray.push(this.model);
    };
    ParentChildDelegate.prototype.moveToBack = function () {
        var parent = this.model.getParent();
        if ( true && !parent)
            throw new debugError_DebugError("can not move to back: object is detached");
        var parentArray = parent.children;
        var index = parentArray.indexOf(this.model);
        if ( true && index === -1)
            throw new debugError_DebugError("can not move to front: object is not belong to current scene");
        parentArray.splice(index, 1);
        parentArray.unshift(this.model);
    };
    ParentChildDelegate.prototype.findChildById = function (id) {
        if (id === this.model.id)
            return this.model;
        for (var _i = 0, _a = this.model.children; _i < _a.length; _i++) {
            var c = _a[_i];
            var possibleObject = c.findChildById(id);
            if (possibleObject)
                return possibleObject;
        }
        return undefined;
    };
    return ParentChildDelegate;
}());


// CONCATENATED MODULE: ./engine/core/baseModel.ts



var baseModel_BaseModel = (function () {
    function BaseModel(game) {
        this.game = game;
        this.size = new size_Size();
        this.pos = new point2d_Point2d(0, 0);
        this.posZ = 0;
        if ( true && !game)
            throw new debugError_DebugError("can not create model '" + this.type + "': game instance not passed to model constructor");
    }
    return BaseModel;
}());


// CONCATENATED MODULE: ./engine/renderable/abstract/transformableModel.ts





var transformableModel_Mat16Holder = mat4_mat4.Mat16Holder;
var AnglePoint3d = (function () {
    function AnglePoint3d(m, zProperty) {
        this.m = m;
        this.zProperty = zProperty;
        this.x = 0;
        this.y = 0;
        this._z = 0;
    }
    Object.defineProperty(AnglePoint3d.prototype, "z", {
        get: function () {
            return this._z;
        },
        set: function (val) {
            this.m[this.zProperty] = val;
        },
        enumerable: true,
        configurable: true
    });
    AnglePoint3d.prototype._setZSilently = function (val) {
        this._z = val;
    };
    AnglePoint3d.prototype.clone = function (m) {
        var a = new AnglePoint3d(m, this.zProperty);
        a.x = this.x;
        a.y = this.y;
        a.z = this.z;
        return a;
    };
    return AnglePoint3d;
}());
var transformableModel_ModelPoint2d = (function (_super) {
    __extends(ModelPoint2d, _super);
    function ModelPoint2d(model) {
        var _this = _super.call(this) || this;
        _this.model = model;
        return _this;
    }
    ModelPoint2d.prototype.setToCenter = function () {
        this.model.revalidate();
        if ( true && !(this.model.size.width && this.model.size.height))
            throw new debugError_DebugError("can not set anchor to center: width or height of transformable object is not set");
        this.setXY(this.model.size.width / 2, this.model.size.height / 2);
    };
    return ModelPoint2d;
}(point2d_Point2d));
var transformableModel_TransformableModel = (function (_super) {
    __extends(TransformableModel, _super);
    function TransformableModel(game) {
        var _this = _super.call(this, game) || this;
        _this.game = game;
        _this.worldTransformMatrix = new transformableModel_Mat16Holder();
        _this.worldTransformDirty = true;
        _this.children = [];
        _this.scale = new point2d_Point2d(1, 1);
        _this.skew = new point2d_Point2d(0, 0);
        _this.anchorPoint = new transformableModel_ModelPoint2d(_this);
        _this.transformPoint = new transformableModel_ModelPoint2d(_this);
        _this.angle3d = new AnglePoint3d(_this, 'angle');
        _this.billBoard = false;
        _this._angleVelocity3d = new AnglePoint3d(_this, 'angleVelocity');
        _this._angle = 0;
        var observer = function () {
            _this.worldTransformDirty = true;
            _this.children.forEach(function (c) { return c.worldTransformDirty = true; });
        };
        _this.pos.observe(observer);
        _this.scale.observe(observer);
        _this.transformPoint.observe(observer);
        _this.anchorPoint.observe(observer);
        return _this;
    }
    Object.defineProperty(TransformableModel.prototype, "angle", {
        get: function () {
            return this._angle;
        },
        set: function (val) {
            if (this._angle !== val)
                this.worldTransformDirty = true;
            this._angle = val;
            this.angle3d._setZSilently(val);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TransformableModel.prototype, "angleVelocity", {
        get: function () {
            return this._angle;
        },
        set: function (val) {
            this._angle = val;
            this._angleVelocity3d._setZSilently(val);
        },
        enumerable: true,
        configurable: true
    });
    TransformableModel.prototype.translate = function () {
        var renderer = this.game.getRenderer();
        renderer.transformTranslate(this.pos.x, this.pos.y);
    };
    TransformableModel.prototype.transform = function () {
        var renderer = this.game.getRenderer();
        renderer.transformTranslate(-this.anchorPoint.x, -this.anchorPoint.y, this.posZ);
        renderer.transformTranslate(this.transformPoint.x, this.transformPoint.y);
        renderer.transformRotateZ(this.angle3d.z);
        renderer.transformRotateX(this.angle3d.x);
        renderer.transformRotateY(this.angle3d.y);
        var _a = this.scale.toArray(), x = _a[0], y = _a[1], z = _a[2];
        renderer.transformScale(x, y, z);
        renderer.transformSkewX(this.skew.x);
        renderer.transformSkewY(this.skew.y);
        renderer.transformTranslate(-this.transformPoint.x, -this.transformPoint.y);
        if (this.billBoard)
            renderer.transformRotationReset();
    };
    TransformableModel.prototype.setClonedProperties = function (cloned) {
        cloned.angle = this.angle;
        cloned.angleVelocity = this.angleVelocity;
        cloned.pos.set(this.pos);
        cloned.scale.set(this.scale);
        cloned.anchorPoint.set(this.anchorPoint);
        cloned.skew.set(this.skew);
        cloned.transformPoint.set(this.transformPoint);
        var angle3dCloned = this.angle3d.clone(this);
        cloned.angle3d.x = angle3dCloned.x;
        cloned.angle3d.y = angle3dCloned.y;
        cloned.angle3d.z = angle3dCloned.z;
    };
    return TransformableModel;
}(baseModel_BaseModel));


// CONCATENATED MODULE: ./engine/renderable/abstract/renderableModel.ts










var renderableModel_RenderableModel = (function (_super) {
    __extends(RenderableModel, _super);
    function RenderableModel(game) {
        var _this = _super.call(this, game) || this;
        _this.game = game;
        _this.alpha = 1;
        _this.visible = true;
        _this.blendMode = 0;
        _this.depthTest = false;
        _this.filters = [];
        _this.forceDrawChildrenOnNewSurface = false;
        _this.children = [];
        _this.velocity = new point2d_Point2d(0, 0);
        _this.passMouseEventsThrough = false;
        _this._destRect = new rect_Rect();
        _this._behaviours = [];
        _this._propertyAnimations = [];
        _this._tweenDelegate = new tweenableDelegate_TweenableDelegate();
        _this._timerDelegate = new timerDelegate_TimerDelegate();
        _this._eventEmitterDelegate = new eventEmitterDelegate_EventEmitterDelegate();
        _this._parentChildDelegate = new parentChildDelegate_ParentChildDelegate(_this);
        _this.id = "object_" + Incrementer.getValue();
        return _this;
    }
    RenderableModel._afterChildRemoved = function (child) {
        child.setLayer(undefined);
        child.setScene(undefined);
    };
    RenderableModel.prototype.revalidate = function () {
        for (var _i = 0, _a = this._behaviours; _i < _a.length; _i++) {
            var b = _a[_i];
            b.revalidate();
        }
    };
    RenderableModel.prototype.getLayer = function () {
        return this._layer;
    };
    RenderableModel.prototype.setLayer = function (value) {
        this._layer = value;
    };
    RenderableModel.prototype.getScene = function () {
        return this._scene;
    };
    RenderableModel.prototype.setScene = function (value) {
        this._scene = value;
    };
    RenderableModel.prototype.getDestRect = function () {
        this._destRect.setPoint(this.pos);
        this._destRect.setSize(this.size);
        return this._destRect;
    };
    RenderableModel.prototype.addBehaviour = function (b) {
        this._behaviours.push(b);
        b.manage(this);
    };
    RenderableModel.prototype.addPropertyAnimation = function (animation) {
        animation.target = this;
        this._propertyAnimations.push(animation);
    };
    RenderableModel.prototype.setWH = function (w, h) {
        if (h === void 0) { h = w; }
        this.setXYWH(this.pos.x, this.pos.y, w, h);
    };
    RenderableModel.prototype.setXYWH = function (x, y, w, h) {
        this.pos.setXY(x, y);
        this.size.setWH(w, h);
    };
    RenderableModel.prototype.setRigidBody = function (rigidBody) {
        this._rigidBody = rigidBody;
        rigidBody.updateBounds(this);
    };
    RenderableModel.prototype.getRigidBody = function () {
        return this._rigidBody;
    };
    RenderableModel.prototype.destroy = function () {
        for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
            var c = _a[_i];
            c.destroy();
        }
        if ( true && !this.getParent())
            throw new debugError_DebugError("can not kill object: gameObject is detached");
        var parentArray = this.getParent().children;
        var index = parentArray.indexOf(this);
        if ( true && index === -1) {
            console.error(this);
            throw new debugError_DebugError('can not kill: object is not belong to current scene');
        }
        parentArray.splice(index, 1);
        for (var _b = 0, _c = this._behaviours; _b < _c.length; _b++) {
            var b = _c[_b];
            b.destroy();
        }
        this.game.getRenderer().killObject(this);
    };
    RenderableModel.prototype.render = function () {
        if (!this.visible)
            return;
        if (this.alpha === 0)
            return;
        var renderer = this.game.getRenderer();
        if (renderer.getAlphaBlend() === 0)
            return;
        renderer.saveAlphaBlend();
        renderer.transformSave();
        if (this.game.camera.worldTransformDirty || this.worldTransformDirty) {
            this.translate();
            this.transform();
            this.worldTransformMatrix.fromMat16(renderer.transformGet());
            this.worldTransformDirty = false;
        }
        else {
            renderer.transformSet.apply(renderer, this.worldTransformMatrix.mat16);
        }
        renderer.setAlphaBlend(this.alpha);
        var statePointer = renderer.beforeItemStackDraw(this.filters, this.forceDrawChildrenOnNewSurface);
        this.draw();
        if (this.children.length > 0) {
            renderer.transformSave();
            renderer.saveAlphaBlend();
            renderer.transformTranslate(this.anchorPoint.x, this.anchorPoint.y);
            for (var i = 0, max = this.children.length; i < max; i++) {
                this.children[i].render();
            }
            renderer.transformRestore();
            renderer.restoreAlphaBlend();
        }
        renderer.afterItemStackDraw(statePointer);
        renderer.transformRestore();
        renderer.restoreAlphaBlend();
        if ( true && this._rigidBody !== undefined)
            this._rigidBody.debugRender();
    };
    RenderableModel.prototype.update = function () {
        var delta = this.game.getDeltaTime();
        this._tweenDelegate.update();
        this._timerDelegate.update();
        for (var _i = 0, _a = this._behaviours; _i < _a.length; _i++) {
            var bh = _a[_i];
            bh.update();
        }
        for (var _b = 0, _c = this._propertyAnimations; _b < _c.length; _b++) {
            var pa = _c[_b];
            pa.update();
        }
        if (this._rigidBody !== undefined) {
            this._rigidBody.nextTick();
        }
        else {
            if (this.velocity.x)
                this.pos.x += this.velocity.x * delta / 1000;
            if (this.velocity.y)
                this.pos.y += this.velocity.y * delta / 1000;
        }
        if (this._angleVelocity3d.x)
            this.angle3d.x += this._angleVelocity3d.x * delta / 1000;
        if (this._angleVelocity3d.y)
            this.angle3d.y += this._angleVelocity3d.y * delta / 1000;
        if (this._angleVelocity3d.z)
            this.angle3d.z += this._angleVelocity3d.z * delta / 1000;
        for (var _d = 0, _e = this.children; _d < _e.length; _d++) {
            var c = _e[_d];
            c.update();
        }
    };
    RenderableModel.prototype.addTween = function (t) {
        this._tweenDelegate.addTween(t);
    };
    RenderableModel.prototype.addTweenMovie = function (tm) {
        this._tweenDelegate.addTweenMovie(tm);
    };
    RenderableModel.prototype.tween = function (desc) {
        return this._tweenDelegate.tween(desc);
    };
    RenderableModel.prototype.setTimeout = function (callback, interval) {
        return this._timerDelegate.setTimeout(callback, interval);
    };
    RenderableModel.prototype.setInterval = function (callback, interval) {
        return this._timerDelegate.setInterval(callback, interval);
    };
    RenderableModel.prototype.off = function (eventName, callBack) {
        this._eventEmitterDelegate.off(eventName, callBack);
    };
    RenderableModel.prototype.on = function (eventName, callBack) {
        return this._eventEmitterDelegate.on(eventName, callBack);
    };
    RenderableModel.prototype.once = function (eventName, callBack) {
        this._eventEmitterDelegate.once(eventName, callBack);
    };
    RenderableModel.prototype.trigger = function (eventName, data) {
        this._eventEmitterDelegate.trigger(eventName, data);
    };
    RenderableModel.prototype.appendChild = function (newChild) {
        this._parentChildDelegate.appendChild(newChild, this._afterChildAppended.bind(this));
    };
    RenderableModel.prototype.appendChildAt = function (newChild, index) {
        this._parentChildDelegate.appendChildAt(newChild, index, this._afterChildAppended.bind(this));
    };
    RenderableModel.prototype.appendChildAfter = function (modelAfter, newChild) {
        this._parentChildDelegate.appendChildAfter(modelAfter, newChild, this._afterChildAppended.bind(this));
    };
    RenderableModel.prototype.appendChildBefore = function (modelBefore, newChild) {
        this._parentChildDelegate.appendChildBefore(modelBefore, newChild, this._afterChildAppended.bind(this));
    };
    RenderableModel.prototype.prependChild = function (newChild) {
        this._parentChildDelegate.prependChild(newChild, this._afterChildAppended.bind(this));
    };
    RenderableModel.prototype.removeChild = function (c) {
        this._parentChildDelegate.removeChild(c, RenderableModel._afterChildRemoved);
    };
    RenderableModel.prototype.removeChildAt = function (i) {
        this._parentChildDelegate.removeChildAt(i, RenderableModel._afterChildRemoved);
    };
    RenderableModel.prototype.removeChildren = function () {
        this._parentChildDelegate.removeChildren(RenderableModel._afterChildRemoved);
    };
    RenderableModel.prototype.removeSelf = function () {
        this._parentChildDelegate.removeSelf(RenderableModel._afterChildRemoved);
    };
    RenderableModel.prototype.moveToFront = function () {
        this._parentChildDelegate.moveToFront();
    };
    RenderableModel.prototype.moveToBack = function () {
        this._parentChildDelegate.moveToBack();
    };
    RenderableModel.prototype.findChildById = function (id) {
        return this._parentChildDelegate.findChildById(id);
    };
    RenderableModel.prototype.getParent = function () {
        return this.parent || this._layer;
    };
    RenderableModel.prototype.renderToTexture = function (target, clearColor) {
        this.game.getRenderer().getHelper().renderModelToTexture(this, target, clearColor);
    };
    RenderableModel.prototype.isDetached = function () {
        return this._scene === undefined;
    };
    RenderableModel.prototype.setClonedProperties = function (cloned) {
        cloned.size.set(cloned.size);
        cloned.alpha = this.alpha;
        cloned.blendMode = this.blendMode;
        cloned.visible = this.visible;
        cloned.filters = __spreadArrays(this.filters);
        cloned.forceDrawChildrenOnNewSurface = this.forceDrawChildrenOnNewSurface;
        if (this.getRigidBody() !== undefined)
            cloned.setRigidBody(this.getRigidBody().clone());
        this.children.forEach(function (c) {
            if ( true && !('clone' in c)) {
                console.error(c);
                throw new debugError_DebugError("can not clone object: cloneable interface is not implemented");
            }
            var clonedChildren = c.clone();
            if ( true && !(clonedChildren instanceof RenderableModel)) {
                console.error(c);
                throw new debugError_DebugError("can not clone object: \"clone\"  method must return Cloneable object");
            }
            cloned.appendChild(clonedChildren);
        });
        cloned.game = this.game;
        _super.prototype.setClonedProperties.call(this, cloned);
    };
    RenderableModel.prototype._afterChildAppended = function (newChild) {
        newChild.setLayer(this._layer);
        newChild.setScene(this.game.getCurrScene());
        newChild.revalidate();
    };
    return RenderableModel;
}(transformableModel_TransformableModel));


// CONCATENATED MODULE: ./engine/renderable/impl/ui/abstract/container.ts




var container_Container = (function (_super) {
    __extends(Container, _super);
    function Container(game) {
        var _this = _super.call(this, game) || this;
        _this.marginLeft = 0;
        _this.marginTop = 0;
        _this.marginRight = 0;
        _this.marginBottom = 0;
        _this.paddingLeft = 0;
        _this.paddingTop = 0;
        _this.paddingRight = 0;
        _this.paddingBottom = 0;
        _this.layoutWidth = 1;
        _this.layoutHeight = 1;
        _this.overflow = 0;
        _this.drawingRect = new rect_Rect();
        _this.maxWidth = 0;
        _this.maxHeight = 0;
        _this._dirty = false;
        return _this;
    }
    Container.normalizeBorders = function (top, right, bottom, left) {
        if (right === undefined && bottom === undefined && left === undefined) {
            right = bottom = left = top;
        }
        else if (bottom === undefined && left === undefined) {
            bottom = top;
            left = right;
        }
        else if (left === undefined) {
            left = right;
        }
        return { top: top, right: right, bottom: bottom, left: left };
    };
    Container.prototype.testLayout = function () {
        if (true) {
            if (this.layoutWidth === 0 && this.size.width === 0)
                throw new debugError_DebugError("layoutWidth is LAYOUT_SIZE.FIXED so width must be specified");
            if (this.layoutHeight === 0 && this.size.height === 0)
                throw new debugError_DebugError("layoutHeight is LAYOUT_SIZE.FIXED so height must be specified");
        }
    };
    Container.prototype.setMargins = function (top, right, bottom, left) {
        var _a;
        (_a = Container.normalizeBorders(top, right, bottom, left), top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left);
        this.marginTop = top;
        this.marginRight = right;
        this.marginBottom = bottom;
        this.marginLeft = left;
        this.setDirty();
    };
    Container.prototype.setMarginsTopBottom = function (top, bottom) {
        if (bottom === undefined)
            bottom = top;
        this.paddingTop = top;
        this.paddingBottom = bottom;
        this.setDirty();
    };
    Container.prototype.setMarginsLeftRight = function (left, right) {
        if (right === undefined)
            right = left;
        this.marginLeft = left;
        this.marginRight = right;
        this.setDirty();
    };
    Container.prototype.setPaddings = function (top, right, bottom, left) {
        var _a;
        (_a = Container.normalizeBorders(top, right, bottom, left), top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left);
        this.paddingTop = top;
        this.paddingRight = right;
        this.paddingBottom = bottom;
        this.paddingLeft = left;
        this.setDirty();
    };
    Container.prototype.setPaddingsTopBottom = function (top, bottom) {
        if (bottom === void 0) { bottom = top; }
        if (bottom === undefined)
            bottom = top;
        this.paddingTop = top;
        this.paddingBottom = bottom;
        this.setDirty();
    };
    Container.prototype.setPaddingsLeftRight = function (left, right) {
        if (right === void 0) { right = left; }
        this.paddingLeft = left;
        this.paddingRight = right;
        this.setDirty();
    };
    Container.prototype.revalidate = function () {
        this.updateUIRect();
        if (this.background)
            this.background.size.set(this.size);
        _super.prototype.revalidate.call(this);
    };
    Container.prototype.onGeometryChanged = function () {
        this.revalidate();
        this._dirty = false;
    };
    Container.prototype.setWH = function (w, h) {
        this.size.setWH(w, h);
        this.drawingRect.setWH(w, h);
        this.setDirty();
    };
    Container.prototype.calcDrawableRect = function (contentWidth, contentHeight) {
        var paddedWidth = contentWidth + this.paddingLeft + this.paddingRight;
        var paddedHeight = contentHeight + this.paddingTop + this.paddingBottom;
        if (this.background) {
            this.background.setWH(paddedWidth, paddedHeight);
            this.size.set(this.background.size);
        }
        else {
            this.size.setWH(paddedWidth, paddedHeight);
        }
        this.updateUIRect();
    };
    Container.prototype.update = function () {
        if (this.isDirty()) {
            this.onGeometryChanged();
        }
        _super.prototype.update.call(this);
    };
    Container.prototype.translate = function () {
        _super.prototype.translate.call(this);
        this.game.getRenderer().transformTranslate(this.marginLeft, this.marginTop);
    };
    Container.prototype.setDirty = function () {
        this._dirty = true;
    };
    Container.prototype.isDirty = function () {
        return this._dirty;
    };
    Container.prototype.updateUIRect = function () {
        this.size.setWH(this.size.width + this.marginLeft + this.marginRight, this.size.height + this.marginTop + this.marginBottom);
    };
    return Container;
}(renderableModel_RenderableModel));


// CONCATENATED MODULE: ./engine/renderer/common/color.ts



var color_Color = (function (_super) {
    __extends(Color, _super);
    function Color(r, g, b, a) {
        if (r === void 0) { r = 0; }
        if (g === void 0) { g = r; }
        if (b === void 0) { b = g; }
        if (a === void 0) { a = 255; }
        var _this = _super.call(this) || this;
        _this.type = 'Color';
        _this._friezed = false;
        _this.setRGBA(r, g, b, a);
        return _this;
    }
    Color.RGB = function (r, g, b) {
        if (g === void 0) { g = r; }
        if (b === void 0) { b = r; }
        return Color.RGBA(r, g, b, 255);
    };
    Color.HSLA = function (h, s, l, a) {
        var c = new Color();
        c.setHSLA(h, s, l, a);
        return c;
    };
    Color.HSL = function (h, s, l) {
        return Color.HSLA(h, s, l, 255);
    };
    Color.RGBA = function (r, g, b, a) {
        if (g === void 0) { g = r; }
        if (b === void 0) { b = r; }
        if (a === void 0) { a = b; }
        var c = new Color(0, 0, 0);
        c.setRGBA(r, g, b, a);
        return c;
    };
    Color.fromRGBNumeric = function (col) {
        var r = (col & 16711680) >> (4 * 4);
        var g = (col & 65280) >> (4 * 2);
        var b = (col & 255);
        return new Color(r, g, b);
    };
    Color.prototype.setRGBA = function (r, g, b, a) {
        if (a === void 0) { a = 255; }
        this.checkFriezed();
        var changed = this.r !== r || this.g !== g || this.b !== b || this.a !== a;
        if (!changed)
            return;
        this.r = r;
        this.g = g;
        this.b = b;
        this.a = a;
        this.triggerObservable();
        this.normalizeToZeroOne();
    };
    Color.prototype.setRGB = function (r, g, b) {
        this.setRGBA(r, g, b, 255);
    };
    Color.prototype.setHSLA = function (h, s, l, a) {
        h = (h % 360) / 360;
        s /= 100;
        l /= 100;
        var r, g, b;
        if (s === 0) {
            r = g = b = l;
        }
        else {
            var hue2rgb = function (pCol, qCol, t) {
                if (t < 0)
                    t += 1;
                if (t > 1)
                    t -= 1;
                if (t < 1 / 6)
                    return pCol + (qCol - pCol) * 6 * t;
                if (t < 1 / 2)
                    return qCol;
                if (t < 2 / 3)
                    return pCol + (qCol - pCol) * (2 / 3 - t) * 6;
                return pCol;
            };
            var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
            var p = 2 * l - q;
            r = hue2rgb(p, q, h + 1 / 3);
            g = hue2rgb(p, q, h);
            b = hue2rgb(p, q, h - 1 / 3);
        }
        var rResult = Math.round(r * 255);
        var gResult = Math.round(g * 255);
        var bResult = Math.round(b * 255);
        this.setRGBA(rResult, gResult, bResult, a);
    };
    Color.prototype.setHSL = function (h, s, l) {
        this.setHSLA(h, s, l, 255);
    };
    Color.prototype.getR = function () { return this.r; };
    Color.prototype.getG = function () { return this.g; };
    Color.prototype.getB = function () { return this.b; };
    Color.prototype.getA = function () { return this.a; };
    Color.prototype.setR = function (val) {
        this.setRGBA(val, this.g, this.b, this.a);
    };
    Color.prototype.setG = function (val) {
        this.setRGBA(this.r, val, this.b, this.a);
    };
    Color.prototype.setB = function (val) {
        this.setRGBA(this.r, this.g, val, this.a);
    };
    Color.prototype.setA = function (val) {
        this.setRGBA(this.r, this.g, this.b, val);
    };
    Color.prototype.set = function (another) {
        this.setRGBA(another.r, another.g, another.b, another.a);
    };
    Color.prototype.clone = function () {
        return new Color(this.r, this.g, this.b, this.a);
    };
    Color.prototype.freeze = function () {
        this._friezed = true;
        return this;
    };
    Color.prototype.asGL = function () {
        if (!this._arr)
            this._arr = new Array(3);
        this._arr[0] = this.rNorm;
        this._arr[1] = this.gNorm;
        this._arr[2] = this.bNorm;
        this._arr[3] = this.aNorm;
        return this._arr;
    };
    Color.prototype.asCSS = function () {
        return "rgba(" + this.r + "," + this.g + "," + this.b + "," + this.a / 255 + ")";
    };
    Color.prototype.asRGBNumeric = function () {
        return (this.r << 16) | (this.g << 8) | this.b;
    };
    Color.prototype.toJSON = function () {
        return { r: this.r, g: this.g, b: this.b, a: this.a };
    };
    Color.prototype.fromJSON = function (json) {
        this.setRGBA(json.r, json.g, json.b, json.a);
    };
    Color.prototype.checkFriezed = function () {
        if (this._friezed) {
            if (true) {
                console.error(this);
                throw new debugError_DebugError("the color is friezed and can no be changed");
            }
            else
                {}
        }
    };
    Color.prototype.normalizeToZeroOne = function () {
        this.rNorm = this.r / 0xff;
        this.gNorm = this.g / 0xff;
        this.bNorm = this.b / 0xff;
        this.aNorm = this.a / 0xff;
    };
    Color.WHITE = Color.RGB(255, 255, 255).freeze();
    Color.GREY = Color.RGB(127, 127, 127).freeze();
    Color.BLACK = Color.RGB(0, 0, 0).freeze();
    Color.NONE = Color.RGBA(0, 0, 0, 0).freeze();
    return Color;
}(observableEntity_ObservableEntity));


// CONCATENATED MODULE: ./engine/renderable/impl/general/image.ts






var image_Image = (function (_super) {
    __extends(Image, _super);
    function Image(game) {
        var _this = _super.call(this, game) || this;
        _this.type = 'Image';
        _this.borderRadius = 0;
        _this.offset = new point2d_Point2d();
        _this.stretchMode = 0;
        _this.color = color_Color.NONE.clone();
        _this.lineWidth = 0;
        _this._pixelPerfect = false;
        _this._srcRect = new rect_Rect();
        return _this;
    }
    Image.prototype.revalidate = function () {
        if ( true && !this.getResourceLink()) {
            console.error(this);
            throw new debugError_DebugError("can not render Image: resourceLink is not specified");
        }
        if ( true && !this.getResourceLink().getTarget()) {
            console.error(this);
            throw new debugError_DebugError("can not render Image: can not find texture by resource link");
        }
        var tex = this.getResourceLink().getTarget();
        if (this.size.isZero()) {
            this.size.width = tex.size.width;
            this.size.height = tex.size.height;
        }
        if (this._srcRect.isZeroSize()) {
            this._srcRect.setWH(tex.size.width, tex.size.height);
        }
    };
    Image.prototype.draw = function () {
        this.game.getRenderer().drawImage(this);
    };
    Image.prototype.clone = function () {
        var cloned = new Image(this.game);
        this.setClonedProperties(cloned);
        return cloned;
    };
    Image.prototype.getSrcRect = function () {
        return this._srcRect;
    };
    Image.prototype.setResourceLink = function (link) {
        if ( true && !link) {
            throw new debugError_DebugError("can not set resource link: link is not passed");
        }
        this._resourceLink = link;
        this.revalidate();
    };
    Image.prototype.getResourceLink = function () {
        return this._resourceLink;
    };
    Image.prototype.setPixelPerfect = function (val) {
        this._pixelPerfect = val;
    };
    Image.prototype.isPixelPerfect = function () {
        return this._pixelPerfect;
    };
    Image.prototype.setClonedProperties = function (cloned) {
        cloned._srcRect.set(this._srcRect);
        cloned.size.set(this.size);
        cloned.borderRadius = this.borderRadius;
        cloned.offset.set(this.offset);
        cloned.stretchMode = this.stretchMode;
        cloned.color = this.color.clone();
        cloned.lineWidth = this.lineWidth;
        cloned._pixelPerfect = this._pixelPerfect;
        cloned.setResourceLink(this.getResourceLink());
        _super.prototype.setClonedProperties.call(this, cloned);
    };
    return Image;
}(renderableModel_RenderableModel));


// CONCATENATED MODULE: ./engine/renderable/abstract/shape.ts





var shape_Shape = (function (_super) {
    __extends(Shape, _super);
    function Shape(game) {
        var _this = _super.call(this, game) || this;
        _this.color = color_Color.BLACK.clone();
        _this.lineWidth = 0;
        _this.fillColor = color_Color.RGB(100, 100, 100);
        _this.filters = [];
        return _this;
    }
    Shape.prototype.cacheAsBitmap = function () {
        var sizeInt = new size_Size().setWH(~~this.size.width, ~~this.size.height);
        var renderTarget = this.game.getRenderer().getHelper().
            createRenderTarget(this.game, sizeInt);
        var image = new image_Image(this.game);
        image.size.set(sizeInt);
        this.renderToTexture(renderTarget, color_Color.NONE);
        image.setResourceLink(renderTarget.getResourceLink());
        renderTarget.destroy();
        return image;
    };
    Shape.prototype.setClonedProperties = function (cloned) {
        cloned.color.set(this.color);
        cloned.lineWidth = this.lineWidth;
        if (!cloned.fillColor)
            cloned.fillColor = this.fillColor.clone();
        else
            cloned.fillColor.set(this.fillColor);
        cloned.filters = __spreadArrays(this.filters);
        _super.prototype.setClonedProperties.call(this, cloned);
    };
    return Shape;
}(renderableModel_RenderableModel));


// CONCATENATED MODULE: ./engine/renderable/impl/geometry/rectangle.ts


var rectangle_Rectangle = (function (_super) {
    __extends(Rectangle, _super);
    function Rectangle(game) {
        var _this = _super.call(this, game) || this;
        _this.type = 'Rectangle';
        _this.borderRadius = 0;
        _this.size.setWH(16);
        _this.lineWidth = 1;
        return _this;
    }
    Rectangle.prototype.draw = function () {
        this.game.getRenderer().drawRectangle(this);
    };
    Rectangle.prototype.clone = function () {
        var cloned = new Rectangle(this.game);
        this.setClonedProperties(cloned);
        return cloned;
    };
    Rectangle.prototype.setClonedProperties = function (cloned) {
        cloned.borderRadius = this.borderRadius;
        cloned.size.set(this.size);
        cloned.lineWidth = this.lineWidth;
        _super.prototype.setClonedProperties.call(this, cloned);
    };
    return Rectangle;
}(shape_Shape));


// CONCATENATED MODULE: ./engine/renderable/impl/ui/components/vScroll.ts




var vScroll_VScroll = (function (_super) {
    __extends(VScroll, _super);
    function VScroll(game) {
        var _this = _super.call(this, game) || this;
        _this.type = 'VScroll';
        _this.maxValue = 0;
        _this.value = 0;
        _this._enabled = false;
        var bg = new rectangle_Rectangle(game);
        bg.size.width = 5;
        bg.fillColor = new color_Color(50, 50, 50, 10);
        bg.color = color_Color.NONE.clone();
        var hnd = new rectangle_Rectangle(game);
        hnd.size.height = 10;
        hnd.color = color_Color.NONE.clone();
        hnd.fillColor = new color_Color(10, 10, 10, 100);
        _this.background = bg;
        _this.handler = hnd;
        _this.appendChild(bg);
        _this.appendChild(hnd);
        return _this;
    }
    Object.defineProperty(VScroll.prototype, "enabled", {
        get: function () {
            return this._enabled;
        },
        set: function (value) {
            this._enabled = value;
            this.visible = value;
        },
        enumerable: true,
        configurable: true
    });
    VScroll.prototype.onGeometryChanged = function () {
        this.handler.size.width = this.background.size.width;
        if (this.value > this.maxValue)
            this.value = this.maxValue;
        if (this.maxValue)
            this.handler.size.height = this.size.height * this.size.height / this.maxValue;
        if (this.maxValue)
            this.handler.pos.y =
                this.size.height * this.value / this.maxValue;
        this.background.revalidate();
        this.handler.revalidate();
        this.calcDrawableRect(this.size.width, this.size.height);
    };
    VScroll.prototype.draw = function () { };
    return VScroll;
}(container_Container));


// CONCATENATED MODULE: ./engine/renderable/impl/ui/abstract/scrollableContainer.ts





var scrollableContainer_ScrollInfo = (function () {
    function ScrollInfo(game) {
        this.game = game;
        this.offset = 0;
        this.scrollHeight = 0;
        this._scrollVelocity = 0;
        this._deceleration = 0;
        this._enabled = false;
    }
    ScrollInfo.prototype.setEnabled = function (val) {
        this._enabled = val;
        this.vScroll.enabled = val;
    };
    ScrollInfo.prototype.onScroll = function () {
        this.vScroll.maxValue = this.scrollHeight;
        this.vScroll.value = this.offset;
        this.vScroll.onGeometryChanged();
    };
    ScrollInfo.prototype.listenScroll = function (container) {
        var _this = this;
        this._container = container;
        container.on(MOUSE_EVENTS.mouseDown, function (p) {
            _this._lastPoint = {
                point: p,
                time: Date.now()
            };
            _this._prevPoint = {
                point: _this._lastPoint.point,
                time: _this._lastPoint.time
            };
            _this._scrollVelocity = 0;
            _this._deceleration = 0;
        });
        container.on(MOUSE_EVENTS.mouseMove, function (p) {
            if (!p.isMouseDown)
                return;
            var lastPoint = _this._lastPoint;
            _this._lastPoint = {
                point: p,
                time: Date.now()
            };
            if (!lastPoint)
                lastPoint = _this._lastPoint;
            _this._prevPoint = {
                point: lastPoint.point,
                time: lastPoint.time,
            };
            _this.offset -=
                _this._lastPoint.point.screenY - _this._prevPoint.point.screenY;
            if (_this.offset > _this.scrollHeight - _this._container.size.height)
                _this.offset = _this.scrollHeight - _this._container.size.height;
            if (_this.offset < 0)
                _this.offset = 0;
            _this.onScroll();
        });
        container.on(MOUSE_EVENTS.scroll, function (p) {
            _this._scrollVelocity = -p.nativeEvent.wheelDelta;
            _this._deceleration = 0;
        });
        container.on(MOUSE_EVENTS.mouseUp, function (p) {
            if (!_this._lastPoint)
                return;
            if (!_this._prevPoint)
                return;
            if (_this._lastPoint.time === _this._prevPoint.time) {
                _this._scrollVelocity = 0;
            }
            else if (Date.now() - _this._lastPoint.time > 100) {
                _this._scrollVelocity = 0;
            }
            else {
                _this._scrollVelocity = 1000 *
                    (_this._prevPoint.point.screenY - _this._lastPoint.point.screenY) /
                    (_this._lastPoint.time - _this._prevPoint.time);
            }
            _this._deceleration = 0;
        });
        this._initScrollBar();
    };
    ScrollInfo.prototype.getContainerSize = function () {
        return this._container.size;
    };
    ScrollInfo.prototype.update = function () {
        if (!this._enabled)
            return;
        if (this._scrollVelocity)
            this.onScroll();
        var delta = this.game.getDeltaTime();
        if (this._scrollVelocity) {
            this._scrollBy(this._scrollVelocity * delta / 1000);
        }
        this._deceleration = this._deceleration + 0.5 / delta;
        if (delta > 1000) {
            this._scrollVelocity = 0;
            this._deceleration = 0;
        }
        if (this._scrollVelocity > 0)
            this._scrollVelocity -= this._deceleration;
        else if (this._scrollVelocity < 0)
            this._scrollVelocity += this._deceleration;
        if (mathEx_MathEx.closeTo(this._scrollVelocity, 0, 3)) {
            this._scrollVelocity = 0;
            this._deceleration = 0;
        }
    };
    ScrollInfo.prototype._initScrollBar = function () {
        this.vScroll = new vScroll_VScroll(this.game);
        this.vScroll.size.width = 5;
        this._container.appendChild(this.vScroll);
    };
    ScrollInfo.prototype._scrollBy = function (val) {
        this.offset += val;
        if (this.offset > this.scrollHeight - this._container.size.height) {
            this.offset = this.scrollHeight - this._container.size.height;
            this._scrollVelocity = 0;
            this._deceleration = 0;
        }
        if (this.offset < 0) {
            this.offset = 0;
            this._scrollVelocity = 0;
            this._deceleration = 0;
        }
        this.onScroll();
    };
    return ScrollInfo;
}());

var scrollableContainer_ScrollableContainer = (function (_super) {
    __extends(ScrollableContainer, _super);
    function ScrollableContainer(game) {
        return _super.call(this, game) || this;
    }
    ScrollableContainer.prototype.getSideScrollSize = function () {
        return this.vScrollInfo.getContainerSize();
    };
    ScrollableContainer.prototype.update = function () {
        if (this.vScrollInfo)
            this.vScrollInfo.update();
        _super.prototype.update.call(this);
    };
    ScrollableContainer.prototype._initScrolling = function (desc) {
        if (desc.vertical) {
            this.vScrollInfo = new scrollableContainer_ScrollInfo(this.game);
            this.vScrollInfo.listenScroll(this);
        }
    };
    ScrollableContainer.prototype.updateScrollSize = function (desireableHeight, allowedHeight) {
        if (!this.vScrollInfo)
            return;
        if (allowedHeight !== 0 && desireableHeight > allowedHeight) {
            this.vScrollInfo.scrollHeight = desireableHeight;
            this.vScrollInfo.setEnabled(true);
        }
        else {
            this.vScrollInfo.setEnabled(false);
        }
        this.vScrollInfo.vScroll.size.height = allowedHeight;
        this.vScrollInfo.vScroll.pos.x = this.size.width - this.vScrollInfo.vScroll.size.width - 2;
        this.vScrollInfo.onScroll();
    };
    return ScrollableContainer;
}(container_Container));


// CONCATENATED MODULE: ./engine/renderable/impl/ui/components/textField.ts







var SPACE = ' ';
var textField_TextInfo = (function () {
    function TextInfo(textField) {
        this.textField = textField;
        this.allCharsCached = [];
        this.size = new size_Size();
        this.pos = new point2d_Point2d();
        this.strings = [];
    }
    TextInfo.prototype.reset = function () {
        this.allCharsCached = [];
        this.strings = [];
        this.pos.setXY(this.textField.paddingLeft, this.textField.paddingTop);
    };
    TextInfo.prototype.newString = function () {
        this.pos.x = this.textField.paddingLeft;
        if (this.strings.length) {
            this.pos.y += this.textField.getFont().fontContext.lineHeight;
        }
        this.strings.push(new textField_StringInfo());
    };
    TextInfo.prototype.addChar = function (c) {
        this.strings[this.strings.length - 1].chars.push(c);
        this.allCharsCached.push(c);
        c.destRect.setPoint(this.pos);
        c.destRect.addXY(c.destOffsetX, c.destOffsetY);
        this.pos.addX(c.sourceRect.width + c.destOffsetX);
    };
    TextInfo.prototype.addWord = function (w) {
        for (var _i = 0, _a = w.chars; _i < _a.length; _i++) {
            var c = _a[_i];
            this.addChar(c);
        }
    };
    TextInfo.prototype.revalidate = function (defaultSymbolHeight) {
        this.size.setWH(this.textField.paddingLeft + this.textField.paddingRight, this.textField.paddingTop + this.textField.paddingBottom);
        for (var _i = 0, _a = this.strings; _i < _a.length; _i++) {
            var s = _a[_i];
            s.calcSize(defaultSymbolHeight);
            this.size.height += s.height;
            if (s.width > this.size.width)
                this.size.width = s.width;
        }
    };
    TextInfo.prototype.align = function (textAlign) {
        for (var _i = 0, _a = this.strings; _i < _a.length; _i++) {
            var s = _a[_i];
            s.align(textAlign, this.textField);
        }
    };
    return TextInfo;
}());
var textField_CharInfo = (function () {
    function CharInfo() {
        this.destRect = new rect_Rect();
        this.sourceRect = new rect_Rect();
        this.destOffsetX = 0;
        this.destOffsetY = 0;
    }
    return CharInfo;
}());
var CharsHolder = (function () {
    function CharsHolder() {
        this.chars = [];
    }
    CharsHolder.prototype.moveBy = function (dx, dy) {
        for (var _i = 0, _a = this.chars; _i < _a.length; _i++) {
            var ch = _a[_i];
            ch.destRect.addXY(dx, dy);
        }
    };
    CharsHolder.prototype.moveTo = function (x, y) {
        var initialOffsetX = 0;
        for (var _i = 0, _a = this.chars; _i < _a.length; _i++) {
            var ch = _a[_i];
            ch.destRect.setXY(initialOffsetX + x, y);
            initialOffsetX += ch.sourceRect.width;
        }
    };
    return CharsHolder;
}());
var textField_WordInfo = (function (_super) {
    __extends(WordInfo, _super);
    function WordInfo() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.width = 0;
        return _this;
    }
    WordInfo.prototype.revalidate = function () {
        this.width = 0;
        for (var _i = 0, _a = this.chars; _i < _a.length; _i++) {
            var ch = _a[_i];
            this.width += ch.destRect.width;
        }
    };
    WordInfo.prototype.addChar = function (c) {
        this.chars.push(c);
        this.width += c.sourceRect.width;
    };
    return WordInfo;
}(CharsHolder));
var textField_StringInfo = (function (_super) {
    __extends(StringInfo, _super);
    function StringInfo() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.width = 0;
        _this.height = 0;
        return _this;
    }
    StringInfo.prototype.calcSize = function (defaultSymbolHeight) {
        this.width = 0;
        this.height = defaultSymbolHeight;
        for (var _i = 0, _a = this.chars; _i < _a.length; _i++) {
            var ch = _a[_i];
            this.width += ch.sourceRect.width;
        }
    };
    StringInfo.prototype.align = function (textAlign, textField) {
        var AVAILABLE_WIDTH = textField.size.width - textField.paddingLeft - textField.paddingRight;
        switch (textAlign) {
            case 0:
                break;
            case 2:
                var offset = AVAILABLE_WIDTH - this.width;
                if (offset < 0)
                    return;
                offset /= 2;
                this.moveBy(offset, 0);
                break;
            case 1:
                offset = AVAILABLE_WIDTH - this.width;
                if (offset < 0)
                    return;
                this.moveBy(offset, 0);
                break;
            case 3:
                var words = this.toWords();
                if (words.length <= 1)
                    return;
                if (!words[0].chars.length)
                    return;
                var totalWordsWidth = 0;
                for (var _i = 0, words_1 = words; _i < words_1.length; _i++) {
                    var w = words_1[_i];
                    w.revalidate();
                    totalWordsWidth += w.width;
                }
                var totalSpaceWidth = AVAILABLE_WIDTH - totalWordsWidth;
                var oneSpaceWidth = totalSpaceWidth / (words.length - 1);
                if (oneSpaceWidth > textField.getFont().fontContext.lineHeight * 2)
                    return;
                var initialPosY = this.chars[0].destRect.y;
                var currXPointer = this.chars[0].destRect.x;
                for (var _a = 0, words_2 = words; _a < words_2.length; _a++) {
                    var w = words_2[_a];
                    w.moveTo(currXPointer, initialPosY);
                    currXPointer += w.width + oneSpaceWidth;
                }
                break;
            default:
                if (true)
                    throw new debugError_DebugError("unknown TEXT_ALIGN value: " + textAlign);
        }
    };
    StringInfo.prototype.toWords = function () {
        var res = [];
        var currWord = new textField_WordInfo();
        for (var _i = 0, _a = this.chars; _i < _a.length; _i++) {
            var ch = _a[_i];
            if (ch.symbol === SPACE) {
                if (currWord.chars.length) {
                    res.push(currWord);
                    currWord = new textField_WordInfo();
                }
            }
            else {
                currWord.chars.push(ch);
            }
        }
        if (res.indexOf(currWord) === -1)
            res.push(currWord);
        return res;
    };
    return StringInfo;
}(CharsHolder));
var textField_TextField = (function (_super) {
    __extends(TextField, _super);
    function TextField(game) {
        var _this = _super.call(this, game) || this;
        _this.type = 'TextField';
        _this.textAlign = 0;
        _this.wordBreak = 0;
        _this._text = '';
        _this._textInfo = new textField_TextInfo(_this);
        _this._symbolImage = new image_Image(_this.game);
        _this._initScrolling({ vertical: true });
        return _this;
    }
    TextField.prototype.revalidate = function () {
        _super.prototype.revalidate.call(this);
        if ( true && !this._font)
            throw new debugError_DebugError("font is not provided");
        this._font.revalidate();
    };
    TextField.prototype.onGeometryChanged = function () {
        var textInfo = this._textInfo;
        textInfo.reset();
        textInfo.newString();
        var text = this._text;
        if (this.wordBreak === 1) {
            text = text.split('\n').map(function (str) { return str.trim(); }).join(' ');
        }
        var strings = text.split('\n');
        var MAX_WIDTH = this.maxWidth - this.paddingLeft - this.paddingRight;
        for (var i = 0; i < strings.length; i++) {
            var str = strings[i];
            if (this.wordBreak === 0) {
                var wordInfo = new textField_WordInfo();
                for (var k = 0; k < str.length; k++) {
                    var charInfo = this._getCharInfo(str[k]);
                    wordInfo.addChar(charInfo);
                }
                textInfo.addWord(wordInfo);
            }
            else {
                var words = str.split(SPACE);
                for (var j = 0; j < words.length; j++) {
                    var w = words[j];
                    var wordInfo = new textField_WordInfo();
                    for (var k = 0; k < w.length; k++) {
                        var charInfo = this._getCharInfo(w[k]);
                        wordInfo.addChar(charInfo);
                    }
                    if (this.maxWidth && textInfo.pos.x + wordInfo.width > MAX_WIDTH && i < words.length - 1) {
                        textInfo.newString();
                    }
                    textInfo.addWord(wordInfo);
                    if (i < str.length - 1) {
                        var spaceChar = this._getCharInfo(SPACE);
                        textInfo.addChar(spaceChar);
                    }
                }
            }
            if (i < strings.length - 1) {
                textInfo.newString();
            }
        }
        textInfo.revalidate(this._font.fontContext.lineHeight);
        this.size.width = textInfo.size.width;
        if (this.maxHeight !== 0 && textInfo.size.height > this.maxHeight) {
            this.size.height = this.maxHeight;
        }
        else {
            this.size.height = textInfo.size.height;
        }
        textInfo.align(this.textAlign);
        this.updateScrollSize(textInfo.size.height, this.size.height);
        _super.prototype.onGeometryChanged.call(this);
    };
    TextField.prototype.setText = function (text) {
        if (text === void 0) { text = ''; }
        this._text = text + '';
        this.setDirty();
    };
    TextField.prototype.setTextAlign = function (ta) {
        this.textAlign = ta;
        this.setDirty();
    };
    TextField.prototype.setWordBreak = function (wb) {
        this.wordBreak = wb;
        this.setDirty();
    };
    TextField.prototype.getText = function () {
        return this._text;
    };
    TextField.prototype.setFont = function (font) {
        this._font = font;
        this.setDirty();
    };
    TextField.prototype.getFont = function () {
        return this._font;
    };
    TextField.prototype.draw = function () {
        if (this.background)
            this.background.render();
        var renderer = this.game.getRenderer();
        renderer.transformSave();
        if (this.vScrollInfo.offset)
            renderer.transformTranslate(0, -this.vScrollInfo.offset, 0);
        this._symbolImage.setResourceLink(this._font.getResourceLink());
        for (var _i = 0, _a = this._textInfo.allCharsCached; _i < _a.length; _i++) {
            var charInfo = _a[_i];
            if (charInfo.destRect.y - this.vScrollInfo.offset > this.size.height)
                continue;
            if (charInfo.destRect.y + charInfo.destRect.height - this.vScrollInfo.offset < 0)
                continue;
            this._symbolImage.getSrcRect().set(charInfo.sourceRect);
            this._symbolImage.size.setWH(charInfo.sourceRect.width, charInfo.sourceRect.height);
            this._symbolImage.pos.setXY(charInfo.destRect.x, charInfo.destRect.y);
            if (this._symbolImage.size.height === 0)
                continue;
            this._symbolImage.render();
        }
        renderer.transformRestore();
    };
    TextField.prototype._getDefaultSymbolRect = function () {
        var defaultChar = SPACE;
        if (!this._font.fontContext.symbols[SPACE]) {
            var firstSymbol = Object.keys(this._font.fontContext.symbols)[0];
            if ( true && !firstSymbol)
                throw new debugError_DebugError("no symbols in font");
            defaultChar = firstSymbol;
        }
        return this._font.fontContext.symbols[defaultChar];
    };
    TextField.prototype._getCharInfo = function (c) {
        var charRect = this._font.fontContext.symbols[c] || this._getDefaultSymbolRect();
        var charInfo = new textField_CharInfo();
        charInfo.symbol = c;
        charInfo.sourceRect = new rect_Rect();
        charInfo.sourceRect.fromJSON(charRect);
        charInfo.destRect.setWH(charRect.width, charRect.height);
        charInfo.destOffsetX = charRect.destOffsetX;
        charInfo.destOffsetY = charRect.destOffsetY;
        return charInfo;
    };
    return TextField;
}(scrollableContainer_ScrollableContainer));


// CONCATENATED MODULE: ./engine/resources/resourceLink.ts
var ResourceLink = (function () {
    function ResourceLink(url) {
        this.url = url;
    }
    ResourceLink.create = function (target) {
        var url = 'url' + Math.random() + '_' + Math.random();
        var link = new ResourceLink(url);
        link.setTarget(target);
        return link;
    };
    ResourceLink.prototype.getUrl = function () {
        return this.url;
    };
    ResourceLink.prototype.setTarget = function (t) {
        this.target = t;
    };
    ResourceLink.prototype.getTarget = function () {
        return this.target;
    };
    return ResourceLink;
}());


// CONCATENATED MODULE: ./engine/resources/queue.ts


var queue_TaskRef = (function () {
    function TaskRef() {
        this.id = Incrementer.getValue();
    }
    return TaskRef;
}());

var queue_Queue = (function () {
    function Queue() {
        this.tasksResolved = 0;
        this.tasks = [];
        this.tasksProgressById = {};
        this.completed = false;
        this.nextTaskIndex = 0;
        this.currProgress = 0;
    }
    Queue.prototype.progressTask = function (taskRef, progress) {
        if (progress === 1)
            return;
        var taskId = taskRef.id;
        this.tasksProgressById[taskId] = progress;
        if (this.onProgress)
            this.onProgress(this.calcProgress());
    };
    Queue.prototype.resolveTask = function (taskRef) {
        var taskId = taskRef.id;
        if (true) {
            if (this.tasksProgressById[taskId] === undefined)
                throw new debugError_DebugError("can not resolve task: no task with id " + taskId);
            if (this.tasksProgressById[taskId] === 1)
                throw new debugError_DebugError("task with id " + taskId + " resolved already");
        }
        this.tasksResolved++;
        this.tasksProgressById[taskId] = 1;
        if (this.tasks.length === this.tasksResolved) {
            if (this.onProgress)
                this.onProgress(1);
            this.completed = true;
            if (this.onResolved)
                this.onResolved();
        }
        else {
            if (this.onProgress)
                this.onProgress(this.calcProgress());
            this.tasks[this.nextTaskIndex++]();
        }
    };
    Queue.prototype.addTask = function (taskFn) {
        var taskRef = new queue_TaskRef();
        this.tasks.push(taskFn);
        this.tasksProgressById[taskRef.id] = 0;
        return taskRef;
    };
    Queue.prototype.isCompleted = function () {
        return this.completed;
    };
    Queue.prototype.calcProgress = function () {
        var _this = this;
        var sum = 0;
        Object.keys(this.tasksProgressById).forEach(function (taskId) {
            sum += _this.tasksProgressById[taskId] || 0;
        });
        var progress = sum / this.tasks.length;
        if (progress > this.currProgress)
            this.currProgress = progress;
        return this.currProgress;
    };
    Queue.prototype.start = function () {
        if (this.size() === 0) {
            this.completed = true;
            if (this.onResolved)
                this.onResolved();
        }
        else {
            this.tasks[this.nextTaskIndex++]();
        }
    };
    Queue.prototype.size = function () {
        return this.tasks.length;
    };
    return Queue;
}());


// CONCATENATED MODULE: ./engine/resources/urlLoader.ts

var addUrlParameter = function (url, param, value) {
    if (url.indexOf('?') > -1)
        url += '&';
    else
        url += '?';
    return "" + url + param + "=" + value;
};
var loadBase64 = function (urlRequest) {
    return Promise.resolve(urlRequest.url);
};
var loadViaXmlHttp = function (urlRequest, onProgress) {
    if (!urlRequest.method)
        urlRequest.method = 'GET';
    var xhr = new XMLHttpRequest();
    xhr.open(urlRequest.method, addUrlParameter(urlRequest.url, 'modified', 1589043571594), true);
    xhr.responseType = urlRequest.responseType;
    if (xhr.responseType === 'blob') {
        xhr.setRequestHeader('Accept-Ranges', 'bytes');
        xhr.setRequestHeader('Content-Range', 'bytes');
    }
    if (urlRequest.headers) {
        for (var _i = 0, _a = urlRequest.headers; _i < _a.length; _i++) {
            var header = _a[_i];
            xhr.setRequestHeader(header.name, header.value);
        }
    }
    return new Promise(function (resolve, reject) {
        xhr.onload = function () {
            if (xhr.readyState === 4) {
                if (xhr.status === 200) {
                    resolve(xhr.response);
                }
                else {
                    var message =  true ? "can not load resource with url '" + urlRequest.url + "', status " + xhr.status : undefined;
                    reject(message);
                }
            }
        };
        if (onProgress) {
            xhr.onprogress = function (e) {
                onProgress(e.loaded / e.total);
            };
        }
        xhr.onerror = function (e) {
            console.error(e);
            var rejectError =  true ? "can not load resource with url " + urlRequest.url : undefined;
            reject(rejectError);
        };
        xhr.ontimeout = function (e) {
            console.error(e);
            var rejectError =  true ? "can not load resource with url " + urlRequest.url : undefined;
            reject(rejectError);
        };
        xhr.send();
    });
};
var urlLoader_UrlLoader = (function () {
    function UrlLoader(urlRequest) {
        this.urlRequest = urlRequest;
    }
    UrlLoader.prototype.getUrl = function () {
        return this.urlRequest.url;
    };
    UrlLoader.prototype.load = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                if (this.getUrl().indexOf('data:') === 0)
                    return [2, loadBase64(this.urlRequest)];
                else
                    return [2, loadViaXmlHttp(this.urlRequest, this.onProgress)];
                return [2];
            });
        });
    };
    return UrlLoader;
}());


// CONCATENATED MODULE: ./engine/resources/resourceUtil.ts


var resourceUtil_ResourceUtil;
(function (ResourceUtil) {
    var _this = this;
    var loadArrayBuffer = function (req, q, taskRef) { return __awaiter(_this, void 0, void 0, function () {
        var iReq, loader;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    if (req.substr !== undefined) {
                        iReq = { url: req, responseType: 'arraybuffer', method: 'GET' };
                    }
                    else
                        iReq = req;
                    loader = new urlLoader_UrlLoader(iReq);
                    loader.onProgress = function (n) { return q.progressTask(taskRef, n); };
                    return [4, loader.load()];
                case 1: return [2, _a.sent()];
            }
        });
    }); };
    var createBitmapFromBlob = function (imgBlob) { return __awaiter(_this, void 0, void 0, function () {
        return __generator(this, function (_a) {
            return [2, globalThis.createImageBitmap(imgBlob)];
        });
    }); };
    var createHTMLImageFromUrl = function (imgUrl) { return __awaiter(_this, void 0, void 0, function () {
        var url;
        return __generator(this, function (_a) {
            url = imgUrl.url ? imgUrl.url : imgUrl;
            return [2, new Promise(function (resolve, reject) {
                    var img = new window.Image();
                    img.src = url;
                    img.onload = function () {
                        resolve(img);
                    };
                    img.onerror = function (e) {
                        console.error(e);
                        var msg =  true ? "can not create image. Bad url data: " + url : undefined;
                        reject(msg);
                    };
                })];
        });
    }); };
    ResourceUtil.createImageFromData = function (imageData, q, taskRef) { return __awaiter(_this, void 0, void 0, function () {
        var isBase64, arrayBuffer, arrayBufferView, imgBlob;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    isBase64 = imageData.substr !== undefined && imageData.indexOf('data:image/') === 0;
                    if (!isBase64) return [3, 2];
                    return [4, createHTMLImageFromUrl(imageData)];
                case 1: return [2, _a.sent()];
                case 2:
                    if (!(globalThis.createImageBitmap === undefined)) return [3, 4];
                    return [4, createHTMLImageFromUrl(imageData)];
                case 3: return [2, _a.sent()];
                case 4: return [4, loadArrayBuffer(imageData, q, taskRef)];
                case 5:
                    arrayBuffer = _a.sent();
                    arrayBufferView = new Uint8Array(arrayBuffer);
                    imgBlob = new Blob([arrayBufferView]);
                    return [4, createBitmapFromBlob(imgBlob)];
                case 6: return [2, _a.sent()];
            }
        });
    }); };
})(resourceUtil_ResourceUtil || (resourceUtil_ResourceUtil = {}));

// CONCATENATED MODULE: ./engine/resources/resourceLoader.ts





var createImageFromData = resourceUtil_ResourceUtil.createImageFromData;
var resourceCache;
(function (resourceCache) {
    resourceCache.cache = {};
    resourceCache.clear = function () {
        var keys = Object.keys(resourceCache.cache);
        keys.forEach(function (k) { return delete resourceCache.cache[k]; });
    };
})(resourceCache || (resourceCache = {}));
var resourceLoader_ResourceLoader = (function () {
    function ResourceLoader(game) {
        this.game = game;
        this.q = new queue_Queue();
        this.game = game;
    }
    ResourceLoader.createUrlLoader = function (req, responseType) {
        if (responseType === void 0) { responseType = 'text'; }
        var iReq;
        if (req.substr !== undefined) {
            iReq = { url: req, responseType: responseType, method: 'GET' };
        }
        else
            iReq = req;
        return new urlLoader_UrlLoader(iReq);
    };
    ResourceLoader.prototype.loadTexture = function (req) {
        var _this = this;
        var _a, _b;
        var link = new ResourceLink(req);
        if (resourceCache.cache[(_a = req.url) !== null && _a !== void 0 ? _a : req] !== undefined) {
            link.setTarget(resourceCache.cache[(_b = req.url) !== null && _b !== void 0 ? _b : req]);
            return link;
        }
        var taskRef = this.q.addTask(function () { return __awaiter(_this, void 0, void 0, function () {
            var img, texture, e_1;
            var _a;
            return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        _b.trys.push([0, 2, , 3]);
                        return [4, createImageFromData(req, this.q, taskRef)];
                    case 1:
                        img = _b.sent();
                        texture = this.game.getRenderer().createTexture(img);
                        link.setTarget(texture);
                        resourceCache.cache[(_a = req.url) !== null && _a !== void 0 ? _a : req] = texture;
                        console.log(resourceCache.cache);
                        this.q.resolveTask(taskRef);
                        return [3, 3];
                    case 2:
                        e_1 = _b.sent();
                        console.error(e_1);
                        throw e_1;
                    case 3: return [2];
                }
            });
        }); });
        return link;
    };
    ResourceLoader.prototype.loadCubeTexture = function (leftSide, rightSide, topSide, bottomSide, frontSide, backSide) {
        var _this = this;
        var link = new ResourceLink('');
        var taskRef = this.q.addTask(function () { return __awaiter(_this, void 0, void 0, function () {
            var imgLeft, imgRight, imgTop, imgBottom, imgFront, imgBack, texture;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4, createImageFromData(leftSide, this.q, taskRef)];
                    case 1:
                        imgLeft = _a.sent();
                        return [4, createImageFromData(rightSide, this.q, taskRefsAdditionals[0])];
                    case 2:
                        imgRight = _a.sent();
                        this.q.resolveTask(taskRefsAdditionals[0]);
                        return [4, createImageFromData(topSide, this.q, taskRefsAdditionals[1])];
                    case 3:
                        imgTop = _a.sent();
                        this.q.resolveTask(taskRefsAdditionals[1]);
                        return [4, createImageFromData(bottomSide, this.q, taskRefsAdditionals[2])];
                    case 4:
                        imgBottom = _a.sent();
                        this.q.resolveTask(taskRefsAdditionals[2]);
                        return [4, createImageFromData(frontSide, this.q, taskRefsAdditionals[3])];
                    case 5:
                        imgFront = _a.sent();
                        this.q.resolveTask(taskRefsAdditionals[3]);
                        return [4, createImageFromData(backSide, this.q, taskRefsAdditionals[4])];
                    case 6:
                        imgBack = _a.sent();
                        this.q.resolveTask(taskRefsAdditionals[4]);
                        texture = this.game.getRenderer().createCubeTexture(imgLeft, imgRight, imgTop, imgBottom, imgFront, imgBack);
                        link.setTarget(texture);
                        this.q.resolveTask(taskRef);
                        return [2];
                }
            });
        }); });
        var taskRefsAdditionals = new Array(5);
        for (var i = 0; i < taskRefsAdditionals.length; i++) {
            taskRefsAdditionals[i] = (this.q.addTask(function () { }));
        }
        return link;
    };
    ResourceLoader.prototype.loadText = function (req) {
        return this._loadAndProcessText(req, function (t) { return t; });
    };
    ResourceLoader.prototype.loadJSON = function (req) {
        var postPrecessFn = function (t) { return JSON.parse(t); };
        return this._loadAndProcessText(req, postPrecessFn);
    };
    ResourceLoader.prototype.loadSound = function (req) {
        var _this = this;
        var loader = ResourceLoader.createUrlLoader(req, 'arraybuffer');
        var link = new ResourceLink(loader.getUrl());
        var taskRef = this.q.addTask(function () { return __awaiter(_this, void 0, void 0, function () {
            var buff, e_2;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        _a.trys.push([0, 3, , 4]);
                        return [4, loader.load()];
                    case 1:
                        buff = _a.sent();
                        return [4, this.game.getAudioPlayer().loadSound(buff, link)];
                    case 2:
                        _a.sent();
                        this.q.resolveTask(taskRef);
                        return [3, 4];
                    case 3:
                        e_2 = _a.sent();
                        console.error(e_2);
                        throw e_2;
                    case 4: return [2];
                }
            });
        }); });
        loader.onProgress = function (n) { return _this.q.progressTask(taskRef, n); };
        return link;
    };
    ResourceLoader.prototype.loadBinary = function (req) {
        var _this = this;
        var loader = ResourceLoader.createUrlLoader(req, 'arraybuffer');
        var link = new ResourceLink(loader.getUrl());
        loader.onProgress = function (n) { return _this.q.progressTask(taskRef, n); };
        var taskRef = this.q.addTask(function () { return __awaiter(_this, void 0, void 0, function () {
            var buff, e_3;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        _a.trys.push([0, 2, , 3]);
                        return [4, loader.load()];
                    case 1:
                        buff = _a.sent();
                        link.setTarget(buff);
                        this.q.resolveTask(taskRef);
                        return [3, 3];
                    case 2:
                        e_3 = _a.sent();
                        console.error(e_3);
                        throw e_3;
                    case 3: return [2];
                }
            });
        }); });
        return link;
    };
    ResourceLoader.prototype.addNextTask = function (task) {
        var _this = this;
        var taskRef = this.q.addTask(function () {
            task();
            _this.q.resolveTask(taskRef);
        });
    };
    ResourceLoader.prototype.clearCache = function () {
        resourceCache.clear();
    };
    ResourceLoader.prototype.startLoading = function () {
        this.q.start();
    };
    ResourceLoader.prototype.isCompleted = function () {
        return this.q.isCompleted();
    };
    ResourceLoader.prototype.getProgress = function () {
        return this.q.calcProgress();
    };
    ResourceLoader.prototype.onProgress = function (fn) {
        this.q.onProgress = fn;
    };
    ResourceLoader.prototype.onCompleted = function (fn) {
        this.q.onResolved = fn;
    };
    ResourceLoader.prototype._loadAndProcessText = function (req, postProcess) {
        var _this = this;
        var url = req.url ? req.url : req;
        var link = new ResourceLink(url);
        var loader = ResourceLoader.createUrlLoader(req);
        loader.onProgress = function (n) { return _this.q.progressTask(taskRef, n); };
        var taskRef = this.q.addTask(function () { return __awaiter(_this, void 0, void 0, function () {
            var text, data, e_4;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        _a.trys.push([0, 2, , 3]);
                        return [4, loader.load()];
                    case 1:
                        text = _a.sent();
                        data = postProcess(text);
                        link.setTarget(data);
                        this.q.resolveTask(taskRef);
                        return [3, 3];
                    case 2:
                        e_4 = _a.sent();
                        console.error(e_4);
                        throw e_4;
                    case 3: return [2];
                }
            });
        }); });
        return link;
    };
    return ResourceLoader;
}());


// CONCATENATED MODULE: ./engine/renderable/impl/general/font.ts




var getCtx = function (cnv) {
    return cnv.getContext('2d');
};
var FontFactory;
(function (FontFactory) {
    var SYMBOL_PADDING = 4;
    var getFontHeight = function (strFont) {
        var parent = document.createElement("span");
        parent.appendChild(document.createTextNode("height!ДдЙЇ"));
        document.body.appendChild(parent);
        parent.style.cssText = "font: " + strFont + "; white-space: nowrap; display: inline-block;";
        var height = parent.offsetHeight;
        document.body.removeChild(parent);
        return height;
    };
    FontFactory.getFontContext = function (arrFromTo, strFont, w) {
        var cnv = document.createElement('canvas');
        var ctx = getCtx(cnv);
        ctx.font = strFont;
        var lineHeight = getFontHeight(strFont) + 2 * SYMBOL_PADDING;
        var symbols = {};
        var currX = 0, currY = 0, cnvHeight = lineHeight;
        for (var k = 0; k < arrFromTo.length; k++) {
            var arrFromToCurr = arrFromTo[k];
            for (var i = arrFromToCurr.from; i < arrFromToCurr.to; i++) {
                var currentChar = String.fromCharCode(i);
                var context2D = cnv.getContext('2d');
                var textWidth = context2D.measureText(currentChar).width;
                textWidth += 2 * SYMBOL_PADDING;
                if (textWidth === 0)
                    continue;
                if (currX + textWidth > w) {
                    currX = 0;
                    currY += lineHeight;
                    cnvHeight = currY + lineHeight;
                }
                var symbolRect = {};
                symbolRect.x = ~~currX + SYMBOL_PADDING;
                symbolRect.y = ~~currY + SYMBOL_PADDING;
                symbolRect.width = ~~textWidth - 2 * SYMBOL_PADDING;
                symbolRect.height = lineHeight - 2 * SYMBOL_PADDING;
                symbolRect.destOffsetX = symbolRect.destOffsetY = 0;
                symbols[currentChar] = symbolRect;
                currX += textWidth;
            }
        }
        return { symbols: symbols, width: w, height: cnvHeight, lineHeight: lineHeight - 2 * SYMBOL_PADDING };
    };
    var correctColor = function (canvas, color) {
        var _a = color.toJSON(), r = _a.r, g = _a.g, b = _a.b, a = _a.a;
        var ctx = getCtx(canvas);
        var imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
        var clamped = imgData.data;
        for (var i = 0; i < clamped.length; i += 4) {
            var rIndex = i;
            var gIndex = i + 1;
            var bIndex = i + 2;
            var aIndex = i + 3;
            var avg = (clamped[rIndex] + clamped[gIndex] + clamped[bIndex] + clamped[aIndex]) / 4;
            if (avg < 0) {
            }
            else {
                clamped[rIndex] = r;
                clamped[gIndex] = g;
                clamped[bIndex] = b;
                clamped[aIndex] = ~~(clamped[aIndex] * a / 255);
            }
        }
        ctx.putImageData(imgData, 0, 0);
    };
    FontFactory.getFontImageBase64 = function (fontContext, strFont, color) {
        var cnv = document.createElement('canvas');
        cnv.width = fontContext.width;
        cnv.height = fontContext.height;
        var ctx = getCtx(cnv);
        ctx.font = strFont;
        ctx.textBaseline = "top";
        ctx.imageSmoothingEnabled = false;
        ctx.mozImageSmoothingEnabled = false;
        ctx.webkitImageSmoothingEnabled = false;
        ctx.msImageSmoothingEnabled = false;
        ctx.oImageSmoothingEnabled = false;
        ctx.fillStyle = 'rgba(0,0,0,0)';
        ctx.fillRect(0, 0, cnv.width, cnv.height);
        ctx.fillStyle = '#fff';
        var symbols = fontContext.symbols;
        Object.keys(symbols).forEach(function (symbol) {
            var rect = symbols[symbol];
            ctx.fillText(symbol, rect.x, rect.y);
        });
        correctColor(cnv, color);
        return cnv.toDataURL();
    };
})(FontFactory || (FontFactory = {}));
var font_Font = (function () {
    function Font(game) {
        this.game = game;
        this.type = 'Font';
        this.fontSize = 12;
        this.fontFamily = 'Monospace';
        this.fontColor = color_Color.BLACK.clone();
    }
    Font.getSystemFont = function () {
        if (Font._systemFontInstance)
            return Font._systemFontInstance;
        var f = new Font(game_Game.getInstance());
        f.fontFamily = 'monospace';
        f.fontSize = 12;
        f.createContext();
        var resourceLoader = new resourceLoader_ResourceLoader(game_Game.getInstance());
        var link = resourceLoader.loadTexture(f.createBitmap());
        resourceLoader.startLoading();
        f.setResourceLink(link);
        Font._systemFontInstance = f;
        return f;
    };
    Font.fromAtlas = function (game, link, fontContext) {
        var fnt = new Font(game);
        fnt.setResourceLink(link);
        fnt.fontContext = fontContext;
        return fnt;
    };
    Font.prototype.generate = function () {
        this.createContext();
        var base64 = this.createBitmap();
        var link = this.game.getCurrScene().resourceLoader.loadTexture(base64);
        this.setResourceLink(link);
    };
    Font.prototype.asCss = function () {
        return this.fontSize + "px " + this.fontFamily;
    };
    Font.prototype.createContext = function () {
        var ranges = [{ from: 32, to: 126 }, { from: 1040, to: 1116 }];
        var WIDTH = 512;
        this.fontContext = FontFactory.getFontContext(ranges, this.asCss(), WIDTH);
    };
    Font.prototype.createBitmap = function () {
        return FontFactory.getFontImageBase64(this.fontContext, this.asCss(), this.fontColor);
    };
    Font.prototype.revalidate = function () {
        if (true) {
            if (!this.fontContext)
                throw new debugError_DebugError("font context is not created. Did you invoke font.generate() method?");
            if (!this.getResourceLink())
                throw new debugError_DebugError("font without resource link");
        }
    };
    Font.prototype.setResourceLink = function (link) {
        this._resourceLink = link;
    };
    Font.prototype.getResourceLink = function () {
        return this._resourceLink;
    };
    return Font;
}());


// CONCATENATED MODULE: ./engine/renderer/common/alphaBlendStack.ts

var alphaBlendStack_AlphaBlendStack = (function () {
    function AlphaBlendStack() {
        this.stack = new stack_Stack();
        this.stack.push(1);
    }
    AlphaBlendStack.prototype.getCurrentValue = function () {
        return this.stack.getLast();
    };
    AlphaBlendStack.prototype.restore = function () {
        if (this.stack.isEmpty())
            this.stack.push(1);
        else
            this.stack.pop();
    };
    AlphaBlendStack.prototype.save = function () {
        var last = this.stack.getLast();
        this.stack.push(last);
    };
    AlphaBlendStack.prototype.mult = function (alpha) {
        this.setCurrentValue(this.getCurrentValue() * alpha);
    };
    AlphaBlendStack.prototype.setCurrentValue = function (v) {
        this.stack.replaceLast(v);
    };
    return AlphaBlendStack;
}());


// CONCATENATED MODULE: ./engine/renderer/abstract/abstractRenderer.ts





var abstractRenderer_AbstractRenderer = (function () {
    function AbstractRenderer(game) {
        this.game = game;
        this.clearBeforeRender = true;
        this.clearColor = color_Color.RGB(0, 0, 0);
        this.viewPortSize = new size_Size();
        this.alphaBlendStack = new alphaBlendStack_AlphaBlendStack();
        this.fullScreenRequested = false;
        this.game = game;
    }
    AbstractRenderer.prototype.requestFullScreen = function () {
        var _this = this;
        var canRequest = this._requestFullScreen();
        if (canRequest) {
            var fn_1 = function () {
                if (_this.fullScreenRequested)
                    _this._requestFullScreen();
                document.body.removeEventListener('click', fn_1);
            };
            document.body.addEventListener('click', fn_1);
        }
    };
    AbstractRenderer.prototype.cancelFullScreen = function () {
        this.fullScreenRequested = false;
        var doc = globalThis.document;
        if (doc.cancelFullScreen) {
            (doc).cancelFullScreen();
        }
        else if (doc.mozCancelFullScreen) {
            doc.mozCancelFullScreen();
        }
        else if (doc.webkitCancelFullScreen) {
            doc.webkitCancelFullScreen();
        }
    };
    AbstractRenderer.prototype.beforeItemStackDraw = function (filters, forceDrawChildrenOnNewSurface) {
        return undefined;
    };
    AbstractRenderer.prototype.afterItemStackDraw = function (stackPointer) { };
    AbstractRenderer.prototype.beforeFrameDraw = function (filters) {
        return undefined;
    };
    AbstractRenderer.prototype.afterFrameDraw = function (stackPointer) { };
    AbstractRenderer.prototype.destroy = function () {
        globalThis.removeEventListener('resize', this.onResize);
    };
    AbstractRenderer.prototype.killObject = function (r) { };
    AbstractRenderer.prototype.saveAlphaBlend = function () {
        this.alphaBlendStack.save();
    };
    AbstractRenderer.prototype.restoreAlphaBlend = function () {
        this.alphaBlendStack.restore();
    };
    AbstractRenderer.prototype.setAlphaBlend = function (alpha) {
        this.alphaBlendStack.mult(alpha);
    };
    AbstractRenderer.prototype.getAlphaBlend = function () {
        return this.alphaBlendStack.getCurrentValue();
    };
    AbstractRenderer.prototype.log = function () {
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        if (false)
            {}
        var textField = this.debugTextField;
        if (!textField) {
            textField = new textField_TextField(this.game);
            textField.setFont(font_Font.getSystemFont());
            textField.revalidate();
            this.debugTextField = textField;
        }
        textField.setScene(this.game.getCurrScene());
        var res = '';
        Array.prototype.slice.call(arguments).forEach(function (txt) {
            if (txt === undefined)
                txt = 'undefined';
            else if (txt === null)
                txt = 'null';
            else if (txt instanceof HTMLElement) {
                txt = "[object " + txt.tagName + "]";
            }
            else if (txt.toJSON) {
                txt = JSON.stringify(txt.toJSON(), undefined, 4);
            }
            else if (typeof txt === 'function') {
                txt = txt.toString();
            }
            else {
                if (!txt.substr) {
                    try {
                        txt = JSON.stringify(txt);
                    }
                    catch (e) {
                        if (txt.constructor && txt.constructor.name)
                            txt = "[object " + txt.constructor.name + "]";
                        else
                            txt = txt.toString();
                    }
                }
            }
            res += txt + "\n";
        });
        textField.setText(textField.getText() + res);
        textField.onGeometryChanged();
        while (textField.size.height > this.game.size.height) {
            var strings = textField.getText().split('\n');
            strings.shift();
            textField.setText(strings.join('\n'));
            textField.onGeometryChanged();
        }
    };
    AbstractRenderer.prototype.clearLog = function () {
        if (false)
            {}
        if (!this.debugTextField)
            return;
        this.debugTextField.setText('');
    };
    AbstractRenderer.prototype.getHelper = function () {
        return this.rendererHelper;
    };
    AbstractRenderer.prototype.registerResize = function () {
        var _this = this;
        this.onResize();
        globalThis.addEventListener('resize', function () {
            _this.onResize();
            setTimeout(function () { return _this.onResize(); }, 100);
        });
        document.addEventListener('gesturestart', function (e) { return e.preventDefault(); });
        this.container.addEventListener('gesturestart', function (e) { return e.preventDefault(); });
    };
    AbstractRenderer.prototype.onResize = function () {
        var container = this.container;
        var _a = this.getScreenResolution(), innerWidth = _a[0], innerHeight = _a[1];
        if (this.game.scaleStrategy === 0)
            return;
        else if (this.game.scaleStrategy === 2) {
            container.style.width = innerWidth + "px";
            container.style.height = innerHeight + "px";
            this.viewPortSize.setWH(innerWidth, innerHeight);
            this.game.scale.setXY(innerWidth / this.game.size.width, innerHeight / this.game.size.height);
            this.game.pos.setXY(0);
        }
        else {
            var canvasRatio = this.game.size.height / this.game.size.width;
            var windowRatio = innerHeight / innerWidth;
            var width = void 0;
            var height = void 0;
            if (windowRatio < canvasRatio) {
                height = innerHeight;
                width = height / canvasRatio;
            }
            else {
                width = innerWidth;
                height = width * canvasRatio;
            }
            this.game.scale.setXY(width / this.game.size.width, height / this.game.size.height);
            this.game.pos.setXY((innerWidth - width) / 2, (innerHeight - height) / 2);
            this.container.style.width = width + 'px';
            this.container.style.height = height + 'px';
            this.container.style.marginTop = this.game.pos.y + "px";
            this.viewPortSize.setWH(width, height);
        }
    };
    AbstractRenderer.prototype.getScreenResolution = function () {
        return [globalThis.innerWidth, globalThis.innerHeight];
    };
    AbstractRenderer.prototype._requestFullScreen = function () {
        var element = this.container;
        this.fullScreenRequested = true;
        var canRequest = false;
        if (element.requestFullScreen) {
            element.requestFullScreen();
            canRequest = true;
        }
        else if (element.mozRequestFullScreen) {
            element.mozRequestFullScreen();
            canRequest = true;
        }
        else if (element.webkitRequestFullScreen) {
            element.webkitRequestFullScreen();
            canRequest = true;
        }
        return canRequest;
    };
    return AbstractRenderer;
}());


// CONCATENATED MODULE: ./engine/renderer/abstract/abstractCanvasRenderer.ts


var abstractCanvasRenderer_AbstractCanvasRenderer = (function (_super) {
    __extends(AbstractCanvasRenderer, _super);
    function AbstractCanvasRenderer(game) {
        var _this = _super.call(this, game) || this;
        var container = document.createElement('canvas');
        document.body.appendChild(container);
        container.setAttribute('width', game.size.width.toString());
        container.setAttribute('height', game.size.height.toString());
        container.ondragstart = function (e) {
            e.preventDefault();
        };
        _this.container = container;
        return _this;
    }
    return AbstractCanvasRenderer;
}(abstractRenderer_AbstractRenderer));


// EXTERNAL MODULE: ./engine/renderer/webGl/programs/impl/base/mesh/mesh.fragment.glsl
var mesh_fragment = __webpack_require__(3);

// EXTERNAL MODULE: ./engine/renderer/webGl/programs/impl/base/mesh/mesh.vertex.glsl
var mesh_vertex = __webpack_require__(2);

// CONCATENATED MODULE: ./engine/renderer/webGl/programs/impl/base/mesh/meshDrawer.ts







var meshDrawer_MeshDrawer = (function (_super) {
    __extends(MeshDrawer, _super);
    function MeshDrawer(gl) {
        var _this = _super.call(this, gl) || this;
        _this.a_position = 'a_position';
        _this.a_normal = 'a_normal';
        _this.a_texCoord = 'a_texCoord';
        _this.u_modelMatrix = 'u_modelMatrix';
        _this.u_inverseTransposeModelMatrix = 'u_inverseTransposeModelMatrix';
        _this.u_textureMatrix = 'u_textureMatrix';
        _this.u_projectionMatrix = 'u_projectionMatrix';
        _this.u_color = 'u_color';
        _this.u_color_mix = 'u_color_mix';
        _this.u_alpha = 'u_alpha';
        _this.u_reflectivity = 'u_reflectivity';
        _this.u_textureUsed = 'u_textureUsed';
        _this.u_normalsTextureUsed = 'u_normalsTextureUsed';
        _this.u_lightUsed = 'u_lightUsed';
        _this.u_heightMapTextureUsed = 'u_heightMapTextureUsed';
        _this.u_cubeMapTextureUsed = 'u_cubeMapTextureUsed';
        _this.u_heightMapFactor = 'u_heightMapFactor';
        _this.program = new shaderProgram_ShaderProgram(gl, mesh_vertex, mesh_fragment);
        return _this;
    }
    MeshDrawer.prototype.bindModel = function (mesh) {
        this.mesh = mesh;
        if (!this.mesh.bufferInfo)
            this._initBufferInfo(mesh.modelPrimitive.drawMethod, mesh.vertexItemSize);
        if (mesh.isLightAccepted() === undefined) {
            mesh.acceptLight(!!this.mesh.bufferInfo.normalBuffer);
        }
        this.bufferInfo = this.mesh.bufferInfo;
    };
    MeshDrawer.prototype.setModelMatrix = function (m) {
        this.setUniform(this.u_modelMatrix, m);
    };
    MeshDrawer.prototype.setInverseTransposeModelMatrix = function (m) {
        this.setUniform(this.u_inverseTransposeModelMatrix, m);
    };
    MeshDrawer.prototype.setProjectionMatrix = function (m) {
        this.setUniform(this.u_projectionMatrix, m);
    };
    MeshDrawer.prototype.setTextureMatrix = function (m) {
        this.setUniform(this.u_textureMatrix, m);
    };
    MeshDrawer.prototype.setAlfa = function (a) {
        this.setUniform(this.u_alpha, a);
    };
    MeshDrawer.prototype.setReflectivity = function (r) {
        this.setUniform(this.u_reflectivity, r);
    };
    MeshDrawer.prototype.setTextureUsed = function (used) {
        this.setUniform(this.u_textureUsed, used);
    };
    MeshDrawer.prototype.setNormalsTextureUsed = function (used) {
        this.setUniform(this.u_normalsTextureUsed, used);
    };
    MeshDrawer.prototype.setHeightMapTextureUsed = function (used) {
        this.setUniform(this.u_heightMapTextureUsed, used);
    };
    MeshDrawer.prototype.setCubeMapTextureUsed = function (used) {
        this.setUniform(this.u_cubeMapTextureUsed, used);
    };
    MeshDrawer.prototype.setHeightMapFactor = function (val) {
        this.setUniform(this.u_heightMapFactor, val);
    };
    MeshDrawer.prototype.setLightUsed = function (used) {
        this.setUniform(this.u_lightUsed, used);
    };
    MeshDrawer.prototype.setColor = function (c) {
        this.setUniform(this.u_color, c.asGL());
    };
    MeshDrawer.prototype.setColorMix = function (val) {
        this.setUniform(this.u_color_mix, val);
    };
    MeshDrawer.prototype.bind = function () {
        if ( true && this.mesh === undefined)
            throw new debugError_DebugError("can not bind modelDrawer;bindModel must be invoked firstly");
        _super.prototype.bind.call(this);
        if (!this.mesh.modelPrimitive.texCoordArr) {
            this.program.disableAttribute(this.a_texCoord);
        }
        else {
            this.program.enableAttribute(this.a_texCoord);
        }
        if (!this.mesh.modelPrimitive.normalArr) {
            this.program.disableAttribute(this.a_normal);
        }
        else {
            this.program.enableAttribute(this.a_normal);
        }
    };
    MeshDrawer.prototype._initBufferInfo = function (drawMethod, vertexSize) {
        if (drawMethod === void 0) { drawMethod = 3; }
        if (vertexSize === void 0) { vertexSize = 3; }
        var bufferInfo = {
            posVertexInfo: {
                array: this.mesh.modelPrimitive.vertexArr, type: this.gl.FLOAT,
                size: vertexSize, attrName: this.a_position
            },
            drawMethod: drawMethod
        };
        if (this.mesh.modelPrimitive.indexArr) {
            bufferInfo.posIndexInfo = {
                array: this.mesh.modelPrimitive.indexArr
            };
        }
        if (this.mesh.modelPrimitive.normalArr) {
            bufferInfo.normalInfo = {
                array: this.mesh.modelPrimitive.normalArr,
                type: this.gl.FLOAT,
                size: 3,
                attrName: this.a_normal
            };
        }
        if (this.mesh.modelPrimitive.texCoordArr) {
            bufferInfo.texVertexInfo = {
                array: this.mesh.modelPrimitive.texCoordArr, type: this.gl.FLOAT,
                size: 2, attrName: this.a_texCoord
            };
        }
        this.mesh.bufferInfo = new bufferInfo_BufferInfo(this.gl, bufferInfo);
    };
    return MeshDrawer;
}(abstractDrawer_AbstractDrawer));


// CONCATENATED MODULE: ./engine/renderer/webGl/blender/blender.ts

var blender_Blender = (function () {
    function Blender(gl) {
        this.gl = gl;
    }
    Blender.getSingleton = function (gl) {
        if (Blender.instance === undefined)
            Blender.instance = new Blender(gl);
        return Blender.instance;
    };
    Blender.prototype.enable = function () {
        if (this._enabled)
            return;
        this._enabled = true;
        this.gl.enable(this.gl.BLEND);
    };
    Blender.prototype.disable = function () {
        if (this._enabled === false)
            return;
        this._enabled = false;
        this.gl.disable(this.gl.BLEND);
    };
    Blender.prototype.setBlendMode = function (blendMode) {
        if (blendMode === this._lastMode)
            return;
        this._lastMode = blendMode;
        var gl = this.gl;
        switch (blendMode) {
            case 0:
                gl.blendEquation(gl.FUNC_ADD);
                gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
                break;
            case 1:
                gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
                break;
            case 2:
                gl.blendEquation(gl.FUNC_ADD);
                gl.blendFunc(gl.ONE, gl.ONE);
                break;
            case 3:
                gl.blendEquation(gl.FUNC_SUBTRACT);
                gl.blendFunc(gl.ONE, gl.ONE);
                break;
            case 4:
                gl.blendEquation(gl.FUNC_REVERSE_SUBTRACT);
                gl.blendFunc(gl.ONE, gl.ONE);
                break;
            default:
                if (true) {
                    throw new debugError_DebugError("unknown blend mode: " + blendMode);
                }
                break;
        }
    };
    return Blender;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/programs/impl/base/simpleRect/simpleRectDrawer.ts








var simpleRectDrawer_SimpleRectDrawer = (function (_super) {
    __extends(SimpleRectDrawer, _super);
    function SimpleRectDrawer(gl) {
        var _this = _super.call(this, gl) || this;
        _this.gen = new shaderGenerator_ShaderGenerator();
        var gen = _this.gen;
        _this.a_position = gen.addAttribute(GL_TYPE.FLOAT_VEC4, 'a_position');
        _this.a_texCoord = gen.addAttribute(GL_TYPE.FLOAT_VEC2, 'a_texCoord');
        _this.u_vertexMatrix = gen.addVertexUniform(GL_TYPE.FLOAT_MAT4, 'u_vertexMatrix');
        _this.u_textureMatrix = gen.addVertexUniform(GL_TYPE.FLOAT_MAT4, 'u_textureMatrix');
        gen.addVarying(GL_TYPE.FLOAT_VEC2, 'v_texCoord');
        gen.setVertexMainFn("void main(){\ngl_Position = u_vertexMatrix * a_position;\nv_texCoord = (u_textureMatrix * vec4(a_texCoord, 0, 1)).xy;\n}");
        gen.addScalarFragmentUniform(GL_TYPE.SAMPLER_2D, 'texture');
        gen.setFragmentMainFn("void main(){\ngl_FragColor = texture2D(texture, v_texCoord);\n}");
        return _this;
    }
    SimpleRectDrawer.prototype.initProgram = function () {
        if (true) {
            if (!this.gen)
                throw new debugError_DebugError("can not init simpleRectDrawer instance: ShaderGenerator must be created");
        }
        this.primitive = new plane_Plane();
        this.program = new shaderProgram_ShaderProgram(this.gl, this.gen.getVertexSource(), this.gen.getFragmentSource());
        this.bufferInfo = new bufferInfo_BufferInfo(this.gl, {
            posVertexInfo: { array: this.primitive.vertexArr, type: this.gl.FLOAT, size: 2, attrName: 'a_position' },
            posIndexInfo: { array: this.primitive.indexArr },
            texVertexInfo: { array: this.primitive.texCoordArr, type: this.gl.FLOAT, size: 2, attrName: 'a_texCoord' },
            drawMethod: 2
        });
    };
    return SimpleRectDrawer;
}(abstractDrawer_AbstractDrawer));


// CONCATENATED MODULE: ./engine/renderer/webGl/programs/impl/base/tileMap/tileMapDrawer.ts



var tileMapDrawer_TileMapDrawer = (function (_super) {
    __extends(TileMapDrawer, _super);
    function TileMapDrawer(gl) {
        var _this = _super.call(this, gl) || this;
        _this.tileSize = [0, 0];
        var gen = _this.gen;
        _this.u_tileSize = gen.addScalarFragmentUniform(GL_TYPE.FLOAT_VEC2, 'u_tileSize');
        gen.setFragmentMainFn("void main(){\nvec2 tileCoord = mod(v_texCoord,u_tileSize);\ngl_FragColor = texture2D(texture, tileCoord);\n}");
        return _this;
    }
    TileMapDrawer.prototype.setTileSize = function (width, height) {
        this.tileSize[0] = width;
        this.tileSize[1] = height;
        this.setUniform(this.u_tileSize, this.tileSize);
    };
    return TileMapDrawer;
}(simpleRectDrawer_SimpleRectDrawer));


// CONCATENATED MODULE: ./engine/renderer/abstract/rendererHelper.ts
var RendererHelper = (function () {
    function RendererHelper(game) {
        this.game = game;
    }
    RendererHelper.prototype.renderSceneToTexture = function (scene, renderTarget) {
        return undefined;
    };
    RendererHelper.prototype.renderModelToTexture = function (m, renderTarget, clearColor) {
        return undefined;
    };
    RendererHelper.prototype.createRenderTarget = function (game, size) {
        return undefined;
    };
    RendererHelper.prototype.destroyRenderTarget = function (t) { };
    return RendererHelper;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/base/frameBuffer.ts



var frameBuffer_FrameBuffer = (function () {
    function FrameBuffer(gl, size) {
        this.destroyed = false;
        if ( true && !gl)
            throw new debugError_DebugError("can not create FrameBuffer, gl context not passed to constructor, expected: FrameBuffer(gl)");
        this.gl = gl;
        this.width = size.width;
        this.height = size.height;
        this.texture = new texture_Texture(gl);
        this.texture.setImage(undefined, size);
        this._init(gl, size);
        this.link = ResourceLink.create(this.texture);
    }
    FrameBuffer.prototype.setInterpolationMode = function (mode) {
        this.texture.setInterpolationMode(mode);
    };
    FrameBuffer.prototype.bind = function () {
        if (true) {
            if (this.destroyed) {
                console.error(this);
                throw new debugError_DebugError("can not bind destroyed frame buffer");
            }
        }
        if (FrameBuffer.currInstance === this)
            return;
        this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, this.glFrameBuffer);
        this.gl.viewport(0, 0, ~~this.width, ~~this.height);
        FrameBuffer.currInstance = this;
    };
    FrameBuffer.prototype.unbind = function () {
        this._checkBound();
        this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, null);
        FrameBuffer.currInstance = undefined;
    };
    FrameBuffer.prototype.clear = function (color, alphaBlendValue) {
        if (alphaBlendValue === void 0) { alphaBlendValue = 1; }
        this._checkBound();
        var arr = color.asGL();
        this.gl.clearColor(arr[0], arr[1], arr[2], arr[3] * alphaBlendValue);
        this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
    };
    FrameBuffer.prototype.destroy = function () {
        this.gl.deleteRenderbuffer(this.glRenderBuffer);
        this.gl.deleteFramebuffer(this.glFrameBuffer);
        this.destroyed = true;
    };
    FrameBuffer.prototype.getTexture = function () {
        return this.texture;
    };
    FrameBuffer.prototype.getResourceLink = function () {
        return this.link;
    };
    FrameBuffer.prototype._init = function (gl, size) {
        this.glRenderBuffer = gl.createRenderbuffer();
        if ( true && !this.glRenderBuffer)
            throw new debugError_DebugError("can not allocate memory for glRenderBuffer");
        gl.bindRenderbuffer(gl.RENDERBUFFER, this.glRenderBuffer);
        gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, size.width, size.height);
        this.glFrameBuffer = gl.createFramebuffer();
        if ( true && !this.glFrameBuffer)
            throw new debugError_DebugError("can not allocate memory for glFrameBuffer");
        gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFrameBuffer);
        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture.getGlTexture(), 0);
        gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, this.glRenderBuffer);
        var fbStatus = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
        if ( true && fbStatus !== gl.FRAMEBUFFER_COMPLETE) {
            throw new debugError_DebugError("frame buffer status error: " + fbStatus + " (expected gl.FRAMEBUFFER_COMPLETE(" + gl.FRAMEBUFFER_COMPLETE + "))");
        }
        this.texture.unbind();
        gl.bindRenderbuffer(gl.RENDERBUFFER, null);
        gl.bindFramebuffer(gl.FRAMEBUFFER, null);
    };
    FrameBuffer.prototype._checkBound = function () {
        if (true)
            return;
        if (FrameBuffer.currInstance !== this)
            throw new debugError_DebugError("frame buffer is not bound; call bind() method firstly");
    };
    return FrameBuffer;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/base/doubleFrameBuffer.ts

var doubleFrameBuffer_DoubleFrameBuffer = (function () {
    function DoubleFrameBuffer(gl, size) {
        this.gl = gl;
        this.buffers = [
            new frameBuffer_FrameBuffer(gl, size),
            new frameBuffer_FrameBuffer(gl, size)
        ];
    }
    DoubleFrameBuffer.prototype.setInterpolationMode = function (mode) {
        this.buffers[0].getTexture().setInterpolationMode(mode);
        this.buffers[1].getTexture().setInterpolationMode(mode);
    };
    DoubleFrameBuffer.prototype.applyFilters = function (texture, filters) {
        var len = filters.length;
        if (len === 0)
            return texture;
        var filter = filters[0];
        if (!filter.enabled)
            return texture;
        filter.getDrawer().attachTexture('texture', texture);
        filter.doFilter(this.getDestBuffer());
        for (var i = 1; i < len; i++) {
            if (!filters[i].enabled)
                continue;
            this.flip();
            filters[i].getDrawer().attachTexture('texture', this.getSourceBuffer().getTexture());
            filters[i].doFilter(this.getDestBuffer());
        }
        this.flip();
        return this.getSourceBuffer().getTexture();
    };
    DoubleFrameBuffer.prototype.destroy = function () {
        this.buffers.forEach(function (b) { return b.destroy(); });
    };
    DoubleFrameBuffer.prototype.flip = function () {
        var tmp = this.buffers[0];
        this.buffers[0] = this.buffers[1];
        this.buffers[1] = tmp;
    };
    DoubleFrameBuffer.prototype.getSourceBuffer = function () {
        return this.buffers[0];
    };
    DoubleFrameBuffer.prototype.getDestBuffer = function () {
        return this.buffers[1];
    };
    return DoubleFrameBuffer;
}());


// CONCATENATED MODULE: ./engine/misc/device.ts
var Device = (function () {
    function Device() {
    }
    Device.logInfo = function () {
        console.log({
            isTouch: Device.isTouch,
            isFrame: Device.isFrame,
            isIPhone: Device.isIPhone,
            buildAt: 1589043570878,
            embeddedEngine: Device.embeddedEngine,
        });
    };
    Device.isTouch = ('ontouchstart' in window);
    Device.isFrame = window.top !== window.self;
    Device.isIPhone = navigator.platform.toLowerCase().indexOf('iphone') > -1;
    Device.embeddedEngine = navigator.userAgent === 'vEngine';
    return Device;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/base/frameBufferStack.ts








var IDENTITY = mat4_mat4.IDENTITY;
var frameBufferStack_Mat16Holder = mat4_mat4.Mat16Holder;

var FLIP_POSITION_MATRIX;
var NONE_FILTERS = [];
var frameBufferStack_FrameBufferStack = (function () {
    function FrameBufferStack(game, gl, size) {
        this.game = game;
        this.gl = gl;
        this.size = size;
        this.debug = false;
        this._stack = [];
        this._interpolationMode = 1;
        this._doubleFrameBuffer = new doubleFrameBuffer_DoubleFrameBuffer(this.gl, this.size);
        this._pixelPerfectMode = false;
        this.blender = blender_Blender.getSingleton(this.gl);
        this._stack.push({
            frameBuffer: new frameBuffer_FrameBuffer(this.gl, this.size),
            filters: NONE_FILTERS,
            pointer: { ptr: 0 }
        });
        this._stackPointer = 1;
        this.simpleRectDrawer = new simpleRectDrawer_SimpleRectDrawer(gl);
        this.simpleRectDrawer.initProgram();
        this.blender.enable();
        this.blender.setBlendMode(0);
        var m16hResult = frameBufferStack_Mat16Holder.fromPool();
        var m16Scale = frameBufferStack_Mat16Holder.fromPool();
        mat4_mat4.makeScale(m16Scale, this.game.size.width, this.game.size.height, 1);
        var m16Ortho = frameBufferStack_Mat16Holder.fromPool();
        mat4_mat4.ortho(m16Ortho, 0, this.game.size.width, 0, this.game.size.height, -1, 1);
        mat4_mat4.matrixMultiply(m16hResult, m16Scale, m16Ortho);
        FLIP_POSITION_MATRIX = m16hResult.clone();
        m16hResult.release();
        m16Scale.release();
        m16Ortho.release();
        this.resourceLink = ResourceLink.create(this._getFirst().frameBuffer.getTexture());
    }
    FrameBufferStack.prototype.pushState = function (filters, forceDrawChildrenOnNewSurface) {
        var prevPointer = this._getLast().pointer;
        if (filters.length > 0 || forceDrawChildrenOnNewSurface) {
            if (this.debug)
                console.log('state has been pushed');
            if (this._stack[this._stackPointer] === undefined) {
                this._stack[this._stackPointer] = {
                    frameBuffer: new frameBuffer_FrameBuffer(this.gl, this.size),
                    filters: NONE_FILTERS,
                    pointer: { ptr: this._stackPointer }
                };
            }
            this._stack[this._stackPointer].filters = filters;
            this._stack[this._stackPointer].frameBuffer.bind();
            this._stack[this._stackPointer].frameBuffer.clear(color_Color.NONE);
            this._stackPointer++;
        }
        else {
            this._getLast().frameBuffer.bind();
        }
        return prevPointer;
    };
    FrameBufferStack.prototype.clear = function (color, alphaBlend) {
        this._getLast().frameBuffer.bind();
        this._getLast().frameBuffer.clear(color, alphaBlend);
    };
    FrameBufferStack.prototype.setInterpolationMode = function (interpolation) {
        this._getLast().frameBuffer.setInterpolationMode(interpolation);
        this._doubleFrameBuffer.setInterpolationMode(interpolation);
        this._interpolationMode = interpolation;
    };
    FrameBufferStack.prototype.getCurrentTargetSize = function () {
        return this._getLast().frameBuffer.getTexture().size;
    };
    FrameBufferStack.prototype.setPixelPerfectMode = function (mode) {
        this._pixelPerfectMode = mode;
    };
    FrameBufferStack.prototype.getStackSize = function () {
        return this._stackPointer;
    };
    FrameBufferStack.prototype.destroy = function () {
        this._stack.forEach(function (f) { return f.frameBuffer.destroy(); });
        this._doubleFrameBuffer.destroy();
        this.simpleRectDrawer.destroy();
    };
    FrameBufferStack.prototype.reduceState = function (to) {
        if (this._stackPointer === 1)
            return;
        if (this.debug)
            console.log("reducing state from " + (this._stackPointer - 1) + " to " + to.ptr);
        for (var i = this._stackPointer - 1; i > to.ptr; i--) {
            var currItem = this._stack[i];
            var nextItem = this._stack[i - 1];
            var filteredTexture = this._doubleFrameBuffer.applyFilters(currItem.frameBuffer.getTexture(), currItem.filters);
            currItem.filters = NONE_FILTERS;
            nextItem.frameBuffer.bind();
            nextItem.frameBuffer.setInterpolationMode(this._interpolationMode);
            this.simpleRectDrawer.setUniform(this.simpleRectDrawer.u_textureMatrix, IDENTITY);
            var m16h = makeIdentityPositionMatrix(0, 0, this._getLast().frameBuffer.getTexture().size);
            this.simpleRectDrawer.setUniform(this.simpleRectDrawer.u_vertexMatrix, m16h.mat16);
            this.simpleRectDrawer.attachTexture('texture', filteredTexture);
            this.blender.setBlendMode(0);
            this.simpleRectDrawer.draw();
            m16h.release();
        }
        this._stackPointer = to.ptr + 1;
    };
    FrameBufferStack.prototype.renderToScreen = function () {
        this.blender.setBlendMode(0);
        var needFullScreen = this._pixelPerfectMode || Device.embeddedEngine;
        var w = needFullScreen ? this.game.getRenderer().viewPortSize.width : this.game.size.width;
        var h = needFullScreen ? this.game.getRenderer().viewPortSize.height : this.game.size.height;
        this._getLast().frameBuffer.unbind();
        this.gl.viewport(0, 0, ~~w, ~~h);
        this.simpleRectDrawer.setUniform(this.simpleRectDrawer.u_textureMatrix, FLIP_TEXTURE_MATRIX.mat16);
        this.simpleRectDrawer.setUniform(this.simpleRectDrawer.u_vertexMatrix, FLIP_POSITION_MATRIX.mat16);
        this.simpleRectDrawer.attachTexture('texture', this._getLast().frameBuffer.getTexture());
        this.simpleRectDrawer.draw();
    };
    FrameBufferStack.prototype.getResourceLink = function () {
        return this.resourceLink;
    };
    FrameBufferStack.prototype._getLast = function () {
        return this._stack[this._stackPointer - 1];
    };
    FrameBufferStack.prototype._getFirst = function () {
        return this._stack[0];
    };
    return FrameBufferStack;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/webGlRendererHelper.ts





var webGlRendererHelper_Mat16Holder = mat4_mat4.Mat16Holder;
var makeIdentityPositionMatrix = function (dstX, dstY, destSize) {
    var projectionMatrix = webGlRendererHelper_Mat16Holder.fromPool();
    var dstWidth = destSize.width;
    var dstHeight = destSize.height;
    mat4_mat4.ortho(projectionMatrix, 0, dstWidth, 0, dstHeight, -1, 1);
    var scaleMatrix = webGlRendererHelper_Mat16Holder.fromPool();
    mat4_mat4.makeScale(scaleMatrix, dstWidth, dstHeight, 1);
    var result = webGlRendererHelper_Mat16Holder.fromPool();
    mat4_mat4.matrixMultiply(result, scaleMatrix, projectionMatrix);
    projectionMatrix.release();
    scaleMatrix.release();
    return result;
};
var FLIP_TEXTURE_MATRIX = new matrixStack_MatrixStack().translate(0, 1).scale(1, -1).release().getCurrentValue().clone();
var webGlRendererHelper_WebGlRendererHelper = (function (_super) {
    __extends(WebGlRendererHelper, _super);
    function WebGlRendererHelper() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    WebGlRendererHelper.prototype.createRenderTarget = function (game, size) {
        var renderer = this.game.getRenderer();
        return new frameBufferStack_FrameBufferStack(game, renderer.getNativeContext(), size);
    };
    WebGlRendererHelper.prototype.renderSceneToTexture = function (scene, renderTarget) {
        var renderer = this.game.getRenderer();
        renderer.setRenderTarget(renderTarget);
        scene.render();
        renderer.setDefaultRenderTarget();
    };
    WebGlRendererHelper.prototype.renderModelToTexture = function (m, renderTarget, clearColor) {
        var renderer = this.game.getRenderer();
        if (m.size.isZero())
            m.revalidate();
        renderer.setRenderTarget(renderTarget);
        var clearBeforeRenderOrig = renderer.clearBeforeRender;
        var clearColorOrig = renderer.clearColor;
        renderer.clearBeforeRender = clearColor !== undefined;
        if (clearColor !== undefined)
            renderer.clearColor.set(clearColor);
        var statePointer = renderer.beforeFrameDraw(m.filters);
        m.render();
        renderer.afterFrameDraw(statePointer);
        renderer.setDefaultRenderTarget();
        renderer.clearBeforeRender = clearBeforeRenderOrig;
        renderer.clearColor.set(clearColorOrig);
    };
    return WebGlRendererHelper;
}(RendererHelper));


// CONCATENATED MODULE: ./engine/renderer/webGl/base/cubeMapTexture.ts



var cubeMapTexture_CubeMapTexture = (function (_super) {
    __extends(CubeMapTexture, _super);
    function CubeMapTexture(gl) {
        var _this = _super.call(this, gl) || this;
        _this.gl = gl;
        _this.samplerType = _this.gl.TEXTURE_CUBE_MAP;
        return _this;
    }
    CubeMapTexture.prototype.setImages = function (left, right, top, bottom, front, back) {
        this.validate(left, right, top, bottom, front, back);
        this.init(left, right, top, bottom, front, back);
    };
    CubeMapTexture.prototype.setAsZero = function () {
        var _this = this;
        var gl = this.gl;
        var faceInfos = [
            gl.TEXTURE_CUBE_MAP_POSITIVE_X,
            gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
            gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
            gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
            gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
            gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
        ];
        gl.bindTexture(gl.TEXTURE_CUBE_MAP, this.tex);
        faceInfos.forEach(function (faceInfo) {
            gl.bindTexture(gl.TEXTURE_CUBE_MAP, _this.tex);
            gl.texImage2D(faceInfo, 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
        });
        gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
        gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
        gl.bindTexture(gl.TEXTURE_CUBE_MAP, null);
    };
    CubeMapTexture.prototype.validate = function (left, right, top, bottom, front, back) {
        if (true) {
            if (!this.gl)
                throw new debugError_DebugError("can not create Texture, gl context not passed to constructor, expected: Texture(gl)");
            var isZeroImage = function (img) {
                return img.width === 0 || img.height === 0;
            };
            var isOfSize = function (img, width, height) {
                return img.width === width && img.height === height;
            };
            if (isZeroImage(top) ||
                isZeroImage(bottom) ||
                isZeroImage(left) ||
                isZeroImage(right) ||
                isZeroImage(top) ||
                isZeroImage(bottom)) {
                throw new debugError_DebugError("can not create cube texture: wrong image is passed");
            }
            var w = top.width, h = top.height;
            if (!isOfSize(bottom, w, h) ||
                !isOfSize(left, w, h) ||
                !isOfSize(right, w, h) ||
                !isOfSize(front, w, h) ||
                !isOfSize(back, w, h)) {
                throw new debugError_DebugError("can not create cube texture: the same size of images is required");
            }
        }
    };
    CubeMapTexture.prototype.init = function (left, right, top, bottom, front, back) {
        var _this = this;
        var gl = this.gl;
        var faceInfos = [
            {
                target: gl.TEXTURE_CUBE_MAP_POSITIVE_X,
                img: left,
            },
            {
                target: gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
                img: right,
            },
            {
                target: gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
                img: top,
            },
            {
                target: gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
                img: bottom,
            },
            {
                target: gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
                img: back,
            },
            {
                target: gl.TEXTURE_CUBE_MAP_NEGATIVE_Z,
                img: front,
            },
        ];
        gl.bindTexture(gl.TEXTURE_CUBE_MAP, this.tex);
        this.size.setWH(top.width, top.height);
        faceInfos.forEach(function (faceInfo) {
            gl.bindTexture(gl.TEXTURE_CUBE_MAP, _this.tex);
            gl.texImage2D(faceInfo.target, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, faceInfo.img);
        });
        if (isPowerOf2(this.size.width) && isPowerOf2(this.size.height)) {
            gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
        }
        gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
        gl.bindTexture(gl.TEXTURE_CUBE_MAP, null);
    };
    return CubeMapTexture;
}(abstractTexture_AbstractTexture));


// CONCATENATED MODULE: ./engine/renderer/webGl/programs/impl/base/simpleRect/simpleColoredRectDrawer.ts








var simpleColoredRectDrawer_SimpleColoredRectDrawer = (function (_super) {
    __extends(SimpleColoredRectDrawer, _super);
    function SimpleColoredRectDrawer(gl) {
        var _this = _super.call(this, gl) || this;
        _this.gl = gl;
        _this.gen = new shaderGenerator_ShaderGenerator();
        var gen = _this.gen;
        gen.addAttribute(GL_TYPE.FLOAT_VEC4, 'a_position');
        _this.u_vertexMatrix = gen.addVertexUniform(GL_TYPE.FLOAT_MAT4, 'u_vertexMatrix');
        _this.u_alpha = gen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'u_alpha');
        _this.u_color = gen.addScalarFragmentUniform(GL_TYPE.FLOAT_VEC4, 'u_color');
        gen.setVertexMainFn("void main(){\ngl_Position = u_vertexMatrix * a_position;\n}");
        gen.setFragmentMainFn("void main(){\ngl_FragColor = u_color*u_alpha;\n}");
        _this.initProgram();
        return _this;
    }
    SimpleColoredRectDrawer.prototype.initProgram = function () {
        if (true) {
            if (!this.gen)
                throw new debugError_DebugError("can not init simpleRectDrawer instance: ShaderGenerator must be created");
        }
        this.primitive = new plane_Plane();
        this.program = new shaderProgram_ShaderProgram(this.gl, this.gen.getVertexSource(), this.gen.getFragmentSource());
        this.bufferInfo = new bufferInfo_BufferInfo(this.gl, {
            posVertexInfo: { array: this.primitive.vertexArr, type: this.gl.FLOAT, size: 2, attrName: 'a_position' },
            posIndexInfo: { array: this.primitive.indexArr },
            drawMethod: 2
        });
    };
    return SimpleColoredRectDrawer;
}(abstractDrawer_AbstractDrawer));


// CONCATENATED MODULE: ./engine/renderer/webGl/webGlRenderer.ts
















var webGlRenderer_Mat16Holder = mat4_mat4.Mat16Holder;
var webGlRenderer_glEnumToString = debugUtil.glEnumToString;

var webGlRenderer_getCtx = function (el) {
    var contextAttrs = { alpha: false, premultipliedAlpha: false };
    var possibles = ['webgl', 'experimental-webgl', 'webkit-3d', 'moz-webgl'];
    for (var _i = 0, possibles_1 = possibles; _i < possibles_1.length; _i++) {
        var p = possibles_1[_i];
        var ctx = el.getContext(p, contextAttrs);
        if (ctx) {
            return ctx;
        }
    }
    if (true)
        throw new debugError_DebugError("webGl is not accessible on this device");
    return undefined;
};
var SCENE_DEPTH = 1000;
var zToWMatrix = webGlRenderer_Mat16Holder.create();
mat4_mat4.makeZToWMatrix(zToWMatrix, 1);
var makePositionMatrix = function (rect, viewSize, matrixStack) {
    var projectionMatrix = webGlRenderer_Mat16Holder.fromPool();
    mat4_mat4.ortho(projectionMatrix, 0, viewSize.width, 0, viewSize.height, -SCENE_DEPTH, SCENE_DEPTH);
    var scaleMatrix = webGlRenderer_Mat16Holder.fromPool();
    mat4_mat4.makeScale(scaleMatrix, rect.width, rect.height, 1);
    var translationMatrix = webGlRenderer_Mat16Holder.fromPool();
    mat4_mat4.makeTranslation(translationMatrix, rect.x, rect.y, 0);
    var matrix1 = webGlRenderer_Mat16Holder.fromPool();
    mat4_mat4.matrixMultiply(matrix1, scaleMatrix, translationMatrix);
    var matrix2 = webGlRenderer_Mat16Holder.fromPool();
    mat4_mat4.matrixMultiply(matrix2, matrix1, matrixStack.getCurrentValue());
    var matrix3 = webGlRenderer_Mat16Holder.fromPool();
    mat4_mat4.matrixMultiply(matrix3, matrix2, projectionMatrix);
    var matrix4 = webGlRenderer_Mat16Holder.fromPool();
    mat4_mat4.matrixMultiply(matrix4, matrix3, zToWMatrix);
    projectionMatrix.release();
    scaleMatrix.release();
    translationMatrix.release();
    matrix1.release();
    matrix2.release();
    matrix3.release();
    return matrix4;
};
var InstanceHolder = (function () {
    function InstanceHolder(clazz) {
        this.clazz = clazz;
    }
    InstanceHolder.prototype.getInstance = function (gl) {
        if (this.instance === undefined)
            this.instance = new this.clazz(gl);
        return this.instance;
    };
    InstanceHolder.prototype.destroy = function () {
        if (this.instance !== undefined)
            this.instance.destroy();
    };
    InstanceHolder.prototype.isInvoked = function () {
        return this.instance !== undefined;
    };
    return InstanceHolder;
}());
var webGlRenderer_WebGlRenderer = (function (_super) {
    __extends(WebGlRenderer, _super);
    function WebGlRenderer(game) {
        var _this = _super.call(this, game) || this;
        _this.type = 'WebGlRenderer';
        _this.rendererHelper = new webGlRendererHelper_WebGlRendererHelper(_this.game);
        _this.matrixStack = new matrixStack_MatrixStack();
        _this.shapeDrawerHolder = new InstanceHolder(shapeDrawer_ShapeDrawer);
        _this.coloredRectDrawer = new InstanceHolder(simpleColoredRectDrawer_SimpleColoredRectDrawer);
        _this.meshDrawerHolder = new InstanceHolder(meshDrawer_MeshDrawer);
        _this.tileMapDrawerHolder = new InstanceHolder(tileMapDrawer_TileMapDrawer);
        _this._pixelPerfectMode = false;
        _this.registerResize();
        _this._init();
        return _this;
    }
    WebGlRenderer.prototype.setPixelPerfectMode = function (mode) {
        var interpolation = mode ? 0 : 1;
        this.currFrameBufferStack.setInterpolationMode(interpolation);
        this.currFrameBufferStack.setPixelPerfectMode(mode);
        this._pixelPerfectMode = mode;
        this.onResize();
    };
    WebGlRenderer.prototype.drawImage = function (img) {
        if (true) {
            if (!img.getResourceLink()) {
                throw new debugError_DebugError("image resource link is not set");
            }
            if (!img.getResourceLink().getTarget()) {
                console.error(img);
                throw new debugError_DebugError("no target associated with resource link");
            }
        }
        img.getResourceLink().getTarget().
            setInterpolationMode(img.isPixelPerfect() ? 0 : 1);
        var texture = img.getResourceLink().getTarget();
        var maxSize = Math.max(img.size.width, img.size.height);
        var sd = this.shapeDrawerHolder.getInstance(this.gl);
        this.prepareGeometryUniformInfo(img);
        sd.setUniform(sd.u_lineWidth, Math.min(img.lineWidth / maxSize, 1));
        sd.setUniform(sd.u_color, img.color.asGL());
        var repeatFactor = size_Size.fromPool();
        repeatFactor.setWH(img.size.width / img.getSrcRect().width, img.size.height / img.getSrcRect().height);
        sd.setUniform(sd.u_repeatFactor, repeatFactor.toArray());
        repeatFactor.release();
        sd.setUniform(sd.u_borderRadius, Math.min(img.borderRadius / maxSize, 1));
        sd.setUniform(sd.u_shapeType, 1);
        sd.setUniform(sd.u_fillType, 1);
        var _a = texture.size, textureWidth = _a.width, textureHeight = _a.height;
        var _b = img.getSrcRect(), srcRectX = _b.x, srcRectY = _b.y;
        var _c = img.getSrcRect(), destRectWidth = _c.width, destRectHeight = _c.height;
        var destArr = rect_Rect.fromPool().setXYWH(srcRectX / textureWidth, srcRectY / textureHeight, destRectWidth / textureWidth, destRectHeight / textureHeight).release().toArray();
        sd.setUniform(sd.u_texRect, destArr);
        var offSetArr = size_Size.fromPool().setWH(img.offset.x / maxSize, img.offset.y / maxSize).release().toArray();
        sd.setUniform(sd.u_texOffset, offSetArr);
        sd.setUniform(sd.u_stretchMode, img.stretchMode);
        sd.attachTexture('texture', texture);
        sd.draw();
    };
    WebGlRenderer.prototype.drawMesh = function (mesh) {
        var md = this.meshDrawerHolder.getInstance(this.gl);
        md.bindModel(mesh);
        md.bind();
        var modelMatrix = this.matrixStack.getCurrentValue();
        var orthoProjectionMatrix = webGlRenderer_Mat16Holder.fromPool();
        var currViewSize = this.currFrameBufferStack.getCurrentTargetSize();
        mat4_mat4.ortho(orthoProjectionMatrix, 0, currViewSize.width, 0, currViewSize.height, -SCENE_DEPTH, SCENE_DEPTH);
        var zToWProjectionMatrix = webGlRenderer_Mat16Holder.fromPool();
        mat4_mat4.matrixMultiply(zToWProjectionMatrix, orthoProjectionMatrix, zToWMatrix);
        var inverseTransposeModelMatrix = webGlRenderer_Mat16Holder.fromPool();
        mat4_mat4.inverse(inverseTransposeModelMatrix, modelMatrix);
        mat4_mat4.transpose(inverseTransposeModelMatrix, inverseTransposeModelMatrix);
        md.setModelMatrix(modelMatrix.mat16);
        md.setInverseTransposeModelMatrix(inverseTransposeModelMatrix.mat16);
        md.setProjectionMatrix(zToWProjectionMatrix.mat16);
        md.setAlfa(this.getAlphaBlend());
        var isTextureUsed = mesh.texture !== undefined;
        if ( true && isTextureUsed && mesh.modelPrimitive.texCoordArr === undefined)
            throw new debugError_DebugError("can not apply texture without texture coordinates");
        md.setTextureUsed(isTextureUsed);
        if (isTextureUsed)
            md.setTextureMatrix(FLIP_TEXTURE_MATRIX.mat16);
        md.attachTexture('u_texture', isTextureUsed ? mesh.texture : this.nullTexture);
        var isNormalsTextureUsed = mesh.normalsTexture !== undefined;
        md.setNormalsTextureUsed(isNormalsTextureUsed);
        md.attachTexture('u_normalsTexture', isNormalsTextureUsed ? mesh.normalsTexture : this.nullTexture);
        var isHeightMapTextureUsed = mesh.heightMapTexture !== undefined;
        md.setHeightMapTextureUsed(isHeightMapTextureUsed);
        md.attachTexture('u_heightMapTexture', isHeightMapTextureUsed ? mesh.heightMapTexture : this.nullTexture);
        md.setHeightMapFactor(mesh.heightMapFactor);
        var isCubeMapTextureUsed = mesh.cubeMapTexture !== undefined;
        if ( true && !isCubeMapTextureUsed && mesh.reflectivity !== 0)
            throw new debugError_DebugError("can not apply reflectivity without cubeMapTexture");
        md.setCubeMapTextureUsed(isCubeMapTextureUsed);
        md.setReflectivity(mesh.reflectivity);
        md.attachTexture('u_cubeMapTexture', isCubeMapTextureUsed ? mesh.cubeMapTexture : this.nullCubeMapTexture);
        md.setLightUsed(mesh.isLightAccepted() || false);
        md.setColor(mesh.fillColor);
        md.setColorMix(mesh.colorMix);
        if (mesh.depthTest)
            this.gl.enable(this.gl.DEPTH_TEST);
        else
            this.gl.disable(this.gl.DEPTH_TEST);
        md.draw();
        zToWMatrix.release();
        orthoProjectionMatrix.release();
        zToWProjectionMatrix.release();
        inverseTransposeModelMatrix.release();
    };
    WebGlRenderer.prototype.drawRectangle = function (rectangle) {
        if (rectangle.lineWidth === 0 && rectangle.borderRadius === 0 && rectangle.fillColor.type === 'Color') {
            this.drawSimpleColoredRectangle(rectangle);
        }
        else {
            var _a = rectangle.size, rw = _a.width, rh = _a.height;
            var maxSize = Math.max(rw, rh);
            var sd = this.shapeDrawerHolder.getInstance(this.gl);
            this.prepareGeometryUniformInfo(rectangle);
            this.prepareShapeUniformInfo(rectangle);
            sd.setUniform(sd.u_borderRadius, Math.min(rectangle.borderRadius / maxSize, 1));
            sd.setUniform(sd.u_shapeType, 1);
            sd.attachTexture('texture', this.nullTexture);
            sd.draw();
        }
    };
    WebGlRenderer.prototype.drawLine = function (line) {
        var r = line.getRectangleRepresentation();
        this.drawRectangle(r);
    };
    WebGlRenderer.prototype.drawEllipse = function (ellipse) {
        var maxR = Math.max(ellipse.radiusX, ellipse.radiusY);
        this.prepareGeometryUniformInfo(ellipse);
        this.prepareShapeUniformInfo(ellipse);
        var sd = this.shapeDrawerHolder.getInstance(this.gl);
        sd.setUniform(sd.u_lineWidth, Math.min(ellipse.lineWidth / maxR, 1));
        if (maxR === ellipse.radiusX) {
            sd.setUniform(sd.u_rx, 0.5);
            sd.setUniform(sd.u_ry, ellipse.radiusY / ellipse.radiusX * 0.5);
        }
        else {
            sd.setUniform(sd.u_ry, 0.5);
            sd.setUniform(sd.u_rx, ellipse.radiusX / ellipse.radiusY * 0.5);
        }
        sd.setUniform(sd.u_shapeType, 0);
        sd.setUniform(sd.u_width, 1);
        sd.setUniform(sd.u_height, 1);
        sd.setUniform(sd.u_rectOffsetLeft, 1);
        sd.setUniform(sd.u_rectOffsetTop, 1);
        sd.setUniform(sd.u_arcAngleFrom, ellipse.arcAngleFrom);
        sd.setUniform(sd.u_arcAngleTo, ellipse.arcAngleTo);
        sd.setUniform(sd.u_anticlockwise, ellipse.anticlockwise);
        sd.attachTexture('texture', this.nullTexture);
        sd.draw();
    };
    WebGlRenderer.prototype.transformSave = function () {
        this.matrixStack.save();
    };
    WebGlRenderer.prototype.transformScale = function (x, y, z) {
        if (z === void 0) { z = 1; }
        if (x === 1 && y === 1 && z === 1)
            return;
        this.matrixStack.scale(x, y, z);
    };
    WebGlRenderer.prototype.transformReset = function () {
        this.matrixStack.resetTransform();
    };
    WebGlRenderer.prototype.transformRotateX = function (angleInRadians) {
        if (angleInRadians === 0)
            return;
        this.matrixStack.rotateX(angleInRadians);
    };
    WebGlRenderer.prototype.transformRotateY = function (angleInRadians) {
        if (angleInRadians === 0)
            return;
        this.matrixStack.rotateY(angleInRadians);
    };
    WebGlRenderer.prototype.transformRotateZ = function (angleInRadians) {
        if (angleInRadians === 0)
            return;
        this.matrixStack.rotateZ(angleInRadians);
    };
    WebGlRenderer.prototype.transformTranslate = function (x, y, z) {
        if (z === void 0) { z = 0; }
        if (x === 0 && y === 0 && z === 0)
            return;
        this.matrixStack.translate(x, y, z);
    };
    WebGlRenderer.prototype.transformRotationReset = function () {
        this.matrixStack.rotationReset();
    };
    WebGlRenderer.prototype.transformSkewX = function (angle) {
        if (angle === 0)
            return;
        this.matrixStack.skewX(angle);
    };
    WebGlRenderer.prototype.transformSkewY = function (angle) {
        if (angle === 0)
            return;
        this.matrixStack.skewY(angle);
    };
    WebGlRenderer.prototype.transformRestore = function () {
        this.matrixStack.restore();
    };
    WebGlRenderer.prototype.transformSet = function (v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) {
        this.matrixStack.setMatrixValues(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15);
    };
    WebGlRenderer.prototype.transformGet = function () {
        return this.matrixStack.getCurrentValue().mat16;
    };
    WebGlRenderer.prototype.setLockRect = function (rect) {
        this._lockRect = rect;
    };
    WebGlRenderer.prototype.unsetLockRect = function () {
        this._lockRect = undefined;
    };
    WebGlRenderer.prototype.beforeItemStackDraw = function (filters, forceDrawChildrenOnNewSurface) {
        return this.currFrameBufferStack.pushState(filters, forceDrawChildrenOnNewSurface);
    };
    WebGlRenderer.prototype.afterItemStackDraw = function (stackPointer) {
        this.gl.disable(this.gl.DEPTH_TEST);
        this.currFrameBufferStack.reduceState(stackPointer);
    };
    WebGlRenderer.prototype.beforeFrameDraw = function (filters) {
        var ptr = this.currFrameBufferStack.pushState(filters, false);
        if (this.clearBeforeRender) {
            this.currFrameBufferStack.clear(this.clearColor, this.getAlphaBlend());
        }
        return ptr;
    };
    WebGlRenderer.prototype.afterFrameDraw = function (stackPointer) {
        this.currFrameBufferStack.reduceState(stackPointer);
        if (this.currFrameBufferStack === this.origFrameBufferStack) {
            if (this._lockRect !== undefined) {
                var rect = this._lockRect;
                this.gl.enable(this.gl.SCISSOR_TEST);
                this.gl.scissor(~~rect.x, ~~(this.game.size.height - rect.height - rect.y), ~~rect.width, ~~rect.height);
            }
            this.currFrameBufferStack.renderToScreen();
            this.gl.disable(this.gl.SCISSOR_TEST);
        }
    };
    WebGlRenderer.prototype.getError = function () {
        if (false)
            {}
        var err = this.gl.getError();
        if (err !== this.gl.NO_ERROR) {
            return { code: err, desc: webGlRenderer_glEnumToString(this.gl, err) };
        }
        return undefined;
    };
    WebGlRenderer.prototype.createTexture = function (bitmap) {
        var texture = new texture_Texture(this.gl);
        texture.setImage(bitmap);
        return texture;
    };
    WebGlRenderer.prototype.createCubeTexture = function (imgLeft, imgRight, imgTop, imgBottom, imgFront, imgBack) {
        var cubeTexture = new cubeMapTexture_CubeMapTexture(this.gl);
        cubeTexture.setImages(imgLeft, imgRight, imgTop, imgBottom, imgFront, imgBack);
        return cubeTexture;
    };
    WebGlRenderer.prototype.getNativeContext = function () {
        return this.gl;
    };
    WebGlRenderer.prototype.setRenderTarget = function (fbs) {
        this.currFrameBufferStack = fbs;
    };
    WebGlRenderer.prototype.setDefaultRenderTarget = function () {
        this.currFrameBufferStack = this.origFrameBufferStack;
    };
    WebGlRenderer.prototype.destroy = function () {
        _super.prototype.destroy.call(this);
        this.origFrameBufferStack.destroy();
        this.nullTexture.destroy();
        this.nullCubeMapTexture.destroy();
        this.shapeDrawerHolder.destroy();
        this.meshDrawerHolder.destroy();
        this.tileMapDrawerHolder.destroy();
        texture_Texture.destroyAll();
    };
    WebGlRenderer.prototype.onResize = function () {
        _super.prototype.onResize.call(this);
        if (this._pixelPerfectMode && (this.game.scaleStrategy === 2 || this.game.scaleStrategy === 1)) {
            this.container.width = this.viewPortSize.width;
            this.container.height = this.viewPortSize.height;
        }
        else {
            this.container.width = this.game.size.width;
            this.container.height = this.game.size.height;
        }
    };
    WebGlRenderer.prototype._init = function () {
        var gl = webGlRenderer_getCtx(this.container);
        if ( true && gl === undefined)
            throw new debugError_DebugError("WebGLRenderingContext is not supported by this device");
        this.gl = gl;
        this.nullTexture = new texture_Texture(gl);
        this.nullCubeMapTexture = new cubeMapTexture_CubeMapTexture(gl);
        this.nullCubeMapTexture.setAsZero();
        this.blender = blender_Blender.getSingleton(gl);
        this.blender.enable();
        this.blender.setBlendMode(0);
        this.origFrameBufferStack = new frameBufferStack_FrameBufferStack(this.game, this.getNativeContext(), this.game.size);
        this.setDefaultRenderTarget();
    };
    WebGlRenderer.prototype.drawSimpleColoredRectangle = function (rectangle) {
        var scd = this.coloredRectDrawer.getInstance(this.gl);
        var rect = rect_Rect.fromPool();
        rect.setXYWH(0, 0, rectangle.size.width, rectangle.size.height);
        var size = size_Size.fromPool();
        size.set(this.currFrameBufferStack.getCurrentTargetSize());
        var pos16h = makePositionMatrix(rect, size, this.matrixStack);
        scd.setUniform(scd.u_vertexMatrix, pos16h.mat16);
        pos16h.release();
        rect.release();
        size.release();
        scd.setUniform(scd.u_alpha, this.getAlphaBlend());
        scd.setUniform(scd.u_color, (rectangle.fillColor).asGL());
        scd.draw();
    };
    WebGlRenderer.prototype.prepareGeometryUniformInfo = function (model) {
        if (true) {
            if (!model.size.width || !model.size.height) {
                console.error(model);
                throw new debugError_DebugError("Can not render model with zero size");
            }
        }
        var _a = model.size, rw = _a.width, rh = _a.height;
        var maxSize = Math.max(rw, rh);
        var sd = this.shapeDrawerHolder.getInstance(this.gl);
        var offsetX = 0, offsetY = 0;
        if (maxSize === rw) {
            sd.setUniform(sd.u_width, 1);
            sd.setUniform(sd.u_height, rh / rw);
            offsetY = (maxSize - rh) / 2;
            sd.setUniform(sd.u_rectOffsetLeft, 0);
            sd.setUniform(sd.u_rectOffsetTop, offsetY / maxSize);
        }
        else {
            sd.setUniform(sd.u_height, 1);
            sd.setUniform(sd.u_width, rw / rh);
            offsetX = (maxSize - rw) / 2;
            sd.setUniform(sd.u_rectOffsetLeft, offsetX / maxSize);
            sd.setUniform(sd.u_rectOffsetTop, 0);
        }
        var rect = rect_Rect.fromPool();
        rect.setXYWH(-offsetX, -offsetY, maxSize, maxSize);
        var size = size_Size.fromPool();
        size.set(this.currFrameBufferStack.getCurrentTargetSize());
        var pos16h = makePositionMatrix(rect, size, this.matrixStack);
        sd.setUniform(sd.u_vertexMatrix, pos16h.mat16);
        pos16h.release();
        rect.release();
        size.release();
        sd.setUniform(sd.u_alpha, this.getAlphaBlend());
        sd.setUniform(sd.u_stretchMode, 0);
        this.blender.setBlendMode(model.blendMode);
        if (model.depthTest)
            this.gl.enable(this.gl.DEPTH_TEST);
        else
            this.gl.disable(this.gl.DEPTH_TEST);
    };
    WebGlRenderer.prototype.prepareShapeUniformInfo = function (model) {
        var maxSize = Math.max(model.size.width, model.size.height);
        var sd = this.shapeDrawerHolder.getInstance(this.gl);
        sd.setUniform(sd.u_lineWidth, Math.min(model.lineWidth / maxSize, 1));
        sd.setUniform(sd.u_color, model.color.asGL());
        if (model.fillColor.type === 'LinearGradient') {
            sd.setUniform(sd.u_fillLinearGradient, model.fillColor.asGL());
            sd.setUniform(sd.u_fillType, 2);
        }
        else if (model.fillColor.type === 'Color') {
            sd.setUniform(sd.u_fillColor, model.fillColor.asGL());
            sd.setUniform(sd.u_fillType, 0);
        }
    };
    return WebGlRenderer;
}(abstractCanvasRenderer_AbstractCanvasRenderer));


// CONCATENATED MODULE: ./engine/control/gamepad/gamePadKeys.ts
var GAME_PAD_BUTTON;
(function (GAME_PAD_BUTTON) {
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["BTN_A"] = 0] = "BTN_A";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["BTN_B"] = 1] = "BTN_B";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["BTN_X"] = 2] = "BTN_X";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["BTN_Y"] = 3] = "BTN_Y";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["BTN_LEFT_BUMPER"] = 4] = "BTN_LEFT_BUMPER";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["BTN_RIGHT_BUMPER"] = 5] = "BTN_RIGHT_BUMPER";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["BTN_LEFT_TRIGGER"] = 6] = "BTN_LEFT_TRIGGER";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["BTN_RIGHT_TRIGGER"] = 7] = "BTN_RIGHT_TRIGGER";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["BTN_SELECT"] = 8] = "BTN_SELECT";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["BTN_START"] = 9] = "BTN_START";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["BTN_STICK_L"] = 10] = "BTN_STICK_L";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["BTN_STICK_R"] = 11] = "BTN_STICK_R";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["D_PAD_UP"] = 12] = "D_PAD_UP";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["D_PAD_DOWN"] = 13] = "D_PAD_DOWN";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["D_PAD_LEFT"] = 14] = "D_PAD_LEFT";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["D_PAD_RIGHT"] = 15] = "D_PAD_RIGHT";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["STICK_L_LEFT"] = 100] = "STICK_L_LEFT";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["STICK_L_RIGHT"] = 101] = "STICK_L_RIGHT";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["STICK_L_UP"] = 102] = "STICK_L_UP";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["STICK_L_DOWN"] = 103] = "STICK_L_DOWN";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["STICK_R_LEFT"] = 200] = "STICK_R_LEFT";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["STICK_R_RIGHT"] = 201] = "STICK_R_RIGHT";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["STICK_R_UP"] = 202] = "STICK_R_UP";
    GAME_PAD_BUTTON[GAME_PAD_BUTTON["STICK_R_DOWN"] = 203] = "STICK_R_DOWN";
})(GAME_PAD_BUTTON || (GAME_PAD_BUTTON = {}));

// CONCATENATED MODULE: ./engine/control/gamepad/gamePadControl.ts




var gamePadControl_navigator = window.navigator;
var AXIS_THRESHOLD = 0.005;
if (true) {
    window.addEventListener("gamepadconnected", function (e) {
        console.log("Gamepad connected at index %d: %s. %d buttons, %d axes.", e.gamepad.index, e.gamepad.id, e.gamepad.buttons.length, e.gamepad.axes.length);
    });
    window.addEventListener("gamepaddisconnected", function (e) {
        console.log("Gamepad disconnected from index %d: %s", e.gamepad.index, e.gamepad.id);
    });
}
var EMPTY_ARR = [];
var NullGamepadGetter = function () { return EMPTY_ARR; };
var gamePadGetterFactory = function () {
    if (gamePadControl_navigator.getGamepads)
        return [(function () { return gamePadControl_navigator.getGamepads(); }), true];
    else if (gamePadControl_navigator.webkitGetGamepads)
        return [(function () { return gamePadControl_navigator.webkitGetGamepads(); }), true];
    else {
        var possibles = ['webkitGamepads', 'mozGamepads', 'msGamepads', 'msGamepads'];
        var possible_1 = '';
        for (var i = 0; i < possibles.length; i++) {
            if (gamePadControl_navigator[possibles[i]]) {
                possible_1 = possibles[i];
                if (true)
                    console.log("gamepad control with prefix is used (" + possible_1 + ")");
                break;
            }
        }
        if (!possible_1)
            return [NullGamepadGetter, false];
        else
            return [(function () { return gamePadControl_navigator[possible_1]; }), true];
    }
};
var gamePadControl_a = gamePadGetterFactory(), gamePadGetter = gamePadControl_a[0], isEnabled = gamePadControl_a[1];
var gamePadControl_GamePadControl = (function (_super) {
    __extends(GamePadControl, _super);
    function GamePadControl(game) {
        var _this = _super.call(this, game) || this;
        _this.type = 'GamePadControl';
        _this.keyPressed = GAME_PAD_EVENTS.buttonPressed;
        _this.keyHold = GAME_PAD_EVENTS.buttonHold;
        _this.keyReleased = GAME_PAD_EVENTS.buttonReleased;
        return _this;
    }
    GamePadControl.prototype.update = function () {
        _super.prototype.update.call(this);
        this.gamepads = gamePadGetter();
        for (var i = 0, max = this.gamepads.length; i < max; i++) {
            var gp = this.gamepads[i];
            if (!gp)
                continue;
            this.pollButtons(gp, i);
            if (gp.axes.length >= 2) {
                var axisLeftStick0 = this.clampAxis(gp.axes[0]);
                var axisLeftStick1 = this.clampAxis(gp.axes[1]);
                this.pollAxes(axisLeftStick0, axisLeftStick1, GAME_PAD_BUTTON.STICK_L_LEFT, GAME_PAD_BUTTON.STICK_L_RIGHT, GAME_PAD_BUTTON.STICK_L_UP, GAME_PAD_BUTTON.STICK_L_DOWN, i);
            }
            if (gp.axes.length >= 4) {
                var axisRightStick0 = this.clampAxis(gp.axes[2]);
                var axisRightStick1 = this.clampAxis(gp.axes[3]);
                this.pollAxes(axisRightStick0, axisRightStick1, GAME_PAD_BUTTON.STICK_R_LEFT, GAME_PAD_BUTTON.STICK_R_RIGHT, GAME_PAD_BUTTON.STICK_R_UP, GAME_PAD_BUTTON.STICK_R_DOWN, i);
            }
        }
    };
    GamePadControl.prototype.listenTo = function () { };
    GamePadControl.prototype.destroy = function () { };
    GamePadControl.prototype.pressButton = function (buton, value, gamePadIndex, eventFromBuffer) {
        if (eventFromBuffer === undefined) {
            var eventJustCreated = gamePadEvents_GamePadEvent.fromPool();
            if (eventJustCreated === undefined) {
                if (true)
                    console.warn('gamepad pool is full');
                return;
            }
            eventJustCreated.button = buton;
            eventJustCreated.gamePadIndex = gamePadIndex;
            eventJustCreated.value = value;
            this.press(eventJustCreated);
        }
        else {
            eventFromBuffer.value = value;
        }
    };
    GamePadControl.prototype.releaseButton = function (eventFromBuffer) {
        if (eventFromBuffer !== undefined) {
            if (!this.isReleased(eventFromBuffer))
                this.release(eventFromBuffer);
        }
    };
    GamePadControl.prototype.pollButtons = function (gp, gamePadIndex) {
        var maxButtons = gp.buttons.length;
        for (var i = 0; i < maxButtons; i++) {
            var btn = gp.buttons[i];
            var eventFromBuffer = this.findEvent(i, gamePadIndex);
            if (btn.pressed)
                this.pressButton(i, btn.value, gamePadIndex, eventFromBuffer);
            else
                this.releaseButton(eventFromBuffer);
        }
    };
    GamePadControl.prototype.pollAxes = function (axis0, axis1, btnLeft, btnRight, btnUp, btnDown, gamePadIndex) {
        if (Math.abs(axis0) < GamePadControl.SENSITIVITY)
            axis0 = 0;
        if (Math.abs(axis1) < GamePadControl.SENSITIVITY)
            axis1 = 0;
        if (axis0 > 0) {
            var eventFromBuffer = this.findEvent(btnRight, gamePadIndex);
            this.pressButton(btnRight, axis0, gamePadIndex, eventFromBuffer);
        }
        else {
            var eventFromBuffer = this.findEvent(btnRight, gamePadIndex);
            this.releaseButton(eventFromBuffer);
        }
        if (axis0 < 0) {
            var eventFromBuffer = this.findEvent(btnLeft, gamePadIndex);
            this.pressButton(btnLeft, axis0, gamePadIndex, eventFromBuffer);
        }
        else {
            var eventFromBuffer = this.findEvent(btnLeft, gamePadIndex);
            this.releaseButton(eventFromBuffer);
        }
        if (axis1 > 0) {
            var eventFromBuffer = this.findEvent(btnDown, gamePadIndex);
            this.pressButton(btnDown, axis1, gamePadIndex, eventFromBuffer);
        }
        else {
            var eventFromBuffer = this.findEvent(btnDown, gamePadIndex);
            this.releaseButton(eventFromBuffer);
        }
        if (axis1 < 0) {
            var eventFromBuffer = this.findEvent(btnUp, gamePadIndex);
            this.pressButton(btnUp, axis1, gamePadIndex, eventFromBuffer);
        }
        else {
            var eventFromBuffer = this.findEvent(btnUp, gamePadIndex);
            this.releaseButton(eventFromBuffer);
        }
    };
    GamePadControl.prototype.isReleased = function (e) {
        return e.keyState === KEY_STATE.KEY_RELEASED || e.keyState === KEY_STATE.KEY_JUST_RELEASED;
    };
    GamePadControl.prototype.findEvent = function (button, gamePadIndex) {
        for (var _i = 0, _a = this.buffer; _i < _a.length; _i++) {
            var event_1 = _a[_i];
            if (event_1.button === button && event_1.gamePadIndex === gamePadIndex)
                return event_1;
        }
        return undefined;
    };
    GamePadControl.prototype.clampAxis = function (val) {
        if (Math.abs(val) < AXIS_THRESHOLD)
            return 0;
        return val;
    };
    GamePadControl.enabled = isEnabled;
    GamePadControl.SENSITIVITY = 0.05;
    return GamePadControl;
}(abstractKeypad_AbstractKeypad));


// CONCATENATED MODULE: ./engine/control/mouse/mousePoint.ts




var mousePoint_MousePoint = (function (_super) {
    __extends(MousePoint, _super);
    function MousePoint() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.screenCoordinate = new point2d_Point2d();
        _this.sceneCoordinate = new point2d_Point2d();
        return _this;
    }
    MousePoint.fromPool = function () {
        return MousePoint.mousePointsPool.getFreeObject();
    };
    MousePoint.mousePointsPool = new objectPool_ObjectPool(MousePoint);
    return MousePoint;
}(ReleaseableEntity));


// CONCATENATED MODULE: ./engine/control/mouse/mouseControl.ts








var mouseControl_Vec4Holder = vec4_vec4.Vec4Holder;
var pointTopLeft = new mouseControl_Vec4Holder();
pointTopLeft.set(0, 0, 0, 1);
var mouseControl_MouseControl = (function () {
    function MouseControl(game) {
        this.type = 'MouseControl';
        this.objectsCaptured = {};
        this.objectsHovered = {};
        this.objectsFirstHovered = {};
        this.game = game;
    }
    MouseControl.triggerGameObjectEvent = function (e, eventName, mousePoint, go) {
        var goRect = rect_Rect.fromPool();
        var pointBottomRight = mouseControl_Vec4Holder.fromPool();
        pointBottomRight.set(go.size.width, go.size.height, 0, 1);
        var pointTopLeftTransformation = mouseControl_Vec4Holder.fromPool();
        var pointBottomRightTransformation = mouseControl_Vec4Holder.fromPool();
        mat4_mat4.multVecByMatrix(pointTopLeftTransformation, go.worldTransformMatrix, pointTopLeft);
        mat4_mat4.multVecByMatrix(pointBottomRightTransformation, go.worldTransformMatrix, pointBottomRight);
        goRect.setXYWH(pointTopLeftTransformation.x, pointTopLeftTransformation.y, pointBottomRightTransformation.x - pointTopLeftTransformation.x, pointBottomRightTransformation.y - pointTopLeftTransformation.y);
        if (goRect.width < 0) {
            goRect.width = -goRect.width;
            goRect.x -= goRect.width;
        }
        if (goRect.height < 0) {
            goRect.height = -goRect.height;
            goRect.y -= goRect.height;
        }
        pointBottomRight.release();
        pointTopLeftTransformation.release();
        pointBottomRightTransformation.release();
        var screenPoint = point2d_Point2d.fromPool();
        screenPoint.setXY(mousePoint.screenCoordinate.x, mousePoint.screenCoordinate.y);
        var res = false;
        if (mathEx_MathEx.isPointInRect(screenPoint, goRect)) {
            if (!go.passMouseEventsThrough) {
                mousePoint.target = go;
                var mouseEvent = {
                    screenX: mousePoint.screenCoordinate.x,
                    screenY: mousePoint.screenCoordinate.y,
                    sceneX: mousePoint.sceneCoordinate.x,
                    sceneY: mousePoint.sceneCoordinate.y,
                    objectX: mousePoint.sceneCoordinate.x - go.pos.x,
                    objectY: mousePoint.sceneCoordinate.y - go.pos.y,
                    id: mousePoint.id,
                    target: go,
                    nativeEvent: e,
                    eventName: eventName,
                    isMouseDown: mousePoint.isMouseDown,
                    button: e.button,
                };
                go.trigger(eventName, mouseEvent);
            }
            res = !go.passMouseEventsThrough;
        }
        goRect.release();
        screenPoint.release();
        for (var _i = 0, _a = go.children; _i < _a.length; _i++) {
            var ch = _a[_i];
            res = res || MouseControl.triggerGameObjectEvent(e, eventName, mousePoint, ch);
        }
        return res;
    };
    MouseControl.prototype.listenTo = function () {
        var _this = this;
        if ( true && !this.game.getRenderer()) {
            throw new debugError_DebugError("can not initialize mouse control: renderer is not set");
        }
        var container = this.game.getRenderer().container;
        this.container = container;
        container.ontouchstart = function (e) {
            e.preventDefault();
            var l = e.touches.length;
            while (l--) {
                _this.resolveClick(e.touches[l]);
            }
        };
        container.onmousedown = function (e) {
            if (e.button === 0)
                _this.resolveClick(e);
            else
                _this.resolveButtonPressed(e);
        };
        container.ontouchend = container.ontouchcancel = function (e) {
            e.preventDefault();
            var l = e.changedTouches.length;
            while (l--) {
                _this.resolveMouseUp(e.changedTouches[l]);
            }
        };
        container.onmouseup = function (e) {
            _this.resolveMouseUp(e);
        };
        container.ontouchmove = function (e) {
            e.preventDefault();
            var l = e.touches.length;
            while (l--) {
                _this.resolveMouseMove(e.touches[l], true);
            }
        };
        container.onmousemove = function (e) {
            var isMouseDown = e.buttons === 1;
            _this.resolveMouseMove(e, isMouseDown);
        };
        container.ondblclick = function (e) {
            _this.resolveDoubleClick(e);
        };
        container.onmousewheel = function (e) {
            e.preventDefault();
            e.stopPropagation();
            _this.resolveScroll(e);
        };
    };
    MouseControl.prototype.update = function () { };
    MouseControl.prototype.destroy = function () {
        var _this = this;
        if (!this.container)
            return;
        [
            'mouseMove', 'ontouchstart', 'onmousedown',
            'ontouchend', 'onmouseup', 'ontouchmove',
            'onmousemove', 'ondblclick'
        ].forEach(function (evtName) {
            _this.container[evtName] = null;
        });
    };
    MouseControl.prototype.resolveSceneCoordinates = function (mousePoint, layer) {
        var worldPoint = this.game.camera.screenToWorld(mousePoint.screenCoordinate, layer.transformType);
        mousePoint.sceneCoordinate.set(worldPoint);
        worldPoint.release();
    };
    MouseControl.prototype.resolvePoint = function (e) {
        var game = this.game;
        var clientX = e.clientX;
        var clientY = e.clientY;
        var screenX = (clientX - game.pos.x) / game.scale.x;
        var screenY = (clientY - game.pos.y) / game.scale.y;
        var screenPoint = point2d_Point2d.fromPool();
        screenPoint.setXY(screenX, screenY);
        var mousePoint = mousePoint_MousePoint.fromPool();
        mousePoint.screenCoordinate.set(screenPoint);
        mousePoint.id = e.identifier || e.pointerId || 0;
        screenPoint.release();
        return mousePoint;
    };
    MouseControl.prototype.triggerEvent = function (e, mouseEvent, isMouseDown) {
        if (isMouseDown === void 0) { isMouseDown = false; }
        var scene = this.game.getCurrScene();
        var mousePoint = this.resolvePoint(e);
        mousePoint.isMouseDown = isMouseDown;
        var isCaptured = false;
        var i = scene.getLayers().length;
        while (i--) {
            var layer = scene.getLayers()[i];
            this.resolveSceneCoordinates(mousePoint, layer);
            var j = layer.children.length;
            while (j--) {
                var go = layer.children[j];
                isCaptured = MouseControl.triggerGameObjectEvent(e, mouseEvent, mousePoint, go);
                if (isCaptured) {
                    mousePoint.target = go;
                    break;
                }
            }
            if (isCaptured)
                break;
        }
        if (mousePoint.target === undefined)
            mousePoint.target = scene;
        scene.trigger(mouseEvent, {
            screenX: mousePoint.screenCoordinate.x,
            screenY: mousePoint.screenCoordinate.y,
            sceneX: mousePoint.sceneCoordinate.x,
            sceneY: mousePoint.sceneCoordinate.y,
            id: mousePoint.id,
            eventName: mouseEvent,
            nativeEvent: e,
            button: e.button,
            isMouseDown: isMouseDown
        });
        return mousePoint;
    };
    MouseControl.prototype.resolveClick = function (e) {
        var point = this.triggerEvent(e, MOUSE_EVENTS.click);
        this.triggerEvent(e, MOUSE_EVENTS.mouseDown).release();
        this.objectsCaptured[point.id] = point.target;
        point.release();
    };
    MouseControl.prototype.resolveButtonPressed = function (e) {
        var point = this.triggerEvent(e, MOUSE_EVENTS.click);
        this.triggerEvent(e, MOUSE_EVENTS.mousePressed).release();
        this.objectsCaptured[point.id] = point.target;
        point.release();
    };
    MouseControl.prototype.resolveMouseMove = function (e, isMouseDown) {
        var point = this.triggerEvent(e, MOUSE_EVENTS.mouseMove, isMouseDown);
        var lastHoveredObject = this.objectsHovered[point.id];
        if (lastHoveredObject !== undefined) {
            if (lastHoveredObject !== point.target) {
                lastHoveredObject.trigger(MOUSE_EVENTS.mouseLeave, point);
                delete this.objectsFirstHovered[point.id];
            }
            else {
                if (this.objectsFirstHovered[point.id] === undefined) {
                    lastHoveredObject.trigger(MOUSE_EVENTS.mouseEnter, point);
                    this.objectsFirstHovered[point.id] = point.target;
                }
            }
        }
        this.objectsHovered[point.id] = point.target;
        point.release();
    };
    MouseControl.prototype.resolveMouseUp = function (e) {
        var point = this.triggerEvent(e, MOUSE_EVENTS.mouseUp);
        var lastCapturedObject = this.objectsCaptured[point.id];
        if (lastCapturedObject !== undefined && point.target !== lastCapturedObject) {
            lastCapturedObject.trigger(MOUSE_EVENTS.mouseUp, point);
        }
        delete this.objectsCaptured[point.id];
        delete this.objectsHovered[point.id];
        point.release();
    };
    MouseControl.prototype.resolveDoubleClick = function (e) {
        this.triggerEvent(e, MOUSE_EVENTS.doubleClick).release();
    };
    MouseControl.prototype.resolveScroll = function (e) {
        this.triggerEvent(e, MOUSE_EVENTS.scroll).release();
    };
    return MouseControl;
}());


// CONCATENATED MODULE: ./engine/media/context/basicAudioContext.ts

var basicAudioContext_BasicAudioContext = (function () {
    function BasicAudioContext(game, audioPlayer) {
        this.game = game;
        this.audioPlayer = audioPlayer;
        this.type = 'basicAudioContext';
        this._lastTimeId = 0;
    }
    BasicAudioContext.isAcceptable = function () {
        if (true)
            console.log('audio is not supported');
        return true;
    };
    BasicAudioContext.prototype.getLastValueId = function () {
        return this._lastTimeId;
    };
    BasicAudioContext.prototype.isCached = function (l) {
        return false;
    };
    BasicAudioContext.prototype.getAudioPlayer = function () {
        return this.audioPlayer;
    };
    BasicAudioContext.prototype.play = function (sound) { };
    BasicAudioContext.prototype.stop = function () { };
    BasicAudioContext.prototype.isFree = function () { return false; };
    BasicAudioContext.prototype.setGain = function (val) { };
    BasicAudioContext.prototype.setVelocity = function (val) { };
    BasicAudioContext.prototype.setStereoPan = function (val) { };
    BasicAudioContext.prototype.loop = function (val) { };
    BasicAudioContext.prototype.pause = function () { };
    BasicAudioContext.prototype.resume = function () { };
    BasicAudioContext.prototype.load = function (buffer, link) {
        return Promise.resolve();
    };
    BasicAudioContext.prototype.clone = function () {
        return new BasicAudioContext(this.game, this.audioPlayer);
    };
    BasicAudioContext.prototype.setLastTimeId = function () {
        this._lastTimeId = Incrementer.getValue();
    };
    return BasicAudioContext;
}());


// CONCATENATED MODULE: ./engine/media/context/webAudioContext.ts



var WebAudioContextHolder = (function () {
    function WebAudioContextHolder() {
    }
    WebAudioContextHolder.getAudioContextClass = function () {
        return window.AudioContext ||
            window.webkitAudioContext;
    };
    WebAudioContextHolder.getNewAudioContext = function () {
        var c = new (WebAudioContextHolder.getAudioContextClass())();
        CtxHolder.fixAutoPlayPolicy(c);
        return c;
    };
    return WebAudioContextHolder;
}());

var CtxHolder = (function () {
    function CtxHolder() {
    }
    CtxHolder.getCtx = function () {
        if (CtxHolder.ctx && !CtxHolder.res) {
            CtxHolder.res = new CtxHolder.ctx();
            CtxHolder.fixAutoPlayPolicy(CtxHolder.res);
        }
        return CtxHolder.res;
    };
    CtxHolder.fixAutoPlayPolicy = function (res) {
        var listener = function () {
            res.resume();
            document.removeEventListener('click', listener);
        };
        document.addEventListener('click', listener);
    };
    CtxHolder.ctx = WebAudioContextHolder.getAudioContextClass();
    return CtxHolder;
}());
var decode = function (buffer) {
    return new Promise(function (resolve, reject) {
        CtxHolder.getCtx().decodeAudioData(buffer, function (decoded) {
            resolve(decoded);
        }, function (err) {
            reject(err.message);
        });
    });
};
var webAudioContext_WebAudioContext = (function (_super) {
    __extends(WebAudioContext, _super);
    function WebAudioContext(game, audioPLayer) {
        var _this = _super.call(this, game, audioPLayer) || this;
        _this.game = game;
        _this.audioPLayer = audioPLayer;
        _this._free = true;
        _this.type = 'webAudioContext';
        _this._ctx = CtxHolder.getCtx();
        _this._gainNode = _this._ctx.createGain();
        if (_this._ctx.createStereoPanner) {
            _this._stereoPanNode = _this._ctx.createStereoPanner();
            _this._stereoPanNode.pan.value = 0.5;
            _this._stereoPanNode.connect(_this._ctx.destination);
            _this._gainNode.connect(_this._stereoPanNode);
        }
        else {
            _this._gainNode.connect(_this._ctx.destination);
        }
        return _this;
    }
    WebAudioContext.isAcceptable = function () {
        return !!(window && CtxHolder.getCtx());
    };
    WebAudioContext.createContext = function () {
        return CtxHolder.getCtx();
    };
    WebAudioContext.prototype.load = function (buffer, link) {
        return __awaiter(this, void 0, void 0, function () {
            var _a, _b;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        if (audioPlayer_AudioPlayer.cache[link.getUrl()]) {
                            return [2, undefined];
                        }
                        _a = audioPlayer_AudioPlayer.cache;
                        _b = link.getUrl();
                        return [4, decode(buffer)];
                    case 1:
                        _a[_b] = _c.sent();
                        return [2];
                }
            });
        });
    };
    WebAudioContext.prototype.isCached = function (l) {
        return !!audioPlayer_AudioPlayer.cache[l.getUrl()];
    };
    WebAudioContext.prototype.isFree = function () {
        return this._free;
    };
    WebAudioContext.prototype.play = function (sound) {
        var _this = this;
        this.setLastTimeId();
        this._free = false;
        var currSource = this._ctx.createBufferSource();
        currSource.buffer = audioPlayer_AudioPlayer.cache[sound.getResourceLink().getUrl()];
        currSource.connect(this._gainNode);
        currSource.start(0, sound.offset, sound.duration);
        this._currSource = currSource;
        currSource.onended = function () {
            _this.stop();
        };
        this.loop(sound.loop);
        this.setGain(sound.gain);
        this.setStereoPan(sound.stereoPan);
    };
    WebAudioContext.prototype.stop = function () {
        var currSource = this._currSource;
        if (currSource !== undefined) {
            currSource.stop();
            currSource.disconnect(this._gainNode);
            currSource.onended = null;
        }
        this._currSource = undefined;
        this._free = true;
    };
    WebAudioContext.prototype.setGain = function (val) {
        this._gainNode.gain.value = val;
    };
    WebAudioContext.prototype.setVelocity = function (val) {
        this._currSource.playbackRate.value = val;
    };
    WebAudioContext.prototype.setStereoPan = function (val) {
        if (this._stereoPanNode !== undefined)
            this._stereoPanNode.pan.value = val;
    };
    WebAudioContext.prototype.loop = function (val) {
        this._currSource.loop = val;
    };
    WebAudioContext.prototype.pause = function () {
        this._ctx.suspend();
    };
    WebAudioContext.prototype.resume = function () {
        this._ctx.resume();
    };
    WebAudioContext.prototype.clone = function () {
        return new WebAudioContext(this.game, this.audioPLayer);
    };
    return WebAudioContext;
}(basicAudioContext_BasicAudioContext));


// CONCATENATED MODULE: ./engine/media/context/htmlAudioContext.ts




var htmlAudioContext_CtxHolder = (function () {
    function CtxHolder() {
    }
    CtxHolder.getCtx = function () {
        var Ctx = window && window.Audio;
        return new Ctx();
    };
    return CtxHolder;
}());
var htmlAudioContext_HtmlAudioContext = (function (_super) {
    __extends(HtmlAudioContext, _super);
    function HtmlAudioContext(game, audioPlayer) {
        var _this = _super.call(this, game, audioPlayer) || this;
        _this.game = game;
        _this.audioPlayer = audioPlayer;
        _this.type = 'htmlAudioContext';
        _this.free = true;
        _this._ctx = htmlAudioContext_CtxHolder.getCtx();
        return _this;
    }
    HtmlAudioContext.isAcceptable = function () {
        return !!(window && window.Audio);
    };
    HtmlAudioContext.prototype.load = function (buffer, link) {
        var _a;
        return __awaiter(this, void 0, void 0, function () {
            var url, type, canPlayType;
            return __generator(this, function (_b) {
                url = link.getUrl();
                if (true) {
                    type = (_a = url.split('.').pop()) !== null && _a !== void 0 ? _a : '';
                    if (type === '')
                        throw new debugError_DebugError("Can not define audio type from url: " + url);
                    canPlayType = this._ctx.canPlayType("audio/" + type);
                    if (canPlayType === '')
                        throw new debugError_DebugError("Can not play this audio type: " + type);
                }
                audioPlayer_AudioPlayer.cache[url] = url;
                return [2];
            });
        });
    };
    HtmlAudioContext.prototype.isFree = function () {
        return this.free;
    };
    HtmlAudioContext.prototype.play = function (sound) {
        var _this = this;
        var _a;
        this.setLastTimeId();
        var url = audioPlayer_AudioPlayer.cache[sound.getResourceLink().getUrl()];
        if ( true && !url)
            throw new debugError_DebugError("can not retrieve audio from cache (link id=" + sound.getResourceLink().getUrl() + ")");
        this.free = false;
        this._ctx.src = url;
        (_a = this._ctx.play()) === null || _a === void 0 ? void 0 : _a.catch(function (e) { });
        this.loop(sound.loop);
        this.setGain(sound.gain);
        this._ctx.onended = function () {
            _this.stop();
        };
    };
    HtmlAudioContext.prototype.stop = function () {
        this.free = true;
        this._ctx.onended = null;
    };
    HtmlAudioContext.prototype.setGain = function (val) {
        this._ctx.volume = val;
    };
    HtmlAudioContext.prototype.loop = function (val) {
        this._ctx.loop = val;
    };
    HtmlAudioContext.prototype.pause = function () {
        this._ctx.pause();
    };
    HtmlAudioContext.prototype.resume = function () {
        if (true)
            throw new Error("not implemented for now");
    };
    HtmlAudioContext.prototype.clone = function () {
        return new HtmlAudioContext(this.game, this.audioPlayer);
    };
    return HtmlAudioContext;
}(basicAudioContext_BasicAudioContext));


// CONCATENATED MODULE: ./engine/media/audioNode.ts
var AudioNode = (function () {
    function AudioNode(context) {
        this.context = context;
    }
    AudioNode.prototype.play = function (sound) {
        this.stop();
        this.context.play(sound);
        this.currSound = sound;
        this.lastPlayedUrl = sound.getResourceLink().url;
    };
    AudioNode.prototype.stop = function () {
        this.context.stop();
        this.currSound = undefined;
    };
    AudioNode.prototype.setGain = function (val) {
        this.context.setGain(val);
    };
    AudioNode.prototype.setStereoPan = function (val) {
        this.context.setStereoPan(val);
    };
    AudioNode.prototype.setVelocity = function (val) {
        this.context.setVelocity(val);
    };
    AudioNode.prototype.pause = function () {
        this.context.pause();
    };
    AudioNode.prototype.loop = function (val) {
        this.context.loop(val);
    };
    AudioNode.prototype.resume = function () {
        this.context.resume();
    };
    AudioNode.prototype.isFree = function () {
        return this.context.isFree();
    };
    AudioNode.prototype.getLastPlayedUrl = function () {
        return this.lastPlayedUrl;
    };
    AudioNode.prototype.isLooped = function () {
        if (this.currSound === undefined)
            return false;
        return this.currSound.loop;
    };
    AudioNode.prototype.getCurrSound = function () {
        return this.currSound;
    };
    return AudioNode;
}());


// CONCATENATED MODULE: ./engine/media/audioNodeSet.ts

var nodeComparator = function (a, b) {
    return a.context.getLastValueId() > b.context.getLastValueId() ? 1 : -1;
};
var audioNodeSet_AudioNodeSet = (function () {
    function AudioNodeSet(game, context, numOfNodes) {
        this.context = context;
        this.numOfNodes = numOfNodes;
        this.nodes = [];
        for (var i = 0; i < numOfNodes; i++) {
            this.nodes.push(new AudioNode(context.clone()));
        }
    }
    AudioNodeSet.prototype.getFreeNode = function (url) {
        var possibleFreeNode;
        for (var i = 0; i < this.numOfNodes; i++) {
            var node = this.nodes[i];
            if (node.isFree()) {
                possibleFreeNode = node;
                if (possibleFreeNode.getLastPlayedUrl() === url)
                    return node;
            }
        }
        if (possibleFreeNode !== undefined)
            return possibleFreeNode;
        switch (this.context.getAudioPlayer().freeNodeSearchStrategy) {
            case 0:
                return this.nodes.sort(nodeComparator)[0];
            case 1:
                return this.nodes.filter(function (it) { return !it.isLooped(); }).sort(nodeComparator)[0];
            case 2:
                return undefined;
            default:
                return undefined;
        }
    };
    AudioNodeSet.prototype.stopAll = function () {
        for (var i = 0; i < this.numOfNodes; i++) {
            this.nodes[i].stop();
        }
    };
    AudioNodeSet.prototype.pauseAll = function () {
        for (var i = 0; i < this.numOfNodes; i++) {
            this.nodes[i].pause();
        }
    };
    AudioNodeSet.prototype.resumeAll = function () {
        for (var i = 0; i < this.numOfNodes; i++) {
            this.nodes[i].resume();
        }
    };
    AudioNodeSet.prototype.getNodeBySound = function (sound) {
        for (var i = 0; i < this.numOfNodes; i++) {
            if (this.nodes[i].getCurrSound() === sound)
                return this.nodes[i];
        }
        return undefined;
    };
    return AudioNodeSet;
}());


// CONCATENATED MODULE: ./engine/media/audioPlayer.ts





var audioPlayer_AudioPlayer = (function () {
    function AudioPlayer(game) {
        this.game = game;
        this.freeNodeSearchStrategy = 0;
        if (webAudioContext_WebAudioContext.isAcceptable()) {
            this.audioContext = new webAudioContext_WebAudioContext(game, this);
        }
        else if (htmlAudioContext_HtmlAudioContext.isAcceptable()) {
            this.audioContext = new htmlAudioContext_HtmlAudioContext(game, this);
        }
        else {
            this.audioContext = new basicAudioContext_BasicAudioContext(game, this);
        }
        this.audioNodeSet = new audioNodeSet_AudioNodeSet(game, this.audioContext, AudioPlayer.DEFAULT_AUDIO_NODES_COUNT);
    }
    AudioPlayer.prototype.loadSound = function (buffer, link) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4, this.audioContext.load(buffer, link)];
                    case 1:
                        _a.sent();
                        return [2];
                }
            });
        });
    };
    AudioPlayer.prototype.isCached = function (link) {
        return this.audioContext.isCached(link);
    };
    AudioPlayer.prototype.play = function (sound) {
        if (true)
            sound.revalidate();
        var node = this.audioNodeSet.getFreeNode(sound.getResourceLink().url);
        if (node === undefined) {
            if (true) {
                console.log('no free node to play sound');
            }
            return;
        }
        node.play(sound);
    };
    AudioPlayer.prototype.stop = function (sound) {
        var node = this.audioNodeSet.getNodeBySound(sound);
        if (node === undefined)
            return;
        node.stop();
    };
    AudioPlayer.prototype.loop = function (sound) {
        var node = this.audioNodeSet.getNodeBySound(sound);
        if (node === undefined)
            return;
        node.loop(sound.loop);
    };
    AudioPlayer.prototype.getContext = function () {
        return this.audioContext;
    };
    AudioPlayer.prototype.setGain = function (sound) {
        var node = this.audioNodeSet.getNodeBySound(sound);
        if (node === undefined)
            return;
        node.setGain(sound.velocity);
    };
    AudioPlayer.prototype.setStereoPan = function (sound) {
        var node = this.audioNodeSet.getNodeBySound(sound);
        if (node === undefined)
            return;
        node.setStereoPan(sound.stereoPan);
    };
    AudioPlayer.prototype.stopAll = function () {
        this.audioNodeSet.stopAll();
    };
    AudioPlayer.prototype.pauseAll = function () {
        this.audioNodeSet.pauseAll();
    };
    AudioPlayer.prototype.resumeAll = function () {
        this.audioNodeSet.resumeAll();
    };
    AudioPlayer.prototype.update = function (time, delta) {
    };
    AudioPlayer.cache = {};
    AudioPlayer.DEFAULT_AUDIO_NODES_COUNT = 6;
    return AudioPlayer;
}());


// CONCATENATED MODULE: ./engine/physics/arcade/arcadeRigidBody.ts







var ARCADE_RIGID_BODY_TYPE;
(function (ARCADE_RIGID_BODY_TYPE) {
    ARCADE_RIGID_BODY_TYPE[ARCADE_RIGID_BODY_TYPE["KINEMATIC"] = 0] = "KINEMATIC";
    ARCADE_RIGID_BODY_TYPE[ARCADE_RIGID_BODY_TYPE["DYNAMIC"] = 1] = "DYNAMIC";
})(ARCADE_RIGID_BODY_TYPE || (ARCADE_RIGID_BODY_TYPE = {}));
var CollisionFlags = (function () {
    function CollisionFlags() {
        this.left = false;
        this.right = false;
        this.top = false;
        this.bottom = false;
    }
    CollisionFlags.prototype.reset = function () {
        this.left = this.right = this.top = this.bottom = false;
    };
    CollisionFlags.prototype.copyFrom = function (source) {
        this.left = source.left;
        this.right = source.right;
        this.top = source.top;
        this.bottom = source.bottom;
    };
    return CollisionFlags;
}());
var arcadeRigidBody_ArcadeRigidBody = (function () {
    function ArcadeRigidBody(game) {
        this.game = game;
        this.velocity = new point2d_Point2d();
        this.acceleration = new point2d_Point2d();
        this.groupNames = [];
        this.ignoreCollisionWithGroupNames = [];
        this.debug = false;
        this._modelType = ARCADE_RIGID_BODY_TYPE.DYNAMIC;
        this._boundRect = new rect_Rect();
        this._restitution = 0.5;
        this._halfSize = new size_Size();
        this.collisionFlags = new CollisionFlags();
        this._collisionFlagsOld = new CollisionFlags();
        this.offsetX = 0;
        this._eventEmitterDelegate = new eventEmitterDelegate_EventEmitterDelegate();
    }
    ArcadeRigidBody.prototype.nextTick = function () {
        this._oldPos.set(this._pos);
        var delta = this.game.getDeltaTime() / 1000;
        this._collisionFlagsOld.copyFrom(this.collisionFlags);
        this.collisionFlags.reset();
        this.velocity.x += this.acceleration.x * delta;
        if (!this._collisionFlagsOld.bottom)
            this.velocity.y += this.acceleration.y * delta;
        if (this._modelType === ARCADE_RIGID_BODY_TYPE.DYNAMIC) {
            this.velocity.x += ArcadePhysicsSystem_ArcadePhysicsSystem.gravity.x;
            this.velocity.y += ArcadePhysicsSystem_ArcadePhysicsSystem.gravity.y;
        }
        this._pos.x += this.velocity.x * delta;
        this._pos.y += this.velocity.y * delta;
    };
    ArcadeRigidBody.prototype.updateBounds = function (model) {
        var _this = this;
        model.revalidate();
        this.model = model;
        this._pos = model.pos;
        this._oldPos = this._pos.clone();
        if (!this._rect)
            this._rect = new rect_Rect(0, 0, model.size.width, model.size.height);
        this._halfSize.width = this._rect.width / 2;
        this._halfSize.height = this._rect.height / 2;
        if (this._modelType === ARCADE_RIGID_BODY_TYPE.KINEMATIC) {
            var oldX_1;
            this._pos.observe(function () {
                if (oldX_1 === undefined)
                    oldX_1 = _this._pos.x;
                _this.offsetX = _this._pos.x - oldX_1;
                oldX_1 = _this._pos.x;
            });
        }
    };
    ArcadeRigidBody.prototype.getMidX = function () {
        return this._halfSize.width + this._pos.x + this._rect.x;
    };
    ArcadeRigidBody.prototype.getMidY = function () {
        return this._halfSize.height + this._pos.y + this._rect.y;
    };
    ArcadeRigidBody.prototype.getTop = function () {
        return this._pos.y + this._rect.y;
    };
    ArcadeRigidBody.prototype.getLeft = function () {
        return this._pos.x + this._rect.x;
    };
    ArcadeRigidBody.prototype.getRight = function () {
        return this._pos.x + this._rect.x + this._rect.width;
    };
    ArcadeRigidBody.prototype.getBottom = function () {
        return this._pos.y + this._rect.y + this._rect.height;
    };
    ArcadeRigidBody.prototype.calcAndGetBoundRect = function () {
        this._boundRect.setXYWH(this._pos.x + this._rect.x, this._pos.y + this._rect.y, this._rect.width, this._rect.height);
        return this._boundRect;
    };
    ArcadeRigidBody.prototype.debugRender = function () {
        if (false)
            {}
        if (!this.debug)
            return;
        if (this.debugRectangle === undefined) {
            this.debugRectangle = new rectangle_Rectangle(this.game);
            this.debugRectangle.size.setWH(this._rect.width, this._rect.height);
            this.debugRectangle.fillColor = color_Color.RGBA(0, 233, 0, 50);
        }
        this.debugRectangle.pos.setXY(this._pos.x + this._rect.x, this._pos.y + this._rect.y);
        this.debugRectangle.render();
    };
    ArcadeRigidBody.prototype.getHostModel = function () {
        return this.model;
    };
    ArcadeRigidBody.prototype.clone = function () {
        var body = new ArcadeRigidBody(this.game);
        this.setClonedProperties(body);
        return body;
    };
    ArcadeRigidBody.prototype.off = function (eventName, callBack) {
        this._eventEmitterDelegate.off(eventName, callBack);
    };
    ArcadeRigidBody.prototype.on = function (eventName, callBack) {
        return this._eventEmitterDelegate.on(eventName, callBack);
    };
    ArcadeRigidBody.prototype.once = function (eventName, callBack) {
        this._eventEmitterDelegate.once(eventName, callBack);
    };
    ArcadeRigidBody.prototype.trigger = function (eventName, data) {
        this._eventEmitterDelegate.trigger(eventName, data);
    };
    ArcadeRigidBody.prototype.onCollidedWithGroup = function (groupName, callBack) {
        return this.on("collided", function (e) {
            if (e.groupNames.indexOf(groupName) > -1) {
                callBack(e);
            }
        });
    };
    ArcadeRigidBody.prototype.onOverlappedWithGroup = function (groupName, callBack) {
        return this.on("overlapped", function (e) {
            if (e.groupNames.indexOf(groupName) > -1) {
                callBack(e);
            }
        });
    };
    ArcadeRigidBody.prototype.setClonedProperties = function (body) {
        var _a, _b;
        body._modelType = this._modelType;
        body.velocity.set(this.velocity);
        body.acceleration.set(this.acceleration);
        body._restitution = this._restitution;
        body._rect = this._rect.clone();
        (_a = body.groupNames).push.apply(_a, this.groupNames);
        (_b = body.ignoreCollisionWithGroupNames).push.apply(_b, this.ignoreCollisionWithGroupNames);
        body.updateBounds(this.model);
    };
    return ArcadeRigidBody;
}());


// CONCATENATED MODULE: ./engine/physics/arcade/ArcadePhysicsSystem.ts



var instersect = function (a, b) {
    if (a.length === 0 || b.length === 0)
        return false;
    for (var i = 0; i < a.length; i++) {
        if (b.indexOf(a[i]) > -1)
            return true;
    }
    return false;
};
var ArcadePhysicsSystem_ArcadePhysicsSystem = (function () {
    function ArcadePhysicsSystem(game) {
        this.game = game;
    }
    ArcadePhysicsSystem.prototype.createRigidBody = function (params) {
        var _a, _b;
        var _c, _d;
        var body = new arcadeRigidBody_ArcadeRigidBody(this.game);
        body._modelType = (_c = params === null || params === void 0 ? void 0 : params.type) !== null && _c !== void 0 ? _c : body._modelType;
        body._restitution = (_d = params === null || params === void 0 ? void 0 : params.restitution) !== null && _d !== void 0 ? _d : body._restitution;
        if ((params === null || params === void 0 ? void 0 : params.rect) !== undefined)
            body._rect = params.rect.clone();
        if ((params === null || params === void 0 ? void 0 : params.debug) !== undefined)
            body.debug = params.debug;
        if (params === null || params === void 0 ? void 0 : params.groupNames)
            (_a = body.groupNames).push.apply(_a, params.groupNames);
        if (params === null || params === void 0 ? void 0 : params.ignoreCollisionWithGroupNames)
            (_b = body.ignoreCollisionWithGroupNames).push.apply(_b, params.ignoreCollisionWithGroupNames);
        return body;
    };
    ArcadePhysicsSystem.prototype.nextTick = function (scene) {
        for (var ind = 0, layerLength = scene.getLayers().length; ind < layerLength; ind++) {
            var layer = scene.getLayers()[ind];
            var all = layer.children;
            for (var i = 0; i < all.length; i++) {
                var player = all[i];
                var playerBody = player.getRigidBody();
                if (playerBody === undefined)
                    continue;
                for (var j = i + 1; j < all.length; j++) {
                    var entity = all[j];
                    var entityBody = entity.getRigidBody();
                    if (entityBody === undefined)
                        continue;
                    if (!mathEx_MathEx.overlapTest(playerBody.calcAndGetBoundRect(), entityBody.calcAndGetBoundRect()))
                        continue;
                    if (instersect(playerBody.groupNames, entityBody.ignoreCollisionWithGroupNames) ||
                        instersect(entityBody.groupNames, playerBody.ignoreCollisionWithGroupNames)) {
                        this.emitOverlapEvents(playerBody, entityBody);
                    }
                    else {
                        this.interpolateAndResolveCollision(playerBody, entityBody);
                        this.interpolateAndResolveCollision(entityBody, playerBody);
                    }
                }
            }
        }
    };
    ArcadePhysicsSystem.prototype.resolveCollision = function (player, entity) {
        var pMidX = player.getMidX();
        var pMidY = player.getMidY();
        var eMidX = entity.getMidX();
        var eMidY = entity.getMidY();
        var dx = (eMidX - pMidX) / entity._halfSize.width;
        var dy = (eMidY - pMidY) / entity._halfSize.height;
        var absDX = Math.abs(dx);
        var absDY = Math.abs(dy);
        if (absDX > absDY) {
            if (dx < 0) {
                this.collidePlayerWithLeft(player, entity);
            }
            else {
                this.collidePlayerWithRight(player, entity);
            }
        }
        else {
            if (dy < 0) {
                this.collidePlayerWithTop(player, entity);
            }
            else {
                this.collidePlayerWithBottom(player, entity);
            }
        }
    };
    ArcadePhysicsSystem.prototype.interpolateAndResolveCollision = function (player, entity) {
        if (player._modelType === ARCADE_RIGID_BODY_TYPE.KINEMATIC)
            return;
        var oldEntityPosX = entity._modelType === ARCADE_RIGID_BODY_TYPE.KINEMATIC ? entity._pos.x : entity._oldPos.x;
        var oldEntityPosY = entity._modelType === ARCADE_RIGID_BODY_TYPE.KINEMATIC ? entity._pos.y : entity._oldPos.y;
        var newEntityPosX = entity._pos.x;
        var newEntityPosY = entity._pos.y;
        var entityLengthX = newEntityPosX - oldEntityPosX;
        var entityLengthY = newEntityPosY - oldEntityPosY;
        var entityLengthMax = Math.max(Math.abs(entityLengthX), Math.abs(entityLengthY));
        var entityDeltaX = entityLengthX / entityLengthMax;
        var entityDeltaY = entityLengthY / entityLengthMax;
        var steps = 0;
        while (steps <= entityLengthMax) {
            entity._pos.setXY(oldEntityPosX, oldEntityPosY);
            if (mathEx_MathEx.overlapTest(player.calcAndGetBoundRect(), entity.calcAndGetBoundRect())) {
                break;
            }
            oldEntityPosX += entityDeltaX;
            oldEntityPosY += entityDeltaY;
            steps++;
        }
        this.resolveCollision(player, entity);
    };
    ArcadePhysicsSystem.prototype.calcCommonRestitution = function (player, entity) {
        return (player._restitution + entity._restitution) / 2;
    };
    ArcadePhysicsSystem.prototype.getComparedToSticky = function (val) {
        if (Math.abs(val) < ArcadePhysicsSystem.STICKY_THRESHOLD) {
            return 0;
        }
        else
            return val;
    };
    ArcadePhysicsSystem.prototype.reflectVelocityY = function (player, entity) {
        var restitution = this.calcCommonRestitution(player, entity);
        player.velocity.y = this.getComparedToSticky(-player.velocity.y * restitution);
    };
    ArcadePhysicsSystem.prototype.reflectVelocityX = function (player, entity) {
        var restitution = this.calcCommonRestitution(player, entity);
        player.velocity.x = this.getComparedToSticky(-player.velocity.x * restitution);
    };
    ArcadePhysicsSystem.prototype.emitCollisionEvents = function (player, entity) {
        if (player.getHostModel().isDetached() || entity.getHostModel().isDetached())
            return;
        player.trigger("collided", entity);
        entity.trigger("collided", player);
    };
    ArcadePhysicsSystem.prototype.emitOverlapEvents = function (player, entity) {
        if (player.getHostModel().isDetached() || entity.getHostModel().isDetached())
            return;
        player.trigger("overlapped", entity);
        entity.trigger("overlapped", player);
    };
    ArcadePhysicsSystem.prototype.collidePlayerWithTop = function (player, entity) {
        if (!player._collisionFlagsOld.bottom) {
            player._pos.y = entity.getBottom() - player._rect.y;
        }
        player.collisionFlags.top =
            entity.collisionFlags.bottom = true;
        this.reflectVelocityY(player, entity);
        this.emitCollisionEvents(player, entity);
    };
    ArcadePhysicsSystem.prototype.collidePlayerWithBottom = function (player, entity) {
        player._pos.y = entity.getTop() - player._rect.height - player._rect.y;
        player._pos.x += entity.offsetX;
        entity.offsetX = 0;
        player.collisionFlags.bottom =
            entity.collisionFlags.top = true;
        this.reflectVelocityY(player, entity);
        this.emitCollisionEvents(player, entity);
    };
    ArcadePhysicsSystem.prototype.collidePlayerWithLeft = function (player, entity) {
        player._pos.x = entity.getRight() - player._rect.x;
        player.collisionFlags.left =
            entity.collisionFlags.right = true;
        this.reflectVelocityX(player, entity);
        this.emitCollisionEvents(player, entity);
    };
    ArcadePhysicsSystem.prototype.collidePlayerWithRight = function (player, entity) {
        player._pos.x = entity.getLeft() - player._rect.width - player._rect.x;
        player.collisionFlags.right =
            entity.collisionFlags.left = true;
        this.reflectVelocityX(player, entity);
        this.emitCollisionEvents(player, entity);
    };
    ArcadePhysicsSystem.gravity = new point2d_Point2d(0, 5);
    ArcadePhysicsSystem.STICKY_THRESHOLD = 0.01;
    return ArcadePhysicsSystem;
}());


// CONCATENATED MODULE: ./engine/scene/layer.ts

var layer_Layer = (function () {
    function Layer(game) {
        this.game = game;
        this.type = 'Layer';
        this.transformType = 0;
        this.children = [];
        this._parentChildDelegate = new parentChildDelegate_ParentChildDelegate(this);
    }
    Layer.prototype.appendChild = function (newChild) {
        this._parentChildDelegate.appendChild(newChild);
        this._afterChildAppended(newChild);
    };
    Layer.prototype.appendChildAt = function (newChild, index) {
        this._parentChildDelegate.appendChildAt(newChild, index);
        this._afterChildAppended(newChild);
    };
    Layer.prototype.appendChildAfter = function (modelAfter, newChild) {
        this._parentChildDelegate.appendChildAfter(modelAfter, newChild);
        this._afterChildAppended(newChild);
    };
    Layer.prototype.appendChildBefore = function (modelBefore, newChild) {
        this._parentChildDelegate.appendChildBefore(modelBefore, newChild);
        this._afterChildAppended(newChild);
    };
    Layer.prototype.prependChild = function (newChild) {
        this._parentChildDelegate.prependChild(newChild);
        this._afterChildAppended(newChild);
    };
    Layer.prototype.removeChildAt = function (i) {
        this._parentChildDelegate.removeChildAt(i);
    };
    Layer.prototype.removeChild = function (c) {
        this._parentChildDelegate.removeChild(c);
    };
    Layer.prototype.removeSelf = function () {
        this._parentChildDelegate.removeSelf();
    };
    Layer.prototype.removeChildren = function () {
        this._parentChildDelegate.removeChildren();
    };
    Layer.prototype.moveToFront = function () {
        this._parentChildDelegate.moveToFront();
    };
    Layer.prototype.moveToBack = function () {
        this._parentChildDelegate.moveToBack();
    };
    Layer.prototype.findChildById = function (id) {
        return this._parentChildDelegate.findChildById(id);
    };
    Layer.prototype.getParent = function () {
        return this._scene;
    };
    Layer.prototype.setScene = function (scene) {
        this._scene = scene;
    };
    Layer.prototype.update = function () {
        var all = this.children;
        for (var _i = 0, all_1 = all; _i < all_1.length; _i++) {
            var obj = all_1[_i];
            obj.update();
        }
    };
    Layer.prototype.render = function () {
        for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
            var obj = _a[_i];
            obj.render();
        }
    };
    Layer.prototype._afterChildAppended = function (newChild) {
        newChild.setLayer(this);
        newChild.setScene(this.game.getCurrScene());
        newChild.parent = undefined;
        newChild.revalidate();
    };
    return Layer;
}());


// CONCATENATED MODULE: ./engine/scene/scene.ts












var IDENTITY_HOLDER = mat4_mat4.IDENTITY_HOLDER;
var scene_Scene = (function (_super) {
    __extends(Scene, _super);
    function Scene(game) {
        var _this = _super.call(this, game) || this;
        _this.game = game;
        _this.type = "Scene";
        _this.colorBG = color_Color.WHITE.clone();
        _this.pos = new point2d_Point2d();
        _this.filters = [];
        _this.alpha = 1;
        _this.lifeCycleState = 0;
        _this._layers = [];
        _this._propertyAnimations = [];
        _this._tweenDelegate = new tweenableDelegate_TweenableDelegate();
        _this._timerDelegate = new timerDelegate_TimerDelegate();
        _this._eventEmitterDelegate = new eventEmitterDelegate_EventEmitterDelegate();
        _this.resourceLoader = new resourceLoader_ResourceLoader(game);
        _this.size.set(_this.game.size);
        return _this;
    }
    Scene.isLayerGuard = function (modelOrLayer) {
        return modelOrLayer.type === 'Layer';
    };
    Scene.prototype.revalidate = function () {
        if (this.size.isZero())
            this.size.set(this.game.size);
    };
    Scene.prototype.getLayers = function () {
        return this._layers;
    };
    Scene.prototype.getDefaultLayer = function () {
        if (!this._layers.length)
            this.appendChild(new layer_Layer(this.game));
        return this._layers[this._layers.length - 1];
    };
    Scene.prototype.getLayerById = function (id) {
        for (var _i = 0, _a = this._layers; _i < _a.length; _i++) {
            var layer = _a[_i];
            if (layer.id === id)
                return layer;
        }
        return undefined;
    };
    Scene.prototype.getLayerAtIndex = function (index) {
        return this._layers[index];
    };
    Scene.prototype.removeChild = function (modelOrLayer) {
        if (Scene.isLayerGuard(modelOrLayer)) {
            var i = this._layers.indexOf(modelOrLayer);
            if ( true && i === -1)
                throw new debugError_DebugError("can not remove layer: is doesn't belong to target scene");
            this._layers.splice(i, 1);
        }
        else {
            this.getDefaultLayer().removeChild(modelOrLayer);
        }
    };
    Scene.prototype.appendChild = function (modelOrLayer) {
        if (Scene.isLayerGuard(modelOrLayer)) {
            modelOrLayer.setScene(this);
            this._layers.push(modelOrLayer);
        }
        else {
            modelOrLayer.revalidate();
            this.getDefaultLayer().appendChild(modelOrLayer);
        }
    };
    Scene.prototype.prependChild = function (go) {
        this.getDefaultLayer().prependChild(go);
    };
    Scene.prototype.fitSizeToChildren = function () {
        var maxRight = this.game.size.width;
        var maxBottom = this.game.size.height;
        this._layers.forEach(function (l) {
            l.children.forEach(function (c) {
                var right = c.pos.x + c.size.width;
                var bottom = c.pos.y + c.size.height;
                if (right > maxRight)
                    maxRight = right;
                if (bottom > maxBottom)
                    maxBottom = bottom;
            });
        });
        this.size.setWH(maxRight, maxBottom);
    };
    Scene.prototype.update = function () {
        if (!this.resourceLoader.isCompleted()) {
            if (this.preloadingGameObject !== undefined) {
                this.preloadingGameObject.update();
            }
        }
        else {
            this.updateFrame();
        }
    };
    Scene.prototype.renderToTexture = function (target) {
        this.game.getRenderer().getHelper().renderSceneToTexture(this, target);
    };
    Scene.prototype.addPropertyAnimation = function (animation) {
        this._propertyAnimations.push(animation);
    };
    Scene.prototype.addTween = function (t) {
        this._tweenDelegate.addTween(t);
    };
    Scene.prototype.addTweenMovie = function (tm) {
        this._tweenDelegate.addTweenMovie(tm);
    };
    Scene.prototype.tween = function (desc) {
        return this._tweenDelegate.tween(desc);
    };
    Scene.prototype.setTimeout = function (callback, interval) {
        return this._timerDelegate.setTimeout(callback, interval);
    };
    Scene.prototype.setInterval = function (callback, interval) {
        return this._timerDelegate.setInterval(callback, interval);
    };
    Scene.prototype.off = function (eventName, callBack) {
        this._eventEmitterDelegate.off(eventName, callBack);
    };
    Scene.prototype.on = function (eventName, callBack) {
        return this._eventEmitterDelegate.on(eventName, callBack);
    };
    Scene.prototype.once = function (eventName, callBack) {
        this._eventEmitterDelegate.once(eventName, callBack);
    };
    Scene.prototype.trigger = function (eventName, data) {
        this._eventEmitterDelegate.trigger(eventName, data);
    };
    Scene.prototype.findChildById = function (id) {
        for (var _i = 0, _a = this._layers; _i < _a.length; _i++) {
            var l = _a[_i];
            var possibleObject = l.findChildById(id);
            if (possibleObject)
                return possibleObject;
        }
        return undefined;
    };
    Scene.prototype.onPreloading = function () {
        var rect = new rectangle_Rectangle(this.game);
        rect.fillColor.setRGB(10, 100, 100);
        rect.size.height = 10;
        this.preloadingGameObject = rect;
    };
    Scene.prototype.onProgress = function (val) {
        if (this.preloadingGameObject !== undefined)
            this.preloadingGameObject.size.width = val * this.game.size.width;
    };
    Scene.prototype.onReady = function () { };
    Scene.prototype.onContinue = function () { };
    Scene.prototype.render = function () {
        var _a, _b;
        var renderer = this.game.getRenderer();
        renderer.transformSave();
        renderer.saveAlphaBlend();
        renderer.clearColor.set(this.colorBG);
        var statePointer = renderer.beforeFrameDraw(this.filters);
        if (this.game.camera.worldTransformDirty) {
            this.game.camera.translate();
            this.game.camera.transform();
            (_a = this.game.camera.worldTransformMatrix).set.apply(_a, this.game.getRenderer().transformGet());
        }
        else {
            (_b = this.game.getRenderer()).transformSet.apply(_b, this.game.camera.worldTransformMatrix.mat16);
        }
        this.translate();
        this.transform();
        renderer.setAlphaBlend(this.alpha);
        if (!this.resourceLoader.isCompleted()) {
            if (this.preloadingGameObject !== undefined) {
                this.preloadingGameObject.render();
            }
        }
        else {
            for (var _i = 0, _c = this._layers; _i < _c.length; _i++) {
                var l = _c[_i];
                if (l.transformType === 1) {
                    renderer.transformSave();
                    renderer.transformSet.apply(renderer, IDENTITY_HOLDER.mat16);
                }
                l.render();
                if (l.transformType === 1) {
                    renderer.transformRestore();
                }
            }
        }
        renderer.restoreAlphaBlend();
        renderer.transformSave();
        this.onRender();
        renderer.transformRestore();
        if (true) {
            if (this.game.getRenderer().debugTextField &&
                this.game.getRenderer().debugTextField.getFont().getResourceLink() &&
                this.game.getRenderer().debugTextField.getFont().getResourceLink().getTarget()) {
                renderer.transformSave();
                renderer.transformSet.apply(renderer, IDENTITY_HOLDER.mat16);
                this.game.getRenderer().debugTextField.update();
                this.game.getRenderer().debugTextField.render();
                renderer.transformRestore();
            }
        }
        if (this.lockingRect !== undefined)
            renderer.setLockRect(this.lockingRect);
        renderer.afterFrameDraw(statePointer);
        renderer.transformRestore();
        renderer.unsetLockRect();
    };
    Scene.prototype.onInactivated = function () { };
    Scene.prototype.onUpdate = function () { };
    Scene.prototype.onRender = function () { };
    Scene.prototype.updateFrame = function () {
        this.game.camera.update();
        this._tweenDelegate.update();
        this._timerDelegate.update();
        for (var _i = 0, _a = this._propertyAnimations; _i < _a.length; _i++) {
            var a = _a[_i];
            a.update();
        }
        for (var _b = 0, _c = this._layers; _b < _c.length; _b++) {
            var l = _c[_b];
            l.update();
        }
        if (this.game.getPhysicsSystem() !== undefined)
            this.game.getPhysicsSystem().nextTick(this);
        this.onUpdate();
    };
    return Scene;
}(transformableModel_TransformableModel));


// CONCATENATED MODULE: ./engine/resources/resourceDecorators.ts
var PrefabFactory = {
    createPrefab: function (game, clazz) {
        return new clazz(game);
    }
};
var Prefab = function () {
    return function (target) {
        target.prototype.doPrefabStuff = function () {
        };
    };
};
var Source = {
    Test: function (s) {
        return function (target, propertyKey) {
            console.log('decorated field', target, propertyKey);
        };
    },
    Texture: function (src) {
        return function (target, propertyKey) {
            target.preloadingTaskFromDecorators = target.preloadingTaskFromDecorators || [];
            target.preloadingTaskFromDecorators.push(function (currScene) {
                currScene[propertyKey] = currScene.resourceLoader.loadTexture(src);
            });
        };
    },
    Sound: function (src) {
        return function (target, propertyKey) {
            target.preloadingTaskFromDecorators = target.preloadingTaskFromDecorators || [];
            target.preloadingTaskFromDecorators.push(function (currScene) {
                currScene[propertyKey] = currScene.resourceLoader.loadSound(src);
            });
        };
    },
    CubeTexture: function (leftSide, rightSide, topSide, bottomSide, frontSide, backSide) {
        return function (target, propertyKey) {
            target.preloadingTaskFromDecorators = target.preloadingTaskFromDecorators || [];
            target.preloadingTaskFromDecorators.push(function (currScene) {
                currScene[propertyKey] =
                    currScene.resourceLoader.loadCubeTexture(leftSide, rightSide, topSide, bottomSide, frontSide, backSide);
            });
        };
    }
};

// CONCATENATED MODULE: ./engine/media/sound.ts

var sound_Sound = (function () {
    function Sound(game) {
        this.game = game;
        this.type = 'Sound';
        this._loop = false;
        this._gain = 1;
        this._velocity = 1;
        this._stereoPan = 0.5;
    }
    Object.defineProperty(Sound.prototype, "loop", {
        get: function () {
            return this._loop;
        },
        set: function (value) {
            this._loop = value;
            this.game.getAudioPlayer().loop(this);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Sound.prototype, "gain", {
        get: function () {
            return this._gain;
        },
        set: function (value) {
            this._gain = value;
            this.game.getAudioPlayer().setGain(this);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Sound.prototype, "velocity", {
        get: function () {
            return this._velocity;
        },
        set: function (value) {
            this._velocity = value;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Sound.prototype, "stereoPan", {
        get: function () {
            return this._stereoPan;
        },
        set: function (value) {
            this._stereoPan = value;
        },
        enumerable: true,
        configurable: true
    });
    Sound.prototype.revalidate = function () {
        if (!this.getResourceLink())
            throw new debugError_DebugError("can not play sound: resource link is not set");
    };
    Sound.prototype.play = function () {
        this.game.getAudioPlayer().play(this);
    };
    Sound.prototype.stop = function () {
        this.game.getAudioPlayer().stop(this);
    };
    Sound.prototype.pause = function () {
        throw new debugError_DebugError('not implemented');
    };
    Sound.prototype.setResourceLink = function (link) {
        this._resourceLink = link;
    };
    Sound.prototype.getResourceLink = function () {
        return this._resourceLink;
    };
    return Sound;
}());


// CONCATENATED MODULE: ./engine/renderer/common/linearGradient.ts


var linearGradient_LinearGradient = (function () {
    function LinearGradient() {
        this.type = 'LinearGradient';
        this.colorFrom = new color_Color(0, 0, 0);
        this.colorTo = new color_Color(200, 200, 200);
        this.angle = 0.1;
        this._arr = new Array(12);
    }
    LinearGradient.prototype.fromJSON = function (json) {
        if (true) {
            if (!json.colorFrom)
                throw new debugError_DebugError("can not parse LinearGradient from JSON: colorFrom not defined");
            if (!json.colorTo)
                throw new debugError_DebugError("can not parse LinearGradient from JSON: colorTo not defined");
        }
        this.colorFrom.fromJSON(json.colorFrom);
        this.colorTo.fromJSON(json.colorTo);
    };
    LinearGradient.prototype.set = function (g) {
        this.colorFrom.set(g.colorFrom);
        this.colorTo.set(g.colorTo);
        this.angle = g.angle;
    };
    LinearGradient.prototype.toJSON = function () {
        return {
            colorFrom: this.colorFrom.toJSON(),
            colorTo: this.colorTo.toJSON()
        };
    };
    LinearGradient.prototype.asGL = function () {
        var cFrom = this.colorFrom.asGL();
        var cTo = this.colorTo.asGL();
        this._arr[0] = cFrom[0];
        this._arr[1] = cFrom[1];
        this._arr[2] = cFrom[2];
        this._arr[3] = cFrom[3];
        this._arr[4] = cTo[0];
        this._arr[5] = cTo[1];
        this._arr[6] = cTo[2];
        this._arr[7] = cTo[3];
        this._arr[8] = this.angle;
        this._arr[9] = 0;
        this._arr[10] = 0;
        this._arr[11] = 0;
        return this._arr;
    };
    LinearGradient.prototype.asCSS = function () {
        return '';
    };
    LinearGradient.prototype.clone = function () {
        var cloned = new LinearGradient();
        cloned.fromJSON(this.toJSON());
        return cloned;
    };
    return LinearGradient;
}());


// CONCATENATED MODULE: ./catGame/entity/abstract/abstractSprite.ts


var abstractSprite_AbstractSprite = (function () {
    function AbstractSprite(game, spriteSheet) {
        this.game = game;
        this.renderableImage = this.onCreatedRenderableModel(spriteSheet);
        this.onCreatedFrameAnimation();
        this.appendToScene();
    }
    AbstractSprite.prototype.getRenderableModel = function () {
        return this.renderableImage;
    };
    AbstractSprite.prototype.onCreatedFrameAnimation = function () {
    };
    AbstractSprite.prototype.createRange = function (from, to) {
        if (from > to)
            throw new debugError_DebugError("can not create range with from=" + from + " and to=" + to);
        var arr = [];
        while (from <= to) {
            arr.push(from++);
        }
        return arr;
    };
    AbstractSprite.prototype.onCreatedRenderableModel = function (spriteSheet) {
        var img = new image_Image(this.game);
        img.setResourceLink(spriteSheet);
        return img;
    };
    AbstractSprite.prototype.appendToScene = function () {
        this.game.getCurrScene().getLayerAtIndex(1).appendChild(this.renderableImage);
        this.renderableImage.transformPoint.setToCenter();
    };
    return AbstractSprite;
}());


// CONCATENATED MODULE: ./catGame/entity/abstract/abstractEntity.ts


var abstractEntity_AbstractEntity = (function (_super) {
    __extends(AbstractEntity, _super);
    function AbstractEntity(game, spriteSheet, params) {
        var _this = _super.call(this, game, spriteSheet) || this;
        _this.game = game;
        _this.body = _this.onCreatedRigidBody(params);
        return _this;
    }
    AbstractEntity.prototype.onCreatedRigidBody = function (params) {
        var rigidBody = this.game.getPhysicsSystem().createRigidBody(params);
        this.renderableImage.setRigidBody(rigidBody);
        return rigidBody;
    };
    AbstractEntity.groupName = 'abstractEntity';
    return AbstractEntity;
}(abstractSprite_AbstractSprite));


// CONCATENATED MODULE: ./catGame/entity/object/impl/wall.ts




var wall_Wall = (function (_super) {
    __extends(Wall, _super);
    function Wall(game, size, resource, movePlatformInfo) {
        var _this = _super.call(this, game, resource, {
            groupNames: [Wall.groupName],
            type: ARCADE_RIGID_BODY_TYPE.KINEMATIC,
            rect: new rect_Rect(0, 0, size.width, size.height)
        }) || this;
        _this.game = game;
        var rect = _this.getRenderableModel();
        rect.size.set(size);
        rect.setResourceLink(resource);
        rect.stretchMode = 1;
        rect.lineWidth = 2;
        rect.borderRadius = 5;
        if ((movePlatformInfo === null || movePlatformInfo === void 0 ? void 0 : movePlatformInfo.fromY) !== undefined) {
            _this.startMoveableY(movePlatformInfo);
        }
        else if ((movePlatformInfo === null || movePlatformInfo === void 0 ? void 0 : movePlatformInfo.fromX) !== undefined) {
            _this.startMoveableX(movePlatformInfo);
        }
        return _this;
    }
    Wall.prototype.startMoveableY = function (movePlatformInfo) {
        var d = 1;
        if (movePlatformInfo.fromY > movePlatformInfo.toY) {
            var tmp = movePlatformInfo.fromY;
            movePlatformInfo.fromY = movePlatformInfo.toY;
            movePlatformInfo.toY = tmp;
        }
        var model = this.renderableImage;
        this.game.getCurrScene().setInterval(function () {
            model.pos.y += d;
            if (model.pos.y > movePlatformInfo.toY)
                d = -1;
            else if (model.pos.y < movePlatformInfo.fromY)
                d = 1;
        }, 20);
    };
    Wall.prototype.startMoveableX = function (movePlatformInfo) {
        var d = 1;
        if (movePlatformInfo.fromX > movePlatformInfo.toX) {
            var tmp = movePlatformInfo.fromX;
            movePlatformInfo.fromX = movePlatformInfo.toX;
            movePlatformInfo.toX = tmp;
        }
        var model = this.renderableImage;
        this.game.getCurrScene().setInterval(function () {
            model.pos.x += d;
            if (model.pos.x > movePlatformInfo.toX)
                d = -1;
            else if (model.pos.x < movePlatformInfo.fromX)
                d = 1;
        }, 20);
    };
    Wall.groupName = 'wall';
    return Wall;
}(abstractEntity_AbstractEntity));


// EXTERNAL MODULE: ./catGame/level/intro.json
var level_intro = __webpack_require__(10);
var intro_namespaceObject = /*#__PURE__*/__webpack_require__.t(level_intro, 2);

// CONCATENATED MODULE: ./catGame/scene/abstracts/baseAbstractIntroScene.ts














var baseAbstractIntroScene_BaseAbstractIntroScene = (function (_super) {
    __extends(BaseAbstractIntroScene, _super);
    function BaseAbstractIntroScene() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.level = intro_namespaceObject;
        return _this;
    }
    BaseAbstractIntroScene.prototype.onReady = function () {
        this.setBg();
        this.loadLevel();
        this.startSound();
        this.createUI();
        this.listenUI();
    };
    BaseAbstractIntroScene.prototype.startSound = function () {
        var snd = new sound_Sound(this.game);
        snd.setResourceLink(this.soundThemeRes);
        snd.loop = true;
        snd.play();
        this.snd = snd;
    };
    BaseAbstractIntroScene.prototype.setBg = function () {
        var bgLayer = new layer_Layer(this.game);
        bgLayer.transformType = 1;
        var bgImage = new rectangle_Rectangle(this.game);
        bgImage.lineWidth = 0;
        bgImage.size.set(this.game.size);
        var grad = new linearGradient_LinearGradient();
        grad.colorFrom = color_Color.RGB(219, 230, 255);
        grad.colorTo = color_Color.RGB(198, 202, 202);
        grad.angle = -mathEx_MathEx.degToRad(90);
        bgImage.fillColor = grad;
        bgLayer.appendChild(bgImage);
        this.appendChild(bgLayer);
        this.appendChild(new layer_Layer(this.game));
    };
    BaseAbstractIntroScene.prototype.loadLevel = function () {
        var _this = this;
        this.level.layers[0].objects.forEach(function (obj) {
            var objCreated;
            switch (obj.type) {
                case wall_Wall.groupName:
                    objCreated = new wall_Wall(_this.game, new size_Size(obj.width, obj.height), _this.wall1);
                    break;
                default:
                    break;
            }
            if (objCreated !== undefined) {
                objCreated.getRenderableModel().pos.setXY(obj.x, obj.y);
            }
        });
    };
    BaseAbstractIntroScene.prototype.createUI = function () {
        var rectangle = new rectangle_Rectangle(this.game);
        rectangle.fillColor = color_Color.RGBA(22, 22, 22, 100);
        rectangle.size.setWH(this.game.size.width - 40, this.game.size.height - 40);
        rectangle.pos.setXY(20, 20);
        rectangle.borderRadius = 10;
        this.appendChild(rectangle);
        var img = new image_Image(this.game);
        img.setResourceLink(this.spriteSheetLabel);
        this.appendChild(img);
        img.pos.setXY(this.game.size.width / 2, this.game.size.height / 2);
        img.anchorPoint.setToCenter();
        this.setInterval(function () {
            img.visible = !img.visible;
        }, 1000);
    };
    BaseAbstractIntroScene.prototype.listenUI = function () { };
    __decorate([
        Source.Texture('./catGame/res/sprite/wall1.png'),
        __metadata("design:type", ResourceLink)
    ], BaseAbstractIntroScene.prototype, "wall1", void 0);
    return BaseAbstractIntroScene;
}(scene_Scene));


// CONCATENATED MODULE: ./catGame/entity/object/impl/infoPanel.ts



var infoPanel_InfoPanel = (function () {
    function InfoPanel(game, heroSprite) {
        this.game = game;
        this.heroSprite = heroSprite;
        this.heroIcons = [];
        this.container = new rectangle_Rectangle(this.game);
        this.lifeBarWidth = 500;
        this.life = 100;
        this.numOfLives = 0;
        this.container.size.setWH(this.game.size.width, 60);
        this.container.fillColor = color_Color.RGBA(25, 25, 25, 150);
        this.container.borderRadius = 5;
        this.game.getCurrScene().appendChild(this.container);
        this.createLifeBar();
        this.updateLifeBar();
        this.updateNumOfLives(0);
    }
    InfoPanel.getCreatedInstance = function () {
        return InfoPanel.instance;
    };
    InfoPanel.instantiate = function (game, heroSprite) {
        InfoPanel.instance = new InfoPanel(game, heroSprite);
    };
    InfoPanel.prototype.incrementNumOfLives = function () {
        this.updateNumOfLives(this.numOfLives + 1);
    };
    InfoPanel.prototype.decrementPower = function (val, onLifeDecremented) {
        this.life -= val;
        if (this.life <= 0) {
            this.life = 100;
            this.decrementNumOfLives();
            onLifeDecremented();
        }
        this.updateLifeBar();
    };
    InfoPanel.prototype.incrementPower = function () {
        this.life += 10;
        if (this.life > 100) {
            this.life = 100;
            return;
        }
        this.updateLifeBar();
    };
    InfoPanel.prototype.decrementNumOfLives = function () {
        this.life = 100;
        this.updateLifeBar();
        var lastLifeIcon = this.heroIcons.length ? this.heroIcons[this.heroIcons.length - 1] : undefined;
        if (lastLifeIcon !== undefined)
            lastLifeIcon = lastLifeIcon.clone();
        this.updateNumOfLives(this.numOfLives - 1);
        this.game.camera.shake(15, 600);
        if (lastLifeIcon !== undefined) {
            this.container.appendChild(lastLifeIcon);
            var cnt_1 = 0;
            var tmr_1 = this.game.getCurrScene().setInterval(function () {
                lastLifeIcon.visible = !lastLifeIcon.visible;
                cnt_1++;
                if (cnt_1 === 8) {
                    tmr_1.kill();
                    lastLifeIcon.removeSelf();
                }
            }, 300);
        }
    };
    InfoPanel.prototype.updateNumOfLives = function (val) {
        this.numOfLives = val;
        for (var i = 0; i < this.heroIcons.length; i++) {
            var heroIcon = this.heroIcons[i];
            if (heroIcon)
                heroIcon.removeSelf();
        }
        this.heroIcons = [];
        for (var i = 0; i < val; i++) {
            var heroIcon = new image_Image(this.game);
            heroIcon.setResourceLink(this.heroSprite);
            heroIcon.getSrcRect().setWH(64, 64);
            heroIcon.size.setWH(64, 64);
            heroIcon.scale.setXY(0.5);
            heroIcon.pos.setXY(25 * i, 10);
            this.container.appendChild(heroIcon);
            this.heroIcons.push(heroIcon);
        }
    };
    InfoPanel.prototype.getNumOfLives = function () {
        return this.numOfLives;
    };
    InfoPanel.prototype.createLifeBar = function () {
        var outerRect = new rectangle_Rectangle(this.game);
        outerRect.pos.setXY(10, 40);
        outerRect.size.setWH(this.lifeBarWidth + 4, 10);
        outerRect.fillColor = color_Color.BLACK;
        outerRect.color = color_Color.WHITE;
        outerRect.borderRadius = 3;
        var innerRect = new rectangle_Rectangle(this.game);
        innerRect.size.setWH(this.lifeBarWidth, 6);
        innerRect.pos.setXY(2, 2);
        innerRect.fillColor = color_Color.RGB(122, 0, 0);
        innerRect.lineWidth = 0;
        outerRect.appendChild(innerRect);
        this.lifeBarContainer = innerRect;
        this.container.appendChild(outerRect);
    };
    InfoPanel.prototype.updateLifeBar = function () {
        if (this.life < 30)
            this.lifeBarContainer.fillColor.setRGB(123, 22, 23);
        else if (this.life < 50)
            this.lifeBarContainer.fillColor.setRGB(123, 123, 23);
        else
            this.lifeBarContainer.fillColor.setRGB(23, 123, 23);
        this.lifeBarContainer.size.width = this.lifeBarWidth * this.life / 100;
    };
    return InfoPanel;
}());


// EXTERNAL MODULE: ./catGame/level/l0.json
var l0 = __webpack_require__(4);
var l0_namespaceObject = /*#__PURE__*/__webpack_require__.t(l0, 2);

// EXTERNAL MODULE: ./catGame/level/l1.json
var l1 = __webpack_require__(5);
var l1_namespaceObject = /*#__PURE__*/__webpack_require__.t(l1, 2);

// EXTERNAL MODULE: ./catGame/level/l2.json
var l2 = __webpack_require__(6);
var l2_namespaceObject = /*#__PURE__*/__webpack_require__.t(l2, 2);

// EXTERNAL MODULE: ./catGame/level/l3.json
var l3 = __webpack_require__(7);
var l3_namespaceObject = /*#__PURE__*/__webpack_require__.t(l3, 2);

// EXTERNAL MODULE: ./catGame/level/l4.json
var l4 = __webpack_require__(8);
var l4_namespaceObject = /*#__PURE__*/__webpack_require__.t(l4, 2);

// EXTERNAL MODULE: ./catGame/level/l5.json
var l5 = __webpack_require__(9);
var l5_namespaceObject = /*#__PURE__*/__webpack_require__.t(l5, 2);

// CONCATENATED MODULE: ./engine/renderable/impl/general/animatedImage.ts



var animatedImage_AnimatedImage = (function (_super) {
    __extends(AnimatedImage, _super);
    function AnimatedImage(game) {
        var _this = _super.call(this, game) || this;
        _this.type = 'AnimatedImage';
        _this._frameAnimations = {};
        return _this;
    }
    AnimatedImage.prototype.revalidate = function () {
        var _this = this;
        Object.keys(this._frameAnimations).forEach(function (key) {
            _this._frameAnimations[key].revalidate();
        });
        _super.prototype.revalidate.call(this);
    };
    AnimatedImage.prototype.clone = function () {
        var cloned = new AnimatedImage(this.game);
        this.setClonedProperties(cloned);
        return cloned;
    };
    AnimatedImage.prototype.addFrameAnimation = function (name, fa) {
        if ( true && fa.target !== undefined) {
            throw new debugError_DebugError("can not add FrameAnimation: this animation is already attached to another AnimatedImage object");
        }
        if ( true && this._frameAnimations[name] !== undefined) {
            throw new debugError_DebugError("can not add FrameAnimation: another animation with name \"" + name + "\" is already attached");
        }
        fa.name = name;
        this._frameAnimations[name] = fa;
        fa.target = this;
    };
    AnimatedImage.prototype.playFrameAnimation = function (fr) {
        var frameAnimation;
        if (typeof fr === 'string') {
            frameAnimation = this._frameAnimations[fr];
        }
        else
            frameAnimation = fr;
        if ( true && !frameAnimation)
            throw new debugError_DebugError("no such frame animation: '" + fr + "'");
        if (this._currFrameAnimation)
            this._currFrameAnimation.stop();
        this._currFrameAnimation = frameAnimation;
        frameAnimation.play();
    };
    AnimatedImage.prototype.stopFrameAnimation = function () {
        if (this._currFrameAnimation !== undefined)
            this._currFrameAnimation.stop();
        this._currFrameAnimation = undefined;
    };
    AnimatedImage.prototype.getCurrentFrameAnimation = function () {
        return this._currFrameAnimation;
    };
    AnimatedImage.prototype.update = function () {
        _super.prototype.update.call(this);
        if (this._currFrameAnimation)
            this._currFrameAnimation.update();
    };
    AnimatedImage.prototype.setClonedProperties = function (cloned) {
        var _this = this;
        if ( true && !('clone' in this)) {
            console.error(this);
            throw new debugError_DebugError("can not clone sprite: cloneable interface is not implemented");
        }
        Object.keys(this._frameAnimations).forEach(function (key) {
            var fr = _this._frameAnimations[key].clone();
            fr.afterCloned(cloned);
            cloned.addFrameAnimation(key, fr);
        });
        if (this._currFrameAnimation) {
            cloned.playFrameAnimation(this._currFrameAnimation.name);
        }
        _super.prototype.setClonedProperties.call(this, cloned);
    };
    return AnimatedImage;
}(image_Image));


// CONCATENATED MODULE: ./engine/animation/frameAnimation/abstract/abstractFrameAnimation.ts



var abstractFrameAnimation_AbstractFrameAnimation = (function () {
    function AbstractFrameAnimation(game) {
        this.game = game;
        this.duration = 1000;
        this.isRepeating = true;
        this.frames = [];
        this._currFrame = -1;
        this._startTime = 0;
        this._isPlaying = false;
        this._loopReached = false;
        this._eventEmitterDelegate = new eventEmitterDelegate_EventEmitterDelegate();
    }
    AbstractFrameAnimation.prototype.revalidate = function () {
        if ( true && !this.frames.length)
            throw new debugError_DebugError("animation frames can not be empty");
        this._timeForOneFrame = ~~(this.duration / this.frames.length);
        this.onNextFrame(0);
    };
    AbstractFrameAnimation.prototype.play = function () {
        var _a;
        if ( true && !this.target)
            throw new debugError_DebugError("can not play frame animation: it is not attached to parent");
        if ((_a = this.target.getCurrentFrameAnimation()) === null || _a === void 0 ? void 0 : _a._isPlaying) {
            this.target.getCurrentFrameAnimation().trigger("canceled");
        }
        if (this.target.getCurrentFrameAnimation() !== this) {
            this.target.playFrameAnimation(this);
        }
        this._isPlaying = true;
        return this;
    };
    AbstractFrameAnimation.prototype.stop = function () {
        if ( true && !this.target)
            throw new debugError_DebugError("can not stop frame animation: it is not attached to parent");
        this._isPlaying = false;
        this._startTime = 0;
        this._loopReached = false;
    };
    AbstractFrameAnimation.prototype.update = function () {
        if (!this._isPlaying)
            return;
        var time = this.game.getCurrentTime();
        if (!this._startTime)
            this._startTime = time;
        var delta = (time - this._startTime) % this.duration;
        var currFrame = ~~((this.frames.length) * delta / this.duration);
        currFrame = currFrame % this.frames.length;
        if (currFrame === this._currFrame)
            return;
        if (this._loopReached && !this.isRepeating) {
            this.stop();
            this.trigger("completed");
            return;
        }
        this._currFrame = currFrame;
        this.onNextFrame(currFrame);
        if (this._currFrame === this.frames.length - 1) {
            this.trigger("loop");
            this._loopReached = true;
        }
    };
    AbstractFrameAnimation.prototype.off = function (eventName, callBack) {
        this._eventEmitterDelegate.off(eventName, callBack);
    };
    AbstractFrameAnimation.prototype.on = function (eventName, callBack) {
        return this._eventEmitterDelegate.on(eventName, callBack);
    };
    AbstractFrameAnimation.prototype.once = function (eventName, callBack) {
        this._eventEmitterDelegate.once(eventName, callBack);
    };
    AbstractFrameAnimation.prototype.trigger = function (eventName, data) {
        this._eventEmitterDelegate.trigger(eventName, data);
    };
    AbstractFrameAnimation.prototype.afterCloned = function (g) { };
    AbstractFrameAnimation.prototype.setClonedProperties = function (cloned) {
        cloned.frames = __spreadArrays(this.frames);
        cloned.duration = this.duration;
        cloned.isRepeating = this.isRepeating;
        cloned.name = this.name;
    };
    return AbstractFrameAnimation;
}());


// CONCATENATED MODULE: ./engine/animation/frameAnimation/cellFrameAnimation.ts



var cellFrameAnimation_CellFrameAnimation = (function (_super) {
    __extends(CellFrameAnimation, _super);
    function CellFrameAnimation() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.type = 'CellFrameAnimation';
        return _this;
    }
    CellFrameAnimation.prototype.setSpriteSheetSize = function (sizeOrNumOfFramesH, numOfFramesV) {
        if (sizeOrNumOfFramesH.toFixed !== undefined) {
            this._numOfFramesH = sizeOrNumOfFramesH;
            this._numOfFramesV = numOfFramesV;
        }
        else {
            this._numOfFramesH = sizeOrNumOfFramesH.width;
            this._numOfFramesV = sizeOrNumOfFramesH.height;
        }
    };
    CellFrameAnimation.prototype.revalidate = function () {
        if (true) {
            if (!this.target)
                throw new debugError_DebugError("cellFrameAnimation is not attached to target! Invoke animatedImage.setFrameAnimation() method");
            if (this._numOfFramesV <= 0 || this._numOfFramesH <= 0) {
                throw new debugError_DebugError("can not play CellFrameAnimation: cellFrameAnimation.setSpriteSheetSize() not invoked or invoked with wrong parameters");
            }
        }
        var _a = this.target.getResourceLink().getTarget().size, width = _a.width, height = _a.height;
        var frameWidth = ~~(width / this._numOfFramesH);
        var frameHeight = ~~(height / this._numOfFramesV);
        this.target.getSrcRect().setWH(frameWidth, frameHeight);
        this.target.size.setWH(frameWidth, frameHeight);
        _super.prototype.revalidate.call(this);
    };
    CellFrameAnimation.prototype.clone = function () {
        var cloned = new CellFrameAnimation(this.game);
        this.setClonedProperties(cloned);
        return cloned;
    };
    CellFrameAnimation.prototype.afterCloned = function (g) {
        _super.prototype.afterCloned.call(this, g);
        this.setSpriteSheetSize(this._numOfFramesH, this._numOfFramesV);
    };
    CellFrameAnimation.prototype.onNextFrame = function (i) {
        this.setFrameIndex(this.frames[i]);
    };
    CellFrameAnimation.prototype.setClonedProperties = function (cloned) {
        cloned._numOfFramesH = this._numOfFramesH;
        cloned._numOfFramesV = this._numOfFramesV;
        _super.prototype.setClonedProperties.call(this, cloned);
    };
    CellFrameAnimation.prototype.getFramePosX = function (frameIndex) {
        return (frameIndex % this._numOfFramesH) * this.target.getSrcRect().width;
    };
    CellFrameAnimation.prototype.getFramePosY = function (frameIndex) {
        return ~~(frameIndex / this._numOfFramesH) * this.target.getSrcRect().height;
    };
    CellFrameAnimation.prototype.setFrameIndex = function (frameIndex) {
        this.target.getSrcRect().setXY(this.getFramePosX(frameIndex), this.getFramePosY(frameIndex));
    };
    return CellFrameAnimation;
}(abstractFrameAnimation_AbstractFrameAnimation));


// CONCATENATED MODULE: ./catGame/entity/actor/abstract/abstractCharacter.ts




var abstractCharacter_AbstractCharacter = (function (_super) {
    __extends(AbstractCharacter, _super);
    function AbstractCharacter(game, spr, params) {
        var _this = _super.call(this, game, spr, params) || this;
        _this.game = game;
        _this.velocity = 10;
        _this.idle();
        return _this;
    }
    AbstractCharacter.prototype.onCreatedRenderableModel = function (spriteSheet) {
        var img = new animatedImage_AnimatedImage(this.game);
        img.setResourceLink(spriteSheet);
        return img;
    };
    AbstractCharacter.prototype.createFrameAnimation = function (name, frames, duration, spriteSheetSize) {
        var animation = new cellFrameAnimation_CellFrameAnimation(this.game);
        animation.frames = frames;
        animation.duration = duration;
        animation.setSpriteSheetSize(spriteSheetSize);
        this.renderableImage.addFrameAnimation(name, animation);
        return animation;
    };
    AbstractCharacter.prototype.goLeft = function () {
        this.body.velocity.x = -Math.abs(this.velocity);
        this.renderableImage.scale.x = -1;
        this.walkAnimation.play();
    };
    AbstractCharacter.prototype.goRight = function () {
        this.body.velocity.x = Math.abs(this.velocity);
        this.renderableImage.scale.x = 1;
        this.walkAnimation.play();
    };
    AbstractCharacter.prototype.idle = function () {
        this.body.velocity.x = 0;
        this.idleAnimation.play();
    };
    AbstractCharacter.prototype.jump = function (velY) {
        var _this = this;
        if (this.body.collisionFlags.bottom) {
            this.body.velocity.y -= velY;
        }
        if (this.jumpAnimation !== undefined) {
            this.jumpAnimation.play().once("completed", function (ev) { return _this.idleAnimation.play(); });
        }
    };
    AbstractCharacter.groupName = 'abstractCharacter';
    return AbstractCharacter;
}(abstractEntity_AbstractEntity));


// CONCATENATED MODULE: ./engine/renderable/impl/general/nullGameObject.ts


var nullGameObject_NullGameObject = (function (_super) {
    __extends(NullGameObject, _super);
    function NullGameObject(game) {
        var _this = _super.call(this, game) || this;
        _this.game = game;
        return _this;
    }
    NullGameObject.prototype.draw = function () { };
    return NullGameObject;
}(renderableModel_RenderableModel));


// CONCATENATED MODULE: ./engine/renderable/impl/general/particleSystem.ts






var particleSystem_r = function (obj) { return mathEx_MathEx.random(obj.from, obj.to); };
var particleSystem_ParticleSystem = (function (_super) {
    __extends(ParticleSystem, _super);
    function ParticleSystem(game) {
        var _this = _super.call(this, game) || this;
        _this.game = game;
        _this.type = 'ParticleSystem';
        _this.enabled = true;
        _this.emitAuto = true;
        _this.numOfParticlesToEmit = { from: 1, to: 10 };
        _this.particleAngle = { from: 0, to: Math.PI * 2 };
        _this.particleVelocity = { from: 1, to: 100 };
        _this.particleLiveTime = { from: 100, to: 1000 };
        _this.emissionRadius = 0;
        _this.emissionPosition = new point2d_Point2d();
        _this.emissionTarget = _this;
        _this._particles = [];
        _this._prototypes = [];
        _this._onUpdateParticle = object["e" /* noop */];
        _this._onEmitParticle = object["e" /* noop */];
        return _this;
    }
    ParticleSystem.prototype.revalidate = function () {
        if ( true && !this._prototypes.length)
            throw new debugError_DebugError("particle system error: add at least one object to emit");
        if (this.particleAngle.to < this.particleAngle.from)
            this.particleAngle.to += 2 * Math.PI;
    };
    ParticleSystem.prototype.addParticle = function (renderableCloneable) {
        if ( true && !renderableCloneable.clone) {
            console.error(particleSystem_r);
            throw new debugError_DebugError("can not add particle: model does not implement cloneable interface");
        }
        renderableCloneable.revalidate();
        this._prototypes.push(renderableCloneable);
    };
    ParticleSystem.prototype.update = function () {
        if (!this.enabled)
            return;
        _super.prototype.update.call(this);
        var time = this.game.getCurrentTime();
        for (var _i = 0, _a = this._particles; _i < _a.length; _i++) {
            var holder = _a[_i];
            if (!holder.active)
                continue;
            this._onUpdateParticle(holder.particle);
            if (time - holder.createdTime > holder.lifeTime) {
                holder.active = false;
                this.emissionTarget.removeChild(holder.particle);
            }
        }
        if (this.emitAuto)
            this.emit();
    };
    ParticleSystem.prototype.onUpdateParticle = function (onUpdateParticle) {
        this._onUpdateParticle = onUpdateParticle;
    };
    ParticleSystem.prototype.onEmitParticle = function (onEmitParticle) {
        this._onEmitParticle = onEmitParticle;
    };
    ParticleSystem.prototype.draw = function () { };
    ParticleSystem.prototype.emit = function () {
        if (!this.enabled)
            return;
        if ( true && !this.getLayer()) {
            console.error(this);
            throw new debugError_DebugError("particle system is detached");
        }
        var num = particleSystem_r(this.numOfParticlesToEmit);
        for (var i = 0; i < num; i++) {
            var particle = void 0;
            var holder = this._particles.find(function (it) { return !it.active; });
            if (holder === undefined) {
                var particleProto = this._prototypes[mathEx_MathEx.randomInt(0, this._prototypes.length - 1)];
                particle = particleProto.clone();
                holder = { particle: particle, lifeTime: 0, createdTime: 0, active: true };
                this._particles.push(holder);
            }
            else {
                particle = holder.particle;
            }
            var angle = particleSystem_r(this.particleAngle);
            var vel = particleSystem_r(this.particleVelocity);
            var velocityX = vel * Math.cos(angle);
            var velocityY = vel * Math.sin(angle);
            var rigidBody = particle.getRigidBody();
            var velocity = rigidBody === undefined ? particle.velocity : rigidBody.velocity;
            velocity.setXY(velocityX, velocityY);
            particle.pos.x = particleSystem_r({ from: -this.emissionRadius, to: +this.emissionRadius });
            particle.pos.y = particleSystem_r({ from: -this.emissionRadius, to: +this.emissionRadius });
            particle.pos.add(this.emissionPosition);
            holder.lifeTime = particleSystem_r(this.particleLiveTime);
            holder.createdTime = this.game.getCurrentTime();
            holder.active = true;
            this._onEmitParticle(particle);
            this.emissionTarget.appendChild(particle);
        }
    };
    return ParticleSystem;
}(nullGameObject_NullGameObject));


// CONCATENATED MODULE: ./engine/renderable/impl/geometry/ellipse.ts



var ellipse_Ellipse = (function (_super) {
    __extends(Ellipse, _super);
    function Ellipse(game) {
        var _this = _super.call(this, game) || this;
        _this.game = game;
        _this.type = 'Ellipse';
        _this.center = new point2d_Point2d();
        _this.arcAngleFrom = 0;
        _this.arcAngleTo = 0;
        _this.anticlockwise = false;
        _this._radiusX = 10;
        _this._radiusY = 20;
        _this.center.observe(function () {
            var maxR = _this._getMaxRadius();
            _this.pos.setXY(_this.center.x - maxR, _this.center.y - maxR);
        });
        _this.pos.observe(function () {
            var maxR = _this._getMaxRadius();
            _this.center.setXY(_this.pos.x + maxR, _this.pos.y + maxR);
        });
        return _this;
    }
    Object.defineProperty(Ellipse.prototype, "radiusX", {
        get: function () {
            return this._radiusX;
        },
        set: function (value) {
            this._radiusX = value;
            this.size.width = this._getMaxRadius() * 2;
            this.center.forceTriggerChange();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Ellipse.prototype, "radiusY", {
        get: function () {
            return this._radiusY;
        },
        set: function (value) {
            this._radiusY = value;
            this.size.height = this._getMaxRadius() * 2;
            this.center.forceTriggerChange();
        },
        enumerable: true,
        configurable: true
    });
    Ellipse.prototype.draw = function () {
        this.game.getRenderer().drawEllipse(this);
    };
    Ellipse.prototype.update = function () {
        _super.prototype.update.call(this);
    };
    Ellipse.prototype.clone = function () {
        var cloned = new Ellipse(this.game);
        this.setClonedProperties(cloned);
        return cloned;
    };
    Ellipse.prototype.setClonedProperties = function (cloned) {
        cloned.radiusX = this.radiusX;
        cloned.radiusY = this.radiusY;
        cloned.arcAngleFrom = this.arcAngleFrom;
        cloned.arcAngleTo = this.arcAngleTo;
        cloned.anticlockwise = this.anticlockwise;
        _super.prototype.setClonedProperties.call(this, cloned);
    };
    Ellipse.prototype._getMaxRadius = function () {
        return this._radiusX > this._radiusY ? this._radiusX : this._radiusY;
    };
    return Ellipse;
}(shape_Shape));


// CONCATENATED MODULE: ./engine/renderable/impl/geometry/circle.ts


var circle_Circle = (function (_super) {
    __extends(Circle, _super);
    function Circle(game) {
        var _this = _super.call(this, game) || this;
        _this.type = 'Circle';
        _this.radius = 10;
        return _this;
    }
    Object.defineProperty(Circle.prototype, "radius", {
        get: function () {
            return this._radius;
        },
        set: function (val) {
            this._radius = val;
            this.radiusX = this.radiusY = val;
            this.setWH(val * 2);
        },
        enumerable: true,
        configurable: true
    });
    Circle.prototype.draw = function () {
        this.game.getRenderer().drawEllipse(this);
    };
    Circle.prototype.clone = function () {
        var cloned = new Circle(this.game);
        this.setClonedProperties(cloned);
        return cloned;
    };
    Circle.prototype.setClonedProperties = function (cloned) {
        cloned.radius = this.radius;
        _super.prototype.setClonedProperties.call(this, cloned);
    };
    return Circle;
}(ellipse_Ellipse));


// CONCATENATED MODULE: ./catGame/entity/misc/burster.ts




var burster_Burster = (function () {
    function Burster(game) {
        this.game = game;
        this.particleSystem = new particleSystem_ParticleSystem(this.game);
        var particle = new circle_Circle(this.game);
        particle.radius = 2;
        particle.transformPoint.setXY(particle.radius / 2, particle.radius / 2);
        particle.fillColor.setRGBA(12, 100, 0);
        var body = game.getPhysicsSystem().createRigidBody({
            type: ARCADE_RIGID_BODY_TYPE.DYNAMIC,
            debug: true,
            rect: new rect_Rect(0, 0, 2, 2),
        });
        body.groupNames.push(Burster.groupName);
        particle.setRigidBody(body);
        var ps = new particleSystem_ParticleSystem(this.game);
        ps.emitAuto = false;
        ps.addParticle(particle);
        ps.emissionRadius = 5;
        ps.emissionTarget = game.getCurrScene().getLayers()[1];
        ps.numOfParticlesToEmit = { from: 1, to: 5 };
        ps.particleLiveTime = { from: 1000, to: 2000 };
        ps.particleVelocity = { from: 50, to: 100 };
        ps.particleAngle = { from: 0, to: 2 * Math.PI };
        ps.emitAuto = false;
        game.getCurrScene().getLayerAtIndex(1).appendChild(ps);
        this.particleSystem = ps;
    }
    Burster.getCreatedInstance = function () {
        return Burster.instance;
    };
    Burster.instantiate = function (game) {
        Burster.instance = new Burster(game);
    };
    Burster.prototype.burst = function (x, y) {
        this.particleSystem.emissionPosition.setXY(x, y);
        this.particleSystem.emit();
    };
    Burster.groupName = 'particle';
    return Burster;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/filters/abstract/abstractGlFilter.ts







var abstractGlFilter_IDENTITY = mat4_mat4.IDENTITY;
var abstractGlFilter_AbstractGlFilter = (function () {
    function AbstractGlFilter(game) {
        this.game = game;
        this.type = 'WebglFilter';
        this.enabled = true;
        this.uniformCache = new FastMap();
        var renderer = game.getRenderer();
        if ( true && !(renderer instanceof webGlRenderer_WebGlRenderer)) {
            throw new debugError_DebugError("can not apply filter: filters awailable only for WebGlRenerer");
        }
        this.gl = game.getRenderer().getNativeContext();
        this.simpleRectDrawer = new simpleRectDrawer_SimpleRectDrawer(this.gl);
    }
    AbstractGlFilter.prototype.setUniform = function (name, value) {
        this.uniformCache.put(name, value);
    };
    AbstractGlFilter.prototype.getDrawer = function () {
        return this.simpleRectDrawer;
    };
    AbstractGlFilter.prototype.doFilter = function (destFrameBuffer) {
        destFrameBuffer.bind();
        var keys = this.uniformCache.getKeys();
        for (var i = 0; i < keys.length; i++) {
            var name_1 = keys[i];
            var value = this.uniformCache.get(keys[i]);
            this.simpleRectDrawer.setUniform(name_1, value);
        }
        var size = this.simpleRectDrawer.getAttachedTextureAt(0).size;
        this.simpleRectDrawer.setUniform(this.simpleRectDrawer.u_textureMatrix, abstractGlFilter_IDENTITY);
        var m16h = makeIdentityPositionMatrix(0, 0, size);
        this.simpleRectDrawer.setUniform(this.simpleRectDrawer.u_vertexMatrix, m16h.mat16);
        m16h.release();
        destFrameBuffer.clear(color_Color.NONE);
        this.simpleRectDrawer.draw();
    };
    return AbstractGlFilter;
}());


// CONCATENATED MODULE: ./engine/renderer/webGl/filters/texture/colorizeFilter.ts




var colorizeFilter_ColorizeFilter = (function (_super) {
    __extends(ColorizeFilter, _super);
    function ColorizeFilter(game) {
        var _this = _super.call(this, game) || this;
        var programGen = _this.simpleRectDrawer.gen;
        _this.uPixelColor = programGen.addScalarFragmentUniform(GL_TYPE.FLOAT_VEC4, 'uPixelColor');
        programGen.setFragmentMainFn("void main(){\nvec4 col = texture2D(texture, v_texCoord);\nvec3 r = vec3(col) * (1.0-uPixelColor.a) + vec3(uPixelColor) * uPixelColor.a;\nvec4 result = vec4(r,col.a);\nresult.rgb *= col.a;\ngl_FragColor = result;\n}");
        _this.setColor(color_Color.NONE);
        _this.simpleRectDrawer.initProgram();
        return _this;
    }
    ColorizeFilter.prototype.setColor = function (c) {
        this.setUniform(this.uPixelColor, c.asGL());
    };
    return ColorizeFilter;
}(abstractGlFilter_AbstractGlFilter));


// CONCATENATED MODULE: ./catGame/entity/object/impl/bullet.ts








var bullet_Bullet = (function (_super) {
    __extends(Bullet, _super);
    function Bullet(game, spriteSheet) {
        var _this = _super.call(this, game, spriteSheet, {
            type: ARCADE_RIGID_BODY_TYPE.DYNAMIC,
            groupNames: [Bullet.groupName],
            ignoreCollisionWithGroupNames: [hero_Hero.groupName, Bullet.groupName],
            rect: new rect_Rect(0, 0, 8, 2),
        }) || this;
        _this.game = game;
        _this.getRenderableModel().size.setWH(8, 8);
        _this.animation.play();
        _this.game.getCurrScene().setTimeout(function () {
            _this.getRenderableModel().removeSelf();
        }, 2000);
        return _this;
    }
    Bullet.init = function (spriteSheet) {
        Bullet.spriteSheet = spriteSheet;
    };
    Bullet.emit = function (game) {
        return new Bullet(game, Bullet.spriteSheet);
    };
    Bullet.prototype.onCreatedRenderableModel = function (spriteSheet) {
        var img = new animatedImage_AnimatedImage(this.game);
        img.setResourceLink(spriteSheet);
        var animation = new cellFrameAnimation_CellFrameAnimation(this.game);
        animation.frames = [0, 1, 2, 3, 4, 3, 2, 1];
        animation.duration = 300;
        animation.setSpriteSheetSize(new size_Size(3, 3));
        img.addFrameAnimation('bulletAni', animation);
        this.animation = animation;
        return img;
    };
    Bullet.groupName = 'bullet';
    return Bullet;
}(abstractEntity_AbstractEntity));


// CONCATENATED MODULE: ./catGame/entity/actor/abstract/abstractMonster.ts








var abstractMonster_AbstractMonster = (function (_super) {
    __extends(AbstractMonster, _super);
    function AbstractMonster(game, spr, hurtSound, params) {
        var _this = _super.call(this, game, spr, params) || this;
        _this.burstColor = color_Color.RGBA(255, 255, 255, 100);
        _this.hurtColor = color_Color.RGBA(12, 255, 2, 100);
        _this.health = 5;
        _this.hurtSound = new sound_Sound(_this.game);
        _this.hurtSound.setResourceLink(hurtSound);
        _this.colorizeFilter = new colorizeFilter_ColorizeFilter(game);
        _this.colorizeFilter.setColor(_this.burstColor);
        _this.renderableImage.filters = [_this.colorizeFilter];
        _this.colorizeFilter.enabled = false;
        _this.listenCollisionWithBullets();
        return _this;
    }
    AbstractMonster.prototype.burstWithParticles = function () {
        var _this = this;
        var r = 255;
        this.colorizeFilter.enabled = true;
        if (this.tmr !== undefined)
            this.tmr.kill();
        this.tmr = this.getRenderableModel().setInterval(function () {
            _this.burstColor.setG(r);
            _this.burstColor.setB(r);
            r--;
            _this.colorizeFilter.setColor(_this.burstColor);
            if (r < 50) {
                burster_Burster.getCreatedInstance().burst(_this.renderableImage.pos.x, _this.renderableImage.pos.y);
                _this.colorizeFilter.enabled = false;
                _this.tmr.kill();
            }
        }, 10);
    };
    AbstractMonster.prototype.turnToHero = function () {
        var hero = hero_Hero.getCreatedInstance();
        if (this.renderableImage.pos.x > hero.getRenderableModel().pos.x) {
            this.goLeft();
        }
        else {
            this.goRight();
        }
    };
    AbstractMonster.prototype.hurt = function () {
        var _this = this;
        this.health--;
        this.colorizeFilter.setColor(this.hurtColor);
        this.colorizeFilter.enabled = true;
        this.hurtSound.play();
        this.getRenderableModel().setTimeout(function () {
            _this.colorizeFilter.setColor(_this.burstColor);
            _this.colorizeFilter.enabled = false;
            if (_this.health < 0)
                if (!_this.getRenderableModel().isDetached())
                    _this.getRenderableModel().removeSelf();
        }, 200);
    };
    AbstractMonster.prototype.listenCollisionWithBullets = function () {
        var _this = this;
        this.body.onCollidedWithGroup(bullet_Bullet.groupName, function (e) {
            _this.hurt();
        });
    };
    AbstractMonster.groupName = 'abstractMonsterGroup';
    return AbstractMonster;
}(abstractCharacter_AbstractCharacter));


// CONCATENATED MODULE: ./catGame/entity/object/abstract/collectableEntity.ts


var collectableEntity_CollectableEntity = (function (_super) {
    __extends(CollectableEntity, _super);
    function CollectableEntity() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    CollectableEntity.groupName = 'collectable';
    return CollectableEntity;
}(abstractEntity_AbstractEntity));


// CONCATENATED MODULE: ./catGame/entity/object/impl/testTube.ts


var testTube_TestTube = (function (_super) {
    __extends(TestTube, _super);
    function TestTube(game, spriteSheet) {
        var _this = _super.call(this, game, spriteSheet, {
            groupNames: [TestTube.groupName, collectableEntity_CollectableEntity.groupName],
        }) || this;
        _this.game = game;
        return _this;
    }
    TestTube.groupName = 'testTube';
    return TestTube;
}(collectableEntity_CollectableEntity));


// CONCATENATED MODULE: ./catGame/entity/object/impl/bloodDrop.ts


var bloodDrop_BloodDrop = (function (_super) {
    __extends(BloodDrop, _super);
    function BloodDrop(game, spriteSheet) {
        var _this = _super.call(this, game, spriteSheet, {
            groupNames: [BloodDrop.groupName, collectableEntity_CollectableEntity.groupName],
        }) || this;
        _this.game = game;
        return _this;
    }
    BloodDrop.groupName = 'bloodDrop';
    return BloodDrop;
}(collectableEntity_CollectableEntity));


// CONCATENATED MODULE: ./catGame/entity/object/impl/lava.ts







var lava_Lava = (function (_super) {
    __extends(Lava, _super);
    function Lava(game, spriteSheet, size) {
        var _this = _super.call(this, game, spriteSheet, {
            type: ARCADE_RIGID_BODY_TYPE.KINEMATIC,
            groupNames: [Lava.groupName],
            rect: new rect_Rect(0, 0, size.width, size.height)
        }) || this;
        _this.game = game;
        _this.getRenderableModel().size.set(size);
        _this.animation.play();
        return _this;
    }
    Lava.prototype.onCreatedRenderableModel = function (spriteSheet) {
        var img = new animatedImage_AnimatedImage(this.game);
        img.setResourceLink(spriteSheet);
        var animation = new cellFrameAnimation_CellFrameAnimation(this.game);
        animation.frames = this.createRange(0, 44);
        animation.duration = 5000;
        animation.setSpriteSheetSize(new size_Size(45, 1));
        img.addFrameAnimation('lavaAni', animation);
        img.stretchMode = 1;
        this.animation = animation;
        window.img = img;
        return img;
    };
    Lava.groupName = 'lava';
    return Lava;
}(abstractEntity_AbstractEntity));


// CONCATENATED MODULE: ./catGame/entity/object/impl/virus.ts





var virus_Virus = (function (_super) {
    __extends(Virus, _super);
    function Virus(game, spriteSheet) {
        var _this = _super.call(this, game, spriteSheet, {
            groupNames: [Virus.groupName],
            rect: new rect_Rect(5, 5, 35, 35)
        }) || this;
        _this.game = game;
        _this.life = 5;
        _this.body.onCollidedWithGroup(bullet_Bullet.groupName, function (e) {
            _this.life--;
            if (_this.life === 0)
                _this.getRenderableModel().removeSelf();
        });
        var model = _this.getRenderableModel();
        model.setInterval(function () {
            if (mathEx_MathEx.random(0, 5) > 3)
                if (_this.body.collisionFlags.bottom)
                    _this.body.velocity.y -= mathEx_MathEx.random(200, 500);
            if (mathEx_MathEx.random(0, 5) > 3)
                _this.body.velocity.x = mathEx_MathEx.random(-200, 200);
        }, 1000);
        model.setInterval(function () {
            if (_this.body.velocity.x > 0)
                model.angle += 0.1;
            else if (_this.body.velocity.x < 0)
                model.angle -= 0.1;
            model.angle %= Math.PI * 2;
        }, 100);
        return _this;
    }
    Virus.groupName = 'virus';
    return Virus;
}(collectableEntity_CollectableEntity));


// CONCATENATED MODULE: ./catGame/entity/object/impl/fan.ts



var fan_Fan = (function (_super) {
    __extends(Fan, _super);
    function Fan(game, resource) {
        var _this = _super.call(this, game, resource, {
            groupNames: [Fan.groupName],
            type: ARCADE_RIGID_BODY_TYPE.KINEMATIC,
        }) || this;
        _this.game = game;
        var model = _this.getRenderableModel();
        model.alpha = 0.5;
        model.setInterval(function () {
            model.angle += 0.1;
            model.angle %= Math.PI * 2;
        }, 100);
        return _this;
    }
    Fan.groupName = 'fan';
    return Fan;
}(abstractEntity_AbstractEntity));


// CONCATENATED MODULE: ./catGame/entity/actor/impl/hero.ts















var LEFT = -1;
var RIGHT = 1;
var hero_Hero = (function (_super) {
    __extends(Hero, _super);
    function Hero(game, spr) {
        var _this = _super.call(this, game, spr, {
            restitution: 0.2,
            rect: new rect_Rect(23, 20, 15, 33),
            groupNames: [Hero.groupName, abstractCharacter_AbstractCharacter.groupName],
            ignoreCollisionWithGroupNames: [fan_Fan.groupName],
        }) || this;
        _this.game = game;
        _this.hurt = false;
        _this.hurtCnt = 0;
        _this.beating = false;
        _this.direction = RIGHT;
        _this.soundHurt = new sound_Sound(_this.game);
        _this.soundShoot = new sound_Sound(_this.game);
        _this.soundJump = new sound_Sound(_this.game);
        _this.soundPick = new sound_Sound(_this.game);
        Hero.instance = _this;
        _this.game.camera.followTo(_this.renderableImage);
        _this.velocity = 90;
        _this.rotateAnimation.
            play().
            once("completed", function (e) { return _this.idleAnimation.play(); });
        _this.listenKeys();
        _this.listenCollisions();
        _this.listenFallToHole();
        return _this;
    }
    Hero.getCreatedInstance = function () {
        return Hero.instance;
    };
    Hero.prototype.injectResources = function (res) {
        this.soundShoot.setResourceLink(res.soundShoot);
        this.soundHurt.setResourceLink(res.soundHurt);
        this.soundJump.setResourceLink(res.soundJump);
        this.soundPick.setResourceLink(res.soundPick);
    };
    Hero.prototype.onCreatedFrameAnimation = function () {
        this.idleAnimation = this.createFrameAnimation('idle', [0, 1, 2, 3], 1000, new size_Size(16, 16));
        this.jumpAnimation = this.createFrameAnimation('jump', this.createRange(32, 39), 1000, new size_Size(16, 16));
        this.jumpAnimation.isRepeating = false;
        this.rotateAnimation = this.createFrameAnimation('rotate', this.createRange(128, 140), 1000, new size_Size(16, 16));
        this.rotateAnimation.isRepeating = false;
        this.fallAnimation = this.createFrameAnimation('fall', this.createRange(80, 86), 1000, new size_Size(16, 16));
        this.fallAnimation.isRepeating = false;
        this.walkAnimation = this.createFrameAnimation('walk', this.createRange(16, 23), 1000, new size_Size(16, 16));
        this.highKickAnimation = this.createFrameAnimation('highKick', this.createRange(176, 181), 200, new size_Size(16, 16));
        this.highKickAnimation.isRepeating = false;
    };
    Hero.prototype.damage = function (val) {
        if (this.hurt)
            return;
        this.blink();
        gameManager_GameManager.getCreatedInstance().decrementPower(val, this.onLiveDecrementedOnDamage.bind(this));
    };
    Hero.prototype.blink = function () {
        var _this = this;
        this.hurt = true;
        this.beating = false;
        this.soundHurt.play();
        var tmr = this.getRenderableModel().setInterval(function () {
            _this.getRenderableModel().visible = !_this.getRenderableModel().visible;
            _this.hurtCnt++;
            if (_this.hurtCnt === 10) {
                _this.hurtCnt = 0;
                _this.hurt = false;
                _this.getRenderableModel().visible = true;
                tmr.kill();
            }
        }, 200);
    };
    Hero.prototype.onLiveDecrementedOnDamage = function () {
        this.getRenderableModel().pos.y -= 120;
        this.body.velocity.y = -100;
    };
    Hero.prototype.shoot = function () {
        var bullet = bullet_Bullet.emit(this.game);
        bullet.getRenderableModel().pos.setXY(this.getRenderableModel().pos.x + 20, this.getRenderableModel().pos.y + 35);
        bullet.getRenderableModel().getRigidBody().velocity.x = 150 * this.direction;
        this.soundShoot.play();
    };
    Hero.prototype.listenKeys = function () {
        var _this = this;
        var jumpVelocity = 200;
        this.game.getCurrScene().on(KEYBOARD_EVENTS.keyHold, function (e) {
            switch (e.key) {
                case 37:
                    if (!_this.beating)
                        _this.goLeft();
                    _this.direction = LEFT;
                    break;
                case 39:
                    if (!_this.beating)
                        _this.goRight();
                    _this.direction = RIGHT;
                    break;
                case 32:
                    if (_this.renderableImage.getRigidBody().collisionFlags.bottom) {
                        _this.jump(jumpVelocity);
                        _this.soundJump.play();
                    }
                    break;
            }
        });
        this.game.getCurrScene().on(KEYBOARD_EVENTS.keyReleased, function (e) {
            switch (e.key) {
                case 37:
                case 39:
                    _this.idle();
                    break;
            }
        });
        this.game.getCurrScene().on(KEYBOARD_EVENTS.keyPressed, function (e) {
            switch (e.key) {
                case 90:
                    _this.beating = true;
                    _this.highKickAnimation.play();
                    _this.shoot();
                    _this.highKickAnimation.once("completed", function (ev) {
                        _this.beating = false;
                        _this.idle();
                    });
                    _this.highKickAnimation.once("canceled", function (ev) {
                        _this.beating = false;
                        _this.idle();
                    });
                    break;
            }
        });
    };
    Hero.prototype.onCollidedWithMonster = function (monsterBody) {
        this.damage(20);
    };
    Hero.prototype.listenCollisions = function () {
        var _this = this;
        this.body.onCollidedWithGroup(abstractMonster_AbstractMonster.groupName, function (e) {
            _this.onCollidedWithMonster(e);
        });
        this.body.onCollidedWithGroup(burster_Burster.groupName, function (e) {
            _this.onCollidedWithMonster(e);
        });
        this.body.onCollidedWithGroup(burster_Burster.groupName, function (e) {
            _this.onCollidedWithMonster(e);
        });
        this.body.onCollidedWithGroup(lava_Lava.groupName, function (e) {
            _this.damage(30);
        });
        this.body.onCollidedWithGroup(virus_Virus.groupName, function (e) {
            _this.damage(40);
            e.getHostModel().removeSelf();
        });
        this.body.onOverlappedWithGroup(fan_Fan.groupName, function (e) {
            _this.body.velocity.y -= 20;
        });
        this.body.onCollidedWithGroup(bloodDrop_BloodDrop.groupName, function (e) {
            _this.soundPick.play();
            e.getHostModel().removeSelf();
            gameManager_GameManager.getCreatedInstance().incrementNumOfLives();
        });
        this.body.onCollidedWithGroup(testTube_TestTube.groupName, function (e) {
            _this.soundPick.play();
            gameManager_GameManager.getCreatedInstance().onObjectPicked();
            e.getHostModel().removeSelf();
        });
    };
    Hero.prototype.listenFallToHole = function () {
        var _this = this;
        this.getRenderableModel().setInterval(function () {
            if (_this.getRenderableModel().pos.y > _this.game.getCurrScene().size.height + 1000) {
                _this.damage(100);
                _this.getRenderableModel().pos.x = 100;
                _this.getRenderableModel().pos.y = 100;
                _this.body.velocity.setXY(0, 0);
                _this.body.acceleration.setXY(0, 0);
            }
        }, 1000);
    };
    Hero.groupName = 'hero';
    return Hero;
}(abstractCharacter_AbstractCharacter));


// CONCATENATED MODULE: ./catGame/entity/actor/impl/monster1.ts





var monster1_Monster1 = (function (_super) {
    __extends(Monster1, _super);
    function Monster1(game, spr, hurtSound) {
        var _this = _super.call(this, game, spr, hurtSound, {
            restitution: 0.2,
            rect: new rect_Rect(20, 20, 23, 33),
            groupNames: [Monster1.groupName, abstractMonster_AbstractMonster.groupName],
        }) || this;
        _this.game = game;
        _this.baseVelocity = 70;
        _this.game.getCurrScene().setInterval(function () {
            _this.trackPositionByHero();
        }, 2000);
        _this.scheduleBurst();
        return _this;
    }
    Monster1.prototype.onCreatedFrameAnimation = function () {
        this.idleAnimation = this.createFrameAnimation('idle', [0, 1, 2, 3], 900 + mathEx_MathEx.random(10, 100), new size_Size(8, 8));
        this.walkAnimation = this.createFrameAnimation('walk', [8, 9, 10, 11, 12], 900 + mathEx_MathEx.random(10, 100), new size_Size(8, 8));
        this.attackAnimation = this.createFrameAnimation('attack', [16, 17, 18, 19, 20, 21], 900 + mathEx_MathEx.random(10, 100), new size_Size(8, 8));
    };
    Monster1.prototype.scheduleBurst = function () {
        var _this = this;
        this.game.getCurrScene().setTimeout(function () {
            _this.burstWithParticles();
            _this.attackAnimation.play();
            _this.scheduleBurst();
        }, mathEx_MathEx.random(5000, 15000));
    };
    Monster1.prototype.trackPositionByHero = function () {
        if (mathEx_MathEx.random(0, 10) < 3) {
            this.idle();
            return;
        }
        if (mathEx_MathEx.random(0, 50) < 10) {
            this.jump(100 - mathEx_MathEx.random(-50, -100));
            return;
        }
        this.velocity = this.baseVelocity + mathEx_MathEx.random(-5, 5);
        this.turnToHero();
    };
    Monster1.groupName = 'monster1';
    return Monster1;
}(abstractMonster_AbstractMonster));


// CONCATENATED MODULE: ./catGame/entity/actor/impl/zombie.ts







var zombie_Zombie = (function (_super) {
    __extends(Zombie, _super);
    function Zombie(game, spr, hurtSound) {
        var _this = _super.call(this, game, spr, hurtSound, {
            restitution: 0.2,
            rect: new rect_Rect(20, 20, 23, 41),
            groupNames: [Zombie.groupName, abstractMonster_AbstractMonster.groupName, abstractCharacter_AbstractCharacter.groupName],
        }) || this;
        _this.velocity = 10;
        _this.scheduleWalk();
        _this.body.onCollidedWithGroup(hero_Hero.groupName, function (e) {
            _this.turnToHero();
            _this.attackAnimation.play().once("completed", function (it) { return _this.idle(); });
        });
        return _this;
    }
    Zombie.prototype.onCreatedFrameAnimation = function () {
        this.idleAnimation = this.createFrameAnimation('idle', [0, 1, 2, 3], 900 + mathEx_MathEx.random(10, 100), new size_Size(8, 8));
        this.walkAnimation = this.createFrameAnimation('walk', [8, 9, 10, 11], 900 + mathEx_MathEx.random(10, 100), new size_Size(8, 8));
        this.attackAnimation = this.createFrameAnimation('attack', [16, 17, 18, 19], 900 + mathEx_MathEx.random(10, 100), new size_Size(8, 8));
    };
    Zombie.prototype.scheduleWalk = function () {
        var _this = this;
        this.game.getCurrScene().setTimeout(function () {
            var actionID = mathEx_MathEx.random(0, 10);
            if (actionID > 8)
                _this.idle();
            else if (actionID > 5) {
                _this.goLeft();
            }
            else
                _this.goRight();
            _this.scheduleWalk();
        }, mathEx_MathEx.random(2000, 5000));
    };
    Zombie.groupName = 'zombie';
    return Zombie;
}(abstractMonster_AbstractMonster));


// CONCATENATED MODULE: ./catGame/entity/actor/impl/monster2.ts






var monster2_Monster2 = (function (_super) {
    __extends(Monster2, _super);
    function Monster2(game, spr, hurtSound) {
        var _this = _super.call(this, game, spr, hurtSound, {
            restitution: 0.9,
            rect: new rect_Rect(20, 20, 23, 33),
            groupNames: [Monster2.groupName, abstractMonster_AbstractMonster.groupName, abstractCharacter_AbstractCharacter.groupName],
        }) || this;
        _this.game = game;
        _this.baseVelocity = 90;
        _this.burstColor.setRGBA(200, 255, 200, 100);
        _this.game.getCurrScene().setInterval(function () {
            _this.trackPositionByHero();
        }, 2000);
        _this.scheduleBurst();
        return _this;
    }
    Monster2.prototype.onCreatedFrameAnimation = function () {
        this.idleAnimation = this.createFrameAnimation('idle', [0, 1, 2, 3, 4], 900 + mathEx_MathEx.random(10, 100), new size_Size(8, 4));
        this.walkAnimation = this.idleAnimation;
        this.attackAnimation = this.createFrameAnimation('attack', [8, 9, 10, 11, 12], 900 + mathEx_MathEx.random(10, 100), new size_Size(8, 4));
    };
    Monster2.prototype.scheduleBurst = function () {
        var _this = this;
        this.game.getCurrScene().setTimeout(function () {
            _this.burstWithParticles();
            _this.attackAnimation.play();
            _this.scheduleBurst();
        }, mathEx_MathEx.random(2000, 10000));
    };
    Monster2.prototype.trackPositionByHero = function () {
        if (mathEx_MathEx.random(0, 10) < 3) {
            this.idle();
            return;
        }
        if (mathEx_MathEx.random(0, 50) < 10) {
            this.jump(100 - mathEx_MathEx.random(-50, -100));
            return;
        }
        this.velocity = this.baseVelocity + mathEx_MathEx.random(-5, 5);
        this.turnToHero();
    };
    Monster2.groupName = 'monster2';
    return Monster2;
}(abstractMonster_AbstractMonster));


// CONCATENATED MODULE: ./catGame/entity/object/impl/water.ts





var water_Water = (function (_super) {
    __extends(Water, _super);
    function Water(game, spriteSheet, size) {
        var _this = _super.call(this, game, spriteSheet, {
            groupNames: [Water.groupName],
            ignoreCollisionWithGroupNames: [abstractCharacter_AbstractCharacter.groupName],
            type: ARCADE_RIGID_BODY_TYPE.KINEMATIC,
            rect: new rect_Rect(0, 0, size.width, size.height)
        }) || this;
        _this.game = game;
        var img = _this.getRenderableModel();
        img.alpha = 0.5;
        img.size.set(size);
        img.stretchMode = 1;
        _this.animateWater();
        _this.listenCollisions();
        return _this;
    }
    Water.prototype.animateWater = function () {
        var img = this.getRenderableModel();
        this.game.getCurrScene().setInterval(function () {
            img.offset.x += 1;
        }, 10);
    };
    Water.prototype.listenCollisions = function () {
        this.body.onOverlappedWithGroup(abstractCharacter_AbstractCharacter.groupName, function (e) {
            e.velocity.y -= 4;
        });
    };
    Water.groupName = 'water';
    return Water;
}(abstractEntity_AbstractEntity));


// CONCATENATED MODULE: ./catGame/entity/sprite/genericSprite.ts


var genericSprite_GenericSprite = (function (_super) {
    __extends(GenericSprite, _super);
    function GenericSprite(game, spriteSheet) {
        return _super.call(this, game, spriteSheet) || this;
    }
    return GenericSprite;
}(abstractSprite_AbstractSprite));


// CONCATENATED MODULE: ./engine/control/screenTouchPad/abstract/abstractScreenTouchPad.ts

var abstractScreenTouchPad_AbstractScreenTouchPad = (function () {
    function AbstractScreenTouchPad(game) {
        this.game = game;
        this.buttons = [];
    }
    AbstractScreenTouchPad.prototype.addButton = function (b) {
        var _this = this;
        this.buttons.push(b);
        b.renderableModel.on(MOUSE_EVENTS.mouseDown, function () {
            _this.game.getControl('KeyboardControl').triggerKeyPress(b.keyCode);
        });
        b.renderableModel.on(MOUSE_EVENTS.mouseLeave, function () {
            _this.game.getControl('KeyboardControl').triggerKeyRelease(b.keyCode);
        });
        b.renderableModel.on(MOUSE_EVENTS.mouseUp, function () {
            _this.game.getControl('KeyboardControl').triggerKeyRelease(b.keyCode);
        });
    };
    AbstractScreenTouchPad.prototype.appendTo = function (layer) {
        this.buttons.forEach(function (b) {
            layer.appendChild(b.renderableModel);
        });
    };
    return AbstractScreenTouchPad;
}());


// CONCATENATED MODULE: ./engine/control/screenTouchPad/abstract/abstractScreenTouchButton.ts
var AbstractScreenTouchButton = (function () {
    function AbstractScreenTouchButton(game) {
        this.game = game;
    }
    return AbstractScreenTouchButton;
}());


// CONCATENATED MODULE: ./engine/control/screenTouchPad/simpleTouchPad.ts




var simpleTouchPad_TouchButton = (function (_super) {
    __extends(TouchButton, _super);
    function TouchButton(game, keyCode) {
        var _this = _super.call(this, game) || this;
        _this.keyCode = keyCode;
        var c = new circle_Circle(game);
        c.radius = 30;
        c.alpha = 0.5;
        _this.renderableModel = c;
        return _this;
    }
    return TouchButton;
}(AbstractScreenTouchButton));
var simpleTouchPad_SimpleTouchPad = (function (_super) {
    __extends(SimpleTouchPad, _super);
    function SimpleTouchPad(game) {
        var _this = _super.call(this, game) || this;
        _this.game = game;
        var btnLeft = new simpleTouchPad_TouchButton(game, 37);
        btnLeft.renderableModel.pos.setXY(30, game.size.height - 130);
        _this.addButton(btnLeft);
        var btnRight = new simpleTouchPad_TouchButton(game, 39);
        btnRight.renderableModel.pos.setXY(110, game.size.height - 130);
        _this.addButton(btnRight);
        var btnFire = new simpleTouchPad_TouchButton(game, 90);
        btnFire.renderableModel.pos.setXY(game.size.width - 110 - 40, game.size.height - 130);
        _this.addButton(btnFire);
        var btnJump = new simpleTouchPad_TouchButton(game, 32);
        btnJump.renderableModel.pos.setXY(game.size.width - 30 - 40, game.size.height - 130);
        _this.addButton(btnJump);
        return _this;
    }
    return SimpleTouchPad;
}(abstractScreenTouchPad_AbstractScreenTouchPad));


// CONCATENATED MODULE: ./catGame/scene/mainScene.ts




























var mainScene_MainScene = (function (_super) {
    __extends(MainScene, _super);
    function MainScene(game, level, numOfLives) {
        var _this = _super.call(this, game) || this;
        _this.numOfLives = numOfLives;
        _this.level = level;
        return _this;
    }
    MainScene.prototype.onReady = function () {
        this.setBg();
        this.playTheme();
        this.setUpClouds();
        this.loadLevel();
        this.createUI();
    };
    MainScene.prototype.extractExtraProperties = function (properties) {
        if (!properties)
            return {};
        var obj = {};
        properties.forEach(function (p) { return obj[p.name] = p.value; });
        return obj;
    };
    MainScene.prototype.playTheme = function () {
        var sound = new sound_Sound(this.game);
        sound.setResourceLink(this.soundThemeRes);
        sound.loop = true;
        sound.play();
        this.on("inactivated", function () {
            sound.stop();
        });
    };
    MainScene.prototype.setBg = function () {
        var bgLayer = new layer_Layer(this.game);
        bgLayer.transformType = 1;
        var bgImage = new rectangle_Rectangle(this.game);
        bgImage.lineWidth = 0;
        bgImage.size.set(this.game.size);
        var grad = new linearGradient_LinearGradient();
        grad.colorFrom = color_Color.RGB(219, 230, 255);
        grad.colorTo = color_Color.RGB(208, 202, 202);
        grad.angle = -mathEx_MathEx.degToRad(90);
        bgImage.fillColor = grad;
        bgLayer.appendChild(bgImage);
        this.appendChild(bgLayer);
        this.appendChild(new layer_Layer(this.game));
    };
    MainScene.prototype.setUpClouds = function () {
        var _this = this;
        var numOfClouds = 5;
        var clouds = [];
        for (var i = 0; i < numOfClouds; i++) {
            var cloud = new image_Image(this.game);
            cloud.setResourceLink(this.spriteSheetCloud);
            cloud.pos.setXY(mathEx_MathEx.random(-500, 500), mathEx_MathEx.random(0, 100));
            cloud.velocity.x = -mathEx_MathEx.random(10, 50);
            cloud.alpha = 0.1;
            clouds.push(cloud);
            this.appendChild(cloud);
        }
        this.setInterval(function () {
            clouds.forEach(function (c) {
                if (c.pos.x < -500)
                    c.pos.x = _this.game.getCurrScene().size.width + 500;
            });
        }, 1000);
    };
    MainScene.prototype.loadLevel = function () {
        var _this = this;
        this.level.layers[0].objects.forEach(function (obj) {
            var objCreated;
            var needCorrection = true;
            var extraProperties = _this.extractExtraProperties(obj.properties);
            switch (obj.type) {
                case hero_Hero.groupName:
                    var hero = new hero_Hero(_this.game, _this.spriteSheetHero);
                    hero.injectResources({
                        soundShoot: _this.soundShoot,
                        soundHurt: _this.soundHurt,
                        soundJump: _this.soundJump,
                        soundPick: _this.soundPick,
                    });
                    objCreated = hero;
                    break;
                case monster1_Monster1.groupName:
                    objCreated = new monster1_Monster1(_this.game, _this.spriteSheetMonster1, _this.soundHurt2);
                    break;
                case monster2_Monster2.groupName:
                    objCreated = new monster2_Monster2(_this.game, _this.spriteSheetMonster2, _this.soundHurt2);
                    break;
                case zombie_Zombie.groupName:
                    objCreated = new zombie_Zombie(_this.game, _this.spriteSheetZombie, _this.soundHurt2);
                    break;
                case bloodDrop_BloodDrop.groupName:
                    objCreated = new bloodDrop_BloodDrop(_this.game, _this.spriteSheetBloodDrop);
                    break;
                case virus_Virus.groupName:
                    objCreated = new virus_Virus(_this.game, _this.spriteSheetVirus);
                    break;
                case testTube_TestTube.groupName:
                    objCreated = new testTube_TestTube(_this.game, _this.spriteSheetTestTube);
                    break;
                case fan_Fan.groupName:
                    objCreated = new fan_Fan(_this.game, _this.spriteSheetFan);
                    break;
                case lava_Lava.groupName:
                    objCreated = new lava_Lava(_this.game, _this.spriteSheetLava, new size_Size(obj.width, obj.height));
                    needCorrection = false;
                    break;
                case water_Water.groupName:
                    objCreated = new water_Water(_this.game, _this.spriteSheetWater, new size_Size(obj.width, obj.height));
                    needCorrection = false;
                    break;
                case wall_Wall.groupName:
                    if (extraProperties.toX)
                        extraProperties.fromX = obj.x;
                    if (extraProperties.toY)
                        extraProperties.fromY = obj.y;
                    var wallResource = (extraProperties.toX || extraProperties.toY) ?
                        _this.wall2 : _this.wall1;
                    objCreated = new wall_Wall(_this.game, new size_Size(obj.width, obj.height), wallResource, extraProperties);
                    needCorrection = false;
                    break;
                case 'tree':
                    objCreated = new genericSprite_GenericSprite(_this.game, _this.spriteSheetTree);
                    break;
                case 'table':
                    objCreated = new genericSprite_GenericSprite(_this.game, _this.spriteSheetTable);
                    break;
                case 'ironCar':
                    objCreated = new genericSprite_GenericSprite(_this.game, _this.spriteSheetIronCar);
                    break;
                case 'car':
                    objCreated = new genericSprite_GenericSprite(_this.game, _this.spriteSheetCar);
                    break;
                default:
                    break;
            }
            if (objCreated !== undefined) {
                objCreated.getRenderableModel().pos.setXY(obj.x, obj.y);
                if (needCorrection)
                    objCreated.getRenderableModel().pos.y -= obj.height;
            }
        });
        burster_Burster.instantiate(this.game);
        bullet_Bullet.init(this.spriteSheetBullet);
        this.fitSizeToChildren();
    };
    MainScene.prototype.createUI = function () {
        var uiLayer = new layer_Layer(this.game);
        uiLayer.transformType = 1;
        this.appendChild(uiLayer);
        infoPanel_InfoPanel.instantiate(this.game, this.spriteSheetHero);
        infoPanel_InfoPanel.getCreatedInstance().updateNumOfLives(this.numOfLives);
    };
    MainScene.prototype.createTouchPad = function () {
        var touchPadLayer = new layer_Layer(this.game);
        touchPadLayer.transformType = 1;
        this.appendChild(touchPadLayer);
        var touchPad = new simpleTouchPad_SimpleTouchPad(this.game);
        touchPad.appendTo(touchPadLayer);
    };
    __decorate([
        Source.Texture('./catGame/res/sprite/cat.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetHero", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/wall1.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "wall1", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/wall2.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "wall2", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/monster1.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetMonster1", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/lava.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetLava", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/water.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetWater", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/monster2.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetMonster2", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/virus.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetVirus", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/zombie.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetZombie", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/fan.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetFan", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/bloodDrop.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetBloodDrop", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/cloud.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetCloud", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/ironCar.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetIronCar", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/car.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetCar", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/testTube.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetTestTube", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/bullet3.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetBullet", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/tree.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetTree", void 0);
    __decorate([
        Source.Texture('./catGame/res/sprite/table.png'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "spriteSheetTable", void 0);
    __decorate([
        Source.Sound('./catGame/res/sound/theme2.mp3'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "soundThemeRes", void 0);
    __decorate([
        Source.Sound('./catGame/res/sound/hurt.mp3'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "soundHurt", void 0);
    __decorate([
        Source.Sound('./catGame/res/sound/hurt.mp3'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "soundHurt2", void 0);
    __decorate([
        Source.Sound('./catGame/res/sound/shoot.mp3'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "soundShoot", void 0);
    __decorate([
        Source.Sound('./catGame/res/sound/jump.mp3'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "soundJump", void 0);
    __decorate([
        Source.Sound('./catGame/res/sound/pick.mp3'),
        __metadata("design:type", ResourceLink)
    ], MainScene.prototype, "soundPick", void 0);
    return MainScene;
}(scene_Scene));


// CONCATENATED MODULE: ./engine/scene/transition/abstract/abstractSceneTransition.ts


var abstractSceneTransition_AbstractSceneTransition = (function () {
    function AbstractSceneTransition() {
        this._completed = false;
    }
    AbstractSceneTransition.prototype.onComplete = function (fn) {
        this._onComplete = fn;
    };
    AbstractSceneTransition.prototype.start = function (prevScene, currScene) {
        var _this = this;
        var desc = __assign(__assign({}, this.describe()), { progress: function (obj) {
                _this.onTransitionProgress(obj.val);
            }, complete: function () {
                _this.complete();
                _this._onComplete();
            } });
        var t = new tween_Tween(desc);
        this._currScene = currScene;
        this._prevScene = prevScene;
        t.update();
        this._tween = t;
    };
    AbstractSceneTransition.prototype.update = function () {
        if (this._currScene !== undefined)
            this._currScene.update();
        if (this._prevScene !== undefined)
            this._prevScene.update();
        this._tween.update();
    };
    AbstractSceneTransition.prototype.complete = function () {
        if (this._completed)
            return;
        this._completed = true;
        this._tween.complete();
    };
    return AbstractSceneTransition;
}());


// CONCATENATED MODULE: ./engine/scene/transition/appear/cells/cellsAppearingTransition.ts




var cellsAppearingTransition_AbstractCellsAppearingTransition = (function (_super) {
    __extends(AbstractCellsAppearingTransition, _super);
    function AbstractCellsAppearingTransition(game, time, numOfCellsX, numOfCellsY, easeFn) {
        if (time === void 0) { time = 1000; }
        if (numOfCellsX === void 0) { numOfCellsX = 6; }
        if (numOfCellsY === void 0) { numOfCellsY = 6; }
        if (easeFn === void 0) { easeFn = EasingLinear; }
        var _this = _super.call(this) || this;
        _this.game = game;
        _this.time = time;
        _this.numOfCellsX = numOfCellsX;
        _this.numOfCellsY = numOfCellsY;
        _this.easeFn = easeFn;
        _this.lockingRect = new rect_Rect();
        return _this;
    }
    AbstractCellsAppearingTransition.prototype.complete = function () {
        if (this._currScene !== undefined) {
            this._currScene.lockingRect = undefined;
        }
        if (this._prevScene !== undefined) {
            this._prevScene.lockingRect = undefined;
        }
        _super.prototype.complete.call(this);
    };
    AbstractCellsAppearingTransition.prototype.renderScenes = function (a, b) {
        if (b !== undefined)
            b.render();
        if (a !== undefined) {
            var cellWidth = a.size.width / this.numOfCellsX;
            var cellHeight = a.size.height / this.numOfCellsY;
            var total = this.numOfCellsX * this.numOfCellsY;
            var progress = 0;
            for (var y = 0; y < this.numOfCellsY; y++) {
                for (var x = 0; x < this.numOfCellsX; x++) {
                    progress++;
                    var currProgressRelative = progress / total * 100;
                    if (currProgressRelative < this.val) {
                        this.lockingRect.setXYWH(x * cellWidth, y * cellHeight, cellWidth + 1, cellHeight + 1);
                        a.lockingRect = this.lockingRect;
                        a.render();
                    }
                }
            }
        }
    };
    AbstractCellsAppearingTransition.prototype.describe = function () {
        var from = this.getFromTo().from;
        var to = this.getFromTo().to;
        return {
            target: { val: from },
            from: { val: from },
            to: { val: to },
            time: this.time,
            ease: this.easeFn
        };
    };
    AbstractCellsAppearingTransition.prototype.onTransitionProgress = function (val) {
        this.val = val;
    };
    return AbstractCellsAppearingTransition;
}(abstractSceneTransition_AbstractSceneTransition));

var cellsAppearingTransition_CellsAppearingTransition = (function (_super) {
    __extends(CellsAppearingTransition, _super);
    function CellsAppearingTransition() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    CellsAppearingTransition.prototype.getOppositeTransition = function () {
        return new cellsAppearingTransition_CellsDisappearingTransition(this.game, this.time, this.numOfCellsX, this.numOfCellsY, this.easeFn);
    };
    CellsAppearingTransition.prototype.render = function () {
        this.renderScenes(this._currScene, this._prevScene);
    };
    CellsAppearingTransition.prototype.getFromTo = function () {
        return { from: 0, to: 100 };
    };
    return CellsAppearingTransition;
}(cellsAppearingTransition_AbstractCellsAppearingTransition));

var cellsAppearingTransition_CellsDisappearingTransition = (function (_super) {
    __extends(CellsDisappearingTransition, _super);
    function CellsDisappearingTransition() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    CellsDisappearingTransition.prototype.getOppositeTransition = function () {
        return new cellsAppearingTransition_CellsAppearingTransition(this.game, this.time, this.numOfCellsX, this.numOfCellsY, this.easeFn);
    };
    CellsDisappearingTransition.prototype.render = function () {
        this.renderScenes(this._prevScene, this._currScene);
    };
    CellsDisappearingTransition.prototype.getFromTo = function () {
        return { from: 100, to: 0 };
    };
    return CellsDisappearingTransition;
}(cellsAppearingTransition_AbstractCellsAppearingTransition));


// CONCATENATED MODULE: ./catGame/scene/gameOverScene.ts




var gameOverScene_GameOverScene = (function (_super) {
    __extends(GameOverScene, _super);
    function GameOverScene() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    GameOverScene.prototype.onPreloading = function () {
        this.soundThemeRes = this.resourceLoader.loadSound('./catGame/res/sound/gameOver.mp3');
        this.spriteSheetLabel = this.resourceLoader.loadTexture('./catGame/res/sprite/gameOver.png');
    };
    GameOverScene.prototype.startSound = function () {
        _super.prototype.startSound.call(this);
        this.snd.loop = false;
    };
    GameOverScene.prototype.listenUI = function () {
        var _this = this;
        this.on(MOUSE_EVENTS.click, function (e) {
            _this.snd.stop();
            _this.game.camera.shake(5, 200);
            _this.game.runScene(new introScene_IntroScene(_this.game));
        });
    };
    return GameOverScene;
}(baseAbstractIntroScene_BaseAbstractIntroScene));


// CONCATENATED MODULE: ./catGame/scene/winScene.ts




var winScene_WinScene = (function (_super) {
    __extends(WinScene, _super);
    function WinScene() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    WinScene.prototype.onPreloading = function () {
        this.soundThemeRes = this.resourceLoader.loadSound('./catGame/res/sound/win.mp3');
        this.spriteSheetLabel = this.resourceLoader.loadTexture('./catGame/res/sprite/win.png');
    };
    WinScene.prototype.startSound = function () {
        _super.prototype.startSound.call(this);
        this.snd.loop = false;
    };
    WinScene.prototype.listenUI = function () {
        var _this = this;
        this.on(MOUSE_EVENTS.click, function (e) {
            _this.snd.stop();
            _this.game.camera.shake(5, 200);
            _this.game.runScene(new introScene_IntroScene(_this.game));
        });
    };
    return WinScene;
}(baseAbstractIntroScene_BaseAbstractIntroScene));


// CONCATENATED MODULE: ./catGame/scene/levelCompletedScene.ts


var levelCompletedScene_LevelCompletedScene = (function (_super) {
    __extends(LevelCompletedScene, _super);
    function LevelCompletedScene() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    LevelCompletedScene.prototype.onPreloading = function () {
        this.soundThemeRes = this.resourceLoader.loadSound('./catGame/res/sound/levelCompleted.mp3');
        this.spriteSheetLabel = this.resourceLoader.loadTexture('./catGame/res/sprite/levelCompleted.png');
    };
    LevelCompletedScene.prototype.startSound = function () {
        _super.prototype.startSound.call(this);
        this.snd.loop = false;
    };
    LevelCompletedScene.prototype.listenUI = function () {
    };
    return LevelCompletedScene;
}(baseAbstractIntroScene_BaseAbstractIntroScene));


// CONCATENATED MODULE: ./catGame/gameManager.ts













var gameManager_GameManager = (function () {
    function GameManager(game) {
        this.game = game;
        this.initialNumOfLives = 1;
        this.currLevel = -1;
        this.numOfObjectToCollectForNextLevel = 0;
        this.numOfObjectCollected = 0;
        this.levels = [
            l0_namespaceObject,
            l1_namespaceObject,
            l2_namespaceObject,
            l3_namespaceObject,
            l4_namespaceObject,
            l5_namespaceObject,
        ];
    }
    GameManager.instantiate = function (game) {
        GameManager.instance = new GameManager(game);
    };
    GameManager.getCreatedInstance = function () {
        return GameManager.instance;
    };
    GameManager.prototype.incrementNumOfLives = function () {
        infoPanel_InfoPanel.getCreatedInstance().incrementNumOfLives();
    };
    GameManager.prototype.decrementPower = function (val, onLifeDecremented) {
        infoPanel_InfoPanel.getCreatedInstance().decrementPower(val, onLifeDecremented);
        if (infoPanel_InfoPanel.getCreatedInstance().getNumOfLives() < 0)
            this.gameOver();
    };
    GameManager.prototype.incrementPower = function () {
        infoPanel_InfoPanel.getCreatedInstance().incrementPower();
    };
    GameManager.prototype.decrementNumOfLives = function () {
        infoPanel_InfoPanel.getCreatedInstance().decrementNumOfLives();
        var numOfLives = infoPanel_InfoPanel.getCreatedInstance().getNumOfLives();
        if (numOfLives < 0)
            this.gameOver();
    };
    GameManager.prototype.startGame = function () {
        this.currLevel = -1;
        this.numOfObjectCollected = 0;
        this.nextLevel();
    };
    GameManager.prototype.onObjectPicked = function () {
        this.numOfObjectCollected++;
        if (this.numOfObjectCollected >= this.numOfObjectToCollectForNextLevel)
            this.nextLevel();
    };
    GameManager.prototype.nextLevel = function () {
        var _this = this;
        this.currLevel++;
        if (this.currLevel >= this.levels.length) {
            this.game.runScene(new winScene_WinScene(this.game), new cellsAppearingTransition_CellsAppearingTransition(this.game));
        }
        else {
            if (this.currLevel === 0) {
                this._nextLevel(this.initialNumOfLives);
            }
            else {
                var numOfLives_1 = infoPanel_InfoPanel.getCreatedInstance().getNumOfLives();
                var levelCompletedScene = new levelCompletedScene_LevelCompletedScene(this.game);
                this.game.runScene(levelCompletedScene, new cellsAppearingTransition_CellsAppearingTransition(this.game));
                levelCompletedScene.on("completed", function (e) {
                    _this.game.getCurrScene().setTimeout(function () {
                        _this._nextLevel(numOfLives_1);
                    }, 3000);
                });
            }
        }
    };
    GameManager.prototype.gameOver = function () {
        this.game.runScene(new gameOverScene_GameOverScene(this.game));
    };
    GameManager.prototype._nextLevel = function (numOfLives) {
        var _this = this;
        this.game.runScene(new mainScene_MainScene(this.game, this.levels[this.currLevel], numOfLives), new cellsAppearingTransition_CellsAppearingTransition(this.game));
        this.numOfObjectToCollectForNextLevel = 0;
        this.numOfObjectCollected = 0;
        this.levels[this.currLevel].layers[0].objects.forEach(function (it) {
            if (it.type === testTube_TestTube.groupName)
                _this.numOfObjectToCollectForNextLevel++;
        });
    };
    return GameManager;
}());

window.G = gameManager_GameManager;

// CONCATENATED MODULE: ./catGame/scene/introScene.ts




var introScene_IntroScene = (function (_super) {
    __extends(IntroScene, _super);
    function IntroScene() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    IntroScene.prototype.onPreloading = function () {
        this.soundThemeRes = this.resourceLoader.loadSound('./catGame/res/sound/theme1.mp3');
        this.spriteSheetLabel = this.resourceLoader.loadTexture('./catGame/res/sprite/pressKeyToStart.png');
    };
    IntroScene.prototype.listenUI = function () {
        var _this = this;
        this.on(MOUSE_EVENTS.click, function (e) {
            _this.snd.stop();
            _this.game.camera.shake(5, 200);
            gameManager_GameManager.getCreatedInstance().startGame();
        });
    };
    return IntroScene;
}(baseAbstractIntroScene_BaseAbstractIntroScene));


// CONCATENATED MODULE: ./engine/misc/easing/functions/elastic.ts
var EasingElastic;
(function (EasingElastic) {
    EasingElastic.In = function (t, b, c, d) {
        var s = 1.70158, p = 0, a = c;
        if (t === 0)
            return b;
        if ((t /= d) === 1)
            return b + c;
        if (!p)
            p = d * .3;
        if (a < Math.abs(c)) {
            a = c;
            s = p / 4;
        }
        else
            s = p / (2 * Math.PI) * Math.asin(c / a);
        return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
    };
    EasingElastic.Out = function (t, b, c, d) {
        var s = 1.70158, p = 0, a = c;
        if (t === 0)
            return b;
        if ((t /= d) === 1)
            return b + c;
        if (!p)
            p = d * .3;
        if (a < Math.abs(c)) {
            a = c;
            s = p / 4;
        }
        else
            s = p / (2 * Math.PI) * Math.asin(c / a);
        return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
    };
    EasingElastic.InOut = function (t, b, c, d) {
        var s = 1.70158, p = 0, a = c;
        if (t === 0)
            return b;
        if ((t /= d / 2) === 2)
            return b + c;
        if (!p)
            p = d * (.3 * 1.5);
        if (a < Math.abs(c)) {
            a = c;
            s = p / 4;
        }
        else
            s = p / (2 * Math.PI) * Math.asin(c / a);
        if (t < 1)
            return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
        return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
    };
})(EasingElastic || (EasingElastic = {}));

// CONCATENATED MODULE: ./engine/renderer/webGl/filters/texture/posterizeFilter.ts



var posterizeFilter_PosterizeFilter = (function (_super) {
    __extends(PosterizeFilter, _super);
    function PosterizeFilter(game) {
        var _this = _super.call(this, game) || this;
        var programGen = _this.simpleRectDrawer.gen;
        _this.gamma = programGen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'gamma');
        _this.numColors = programGen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'numColors');
        programGen.setFragmentMainFn("void main(){\nvec4 tex = texture2D(texture, v_texCoord.xy);\nvec3 c = tex.rgb;\nc = pow(c, vec3(gamma));\nc = c * numColors;\nc = floor(c);\nc = c / numColors;\nc = pow(c, vec3(1.0/gamma));\ngl_FragColor = vec4(c, tex.a);\n}");
        _this.setGamma(0.6);
        _this.setNumOfColors(8);
        _this.simpleRectDrawer.initProgram();
        return _this;
    }
    PosterizeFilter.prototype.setGamma = function (n) {
        this.setUniform(this.gamma, n);
    };
    PosterizeFilter.prototype.setNumOfColors = function (n) {
        this.setUniform(this.numColors, n);
    };
    return PosterizeFilter;
}(abstractGlFilter_AbstractGlFilter));


// CONCATENATED MODULE: ./engine/renderer/webGl/filters/texture/pixelFilter.ts



var pixelFilter_PixelFilter = (function (_super) {
    __extends(PixelFilter, _super);
    function PixelFilter(game) {
        var _this = _super.call(this, game) || this;
        var programGen = _this.simpleRectDrawer.gen;
        _this.rt_w = programGen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'rt_w');
        _this.rt_h = programGen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'rt_h');
        _this.pixel_w = programGen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'pixel_w');
        _this.pixel_h = programGen.addScalarFragmentUniform(GL_TYPE.FLOAT, 'pixel_h');
        programGen.setFragmentMainFn("void main(){\nvec2 uv = v_texCoord.xy;\nfloat dx = pixel_w*(1./rt_w);\nfloat dy = pixel_h*(1./rt_h);\nvec2 coord = vec2(dx*floor(uv.x/dx),\ndy*floor(uv.y/dy));\ngl_FragColor = texture2D(texture, coord);\n}");
        _this.setPixelSize(5);
        _this.simpleRectDrawer.initProgram();
        return _this;
    }
    PixelFilter.prototype.setPixelWidth = function (n) {
        this.setUniform(this.pixel_w, n);
    };
    PixelFilter.prototype.setPixelHeight = function (n) {
        this.setUniform(this.pixel_h, n);
    };
    PixelFilter.prototype.setPixelSize = function (n) {
        this.setPixelWidth(n);
        this.setPixelHeight(n);
    };
    PixelFilter.prototype.doFilter = function (destFrameBuffer) {
        var size = this.simpleRectDrawer.getAttachedTextureAt(0).size;
        this.setUniform(this.rt_w, size.width);
        this.setUniform(this.rt_h, size.height);
        _super.prototype.doFilter.call(this, destFrameBuffer);
    };
    return PixelFilter;
}(abstractGlFilter_AbstractGlFilter));


// CONCATENATED MODULE: ./catGame/scene/preIntroScene.ts












var preIntroScene_PreIntroScene = (function (_super) {
    __extends(PreIntroScene, _super);
    function PreIntroScene() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    PreIntroScene.prototype.onPreloading = function () {
        this.colorBG = color_Color.BLACK;
    };
    PreIntroScene.prototype.onReady = function () {
        var _this = this;
        var intro = new image_Image(this.game);
        intro.setResourceLink(this.spriteSheetLogo);
        intro.anchorPoint.setToCenter();
        intro.transformPoint.setToCenter();
        intro.pos.setXY(this.game.size.width / 2, this.game.size.height / 2);
        this.appendChild(intro);
        var scale = 20;
        intro.scale.setXY(scale);
        var tw = new tween_Tween({
            target: { val: scale },
            progress: function (_a) {
                var val = _a.val;
                intro.scale.setXY(Math.abs(val));
            },
            complete: function (_a) {
                var val = _a.val;
                intro.setTimeout(function () {
                    _this.game.runScene(new introScene_IntroScene(_this.game), new cellsAppearingTransition_CellsAppearingTransition(_this.game));
                }, 1000);
            },
            ease: EasingElastic.InOut,
            time: 5000,
            delayBeforeStart: 200,
            from: { val: scale },
            to: { val: 0.1 }
        });
        this.addTween(tw);
        var pixelFilter = new pixelFilter_PixelFilter(this.game);
        pixelFilter.setPixelSize(5);
        var posterizeFilter = new posterizeFilter_PosterizeFilter(this.game);
        posterizeFilter.setNumOfColors(2);
        this.filters = [pixelFilter];
    };
    __decorate([
        Source.Texture('./catGame/res/sprite/contest.png'),
        __metadata("design:type", ResourceLink)
    ], PreIntroScene.prototype, "spriteSheetLogo", void 0);
    return PreIntroScene;
}(scene_Scene));


// CONCATENATED MODULE: ./catGame/index.ts









var catGame_game = new game_Game({ width: 640, height: 480 });
catGame_game.setRenderer(webGlRenderer_WebGlRenderer);
catGame_game.addControl(keyboardControl_KeyboardControl);
catGame_game.addControl(gamePadControl_GamePadControl);
catGame_game.addControl(mouseControl_MouseControl);
catGame_game.setAudioPLayer(audioPlayer_AudioPlayer);
catGame_game.getAudioPlayer().freeNodeSearchStrategy = 1;
catGame_game.setPhysicsSystem(ArcadePhysicsSystem_ArcadePhysicsSystem);
gameManager_GameManager.instantiate(catGame_game);
catGame_game.runScene(new preIntroScene_PreIntroScene(catGame_game));


/***/ })
/******/ ]);