Browse Source

no message

ducnt 2 weeks ago
parent
commit
b62312e15e
100 changed files with 16518 additions and 15 deletions
  1. 0 7
      WebChallenge/WebChallenge/WebChallenge.csproj
  2. 7 7
      WebChallenge/WebChallenge/wwwroot/games/G1/js/CCreditsPanel.js
  3. 1 1
      WebChallenge/WebChallenge/wwwroot/games/G1/js/CMain.js
  4. 80 0
      WebChallenge/WebChallenge/wwwroot/games/G11/css/main.css
  5. 38 0
      WebChallenge/WebChallenge/wwwroot/games/G11/css/orientation_utils.css
  6. 46 0
      WebChallenge/WebChallenge/wwwroot/games/G11/css/reset.css
  7. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/css/survivant-webfont.eot
  8. 630 0
      WebChallenge/WebChallenge/wwwroot/games/G11/css/survivant-webfont.svg
  9. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/css/survivant-webfont.ttf
  10. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/css/survivant-webfont.woff
  11. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/css/survivant-webfont.woff2
  12. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/icon..jpg
  13. 610 0
      WebChallenge/WebChallenge/wwwroot/games/G11/index.html
  14. 10866 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/Box2D.js
  15. 133 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CBasket.js
  16. 123 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CConfirmPanel.js
  17. 68 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CCreditsPanel.js
  18. 217 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CEndPanel.js
  19. 143 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CFormatText.js
  20. 555 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CGame.js
  21. 140 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CGfxButton.js
  22. 152 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CHelp.js
  23. 303 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CInterface.js
  24. 23 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CLang.js
  25. 149 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CLevelBut.js
  26. 261 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CLevelMenu.js
  27. 291 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CMain.js
  28. 238 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CMenu.js
  29. 66 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CMsgBox.js
  30. 87 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CObjectToPick.js
  31. 115 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CPhysicsController.js
  32. 228 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CPhysicsObject.js
  33. 84 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CPlayer.js
  34. 83 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CPreloader.js
  35. 119 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CRollingTextController.js
  36. 57 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CRollingTextManager.js
  37. 120 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CTextButton.js
  38. 102 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CToggle.js
  39. 63 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/CTweenController.js
  40. 11 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/createjs-2015.11.26.min.js
  41. 9 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/ctl_utils.js
  42. 1 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/howler.min.js
  43. 1 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/jquery-3.2.1.min.js
  44. 163 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/screenfull.js
  45. 64 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/settings.js
  46. 71 0
      WebChallenge/WebChallenge/wwwroot/games/G11/js/sprite_lib.js
  47. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sounds/click.mp3
  48. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sounds/click.ogg
  49. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sounds/game_over.mp3
  50. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sounds/game_over.ogg
  51. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sounds/hit_basket.mp3
  52. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sounds/hit_basket.ogg
  53. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sounds/hit_obstacles.mp3
  54. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sounds/hit_obstacles.ogg
  55. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sounds/next_level.mp3
  56. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sounds/next_level.ogg
  57. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sounds/pick_object.mp3
  58. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sounds/pick_object.ogg
  59. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sounds/soundtrack.mp3
  60. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sounds/soundtrack.ogg
  61. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/audio_icon.png
  62. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/ball_0.png
  63. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/ball_1.png
  64. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/basket_back.png
  65. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/basket_front.png
  66. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_game.jpg
  67. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu.jpg
  68. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/0-main-menu-animation.png
  69. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/1-main-menu-animation.png
  70. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/10-main-menu-animation.png
  71. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/11-main-menu-animation.png
  72. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/12-main-menu-animation.png
  73. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/13-main-menu-animation.png
  74. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/14-main-menu-animation.png
  75. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/15-main-menu-animation.png
  76. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/16-main-menu-animation.png
  77. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/17-main-menu-animation.png
  78. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/18-main-menu-animation.png
  79. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/19-main-menu-animation.png
  80. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/2-main-menu-animation.png
  81. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/20-main-menu-animation.png
  82. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/21-main-menu-animation.png
  83. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/3-main-menu-animation.png
  84. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/4-main-menu-animation.png
  85. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/5-main-menu-animation.png
  86. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/6-main-menu-animation.png
  87. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/7-main-menu-animation.png
  88. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/8-main-menu-animation.png
  89. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/9-main-menu-animation.png
  90. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_preloader.jpg
  91. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_tile.jpg
  92. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_continue.png
  93. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_exit.png
  94. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_fullscreen.png
  95. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_home.png
  96. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_info.png
  97. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_next.png
  98. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_play.png
  99. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_restart.png
  100. BIN
      WebChallenge/WebChallenge/wwwroot/games/G11/sprites/cursor_help.png

+ 0 - 7
WebChallenge/WebChallenge/WebChallenge.csproj

@@ -5,13 +5,6 @@
     <CopyRefAssembliesToPublishDirectory>false</CopyRefAssembliesToPublishDirectory>
   </PropertyGroup>
 
-  <ItemGroup>
-    <Compile Remove="wwwroot\games\**" />
-    <Content Remove="wwwroot\games\**" />
-    <EmbeddedResource Remove="wwwroot\games\**" />
-    <None Remove="wwwroot\games\**" />
-  </ItemGroup>
-
   <ItemGroup>
     <Content Remove="Views\Home\TopPlayer.cshtml" />
     <Content Remove="Views\Shared\_LayoutLogin.cshtml" />

+ 7 - 7
WebChallenge/WebChallenge/wwwroot/games/G1/js/CCreditsPanel.js

@@ -49,13 +49,13 @@ function CCreditsPanel(){
         _oMsgText.textAlign = "center";
         _oContainer.addChild(_oMsgText);
 		
-        oSprite = s_oSpriteLibrary.getSprite('ctl_logo');
-        var oLogo = createBitmap(oSprite);
-        oLogo.regX = oSprite.width/2;
-        oLogo.regY = oSprite.height/2;
-        oLogo.x = CANVAS_WIDTH/2;
-        oLogo.y = CANVAS_HEIGHT/2;
-        _oContainer.addChild(oLogo);
+        //oSprite = s_oSpriteLibrary.getSprite('ctl_logo');
+        //var oLogo = createBitmap(oSprite);
+        //oLogo.regX = oSprite.width/2;
+        //oLogo.regY = oSprite.height/2;
+        //oLogo.x = CANVAS_WIDTH/2;
+        //oLogo.y = CANVAS_HEIGHT/2;
+        //_oContainer.addChild(oLogo);
         
         _oLink = new createjs.Text("movitel.co.mz","46px "+PRIMARY_FONT, "#ffffff");
         _oLink.x = CANVAS_WIDTH/2;

+ 1 - 1
WebChallenge/WebChallenge/wwwroot/games/G1/js/CMain.js

@@ -214,7 +214,7 @@ function CMain(oData) {
         s_oSpriteLibrary.addSprite("but_no", "./sprites/but_no.png");
 
         s_oSpriteLibrary.addSprite("life", "./sprites/life.png");
-        s_oSpriteLibrary.addSprite("ctl_logo", "./sprites/ctl_logo.png");
+        //s_oSpriteLibrary.addSprite("ctl_logo", "./sprites/ctl_logo.png");
         s_oSpriteLibrary.addSprite("but_credits", "./sprites/but_credits.png");
         s_oSpriteLibrary.addSprite("but_fullscreen", "./sprites/but_fullscreen.png");
         s_oSpriteLibrary.addSprite("but_clear_save", "./sprites/but_clear_save.png");

+ 80 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/css/main.css

@@ -0,0 +1,80 @@
+root { 
+    display: block;
+}
+
+body{
+    background-color: #f3f3f3;
+    background-repeat: repeat-x;
+    background-position: top;
+    background-image: url(../sprites/bg_tile.jpg);  
+}
+
+*, *:before, *:after {
+    -webkit-user-select: none;
+    -khtml-user-select: none;
+    -moz-user-select: none;
+    -ms-user-select: none;
+    user-select: none;
+}
+     
+input, input:before, input:after {
+    -webkit-user-select: initial;
+    -khtml-user-select: initial;
+    -moz-user-select: initial;
+    -ms-user-select: initial;
+    user-select: initial;
+}
+
+::selection { background: transparent;color:inherit; }
+::-moz-selection { background: transparent;color:inherit; }
+
+#canvas{
+    position: fixed;
+    background-color: #000;
+}
+
+canvas {
+    image-rendering: optimizeSpeed;
+    image-rendering:-o-crisp-edges;
+    image-rendering:-webkit-optimize-contrast;
+    -ms-interpolation-mode: nearest-neighbor;
+	-ms-touch-action: none;
+}
+
+.ani_hack{
+    -webkit-perspective: 1000;
+    -webkit-backface-visibility: hidden;
+    
+    -webkit-touch-callout: none;
+    -webkit-user-select: none;
+    -khtml-user-select: none;
+    -moz-user-select: none;
+    -ms-user-select: none;
+    user-select: none;
+    outline: none;
+    -webkit-tap-highlight-color: transparent; /* mobile webkit */
+}
+
+
+/***************FONTS*******************/
+
+@font-face {
+    font-family: 'survivantregular';
+    src: url('survivant-webfont.eot');
+    src: url('survivant-webfont.eot?#iefix') format('embedded-opentype'),
+         url('survivant-webfont.woff2') format('woff2'),
+         url('survivant-webfont.woff') format('woff'),
+         url('survivant-webfont.ttf') format('truetype'),
+         url('survivant-webfont.svg#survivantregular') format('svg');
+    font-weight: normal;
+    font-style: normal;
+
+}
+
+.check-fonts{
+        opacity:0;
+}
+
+.check-font-1{
+        font-family: 'survivantregular';
+}

+ 38 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/css/orientation_utils.css

@@ -0,0 +1,38 @@
+
+.orientation-msg-container{
+    width: 100%;
+    height: 100%;
+    display: none;
+    position: fixed;
+    background-color: #000;
+}
+
+.orientation-msg-text{
+    font-size: 40px;
+    font-family: "Arial";
+    color: #fff;
+    text-align: center;
+    width: 80%;
+    
+    position: fixed;
+    top: 50%;
+    -webkit-transform: translate(15%,-50%);
+    -moz-transform: translate(15%,-50%);
+    -ms-transform: translate(15%,-50%);
+    transform: translate(15%,-50%);
+    
+        
+}
+
+@media (max-width: 767px) {
+    .orientation-msg-text{    
+        font-size: 30px;  
+    }
+}
+
+
+@media (max-width: 500px) {
+    .orientation-msg-text{    
+        font-size: 30px;  
+    }
+}

+ 46 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/css/reset.css

@@ -0,0 +1,46 @@
+a, abbr, acronym, address, applet, article, aside, audio,
+b, blockquote, big, body,
+center, canvas, caption, cite, code, command,
+datalist, dd, del, details, dfn, dl, div, dt,
+em, embed,
+fieldset, figcaption, figure, font, footer, form,
+h1, h2, h3, h4, h5, h6, header, hgroup, html,
+i, iframe, img, ins,
+kbd,
+keygen,
+label, legend, li,
+meter,
+nav,
+object, ol, output,
+p, pre, progress,
+q,
+s, samp, section, small, span, source, strike, strong, sub, sup,
+table, tbody, tfoot, thead, th, tr, tdvideo, tt,
+u, ul,
+var{
+    background: transparent;
+    border: 0 none;
+    font-size: 100%;
+	margin: 0;
+	padding: 0;
+	border: 0;
+	outline: 0;
+    vertical-align: top; }
+
+ol, ul {
+	list-style: none;
+}
+blockquote, q {
+	quotes: none;
+}
+table, table td {
+	padding:0;
+	border:none;
+	border-collapse:collapse;
+}
+img {
+	vertical-align:top;
+}
+embed {
+	vertical-align:top;
+}

BIN
WebChallenge/WebChallenge/wwwroot/games/G11/css/survivant-webfont.eot


+ 630 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/css/survivant-webfont.svg

@@ -0,0 +1,630 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
+<svg xmlns="http://www.w3.org/2000/svg">
+<metadata></metadata>
+<defs>
+<font id="survivantregular" horiz-adv-x="1394" >
+<font-face units-per-em="2048" ascent="1638" descent="-410" />
+<missing-glyph horiz-adv-x="753" />
+<glyph horiz-adv-x="0" />
+<glyph unicode="&#xd;" horiz-adv-x="753" />
+<glyph unicode=" "  horiz-adv-x="753" />
+<glyph unicode="&#x09;" horiz-adv-x="753" />
+<glyph unicode="&#xa0;" horiz-adv-x="753" />
+<glyph unicode="!" horiz-adv-x="731" d="M115 1161v137q205 -2 301 -2q76 0 198 2v-73q0 -6 -6 -88l-71 -779q-121 8 -363 23q-23 188 -53 686q-6 88 -6 94zM150 254q139 11 415 27q-12 -100 -28 -304q-121 12 -363 37q-10 80 -24 240z" />
+<glyph unicode="&#x22;" horiz-adv-x="1015" d="M117 1212v107q123 -2 180 -2q47 0 121 2v-57q0 -10 -15 -220l-32 -458q-74 4 -219 16q-10 104 -25 375q-10 215 -10 237zM588 1212v107q123 -2 180 -2q47 0 121 2v-57q0 -10 -15 -220l-32 -458q-74 4 -219 16q-10 104 -25 375q-10 215 -10 237z" />
+<glyph unicode="#" horiz-adv-x="1406" d="M80 420q0 63 20 100q4 8 148 4l55 252q-102 4 -178 10v15q0 18 -4 53t-4 53q0 63 20 101q2 4 66 4q53 0 153 -4q12 49 74 290q115 -6 170 -6q43 0 117 6q-35 -135 -84 -305l270 -16q16 80 80 321q115 -6 170 -6q43 0 117 6q-35 -135 -94 -337q43 -4 129 -9 q-4 -158 -5 -157q1 -50 5 -62q-90 4 -195 8l-76 -262l234 -14l-4 -158q0 -49 4 -61q-129 6 -299 12l-86 -297q-66 10 -199 35q25 109 59 270l-321 15l-92 -320q-66 10 -199 35q25 115 66 297q-59 2 -109 6v14q0 18 -4 53t-4 54zM489 512q125 -6 306 -18l57 258l-289 12z" />
+<glyph unicode="$" horiz-adv-x="1323" d="M92 143v314h412q18 -16 18 -54q0 -20 -8 -59t-8 -57q25 -6 61 -8l-10 331q-133 27 -395 92q0 12 -8 191q-8 160 -13 321q88 16 174 33q125 23 177 23h47l-2 225q88 -4 131 -4q33 0 86 4q2 -121 0 -227q76 -4 184 -23q92 -16 184 -33q25 -90 25 -301q-31 8 -103 9 q-72 0 -231 -7q0 25 -5 78t-5 80l-51 2l-2 -252q139 -31 192 -45q113 -33 182 -69q37 -18 76 -175q37 -141 37 -200q0 -186 -330 -266q-80 -18 -125 -19q-6 0 -41 4l-4 -215q-51 12 -157 37l-7 201zM475 887q33 -9 74 -19l-6 211l-39 2q-8 -66 -29 -194zM743 283 q88 12 88 153q0 61 -83 107z" />
+<glyph unicode="%" horiz-adv-x="1353" d="M45 1053q0 90 96 247q109 10 340 21q35 -72 72 -145q39 -93 39 -154q0 -6 -8 -78l-23 -174l-317 -41q-53 12 -66 19q-33 12 -55.5 41.5t-50 124t-27.5 139.5zM127 2q158 264 408 651q209 322 417 645q111 -6 152 -6q26 0 94 6l-80 -124q-14 -23 -262 -394l-545 -815 q-61 12 -184 37zM233 1028q0 -4 31 -158h103l-15 342q-45 0 -78 5q-41 -164 -41 -189zM745 319q0 90 99 248q106 10 340 21q35 -72 69 -146q41 -92 41 -155q0 -4 -10 -76l-20 -174l-318 -41q-53 12 -65 18q-33 12 -54 37q-25 35 -53.5 129t-28.5 139zM936 295q0 -6 31 -158 h102l-14 342q-47 0 -78 4q-41 -164 -41 -188z" />
+<glyph unicode="&#x26;" horiz-adv-x="1468" d="M74 350q0 84 69.5 188.5t145.5 139.5q-63 39 -119.5 120t-56.5 152q0 121 202 334q209 16 713 29q14 -18 31 -58q25 -61 49 -122q31 -72 61 -119l-391 -45l-43 112q-76 0 -137 4q-4 -8 -40 -86.5t-36 -80.5l51 -156q76 -2 136 -6q20 -4 59 -6q547 -9 643 -7 q-6 -66 -25 -198l-190 -2q-33 -76 -68 -215q-41 -162 -61 -222q-8 -43 -37 -120q-252 6 -754 30q-203 213 -202 334zM483 362q88 -88 115 -149q59 6 137 6l96 320l-299 -4q-25 -74 -49 -173z" />
+<glyph unicode="'" horiz-adv-x="544" d="M117 1212v107q123 -2 180 -2q47 0 121 2v-57q0 -10 -15 -220l-32 -458q-74 4 -219 16q-10 104 -25 375q-10 215 -10 237z" />
+<glyph unicode="(" horiz-adv-x="876" d="M82 590q0 127 73.5 364.5t143.5 352.5q221 23 483 34q4 -35 4 -67q0 -31 -6 -82q-8 -63 -10 -84q-102 0 -174 12q-25 -102 -66 -381q-25 -182 -24 -204q0 -23 20 -195q14 -109 47 -326l232 -61q-2 -8 -29 -240l-250 -12q2 0 -39 10q-168 37 -223 115q-51 72 -119 371 q-63 283 -63 393z" />
+<glyph unicode=")" horiz-adv-x="925" d="M96 -47l232 61q16 88 47 326q20 172 20 195t-24 204q-18 129 -66 381q-74 -12 -174 -12q-2 20 -10 84q-6 51 -6 82q0 33 4 67q260 -12 483 -34q70 -115 143.5 -352.5t73.5 -364.5q0 -111 -63 -393q-68 -299 -119 -371q-55 -78 -223 -115q-41 -10 -39 -10l-250 12z" />
+<glyph unicode="*" horiz-adv-x="1071" d="M94 772l260 195q-233 166 -233 180q0 8 8 31q16 37 58 76.5t53 58.5q102 -74 196 -142q6 115 13 242h12q18 0 52 4t50 4q66 0 90 -20q4 -4 4 -49q0 -51 -6 -168q84 63 178 129q12 -18 58 -62q39 -37 53 -73q8 -23 8 -31q0 -14 -233 -180l262 -195l-129 -158 q-55 39 -221 158q-6 -90 -17 -272h-202l8 254q-66 -47 -195 -140z" />
+<glyph unicode="+" horiz-adv-x="1116" d="M102 643q0 80 21 115q4 4 47 4q74 0 276 -14q10 164 25 333h14q23 0 67 4.5t66 4.5q80 0 113 -21q6 -2 6 -47q0 -78 -16 -297q100 -8 303 -23v-260l-326 17q-8 -96 -22 -291h-260l16 305q-158 10 -321 23v16q0 23 -4.5 66t-4.5 65z" />
+<glyph unicode="," horiz-adv-x="655" d="M131 -346l6 149q217 0 234 189q-61 6 -213 22q-10 154 -25 404q137 10 416 26q-20 -297 -29 -467l-2 3q-10 -143 -129 -238q-111 -88 -258 -88z" />
+<glyph unicode="-" horiz-adv-x="1159" d="M113 643q0 80 20 115q2 4 47 4q74 0 275 -14q193 -18 579 -46v-260q-305 14 -913 54v16q0 23 -4 66t-4 65z" />
+<glyph unicode="." horiz-adv-x="677" d="M135 418q137 10 416 26q-20 -297 -29 -467q-121 12 -362 37q-10 154 -25 404z" />
+<glyph unicode="/" horiz-adv-x="782" d="M59 -199q53 246 199 899q37 164 113 490l59 233q113 -6 172 -6q47 0 115 6l-33 -125q-6 -31 -145 -532l-283 -1002q-66 12 -197 37z" />
+<glyph unicode="0" horiz-adv-x="1323" d="M90 713q0 201 199 553q221 25 698 47q72 -164 146 -328q79 -203 79 -344q0 -14 -20 -197l-41 -364l-653 -92q-106 29 -133 39q-68 29 -107 86q-16 25 -47 100q-121 307 -121 500zM479 657q0 -16 19 -122q14 -78 43 -234h211l-31 766q-92 0 -158 12q-31 -131 -61 -286 q-23 -119 -23 -136z" />
+<glyph unicode="1" horiz-adv-x="1144" d="M125 1016q0 20 182 143q106 70 215 139q203 -4 299 -4q78 0 201 4v-124q0 -8 -8 -119l-19 -269q-18 -270 -53 -809q-121 12 -360 37q-31 412 -58 998q-72 -49 -137 -107q-47 -47 -151 -125q-4 10 -64 123q-47 90 -47 113z" />
+<glyph unicode="2" horiz-adv-x="1292" d="M96 -31q0 94 8 283q4 49 5 72q199 139 397 276q289 209 289 313q0 92 -17 121q-25 41 -106 41q-111 0 -142 -6q16 -127 17 -117q0 -51 -27 -78h-399v379q43 6 399 70l166 29q74 12 80 12q49 0 135 -29q297 -94 297 -305q0 -61 -35 -192q-37 -143 -68.5 -174t-123.5 -107 q-172 -139 -449 -346q68 2 328 6q0 29 4 89.5t4 90.5q147 -8 213 -8q80 0 125 14v-157q0 -102 -25 -211q-252 -47 -553 -47q-82 0 -241.5 -10.5t-239.5 -10.5q-23 0 -41 2z" />
+<glyph unicode="3" horiz-adv-x="1269" d="M88 266l389 66l45 -113q76 0 137 -6q27 61 117 149q-2 16 -51 173l-326 16q-14 66 -43 199h133q8 0 28 2t26 2q59 6 141 8l51 156q0 4 -35 77q-37 82 -41 90q-59 -4 -137 -4l-43 -112l-391 45q31 45 111 241q16 37 30 58q238 -4 713 -29q203 -213 203 -334 q0 -72 -56.5 -152.5t-119.5 -119.5q76 -35 145.5 -139.5t69.5 -188.5q0 -121 -203 -334q-182 -14 -754 -30q-16 27 -56 122t-83 158z" />
+<glyph unicode="4" horiz-adv-x="1302" d="M86 248v250l14 -2l2 67q104 98 398 420l291 317l2 23q113 -6 340 -20q4 -27 4 -173q2 -111 2 -323v-338l73 -2q-4 -31 -4 -37q0 -10 4.5 -27.5t4.5 -27.5q0 -31 -23 -80q-25 -23 -51 -23v-39v-243q-156 2 -228 2q-57 0 -165 -2v92q0 20 6 168q-219 -6 -424 -6 q-160 0 -246 4zM422 469h6q184 0 344 2q8 223 14 473q-117 -162 -364 -475z" />
+<glyph unicode="5" horiz-adv-x="1253" d="M86 49v379h397q25 -27 25 -76q0 8 -14 -116q31 -6 110 -7q78 0 103 9q45 18 51 84q4 25 4 69q0 197 -612 221q0 29 -9 262q-6 217 -10 398q84 20 168 39q113 27 168 26q236 0 307 -10q94 -20 281 -57q25 -111 24 -213v-156q-43 14 -123 14q-66 0 -211 -10q0 31 -5 91.5 t-5 88.5q-82 2 -246 9q-6 -80 -20 -244q23 2 49 2q125 0 277.5 -41t255.5 -106q37 -23 75 -203q35 -156 35 -230q0 -211 -297 -305q-86 -27 -133 -26q-8 0 -80 10q-51 10 -166 31z" />
+<glyph unicode="6" horiz-adv-x="1269" d="M92 487q0 88 62 207q55 96 110 193q43 88 135 262q45 80 164 246q57 -39 178 -109q39 -18 115 -57q-66 -111 -223 -340q106 4 323 12q68 -113 138 -223q82 -146 82 -242q0 -8 -19 -117l-43 -268l-629 -63l-49 8q-135 25 -184 78t-104.5 196.5t-55.5 216.5zM465 449 q0 -8 61 -244h205l-31 526q-90 0 -153 8q-82 -252 -82 -290z" />
+<glyph unicode="7" horiz-adv-x="1247" d="M78 1182q0 45 20 94q2 4 54 10q92 8 315 17q254 8 489 8q141 0 211 -4v-240h-4l-2 -78q-174 -264 -379 -583q-86 -135 -250 -406h-452q154 227 401 612l144 224q25 39 73 118l68 121q-61 -2 -223 -4q-141 -2 -224 -2q-137 0 -235 6q2 8 2 15q0 16 -4 45.5t-4 46.5z" />
+<glyph unicode="8" horiz-adv-x="1300" d="M90 408q0 59 135 227l-63 76q-12 61 -35 161q-20 84 -21 91q0 82 87 206q70 92 139 185q229 -6 688 -29q197 -202 197 -319q0 -63 -68 -185q-61 -106 -117 -164q90 -117 105 -137q63 -94 63 -153q0 -8 -18 -101l-45 -225l-643 -53l-45 6q-68 10 -103 20q-57 16 -90 47 q-49 43 -107.5 164t-58.5 183zM473 377q0 -8 64 -207h208l-30 424l-164 12q-78 -203 -78 -229zM563 766h207q64 201 64 207q0 33 -84 246q-63 -8 -158 -9z" />
+<glyph unicode="9" horiz-adv-x="1275" d="M104 899q0 8 17 117l43 268l631 64l47 -9q135 -25 184 -78t105.5 -196t56.5 -217q0 -88 -64 -207q-53 -96 -108 -192q-43 -88 -135 -263q-47 -80 -164 -245q-59 39 -178 108q-39 18 -117 57q68 111 223 340q-106 -4 -321 -12q-70 113 -140 223q-80 145 -80 242zM549 1130 l29 -526q92 0 155 -8q80 252 80 291q0 8 -61 243h-203z" />
+<glyph unicode=":" horiz-adv-x="661" d="M127 418q140 10 416 26q-18 -297 -29 -467q-121 12 -360 37q-12 154 -27 404zM127 1073q140 11 416 27q-18 -297 -29 -467q-121 12 -360 37q-12 154 -27 403z" />
+<glyph unicode=";" horiz-adv-x="661" d="M127 -346l6 149q215 0 232 189q-61 6 -211 22q-12 154 -27 404q140 10 416 26q-18 -297 -29 -467v3q-12 -143 -127 -234.5t-260 -91.5zM127 1073q140 11 416 27q-18 -297 -29 -467q-121 12 -360 37q-12 154 -27 403z" />
+<glyph unicode="&#x3c;" horiz-adv-x="1122" d="M86 375v424l928 364q-4 -45 -4 -100q0 -53 4 -148q2 -102 2 -147q-461 -131 -715 -197q434 -106 678 -153q-4 -152 -4 -211q0 -68 2 -121l-57 20q-137 49 -502 166q-111 37 -332 103z" />
+<glyph unicode="=" horiz-adv-x="1091" d="M88 377q0 80 21 115q2 4 47 4q74 0 274 -15q193 -18 580 -45v-260q-305 14 -914 53v17q0 23 -4 65.5t-4 65.5zM88 909q0 80 21 115q2 4 47 4q74 0 274 -14q193 -18 580 -45v-260q-305 14 -914 53v16q0 23 -4 66t-4 65z" />
+<glyph unicode="&#x3e;" horiz-adv-x="1093" d="M88 768q0 45 2 147q2 94 2 148q0 55 -2 100l928 -364v-424q-51 -12 -332 -103q-168 -53 -502 -166l-59 -20q4 53 4 121q0 59 -4 211q244 47 678 153q-254 66 -715 197z" />
+<glyph unicode="?" horiz-adv-x="1423" d="M76 899v358l698 101q74 10 80 10q49 0 141 -22q371 -91 371 -304q0 -70 -39 -229q-47 -176 -86 -199q-98 -51 -240 -94q-123 -37 -247 -71l12 -76l-381 -21q14 319 14 307q57 18 197 50q150 37 201 59q113 55 112 156q0 135 -61 163q-31 16 -184 17q-80 0 -123 -10 q2 -20 11 -64.5t9 -71.5q0 -41 -20 -59h-465zM371 254q139 11 415 27q-12 -100 -28 -304q-121 12 -363 37q-10 80 -24 240z" />
+<glyph unicode="@" horiz-adv-x="1411" d="M80 733q0 201 217 553q240 27 762 49q80 -164 158 -327q90 -205 90 -346q0 -12 -17 -144l-35 -266l-665 -39l-21 4q-51 14 -71 25q-39 16 -60 47q-33 43 -60.5 123t-27.5 131q0 59 53 123q47 51 97 102q117 4 284 0l-2 182q-57 2 -102 13q-8 -18 -35 -72q-31 -59 -39 -60 q-12 0 -98 21q-92 23 -143 29q4 49 57 104q45 43 88 88q63 2 135 2q104 0 322 -6q12 -33 32 -215q10 -115 35 -340q6 -68 25 -201l121 2q-6 532 -127 922q-344 0 -580 18q-61 -113 -168 -319q-135 -268 -135 -303q0 -27 102 -252q63 -135 125 -272h766l-6 -56l-631 -43 q-6 0 -57 13q-152 35 -208 113.5t-118.5 286.5t-62.5 310zM602 512q0 -16 12 -66q14 -55 17 -69l137 -10l4 278q-61 4 -104 14q-2 -8 -35 -79q-31 -63 -31 -68z" />
+<glyph unicode="A" horiz-adv-x="1388" d="M66 4v55q0 70 40 263q29 139 250 991h600l365 -1354q-41 2 -107 2q-68 0 -184 -2q-135 -4 -186 -4q-20 88 -53 209q-217 12 -381 22q-20 -104 -35 -184q-139 6 -203 6q-59 0 -106 -4zM469 434l250 -20q-80 287 -133 526q-37 -188 -117 -506z" />
+<glyph unicode="B" horiz-adv-x="1427" d="M92 -25v1321q424 4 570 4q219 0 284 -14q25 -6 74 -37q66 -41 72 -45q184 -96 208 -176q16 -49 17 -86q0 -139 -250 -307q250 -162 250 -293q0 -37 -14 -84q-25 -76 -211 -170q-49 -35 -146 -78q-66 -12 -337 -12h-81v-23q-147 8 -262 9q-111 0 -174 -9zM526 221h215 q15 125 58 305q6 0 -68 0q4 0 -41 -6q-59 -8 -100 -8q-25 0 -39 4q-14 -8 -23 -29q2 -31 2 -69q0 -66 -4 -197zM526 760q57 -2 109 -8q59 -4 51 -4h57q36 2 56 2q-43 186 -60 317h-213q4 -135 4 -203q0 -59 -4 -104z" />
+<glyph unicode="C" horiz-adv-x="1337" d="M68 713q0 201 217 553q227 25 782 47q12 -29 57 -156q47 -135 78 -211l-395 -69l-49 190q-100 0 -174 12q-35 -141 -70 -301q-23 -106 -22 -121q0 -16 18 -112q18 -80 51 -244l230 -61l32 204l447 -32q-14 -131 -45 -394l-711 -30l-49 12q-158 35 -215 113q-16 25 -47 96 q-135 307 -135 504z" />
+<glyph unicode="D" horiz-adv-x="1345" d="M96 719q0 279 37 600q399 -16 447 -21q254 -12 444 -32q217 -352 217 -553q0 -197 -133 -504q-14 -35 -49 -96q-55 -78 -213 -113l-49 -12l-652 30q-10 90 -28 273q-6 41 -15 121q0 -6 0 28q0 47 -3 140.5t-3 138.5zM504 557q0 -125 14 -317l232 61q16 78 47 234 q20 106 20 122t-24 136q-33 156 -66 286q-72 -12 -174 -12l-33 -340z" />
+<glyph unicode="E" horiz-adv-x="1245" d="M102 1065v233l144 -2q0 10 51 11q35 0 106.5 -6.5t106.5 -6.5q6 0 92 4v-10q82 -6 189 -6q51 0 153.5 3t153.5 3q31 0 51 -2v-301l-557 29l-19 -254q217 18 406 18q135 0 141 -10q20 -39 21 -115q0 -16 -6 -73q-3 -30 -3 -52q0 -11 1 -20q-104 -8 -289 -10 q-207 -4 -289 -9l-14 -235q203 -18 608 -49v-260q-209 10 -625 35l-2 -3q-94 8 -286 23l2 6l-76 8q-20 272 -41 664l-12 252q-6 119 -7 135z" />
+<glyph unicode="F" horiz-adv-x="1216" d="M98 1065v233l144 -2q0 10 51 11q35 0 106.5 -6.5t106.5 -6.5q6 0 92 4v-10q82 -6 188 -6q51 0 153.5 3t154.5 3q31 0 51 -2v-301l-557 29l-19 -254q217 18 406 18q135 0 141 -10q20 -39 21 -115q0 -16 -7 -73q-3 -30 -3 -52q0 -11 1 -20q-104 -8 -288 -10 q-207 -4 -289 -9q-10 -170 -33 -512q-94 8 -287 23l2 6l-75 8q-20 272 -41 664l-13 252q-6 119 -6 135z" />
+<glyph unicode="G" horiz-adv-x="1388" d="M86 713q0 201 217 553q225 25 780 47q14 -29 54 -144q51 -147 84 -223l-398 -69l-49 190q-102 0 -174 12q-33 -137 -68 -295q-22 -106 -22 -126q0 -17 18 -117q16 -80 50 -240l231 -61l18 141q-47 6 -141 16l8 260q94 -8 170 -10v2l62 -6q94 -4 280 -16q35 -5 105 -11 q-23 -199 -68 -598l-713 -30q2 0 -38 10q-168 37 -224.5 116t-119 287.5t-62.5 311.5z" />
+<glyph unicode="H" horiz-adv-x="1511" d="M117 1065v233q205 -4 301 -4q76 0 198 4v-124q0 -10 -8 -125l-18 -283q115 -12 344 -33q27 385 37 588q121 -12 362 -37q18 -272 39 -663l14 -252q5 -118 5 -136v-233q-203 6 -299 6q-76 0 -201 -6v125q0 10 8 104l16 238q-115 8 -344 25q-23 -332 -32 -515 q-121 12 -363 37q-18 272 -39 664l-14 252q-6 119 -6 135z" />
+<glyph unicode="I" horiz-adv-x="741" d="M119 1065v233q203 -4 299 -4q78 0 200 4v-124q0 -10 -8 -125l-20 -285q-18 -262 -51 -787q-121 12 -361 37q-18 244 -43 693q-16 330 -16 358z" />
+<glyph unicode="J" horiz-adv-x="1413" d="M131 446l387 134q18 -92 57 -279h291l-32 786q-104 0 -252 -12l-4 225q264 29 684 48q30 -68 30 -262v-13q0 -551 -53 -993l-711 -92q-125 31 -145 39q-78 29 -119 86q-61 86 -133 333z" />
+<glyph unicode="K" horiz-adv-x="1345" d="M72 1065v233q203 -4 301 -4q76 0 198 4v-124q0 -8 -6 -107l-12 -170q96 84 250 258q47 55 147 158l330 -13q-139 -127 -401 -411q-80 -88 -248 -254q195 -211 583 -635l-299 -49q-133 145 -397 440q-16 -258 -24 -414q-121 12 -363 37q-16 233 -41 666l-12 264 q-6 111 -6 121z" />
+<glyph unicode="L" horiz-adv-x="1155" d="M74 1065v233q203 -4 299 -4q76 0 200 4v-124q0 -8 -8 -103l-55 -817q203 -18 610 -49v-260q-209 10 -626 35v-3q-195 23 -361 23v6q0 121 -14 316q-23 268 -25 315l-16 293q-4 123 -4 135z" />
+<glyph unicode="M" horiz-adv-x="1757" d="M86 203q0 186 10 563q10 365 10 563v4q53 14 119 15q59 0 171 -10.5t165 -12.5l88 -221q2 -8 21 -74l37 -141l124 -471l209 653q20 68 70 195q6 12 10 12q23 0 60 -2q47 -4 61 -4q72 -2 191 -2h188l12 -234q0 -12 2 -133v-467q0 -258 -4 -448q-119 -10 -358 -31 q-25 221 -82 684q-133 -428 -234 -657q-51 -23 -122 -23q-33 0 -29 0l-135 -20q-98 236 -308 700q0 -215 -4 -645h-20q-18 0 -58 -3t-61 -3q-74 0 -123 22q-10 4 -10 191z" />
+<glyph unicode="N" horiz-adv-x="1507" d="M115 1106v233q203 -4 301 -4q33 0 99.5 2t98.5 2q6 0 27 -39q45 -86 141 -303q109 -242 191 -448q6 84 6 213q0 92 -6 275.5t-6 273.5q0 31 2 51q121 -12 360 -37q20 -268 41 -686l12 -264q7 -124 7 -142v-233q-203 6 -299 6q-78 0 -201 -6q-61 119 -158 344 q-88 211 -186 463q-10 -147 -17 -414q-6 -291 -12 -416q-115 12 -342 37q-18 270 -39 686l-14 265q-6 123 -6 141z" />
+<glyph unicode="O" horiz-adv-x="1429" d="M98 713q0 201 217 553q242 25 762 47q78 -164 158 -328q90 -205 90 -344q0 -14 -20 -172l-50 -389l-710 -92q-119 29 -146 39q-76 29 -118 86q-18 25 -52 100q-131 307 -131 500zM522 657q0 -16 21 -122q16 -78 47 -234h231l-33 766q-104 0 -174 12q-33 -131 -67 -286 q-25 -119 -25 -136z" />
+<glyph unicode="P" horiz-adv-x="1363" d="M76 -25v1321q430 4 571 4q217 0 281 -16q27 -6 76 -41q68 -51 71 -53q184 -113 211 -207q14 -57 14 -102q0 -178 -292 -389q-55 -39 -209 -76q-141 -33 -224 -33q-23 0 -36 2q-31 -16 -31 -96q0 -45 6 -134t6 -135q0 -23 -2 -45q-150 8 -264 9q-115 0 -178 -9zM516 655 q190 11 246 11h14q-43 209 -57 354h-203q4 -152 4 -229q0 -78 -4 -136z" />
+<glyph unicode="Q" horiz-adv-x="1449" d="M86 713q0 201 217 553q242 25 762 47q78 -164 158 -328q90 -205 90 -344q0 -12 -19 -164l-45 -354q70 -68 107 -105l-150 -165l-211 196l-465 -59q-119 29 -143 37q-78 29 -117 86q-57 80 -120.5 289.5t-63.5 310.5zM504 657q0 -18 26 -147l43 -215h160q-63 61 -123 119 q20 27 62 78q68 86 100 86q19 0 117 -80l-37 563q-88 0 -254 29q-35 -139 -70 -299q-25 -117 -24 -134z" />
+<glyph unicode="R" horiz-adv-x="1425" d="M88 -25v1321q430 4 571 4q217 0 281 -16q27 -6 76 -41q68 -51 71 -53q184 -113 209 -207q16 -57 17 -102q0 -172 -301 -357q80 -45 159 -90q113 -66 125 -108q25 -78 29 -201q4 -103 8 -205q-174 16 -520 43q0 43 10.5 129t10.5 129q0 88 -19 121q-25 45 -104 45 q-20 0 -60.5 -3t-60.5 -3q-25 0 -39 4q-31 -16 -31 -96q0 -45 6 -134t6 -135q0 -23 -2 -45q-150 8 -264 9q-115 0 -178 -9zM528 655q188 11 245 11h15q-43 209 -57 354h-203q4 -152 4 -229q0 -78 -4 -136z" />
+<glyph unicode="S" horiz-adv-x="1449" d="M72 49v359h463q22 -17 22 -57q0 -28 -9 -73t-11 -63q43 -10 122 -10q152 0 183 14q63 31 63 166q0 100 -217 174q-76 25 -303 74q-80 16 -235 55q0 14 -11 223q-8 180 -12 363q94 16 186 35q142 28 205 28h4q291 0 379 -10q111 -20 332 -57q29 -102 29 -342 q-35 10 -117 10t-260 -10q0 31 -6.5 91t-6.5 91l-124 2q-88 4 -211 8q-12 -74 -33 -221q170 -39 508 -125q152 -43 225 -82q39 -20 84 -198q41 -160 41 -230q0 -211 -371 -303q-92 -20 -141 -20q-8 0 -80 8q-59 8 -176 26z" />
+<glyph unicode="T" horiz-adv-x="1372" d="M63 1024v260q262 16 785 45q270 16 369 17q61 0 65 -7q29 -39 29 -114q0 -16 -8 -74q-6 -33 -6 -55q0 -10 1 -17q-199 -12 -380 -20l-72 -1082q-121 12 -363 37q-33 469 -57 1024z" />
+<glyph unicode="U" horiz-adv-x="1423" d="M102 592q0 10 17 219q12 147 31 438h342q-14 -352 -56 -1056q8 -8 10 -9q43 0 126 12.5t124 12.5q86 211 86 483q0 291 -75 643h542q16 -106 39 -329q19 -178 19 -203q0 -8 -11 -68q-57 -381 -116 -682q-154 -102 -336 -102q-25 0 -215 24q-246 31 -400 58 q-127 408 -127 559z" />
+<glyph unicode="V" horiz-adv-x="1337" d="M80 1356q47 -4 125 -4q68 0 186 2q133 2 187 4q57 -242 198 -901q88 446 152 856q150 -6 211 -6q68 0 121 4v-72q0 -96 -68 -430q-63 -317 -178 -809h-611z" />
+<glyph unicode="W" horiz-adv-x="1912" d="M104 1354q39 -2 101 -2q59 0 160 2q115 2 159 4q47 -240 174 -934q74 426 125 790q12 92 13 95l-11 45q39 -2 101 -2q59 0 159 2q117 2 160 4q49 -242 176 -934q82 479 135 889q123 -6 179 -6q55 0 100 4v-66q0 -70 -29 -256q-53 -342 -184 -989h-518l-105 506 q-45 -244 -98 -506h-518z" />
+<glyph unicode="X" horiz-adv-x="1361" d="M57 1356q45 -2 123 -2h189q133 2 186 2q55 -123 199 -467q88 233 151 444q152 -4 211 -4q70 0 121 2v-35q0 -102 -248 -643l326 -680q-45 2 -125 2q-68 0 -186 -2q-133 -2 -189 -2q-66 150 -197 447q-55 -139 -151 -422q-154 2 -211 2q-70 0 -121 -2v37q0 84 246 620z " />
+<glyph unicode="Y" horiz-adv-x="1351" d="M84 1356q45 -4 123 -4q68 0 188 2q131 2 187 2q55 -184 196 -701q90 348 154 666q152 -4 211 -4q68 0 119 4v-55q0 -119 -258 -674q-37 -80 -76 -168q-6 -70 -17 -207q-14 -80 -43 -252q-119 8 -360 23q-8 72 -8 112q0 29 9 52.5t7 29.5v8q-2 33 -27 234z" />
+<glyph unicode="Z" horiz-adv-x="1275" d="M66 -8v260h12l6 88q217 270 518 549q45 45 131 117l45 28q-61 -2 -223 -4q-139 -2 -221 -2q-139 0 -236 6v15q0 18 -4 53t-4 53q0 51 21 100q2 4 57 11q100 10 341 17t462 7q143 0 211 -4v-260h-6v-57q-121 -121 -353 -389q-106 -121 -155 -174q-88 -94 -166 -162h65 q90 0 219 4q150 2 220 2q106 0 202 -6v-15q0 -18 4.5 -53t4.5 -53q0 -51 -21 -100q-2 -4 -61 -11q-106 -10 -363.5 -17t-488.5 -7q-150 0 -217 4z" />
+<glyph unicode="[" horiz-adv-x="806" d="M82 604v715q47 0 141 2h144q262 0 381 -8q-10 -51 -27 -158q-209 -20 -342 -27l-39 -1206h70q229 0 348 -8q-10 -53 -29 -158q-109 -10 -336 -24q-176 -10 -192 -11h-109q-6 59 -8 332q-2 250 -2 551z" />
+<glyph unicode="\" horiz-adv-x="655" d="M12 1423q68 -6 117 -6q57 0 170 6l61 -233q6 -29 111 -490l201 -899q-68 -10 -199 -37q-82 285 -280 1002q-51 176 -148 532z" />
+<glyph unicode="]" horiz-adv-x="919" d="M115 -86q123 8 417 8q-6 172 -38 1206q-133 6 -342 27q-10 51 -27 158q119 8 381 8h143q94 -2 142 -2v-756q0 -295 -3 -543q0 -100 -8 -299h-108q-16 0 -193 11q-113 6 -336 24q-12 51 -28 158z" />
+<glyph unicode="^" horiz-adv-x="1116" d="M90 856l19 39q57 131 176 393q31 63 75 182h293l359 -639q-35 2 -60 3q-37 0 -108 -3q-80 -2 -109 -2q-76 166 -239 494q-23 -90 -78 -236q-68 -174 -86 -233q-176 4 -160 4q-39 0 -82 -2z" />
+<glyph unicode="_" horiz-adv-x="1013" d="M14 -115q0 70 21 115q6 14 274 14q354 0 627 -14v-260q-127 6 -248 6q-84 0 -250 -6t-250 -6q-86 0 -165 6q2 6 2 14q0 23 -5.5 67t-5.5 64z" />
+<glyph unicode="`" horiz-adv-x="743" d="M63 1839h285l350 -375q-35 2 -59 2q-37 0 -104 -2h-107q-57 74 -178 189q-139 133 -187 186z" />
+<glyph unicode="a" horiz-adv-x="1343" d="M31 4v55q0 70 41 263q31 139 252 991h598l366 -1354q-43 2 -106 2q-68 0 -187 -2q-135 -4 -184 -4q-20 88 -55 209q-217 12 -379 22q-23 -104 -35 -184q-139 6 -203 6q-61 0 -108 -4zM436 434l250 -20q-82 287 -133 526q-37 -188 -117 -506z" />
+<glyph unicode="b" horiz-adv-x="1415" d="M92 -25v1321q424 4 570 4q219 0 284 -14q25 -6 74 -37q66 -41 72 -45q184 -96 208 -176q16 -49 17 -86q0 -139 -250 -307q250 -162 250 -293q0 -37 -14 -84q-25 -76 -211 -170q-49 -35 -146 -78q-66 -12 -337 -12h-81v-23q-147 8 -262 9q-111 0 -174 -9zM526 221h215 q15 125 58 305q6 0 -68 0q4 0 -41 -6q-59 -8 -100 -8q-25 0 -39 4q-14 -8 -23 -29q2 -31 2 -69q0 -66 -4 -197zM526 760q57 -2 109 -8q59 -4 51 -4h57q36 2 56 2q-43 186 -60 317h-213q4 -135 4 -203q0 -59 -4 -104z" />
+<glyph unicode="c" horiz-adv-x="1335" d="M68 713q0 201 217 553q225 25 780 47q14 -29 59 -156q45 -135 78 -211l-397 -69l-49 190q-98 0 -174 12q-35 -141 -68 -301q-23 -106 -22 -121q0 -16 18 -112q16 -80 49 -244l232 -61l30 204l447 -32q-14 -131 -43 -394l-713 -30l-49 12q-158 35 -213 113q-18 25 -49 96 q-133 307 -133 504z" />
+<glyph unicode="d" horiz-adv-x="1345" d="M96 719q0 279 37 600q399 -16 447 -21q254 -12 444 -32q217 -352 217 -553q0 -197 -133 -504q-14 -35 -49 -96q-55 -78 -213 -113l-49 -12l-652 30q-10 90 -28 273q-6 41 -15 121q0 -6 0 28q0 47 -3 140.5t-3 138.5zM504 557q0 -125 14 -317l232 61q16 78 47 234 q20 106 20 122t-24 136q-33 156 -66 286q-72 -12 -174 -12l-33 -340z" />
+<glyph unicode="e" horiz-adv-x="1245" d="M102 1065v233l144 -2q0 10 51 11q35 0 106.5 -6.5t106.5 -6.5q6 0 92 4v-10q82 -6 189 -6q51 0 153.5 3t153.5 3q31 0 51 -2v-301l-557 29l-19 -254q217 18 406 18q135 0 141 -10q20 -39 21 -115q0 -16 -6 -73q-3 -30 -3 -52q0 -11 1 -20q-104 -8 -289 -10 q-207 -4 -289 -9l-14 -235q203 -18 608 -49v-260q-209 10 -625 35l-2 -3q-94 8 -286 23l2 6l-76 8q-20 272 -41 664l-12 252q-6 119 -7 135z" />
+<glyph unicode="f" horiz-adv-x="1216" d="M98 1065v233l144 -2q0 10 51 11q35 0 106.5 -6.5t106.5 -6.5q6 0 92 4v-10q82 -6 188 -6q51 0 153.5 3t154.5 3q31 0 51 -2v-301l-557 29l-19 -254q217 18 406 18q135 0 141 -10q20 -39 21 -115q0 -16 -7 -73q-3 -30 -3 -52q0 -11 1 -20q-104 -8 -288 -10 q-207 -4 -289 -9q-10 -170 -33 -512q-94 8 -287 23l2 6l-75 8q-20 272 -41 664l-13 252q-6 119 -6 135z" />
+<glyph unicode="g" horiz-adv-x="1378" d="M76 713q0 201 217 553q227 25 782 47q12 -29 53 -144q51 -147 82 -223l-395 -69l-49 190q-102 0 -174 12q-35 -137 -68 -295q-24 -107 -24 -126q0 -17 20 -117q16 -80 49 -240l230 -61l20 141q-47 6 -141 16l8 260q94 -8 170 -10v2l62 -6q92 -4 278 -16q35 -5 107 -11 q-23 -199 -70 -598l-711 -30l-41 10q-166 37 -223 116t-119.5 287.5t-62.5 311.5z" />
+<glyph unicode="h" horiz-adv-x="1503" d="M111 1065v233q203 -4 299 -4q76 0 200 4v-124q0 -10 -8 -125l-20 -283q115 -12 344 -33q27 385 39 588q119 -12 360 -37q20 -272 41 -663l12 -252q6 -118 6 -136v-233q-205 6 -301 6q-74 0 -198 -6v125q0 10 6 104l16 238q-115 8 -344 25q-23 -332 -33 -515 q-121 12 -360 37q-20 272 -41 664l-12 252q-6 119 -6 135z" />
+<glyph unicode="i" horiz-adv-x="741" d="M119 1065v233q203 -4 299 -4q78 0 200 4v-124q0 -10 -8 -125l-20 -285q-18 -262 -51 -787q-121 12 -361 37q-18 244 -43 693q-16 330 -16 358z" />
+<glyph unicode="j" horiz-adv-x="1415" d="M133 446l387 134q18 -92 58 -279h290l-32 786q-104 0 -252 -12l-4 225q264 29 684 48q30 -68 30 -262v-13q0 -551 -53 -993l-711 -92q-125 31 -145 39q-78 29 -119 86q-61 86 -133 333z" />
+<glyph unicode="k" horiz-adv-x="1304" d="M72 1065v233q203 -4 301 -4q76 0 198 4v-124q0 -8 -6 -107l-12 -170q96 84 250 258q47 55 147 158l330 -13q-139 -127 -401 -411q-80 -88 -248 -254q195 -211 583 -635l-299 -49q-133 145 -397 440q-16 -258 -24 -414q-121 12 -363 37q-16 233 -41 666l-12 264 q-6 111 -6 121z" />
+<glyph unicode="l" horiz-adv-x="1155" d="M74 1065v233q203 -4 299 -4q76 0 200 4v-124q0 -8 -6 -91l-57 -829q203 -18 610 -49v-260q-209 10 -626 35v-3q-96 8 -287 23v6l-76 8q-18 272 -39 664l-14 252q-4 119 -4 135z" />
+<glyph unicode="m" horiz-adv-x="1757" d="M86 203q0 186 10 563q10 365 10 563v4q53 14 119 15q59 0 171 -10.5t165 -12.5l88 -221q2 -8 21 -74l37 -141l124 -471l209 653q20 68 70 195q6 12 10 12q23 0 60 -2q47 -4 61 -4q72 -2 191 -2h188l12 -234q0 -12 2 -133v-467q0 -258 -4 -448q-119 -10 -358 -31 q-25 221 -82 684q-133 -428 -234 -657q-51 -23 -122 -23q-33 0 -29 0l-135 -20q-98 236 -308 700q0 -215 -4 -645h-20q-18 0 -58 -3t-61 -3q-74 0 -123 22q-10 4 -10 191z" />
+<glyph unicode="n" horiz-adv-x="1507" d="M111 1106v233q203 -4 301 -4q33 0 99.5 2t98.5 2q4 0 27 -39q45 -86 141 -303q109 -242 191 -448q6 84 6 213q0 92 -6 275.5t-6 273.5q0 31 2 51q121 -12 360 -37q20 -268 41 -686l12 -264q6 -124 6 -142v-233q-203 6 -299 6q-78 0 -200 -6q-61 119 -158 344 q-90 211 -186 463q-10 -147 -17 -414q-6 -291 -14 -416q-113 12 -340 37q-20 270 -41 686l-12 265q-6 123 -6 141z" />
+<glyph unicode="o" horiz-adv-x="1429" d="M98 713q0 201 217 553q242 25 762 47q78 -164 158 -328q90 -205 90 -344q0 -14 -20 -172l-50 -389l-710 -92q-119 29 -146 39q-76 29 -118 86q-18 25 -52 100q-131 307 -131 500zM522 657q0 -16 21 -122q16 -78 47 -234h231l-33 766q-104 0 -174 12q-33 -131 -67 -286 q-25 -119 -25 -136z" />
+<glyph unicode="p" horiz-adv-x="1363" d="M78 -25v1321q430 4 569 4q217 0 283 -16q27 -6 74 -41q70 -51 71 -53q184 -113 211 -207q17 -57 17 -102q0 -178 -295 -389q-55 -39 -209 -76q-141 -33 -224 -33q-23 0 -36 2q-29 -16 -29 -96q0 -45 5 -134t5 -135v-45q-150 8 -264 9q-117 0 -178 -9zM518 655 q188 11 244 11h14q-41 209 -55 354h-203q4 -152 4 -229q0 -78 -4 -136z" />
+<glyph unicode="q" horiz-adv-x="1437" d="M86 713q0 201 217 553q242 25 762 47q78 -164 158 -328q90 -205 90 -344q0 -12 -19 -164l-45 -354q70 -68 107 -105l-150 -165l-211 196l-465 -59q-119 29 -143 37q-78 29 -117 86q-57 80 -120.5 289.5t-63.5 310.5zM504 657q0 -18 26 -147l43 -215h160q-63 61 -123 119 q20 27 62 78q68 86 100 86q19 0 117 -80l-37 563q-88 0 -254 29q-35 -139 -70 -299q-25 -117 -24 -134z" />
+<glyph unicode="r" horiz-adv-x="1417" d="M88 -25v1321q430 4 569 4q219 0 283 -16q27 -6 76 -41q68 -51 71 -53q184 -113 209 -207q16 -57 17 -102q0 -172 -301 -357q80 -45 159 -90q113 -66 125 -108q25 -78 29 -201q4 -103 8 -205q-174 16 -520 43q0 43 10.5 129t10.5 129q0 88 -19 121q-25 45 -104 45 q-20 0 -60.5 -3t-60.5 -3q-25 0 -39 4q-31 -16 -31 -96q0 -45 6 -134t6 -135q0 -23 -2 -45q-150 8 -264 9q-115 0 -178 -9zM528 655q188 11 245 11h15q-43 209 -57 354h-203q4 -152 4 -229q0 -78 -4 -136z" />
+<glyph unicode="s" horiz-adv-x="1437" d="M72 49v359h463q22 -17 22 -57q0 -28 -9 -73t-11 -63q43 -10 122 -10q152 0 183 14q63 31 63 166q0 100 -217 174q-76 25 -303 74q-80 16 -235 55q0 14 -11 223q-8 180 -12 363q94 16 186 35q142 28 205 28h4q291 0 379 -10q111 -20 332 -57q29 -102 29 -342 q-35 10 -117 10t-260 -10q0 31 -6.5 91t-6.5 91l-124 2q-88 4 -211 8q-12 -74 -33 -221q170 -39 508 -125q152 -43 225 -82q39 -20 84 -198q41 -160 41 -230q0 -211 -371 -303q-92 -20 -141 -20q-8 0 -80 8q-59 8 -176 26z" />
+<glyph unicode="t" horiz-adv-x="1327" d="M47 1024v260q260 16 782 45q270 16 371 17q61 0 66 -7q26 -38 26 -109v-5q0 -16 -8 -74q-4 -28 -4 -48q0 -14 2 -24q-199 -12 -383 -20l-72 -1082q-121 12 -360 37q-35 469 -59 1024z" />
+<glyph unicode="u" horiz-adv-x="1419" d="M102 592q0 10 17 219q12 147 31 438h342q-14 -352 -56 -1056q8 -8 10 -9q43 0 126 12.5t124 12.5q86 211 86 483q0 291 -75 643h542q16 -106 39 -329q19 -178 19 -203q0 -8 -11 -68q-57 -381 -116 -682q-154 -102 -336 -102q-25 0 -215 24q-246 31 -400 58 q-127 408 -127 559z" />
+<glyph unicode="v" horiz-adv-x="1335" d="M80 1356q47 -4 125 -4q68 0 186 2q133 2 187 4q57 -242 198 -901q88 446 152 856q150 -6 211 -6q68 0 121 4v-72q0 -96 -68 -430q-63 -317 -178 -809h-611z" />
+<glyph unicode="w" horiz-adv-x="1908" d="M104 1354q39 -2 101 -2q59 0 160 2q115 2 159 4q47 -240 174 -934q74 426 125 790q12 92 13 95l-11 45q39 -2 101 -2q59 0 159 2q117 2 160 4q49 -242 176 -934q82 479 135 889q123 -6 179 -6q55 0 100 4v-66q0 -70 -29 -256q-53 -342 -184 -989h-518l-105 506 q-45 -244 -98 -506h-518z" />
+<glyph unicode="x" horiz-adv-x="1374" d="M70 1356q43 -2 123 -2h186q133 2 188 2q55 -123 197 -467q90 233 151 444q154 -4 211 -4q70 0 121 2v-35q0 -102 -246 -643l324 -680q-45 2 -123 2q-68 0 -188 -2q-131 -2 -187 -2q-68 150 -196 447q-55 -139 -154 -422q-152 2 -211 2q-68 0 -121 -2v37q0 84 248 620z " />
+<glyph unicode="y" horiz-adv-x="1353" d="M84 1356q45 -4 123 -4q68 0 188 2q131 2 187 2q55 -184 196 -701q90 348 154 666q152 -4 211 -4q68 0 119 4v-55q0 -119 -258 -674q-37 -80 -76 -168q-6 -70 -17 -207q-14 -80 -43 -252q-119 8 -360 23q-8 72 -8 112q0 29 9 52.5t7 29.5v8q-2 33 -27 234z" />
+<glyph unicode="z" horiz-adv-x="1275" d="M66 -8v260h12l6 88q217 270 518 549q45 45 131 117l45 28q-61 -2 -223 -4q-139 -2 -221 -2q-139 0 -236 6v15q0 18 -4 53t-4 53q0 51 21 100q2 4 57 11q100 10 341 17t462 7q143 0 211 -4v-260h-6v-57q-121 -121 -353 -389q-106 -121 -155 -174q-88 -94 -166 -162h65 q90 0 219 4q150 2 220 2q106 0 202 -6v-15q0 -18 4.5 -53t4.5 -53q0 -51 -21 -100q-2 -4 -61 -11q-106 -10 -363.5 -17t-488.5 -7q-150 0 -217 4z" />
+<glyph unicode="{" horiz-adv-x="806" d="M82 604v715q47 0 141 2h144q262 0 381 -8q-10 -51 -27 -158q-209 -20 -342 -27l-39 -1206h70q229 0 348 -8q-10 -53 -29 -158q-109 -10 -336 -24q-176 -10 -192 -11h-109q-6 59 -8 332q-2 250 -2 551z" />
+<glyph unicode="|" horiz-adv-x="548" d="M139 -152q0 203 15 867q8 381 8 387v6l-17 315q115 -6 172 -6q47 0 115 6l-4 -125q-2 -41 -31 -614l-51 -960q-70 12 -207 36v88z" />
+<glyph unicode="}" horiz-adv-x="919" d="M115 -86q123 8 417 8q-6 172 -38 1206q-133 6 -342 27q-10 51 -27 158q119 8 381 8h143q94 -2 142 -2v-756q0 -295 -3 -543q0 -100 -8 -299h-108q-16 0 -193 11q-113 6 -336 24q-12 51 -28 158z" />
+<glyph unicode="~" horiz-adv-x="1382" d="M94 1208q0 20 53 195q63 -2 250 -6q158 -6 250 -6q45 -113 90 -228q72 -143 168 -143q129 0 148 41q6 14 6 53v8q0 27 -18.5 153t-26.5 146l207 6q23 -88 47 -253q16 -115 16 -127q0 -31 -24 -84q-80 -168 -252 -168q-55 0 -193 18q-154 23 -172 43q-51 55 -98 174 q-74 178 -78 187q-63 -4 -188 -17q8 -111 16 -227q2 -43 12 -129q-53 2 -155 14q-20 53 -50 164q-8 45 -8 186z" />
+<glyph unicode="&#xa1;" horiz-adv-x="694" d="M104 -186q0 6 7 88l71 778q121 -6 363 -23q23 -188 53 -686q6 -86 6 -94v-137q-205 2 -301 2q-76 0 -199 -2v74zM154 758q12 100 28 303q121 -12 363 -37q10 -80 24 -240q-139 -10 -415 -26z" />
+<glyph unicode="&#xa2;" horiz-adv-x="1337" d="M68 713q0 201 217 553q135 14 315 24l-6 215q68 -6 100 -6q29 0 68 6q-2 -125 -4 -205q82 4 307 13q14 -29 51 -137q53 -154 86 -230l-397 -69l-49 190h-4l-25 -809l61 -18l33 204l447 -32q-14 -131 -43 -394l-506 -22l-6 -191q-41 12 -121 37v150l-80 -4l-45 10 q-164 39 -219 115q-57 84 -118.5 289.5t-61.5 310.5zM489 657q0 -16 21 -116q16 -80 49 -240l35 -8l8 784l-20 2q-35 -137 -68 -295q-25 -111 -25 -127z" />
+<glyph unicode="&#xa3;" horiz-adv-x="1314" d="M39 668q0 57 20 94q2 2 15 2q-12 0 84 -2v131q0 106 57 223q23 49 117 203q178 18 819 47q41 -120 131 -356l-383 -68l-51 191q-90 0 -168 14l-62 -242q-16 -53 -32 -153l8 6q-10 -10 -8 -23q123 -10 370 -24v-207l-393 16q-10 -113 -20 -278q205 -18 618 -49v-246 q-586 29 -909 53v6l-76 8q-20 258 -20 529l-109 6l2 6q0 18 -5 56t-5 57z" />
+<glyph unicode="&#xa5;" horiz-adv-x="1366" d="M88 1356q45 -4 125 -4q68 0 186 2q133 2 187 2q55 -184 198 -701q88 348 152 666q154 -4 211 -4q70 0 121 4v-55q0 -119 -260 -674q-37 -80 -76 -168l-6 -82q74 -6 217 -16v-260l-246 12q-16 -68 -23 -113q-121 8 -362 23q-8 70 -8 112q-131 8 -275 19q2 8 2 16 q0 23 -4 66t-4 65q0 82 19 115q4 4 49 4q61 0 209 -10l-6 49z" />
+<glyph unicode="&#xa6;" horiz-adv-x="536" d="M135 -154q0 154 8 650l240 -27q-20 -422 -41 -745q-70 12 -207 36v86zM139 1423q117 -6 172 -6q45 0 115 6q-6 -207 -29 -678l-250 -49q10 385 9 406v6z" />
+<glyph unicode="&#xa7;" horiz-adv-x="1372" d="M94 741v23h6q4 172 17 514q96 14 192 29q141 23 185 22q270 0 401 -16q109 -20 330 -60q12 -63 12 -168q0 -14 -10 -151q-41 12 -164 12q-74 0 -211 -4q-2 57 0 168q0 2 -125 6q-88 4 -211 12q-16 -70 -47 -204q10 -4 367 -90q238 -57 352 -117q33 -18 61 -248 q23 -186 23 -283v-22h-6q-4 -172 -17 -514q-96 -14 -190 -31q-143 -20 -187 -20q-268 0 -401 16q-109 20 -328 59q-14 63 -14 168q0 14 10 150q41 -10 164 -10q76 0 213 4q0 -57 -2 -170q2 0 125 -6q88 -2 213 -11q14 68 47 205q-12 4 -369 90q-238 57 -350 117 q-35 18 -63 248q-23 186 -23 282zM477 647q-4 -285 412 -379l2 11q2 287 -414 380v-12z" />
+<glyph unicode="&#xa8;" horiz-adv-x="1239" d="M-18 1749q138 11 417 27q-12 -100 -30 -303q-121 12 -361 36q-10 80 -26 240zM657 1749q139 11 418 27q-12 -100 -31 -303q-121 12 -360 36q-10 80 -27 240z" />
+<glyph unicode="&#xa9;" horiz-adv-x="1413" d="M84 713q0 201 217 553q240 27 762 49q78 -164 158 -328q90 -205 90 -346q0 -4 -54 -197q-43 -156 -55 -204q-29 -117 -41 -207l-633 -43q2 0 -28 6l-33 8q-143 31 -201 111q-14 16 -39 73q-53 115 -94 258q-49 168 -49 267zM172 612q0 -27 102 -252q63 -135 127 -272h693 q76 145 75 512q0 391 -114 617q-342 0 -578 18q-63 -113 -168 -320q-137 -268 -137 -303zM311 672q0 127 140 352q145 16 499 31q29 -78 88 -234l-254 -45l-30 121q-63 0 -113 8q-23 -90 -43 -192q-14 -68 -14 -78q0 -8 43 -227l147 -39l21 131l286 -21q-10 -86 -28 -254 l-455 -18l-33 8q-100 23 -137 73t-77 184t-40 200z" />
+<glyph unicode="&#xaa;" horiz-adv-x="1052" d="M88 416v37q0 47 29 180q18 96 170 680h411l250 -928q-29 2 -71 2q-47 0 -127 -2q-92 -2 -127 -2q-14 59 -37 141q-150 8 -260 17q-16 -72 -25 -127q-96 4 -139 4q-41 0 -74 -2zM365 711q70 -7 172 -15q-55 197 -91 361q-27 -129 -81 -346z" />
+<glyph unicode="&#xab;" horiz-adv-x="1445" d="M84 438v293l661 436q-4 -43 -4 -75q0 -37 2 -105q2 -73 2 -106q-117 -68 -352 -201q-57 -33 -176 -88q94 -43 260 -137q158 -92 242 -148q-2 -154 -2 -151q0 -43 2 -95l-41 21q-41 23 -162 96q-88 55 -266 166q-59 39 -166 94zM678 438v293l661 436q-4 -43 -4 -75 q0 -37 2 -105q2 -73 2 -106q-117 -68 -352 -201q-57 -33 -176 -88q94 -43 260 -137q158 -92 242 -148q-2 -154 -2 -151q0 -43 2 -95l-41 21q-41 23 -162 96q-88 55 -266 166q-59 39 -166 94z" />
+<glyph unicode="&#xac;" horiz-adv-x="1433" d="M100 479v129h1203v-575h-144v446h-1059z" />
+<glyph unicode="&#xad;" horiz-adv-x="1159" d="M113 643q0 80 20 115q2 4 47 4q74 0 275 -14q193 -18 579 -46v-260q-305 14 -913 54v16q0 23 -4 66t-4 65z" />
+<glyph unicode="&#xae;" horiz-adv-x="1413" d="M84 713q0 201 217 553q240 27 762 49q78 -164 158 -328q90 -205 90 -346q0 -4 -54 -197q-43 -156 -55 -204q-29 -117 -41 -207l-633 -43q2 0 -28 6l-33 8q-143 31 -201 111q-14 16 -39 73q-53 115 -94 258q-49 168 -49 267zM172 612q0 -27 102 -252q63 -135 127 -272h693 q76 145 75 512q0 391 -114 617q-342 0 -578 18q-63 -113 -168 -320q-137 -268 -137 -303zM383 240v770q252 2 332 2q127 0 164 -11q31 -20 86 -55q131 -80 131 -178q0 -100 -176 -209q47 -27 92 -51q68 -39 73 -64q14 -45 17 -116q4 -62 6 -121q-102 10 -303 26q0 25 6 75 t6 75q0 51 -12 70q-14 29 -60 28q-12 0 -35.5 -2t-35.5 -2t-23 2q-16 -10 -16 -57q0 -25 3 -76t3 -80v-26q-88 4 -156 4q-66 0 -102 -4zM639 635q127 8 152 8q-25 121 -33 205h-119q2 -86 2 -117v-35q0 -29 -2 -61z" />
+<glyph unicode="&#xaf;" horiz-adv-x="913" d="M84 1585q0 57 20 94q4 4 39 4q57 0 238 -16q154 -18 461 -43v-199q-242 12 -389 23q-119 10 -361 31v14q0 16 -4 46t-4 46z" />
+<glyph unicode="&#xb0;" horiz-adv-x="835" d="M74 1092q0 106 112 290q127 12 400 25q43 -86 84 -172q47 -106 47 -180q0 -8 -10 -90l-27 -205l-373 -47q-61 14 -76 18q-39 16 -63 47q-29 39 -61.5 149.5t-32.5 164.5zM295 1063q0 -6 37 -186h121l-19 401q-53 0 -90 6q-49 -193 -49 -221z" />
+<glyph unicode="&#xb1;" horiz-adv-x="1089" d="M72 879q0 51 14 88q4 12 236 12h90l-2 131q0 98 2 205h6q29 -2 85 8t83 10q51 0 88 -14q14 -4 12 -236v-108q233 -4 305 -2l17 -260l-326 -6q-2 -221 -2 -291l-260 -19l-6 305h-119q-96 0 -205 3v4q2 29 -8 85t-10 85zM80 178q0 53 12 88q6 12 236 13q86 0 336 -5 q209 -2 333 0l19 -262q-508 -8 -715 -8h-203v6q0 29 -9 85.5t-9 82.5z" />
+<glyph unicode="&#xb2;" horiz-adv-x="862" d="M106 618q0 27 5 105q2 61 2 102q111 76 219 150q162 115 162 166q0 47 -9.5 62.5t-50.5 15.5q-51 0 -65 -2q6 -41 6 -54q0 -33 -19 -53h-235v223q31 6 227 41q131 20 139 21q29 0 78 -15q172 -53 172 -176q0 -37 -20 -108q-23 -80 -43 -99q-55 -55 -289 -227q31 2 139 4 q0 10 2 49q2 29 2 47q84 -4 121 -4q51 0 86 13v-101q0 -57 -14 -123q-147 -27 -315 -26q-45 0 -135.5 -5.5t-135.5 -5.5h-29z" />
+<glyph unicode="&#xb3;" horiz-adv-x="837" d="M94 1188q20 31 48 95.5t42 84.5q135 -2 406 -14q117 -123 117 -193q0 -84 -89 -147q41 -25 76 -79t35 -99q0 -70 -117 -193q-106 -6 -428 -16q-12 20 -34.5 72.5t-53.5 97.5l238 41l26 -64q33 0 62 -2q16 31 59 74q-2 14 -24 80l-181 10q-10 41 -28 127l86 -2q16 0 51 4 t49 4q10 25 27 74l-39 82q-29 -2 -62 -2l-24 -62z" />
+<glyph unicode="&#xb4;" horiz-adv-x="743" d="M66 1464l348 375h284q-47 -53 -184 -186q-123 -115 -180 -189q-287 0 -268 0z" />
+<glyph unicode="&#xb5;" horiz-adv-x="1423" d="M100 653h6q16 199 44 596h342q-14 -352 -56 -1056q8 -8 10 -9q43 0 126 12.5t124 12.5q86 211 86 483q0 291 -75 643h542q14 -104 39 -325q19 -182 19 -207q0 -8 -11 -78q-59 -383 -118 -672q-152 -102 -334 -102q-14 0 -131 14q-150 16 -291 37q-4 -66 -16 -195 q-4 -18 -15 -53q-4 -27 -10 -100q-92 10 -279 37v96q0 172 9.5 365.5t9.5 179.5q0 49 -6 129q-10 104 -13 131q0 6 2 18z" />
+<glyph unicode="&#xb6;" horiz-adv-x="1574" d="M100 881q0 45 13 102q23 94 182 207q43 41 125 94q57 16 244 16q29 0 278 -2v2q57 4 111 5q-14 0 391 -5v-1323q-53 8 -109 9q-55 0 -184 -9q-2 25 -2 54q0 80 7 236.5t7 234.5q0 68 -10 155q-4 31 -4 138q0 78 4 227h-86v-1047q-53 8 -109 9q-55 0 -184 -9q-2 23 -2 45 q0 45 5 134.5t5 134.5q0 80 -24 96q-12 -2 -33 -2q-72 0 -195 33q-131 37 -178 76q-252 211 -252 389zM553 666h16q29 2 207 -11q-4 57 -4 136q0 77 4 229h-176q-12 -145 -47 -354z" />
+<glyph unicode="&#xb7;" horiz-adv-x="673" d="M131 807q137 11 416 27q-20 -297 -29 -467q-121 12 -362 36q-10 154 -25 404z" />
+<glyph unicode="&#xb8;" horiz-adv-x="292" d="M14 -242q55 -16 86 -16q78 0 78 41q0 45 -149 43v256h123v-145q61 -12 106 -50q55 -45 55 -100q0 -82 -84 -125q-66 -33 -157 -33q-23 0 -58 4v125z" />
+<glyph unicode="&#xb9;" horiz-adv-x="770" d="M127 1194q0 18 100 86q63 41 125 80q115 -2 168 -2q45 0 123 4v-80q0 -4 -14 -211q-10 -150 -31 -448q-72 6 -219 22q-14 209 -31 531q-49 -45 -155 -121q-4 8 -37 73q-29 55 -29 66z" />
+<glyph unicode="&#xba;" horiz-adv-x="1042" d="M92 901q0 137 150 379q164 18 520 33q55 -113 108 -226q62 -139 62 -235q0 -10 -12 -119l-35 -266l-488 -61q-82 18 -98 24q-53 20 -82 59q-39 53 -82 197.5t-43 214.5zM383 862q0 -8 47 -244h158l-23 527q-72 0 -121 8q-23 -90 -45 -197q-16 -82 -16 -94z" />
+<glyph unicode="&#xbb;" horiz-adv-x="1429" d="M92 881q0 33 2 106q2 68 2 105q0 33 -4 75l662 -436v-293q-25 -8 -166 -94q-88 -55 -266 -166q-53 -33 -162 -96l-41 -21q2 51 2 95q0 -2 -4 151q86 55 243 148q166 94 261 137q-59 23 -176 90.5t-353 198.5zM686 881q0 33 2 106q2 68 2 105q0 33 -4 75l662 -436v-293 q-25 -8 -166 -94q-88 -55 -267 -166q-53 -33 -161 -96l-41 -21q2 51 2 95q0 -2 -4 151q86 55 243 148q166 94 260 137q-59 23 -175.5 90.5t-352.5 198.5z" />
+<glyph unicode="&#xbc;" horiz-adv-x="1599" d="M80 1153q0 18 102 86q61 41 125 80q115 -2 168 -2q43 0 123 4v-80q0 -4 -14 -211q-12 -150 -31 -448q-74 6 -219 22q-16 209 -31 531q-49 -45 -156 -121q-4 8 -38 73q-29 55 -29 66zM246 2q158 264 407 651q209 322 418 645q109 -6 150 -6q28 0 94 6l-78 -124 q-14 -23 -264 -394l-545 -815q-61 12 -182 37zM872 141v156h11v29q61 57 381 401l2 18q68 -4 207 -12q2 -25 4 -160v-292l43 -2q-4 -27 -4 -29q0 -4 2 -14.5t2 -16.5q0 -53 -41 -63v-156q-139 2 -238 0v61q0 8 2 80q-113 -4 -217 -4q-96 0 -154 4zM1092 281q76 0 161 2 q5 100 9 215q-55 -74 -170 -217z" />
+<glyph unicode="&#xbd;" horiz-adv-x="1687" d="M59 1153q0 18 101 86q63 41 125 80q115 -2 168 -2q45 0 122 4v-80q0 -4 -14 -211q-10 -150 -31 -448q-72 6 -219 22q-14 209 -30 531q-49 -45 -156 -121q-4 8 -37 73q-29 55 -29 66zM223 2q158 264 408 651q209 322 418 645q111 -6 151 -6q26 0 94 6l-80 -124 q-14 -23 -262 -394l-544 -815q-61 12 -185 37zM969 0q0 27 4 102q2 63 2 105q111 76 219 149q162 115 162 166q0 47 -6 60q-12 18 -54 18q-51 0 -65 -2q8 -43 8 -53q0 -33 -20 -53h-236v223q31 6 229 39q129 23 138 22q29 0 77 -14q172 -53 172 -176q0 -37 -20 -109 q-20 -80 -43 -98q-55 -55 -289 -227q31 2 139 2q0 12 3 49q2 31 2 49q84 -4 120 -4q51 0 86 10v-98q0 -57 -14 -123q-147 -27 -315 -27q-45 0 -134.5 -6t-134.5 -6q-16 0 -30 2z" />
+<glyph unicode="&#xbe;" horiz-adv-x="1599" d="M72 1167q20 31 47.5 95.5t42.5 85.5q135 -2 405 -15q117 -123 117 -192q0 -84 -88 -148q41 -25 76 -79t35 -99q0 -70 -117 -192q-106 -6 -428 -17q-12 20 -35 72.5t-53 97.5l237 41l27 -63q33 0 61 -2q16 31 60 73q-2 14 -25 80l-180 10q-10 41 -29 127l86 -2 q16 0 51 4.5t50 4.5q10 25 26 73l-39 82q-29 -2 -61 -2l-27 -61zM262 2q158 264 408 651q209 322 417 645q111 -6 152 -6q26 0 94 6l-80 -124q-12 -23 -262 -394l-545 -815q-61 12 -184 37zM891 141v156h8l2 29q61 57 381 401v18q70 -4 209 -12q2 -25 2 -160v-292l43 -2 q-2 -27 -2 -29q0 -4 2 -14.5t2 -16.5q0 -53 -41 -63v-156q-141 2 -237 0v61q0 8 2 80q-115 -4 -218 -4q-98 0 -153 4zM1110 281q74 0 162 2q4 100 6 215q-55 -74 -168 -217z" />
+<glyph unicode="&#xbf;" horiz-adv-x="1402" d="M68 -4q0 70 41 229q45 178 86 199q96 51 237 96l250 70l-12 76l379 20q-12 -319 -13 -307q-57 -16 -196 -49q-152 -35 -201 -60q-115 -55 -115 -153q0 -135 64 -166q31 -16 182 -17q82 0 123 11q0 20 -9.5 65t-9.5 70q0 41 21 59h465v-358l-698 -100q-74 -10 -82 -11 q-49 0 -140 23q-373 92 -372 303zM649 758q10 100 29 303q121 -12 360 -37q13 -80 27 -240q-139 -10 -416 -26z" />
+<glyph unicode="&#xc0;" horiz-adv-x="1386" d="M74 4v55q0 70 40 263q29 139 250 991h600l365 -1354q-41 2 -107 2q-68 0 -184 -2q-135 -4 -186 -4q-20 88 -53 209q-217 12 -381 22q-20 -104 -35 -184q-139 6 -203 6q-59 0 -106 -4zM380 1839h285l350 -375q-35 2 -59 2q-37 0 -104 -2h-107q-57 74 -178 189 q-139 133 -187 186zM477 434l250 -20q-80 287 -133 526q-37 -188 -117 -506z" />
+<glyph unicode="&#xc1;" horiz-adv-x="1421" d="M74 4v55q0 70 40 263q29 139 250 991h600l365 -1354q-41 2 -107 2q-68 0 -184 -2q-135 -4 -186 -4q-20 88 -53 209q-217 12 -381 22q-20 -104 -35 -184q-139 6 -203 6q-59 0 -106 -4zM477 434l250 -20q-80 287 -133 526q-37 -188 -117 -506zM523 1464l348 375h284 q-47 -53 -184 -186q-123 -115 -180 -189q-287 0 -268 0z" />
+<glyph unicode="&#xc2;" horiz-adv-x="1404" d="M74 4v55q0 70 40 263q29 139 250 991h600l365 -1354q-41 2 -107 2q-68 0 -184 -2q-135 -4 -186 -4q-20 88 -53 209q-217 12 -381 22q-20 -104 -35 -184q-139 6 -203 6q-59 0 -106 -4zM332 1470q41 92 123 275q37 72 86 201h233l281 -494q-45 4 -66 4q-29 0 -84 -2h-82 q-55 117 -169 346q-41 -109 -119 -327q-127 2 -123 2q-37 0 -80 -5zM477 434l250 -20q-80 287 -133 526q-37 -188 -117 -506z" />
+<glyph unicode="&#xc3;" horiz-adv-x="1402" d="M74 4v55q0 70 40 263q29 139 250 991h600l365 -1354q-41 2 -107 2q-68 0 -184 -2q-135 -4 -186 -4q-20 88 -53 209q-217 12 -381 22q-20 -104 -35 -184q-139 6 -203 6q-59 0 -106 -4zM246 1769q0 16 43 156q53 0 201 -4q129 -4 200 -4q37 -92 74 -182q57 -117 135 -117 q70 0 90 8q33 14 33 68v8q0 20 -14.5 121.5t-20.5 118.5l166 4q18 -74 39 -213q12 -85 12 -93q0 -23 -16 -59q-63 -145 -207 -145q-45 0 -153 16q-125 18 -140 35q-41 43 -80 139q-59 143 -61 150q-51 -4 -152 -13q6 -94 15 -192q2 -31 8 -94q-41 2 -125 10q-16 45 -39 133 q-8 35 -8 149zM477 434l250 -20q-80 287 -133 526q-37 -188 -117 -506z" />
+<glyph unicode="&#xc4;" horiz-adv-x="1376" d="M56 4v55q0 70 40 263q29 139 250 991h600l365 -1354q-41 2 -107 2q-68 0 -184 -2q-135 -4 -186 -4q-20 88 -53 209q-217 12 -381 22q-20 -104 -35 -184q-139 6 -203 6q-59 0 -106 -4zM140 1749q138 11 417 27q-12 -100 -30 -303q-121 12 -361 36q-10 80 -26 240zM459 434 l250 -20q-80 287 -133 526q-37 -188 -117 -506zM815 1749q139 11 418 27q-12 -100 -31 -303q-121 12 -360 36q-10 80 -27 240z" />
+<glyph unicode="&#xc5;" horiz-adv-x="1406" d="M74 4v55q0 70 40 263q29 139 250 991h600l365 -1354q-41 2 -107 2q-68 0 -184 -2q-135 -4 -186 -4q-20 88 -53 209q-217 12 -381 22q-20 -104 -35 -184q-139 6 -203 6q-59 0 -106 -4zM392 1724q0 86 94 238q102 10 325 20q33 -70 68 -141q39 -86 39 -147q0 -4 -10 -74 l-21 -166l-303 -39q-51 12 -63 17q-33 12 -52 36q-23 33 -50 123t-27 133zM477 434l250 -20q-80 287 -133 526q-37 -188 -117 -506zM574 1702q0 -6 29 -154h98l-14 330q-43 0 -74 4q-39 -158 -39 -180z" />
+<glyph unicode="&#xc6;" horiz-adv-x="1914" d="M84 4l16 55q18 70 111 263q68 137 520 991h518q117 0 103 0q158 -4 469 -19v-309l-557 29l-17 -215v-37q217 16 404 16q135 0 141 -10q20 -37 20 -115q0 -16 -6 -73q-4 -45 -2 -72q-102 -8 -278 -10q-205 -2 -279 -6v-242q190 -16 574 -45v-260l-576 30v-16q-39 2 -90 2 q-55 0 -151 -2q-109 -4 -154 -4q4 86 4 203v6q-215 12 -375 22q-49 -104 -84 -184q-139 6 -202 6q-59 0 -109 -4zM606 434q98 -8 244 -20v139q0 188 10 387q-88 -188 -254 -506z" />
+<glyph unicode="&#xc7;" horiz-adv-x="1302" d="M61 713q0 201 218 553q225 25 780 47q14 -29 55 -148q49 -143 82 -219l-397 -69l-49 190q-102 0 -175 12q-33 -129 -65 -282q-27 -123 -27 -140q0 -16 21 -114q16 -80 49 -242l231 -61l31 204l447 -32q-14 -131 -43 -394l-504 -22v-80q61 -12 106 -49q55 -45 56 -100 q0 -82 -84 -125q-68 -33 -160 -33q-20 0 -55 4v125q55 -16 84 -17q80 0 79 41q0 45 -149 43v187l-86 -4l-45 10q-164 39 -217 115q-59 84 -121 289.5t-62 310.5z" />
+<glyph unicode="&#xc8;" horiz-adv-x="1216" d="M73 1065v233l144 -2q0 10 51 11q35 0 106.5 -6.5t106.5 -6.5q6 0 92 4v-10q82 -6 189 -6q51 0 153.5 3t153.5 3q31 0 51 -2v-301l-557 29l-19 -254q217 18 406 18q135 0 141 -10q20 -39 21 -115q0 -16 -6 -73q-4 -45 -2 -72q-104 -8 -289 -10q-207 -4 -289 -9l-14 -235 q203 -18 608 -49v-260q-209 10 -625 35l-2 -3q-94 8 -286 23l2 6l-76 8q-20 272 -41 664l-12 252q-6 119 -7 135zM348 1839h285l350 -375q-35 2 -59 2q-37 0 -104 -2h-107q-57 74 -178 189q-139 133 -187 186z" />
+<glyph unicode="&#xc9;" horiz-adv-x="1206" d="M71 1065v233l144 -2q0 10 51 11q35 0 106.5 -6.5t106.5 -6.5q6 0 92 4v-10q82 -6 189 -6q51 0 153.5 3t153.5 3q31 0 51 -2v-301l-557 29l-19 -254q217 18 406 18q135 0 141 -10q20 -39 21 -115q0 -16 -6 -73q-4 -45 -2 -72q-104 -8 -289 -10q-207 -4 -289 -9l-14 -235 q203 -18 608 -49v-260q-209 10 -625 35l-2 -3q-94 8 -286 23l2 6l-76 8q-20 272 -41 664l-12 252q-6 119 -7 135zM488 1464l348 375h284q-47 -53 -184 -186q-123 -115 -180 -189q-287 0 -268 0z" />
+<glyph unicode="&#xca;" horiz-adv-x="1187" d="M75 1065v233l144 -2q0 10 51 11q35 0 106.5 -6.5t106.5 -6.5q6 0 92 4v-10q82 -6 189 -6q51 0 153.5 3t153.5 3q31 0 51 -2v-301l-557 29l-19 -254q217 18 406 18q135 0 141 -10q20 -39 21 -115q0 -16 -6 -73q-4 -45 -2 -72q-104 -8 -289 -10q-207 -4 -289 -9l-14 -235 q203 -18 608 -49v-260q-209 10 -625 35l-2 -3q-94 8 -286 23l2 6l-76 8q-20 272 -41 664l-12 252q-6 119 -7 135zM301 1470q41 92 123 275q37 72 86 201h233l281 -494q-45 4 -66 4q-29 0 -84 -2h-82q-55 117 -169 346q-41 -109 -119 -327q-127 2 -123 2q-37 0 -80 -5z" />
+<glyph unicode="&#xcb;" horiz-adv-x="1236" d="M57 1065v233l144 -2q0 10 51 11q35 0 106.5 -6.5t106.5 -6.5q6 0 92 4v-10q82 -6 189 -6q51 0 153.5 3t153.5 3q31 0 51 -2v-301l-557 29l-19 -254q217 18 406 18q135 0 141 -10q20 -39 21 -115q0 -16 -6 -73q-4 -45 -2 -72q-104 -8 -289 -10q-207 -4 -289 -9l-14 -235 q203 -18 608 -49v-260q-209 10 -625 35l-2 -3q-94 8 -286 23l2 6l-76 8q-20 272 -41 664l-12 252q-6 119 -7 135zM109 1749q138 11 417 27q-12 -100 -30 -303q-121 12 -361 36q-10 80 -26 240zM784 1749q139 11 418 27q-12 -100 -31 -303q-121 12 -360 36q-10 80 -27 240z " />
+<glyph unicode="&#xcc;" horiz-adv-x="733" d="M146 1065v233q203 -4 299 -4q78 0 200 4v-124q0 -10 -8 -125l-20 -285q-18 -262 -51 -787q-121 12 -361 37q-18 244 -43 693q-16 330 -16 358zM202 1839h285l350 -375q-35 2 -59 2q-37 0 -104 -2h-107q-57 74 -178 189q-139 133 -187 186z" />
+<glyph unicode="&#xcd;" horiz-adv-x="653" d="M92 1065v233q203 -4 299 -4q78 0 200 4v-124q0 -10 -8 -125l-20 -285q-18 -262 -51 -787q-121 12 -361 37q-18 244 -43 693q-16 330 -16 358zM291 1464l348 375h284q-47 -53 -184 -186q-123 -115 -180 -189q-287 0 -268 0z" />
+<glyph unicode="&#xce;" horiz-adv-x="722" d="M64 1470q41 92 123 275q37 72 86 201h233l281 -494q-45 4 -66 4q-29 0 -84 -2h-82q-55 117 -169 346q-41 -109 -119 -327q-127 2 -123 2q-37 0 -80 -5zM117 1065v233q203 -4 299 -4q78 0 200 4v-124q0 -10 -8 -125l-20 -285q-18 -262 -51 -787q-121 12 -361 37 q-18 244 -43 693q-16 330 -16 358z" />
+<glyph unicode="&#xcf;" horiz-adv-x="718" d="M-110 1749q138 11 417 27q-12 -100 -30 -303q-121 12 -361 36q-10 80 -26 240zM117 1065v233q203 -4 299 -4q78 0 200 4v-124q0 -10 -8 -125l-20 -285q-18 -262 -51 -787q-121 12 -361 37q-18 244 -43 693q-16 330 -16 358zM565 1749q139 11 418 27q-12 -100 -31 -303 q-121 12 -360 36q-10 80 -27 240z" />
+<glyph unicode="&#xd0;" horiz-adv-x="1511" d="M76 676q0 78 18 112q4 6 41 7q41 0 127 -7q4 246 37 531q399 -16 444 -21q256 -12 447 -32q217 -352 217 -553q0 -104 -61.5 -310t-118 -287t-223.5 -118q-43 -10 -41 -10l-652 30q-10 86 -28 263q-6 43 -17 131q2 -8 2 28q0 27 -2 74l-184 14q2 6 2 15q0 23 -4 66.5 t-4 66.5zM672 485q0 -66 12 -245l231 61l48 240q20 100 20 116t-25 134q-33 156 -67 288q-70 -12 -174 -12l-29 -317q123 -12 184 -17v-260z" />
+<glyph unicode="&#xd1;" horiz-adv-x="1472" d="M113 1106v233q203 -4 301 -4q33 0 99.5 2t98.5 2q6 0 27 -39q45 -86 141 -303q109 -242 191 -448q6 84 6 213q0 92 -6 275.5t-6 273.5q0 31 2 51q121 -12 360 -37q20 -268 41 -686l12 -264q7 -124 7 -142v-233q-203 6 -299 6q-78 0 -201 -6q-61 119 -158 344 q-88 211 -186 463q-10 -147 -17 -414q-6 -291 -12 -416q-115 12 -342 37q-18 270 -39 686l-14 265q-6 123 -6 141zM234 1769q0 16 43 156q53 0 201 -4q129 -4 200 -4q37 -92 74 -182q57 -117 135 -117q70 0 90 8q33 14 33 68v8q0 20 -14.5 121.5t-20.5 118.5l166 4 q18 -74 39 -213q12 -85 12 -93q0 -23 -16 -59q-63 -145 -207 -145q-45 0 -153 16q-125 18 -140 35q-41 43 -80 139q-59 143 -61 150q-51 -4 -152 -13q6 -94 15 -192q2 -31 8 -94q-41 2 -125 10q-16 45 -39 133q-8 35 -8 149z" />
+<glyph unicode="&#xd2;" horiz-adv-x="1380" d="M92 713q0 201 217 553q242 25 762 47q78 -164 158 -328q90 -205 90 -344q0 -14 -20 -172l-50 -389l-710 -92q-119 29 -146 39q-76 29 -118 86q-18 25 -52 100q-131 307 -131 500zM362 1839h285l350 -375q-35 2 -59 2q-37 0 -104 -2h-107q-57 74 -178 189 q-139 133 -187 186zM516 657q0 -16 21 -122q16 -78 47 -234h231l-33 766q-104 0 -174 12q-33 -131 -67 -286q-25 -119 -25 -136z" />
+<glyph unicode="&#xd3;" d="M92 713q0 201 217 553q242 25 762 47q78 -164 158 -328q90 -205 90 -344q0 -14 -20 -172l-50 -389l-710 -92q-119 29 -146 39q-76 29 -118 86q-18 25 -52 100q-131 307 -131 500zM504 1464l348 375h284q-47 -53 -184 -186q-123 -115 -180 -189q-287 0 -268 0zM516 657 q0 -16 21 -122q16 -78 47 -234h231l-33 766q-104 0 -174 12q-33 -131 -67 -286q-25 -119 -25 -136z" />
+<glyph unicode="&#xd4;" horiz-adv-x="1417" d="M92 713q0 201 217 553q242 25 762 47q78 -164 158 -328q90 -205 90 -344q0 -14 -20 -172l-50 -389l-710 -92q-119 29 -146 39q-76 29 -118 86q-18 25 -52 100q-131 307 -131 500zM313 1470q41 92 123 275q37 72 86 201h233l281 -494q-45 4 -66 4q-29 0 -84 -2h-82 q-55 117 -169 346q-41 -109 -119 -327q-127 2 -123 2q-37 0 -80 -5zM516 657q0 -16 21 -122q16 -78 47 -234h231l-33 766q-104 0 -174 12q-33 -131 -67 -286q-25 -119 -25 -136z" />
+<glyph unicode="&#xd5;" horiz-adv-x="1386" d="M98 713q0 201 217 553q242 25 762 47q78 -164 158 -328q90 -205 90 -344q0 -14 -20 -172l-50 -389l-710 -92q-119 29 -146 39q-76 29 -118 86q-18 25 -52 100q-131 307 -131 500zM234 1769q0 16 43 156q53 0 201 -4q129 -4 200 -4q37 -92 74 -182q57 -117 135 -117 q70 0 90 8q33 14 33 68v8q0 20 -14.5 121.5t-20.5 118.5l166 4q18 -74 39 -213q12 -85 12 -93q0 -23 -16 -59q-63 -145 -207 -145q-45 0 -153 16q-125 18 -140 35q-41 43 -80 139q-59 143 -61 150q-51 -4 -152 -13q6 -94 15 -192q2 -31 8 -94q-41 2 -125 10q-16 45 -39 133 q-8 35 -8 149zM522 657q0 -16 21 -122q16 -78 47 -234h231l-33 766q-104 0 -174 12q-33 -131 -67 -286q-25 -119 -25 -136z" />
+<glyph unicode="&#xd6;" horiz-adv-x="1386" d="M82 713q0 201 217 553q242 25 762 47q78 -164 158 -328q90 -205 90 -344q0 -14 -20 -172l-50 -389l-710 -92q-119 29 -146 39q-76 29 -118 86q-18 25 -52 100q-131 307 -131 500zM129 1749q138 11 417 27q-12 -100 -30 -303q-121 12 -361 36q-10 80 -26 240zM506 657 q0 -16 21 -122q16 -78 47 -234h231l-33 766q-104 0 -174 12q-33 -131 -67 -286q-25 -119 -25 -136zM804 1749q139 11 418 27q-12 -100 -31 -303q-121 12 -360 36q-10 80 -27 240z" />
+<glyph unicode="&#xd7;" horiz-adv-x="1087" d="M102 293l314 311l-314 311l127 125l310 -307l313 311l125 -124l-309 -318l313 -311l-127 -127l-313 313l-312 -311z" />
+<glyph unicode="&#xd8;" horiz-adv-x="1421" d="M102 713q0 199 215 549q199 20 498 36l70 187q70 -4 106 -4q29 0 58 2q-39 -102 -68 -176l98 4q80 -164 158 -328q90 -207 90 -344q0 -12 -22 -190l-45 -367l-715 -90l-64 14l-67 -174q-33 8 -101 27l62 180q-59 31 -88 74q-59 84 -122 289.5t-63 310.5zM504 657 q0 -16 31 -161l206 596q-76 4 -139 14q-35 -139 -67 -295q-31 -135 -31 -154zM588 279h256l-27 600z" />
+<glyph unicode="&#xd9;" horiz-adv-x="1363" d="M102 592q0 10 17 219q12 147 31 438h342q-14 -352 -56 -1056q8 -8 10 -9q43 0 126 12.5t124 12.5q86 211 86 483q0 291 -75 643h542q16 -106 39 -329q19 -178 19 -203q0 -8 -11 -68q-57 -381 -116 -682q-154 -102 -336 -102q-25 0 -215 24q-246 31 -400 58 q-127 408 -127 559zM372 1839h285l350 -375q-35 2 -59 2q-37 0 -104 -2h-107q-57 74 -178 189q-139 133 -187 186z" />
+<glyph unicode="&#xda;" horiz-adv-x="1363" d="M102 592q0 10 17 219q12 147 31 438h342q-14 -352 -56 -1056q8 -8 10 -9q43 0 126 12.5t124 12.5q86 211 86 483q0 291 -75 643h542q16 -106 39 -329q19 -178 19 -203q0 -8 -11 -68q-57 -381 -116 -682q-154 -102 -336 -102q-25 0 -215 24q-246 31 -400 58 q-127 408 -127 559zM515 1464l348 375h284q-47 -53 -184 -186q-123 -115 -180 -189q-287 0 -268 0z" />
+<glyph unicode="&#xdb;" horiz-adv-x="1370" d="M102 592q0 10 17 219q12 147 31 438h342q-14 -352 -56 -1056q8 -8 10 -9q43 0 126 12.5t124 12.5q86 211 86 483q0 291 -75 643h542q16 -106 39 -329q19 -178 19 -203q0 -8 -11 -68q-57 -381 -116 -682q-154 -102 -336 -102q-25 0 -215 24q-246 31 -400 58 q-127 408 -127 559zM324 1470q41 92 123 275q37 72 86 201h233l281 -494q-45 4 -66 4q-29 0 -84 -2h-82q-55 117 -169 346q-41 -109 -119 -327q-127 2 -123 2q-37 0 -80 -5z" />
+<glyph unicode="&#xdc;" horiz-adv-x="1355" d="M90 592q0 10 17 219q12 147 31 438h342q-14 -352 -56 -1056q8 -8 10 -9q43 0 126 12.5t124 12.5q86 211 86 483q0 291 -75 643h542q16 -106 39 -329q19 -178 19 -203q0 -8 -11 -68q-57 -381 -116 -682q-154 -102 -336 -102q-25 0 -215 24q-246 31 -400 58 q-127 408 -127 559zM138 1749q138 11 417 27q-12 -100 -30 -303q-121 12 -361 36q-10 80 -26 240zM813 1749q139 11 418 27q-12 -100 -31 -303q-121 12 -360 36q-10 80 -27 240z" />
+<glyph unicode="&#xdd;" horiz-adv-x="1298" d="M74 1356q45 -4 123 -4q68 0 188 2q131 2 187 2q55 -184 196 -701q90 348 154 666q152 -4 211 -4q68 0 119 4v-55q0 -119 -258 -674q-37 -80 -76 -168q-6 -70 -17 -207q-14 -80 -43 -252q-119 8 -360 23q-8 72 -8 112q0 29 9 52.5t7 29.5v8q-2 33 -27 234zM502 1464 l348 375h284q-47 -53 -184 -186q-123 -115 -180 -189q-287 0 -268 0z" />
+<glyph unicode="&#xde;" horiz-adv-x="1345" d="M74 1309q330 4 450 4q0 -63 -2 -178q14 0 53 2h54q217 0 282 -17q27 -6 74 -41q70 -51 72 -53q184 -115 211 -207q16 -55 16 -102q0 -180 -295 -389q-55 -39 -209 -76q-141 -33 -223 -33q-23 0 -37 2q-29 -14 -28 -39q0 4 6 -63q4 -47 4 -101v-43q-150 8 -254 9 q-106 0 -168 -9q0 221 -3 666.5t-3 667.5zM500 492q217 12 258 10q-41 209 -56 354h-188q-4 -82 -10 -244q0 -41 -4 -120z" />
+<glyph unicode="&#xdf;" horiz-adv-x="1413" d="M92 -291v1587q424 4 570 4q217 0 282 -14q27 -6 74 -35q68 -43 74 -47q184 -96 208 -176q16 -49 17 -86q0 -139 -250 -307q250 -162 250 -293q0 -37 -17 -84q-25 -78 -208 -170q-51 -35 -146 -78q-55 -10 -219 -12l12 223q6 84 60 305q6 0 -68 0q4 0 -37 -6 q-63 -8 -104 -8q-23 0 -39 4q-14 -8 -23 -29q2 -14 2 -32q0 -35 -2 -108t-2 -109v-265q2 -266 2 -264q-150 8 -262 8q-111 0 -174 -8zM524 1067q6 -135 6 -203q0 -59 -4 -104q55 -2 107 -8q61 -4 53 -4h55q35 2 58 2q-43 186 -60 317h-215z" />
+<glyph unicode="&#xe0;" d="M74 4v55q0 70 40 263q29 139 250 991h600l365 -1354q-41 2 -107 2q-68 0 -184 -2q-135 -4 -186 -4q-20 88 -53 209q-217 12 -381 22q-20 -104 -35 -184q-139 6 -203 6q-59 0 -106 -4zM380 1839h285l350 -375q-35 2 -59 2q-37 0 -104 -2h-107q-57 74 -178 189 q-139 133 -187 186zM477 434l250 -20q-80 287 -133 526q-37 -188 -117 -506z" />
+<glyph unicode="&#xe1;" d="M74 4v55q0 70 40 263q29 139 250 991h600l365 -1354q-41 2 -107 2q-68 0 -184 -2q-135 -4 -186 -4q-20 88 -53 209q-217 12 -381 22q-20 -104 -35 -184q-139 6 -203 6q-59 0 -106 -4zM477 434l250 -20q-80 287 -133 526q-37 -188 -117 -506zM523 1464l348 375h284 q-47 -53 -184 -186q-123 -115 -180 -189q-287 0 -268 0z" />
+<glyph unicode="&#xe2;" horiz-adv-x="1390" d="M74 4v55q0 70 40 263q29 139 250 991h600l365 -1354q-41 2 -107 2q-68 0 -184 -2q-135 -4 -186 -4q-20 88 -53 209q-217 12 -381 22q-20 -104 -35 -184q-139 6 -203 6q-59 0 -106 -4zM332 1470q41 92 123 275q37 72 86 201h233l281 -494q-45 4 -66 4q-29 0 -84 -2h-82 q-55 117 -169 346q-41 -109 -119 -327q-127 2 -123 2q-37 0 -80 -5zM477 434l250 -20q-80 287 -133 526q-37 -188 -117 -506z" />
+<glyph unicode="&#xe3;" horiz-adv-x="1396" d="M74 4v55q0 70 40 263q29 139 250 991h600l365 -1354q-41 2 -107 2q-68 0 -184 -2q-135 -4 -186 -4q-20 88 -53 209q-217 12 -381 22q-20 -104 -35 -184q-139 6 -203 6q-59 0 -106 -4zM246 1769q0 16 43 156q53 0 201 -4q129 -4 200 -4q37 -92 74 -182q57 -117 135 -117 q70 0 90 8q33 14 33 68v8q0 20 -14.5 121.5t-20.5 118.5l166 4q18 -74 39 -213q12 -85 12 -93q0 -23 -16 -59q-63 -145 -207 -145q-45 0 -153 16q-125 18 -140 35q-41 43 -80 139q-59 143 -61 150q-51 -4 -152 -13q6 -94 15 -192q2 -31 8 -94q-41 2 -125 10q-16 45 -39 133 q-8 35 -8 149zM477 434l250 -20q-80 287 -133 526q-37 -188 -117 -506z" />
+<glyph unicode="&#xe4;" horiz-adv-x="1382" d="M56 4v55q0 70 40 263q29 139 250 991h600l365 -1354q-41 2 -107 2q-68 0 -184 -2q-135 -4 -186 -4q-20 88 -53 209q-217 12 -381 22q-20 -104 -35 -184q-139 6 -203 6q-59 0 -106 -4zM140 1749q138 11 417 27q-12 -100 -30 -303q-121 12 -361 36q-10 80 -26 240zM459 434 l250 -20q-80 287 -133 526q-37 -188 -117 -506zM815 1749q139 11 418 27q-12 -100 -31 -303q-121 12 -360 36q-10 80 -27 240z" />
+<glyph unicode="&#xe5;" horiz-adv-x="1392" d="M74 4v55q0 70 40 263q29 139 250 991h600l365 -1354q-41 2 -107 2q-68 0 -184 -2q-135 -4 -186 -4q-20 88 -53 209q-217 12 -381 22q-20 -104 -35 -184q-139 6 -203 6q-59 0 -106 -4zM392 1724q0 86 94 238q102 10 325 20q33 -70 68 -141q39 -86 39 -147q0 -4 -10 -74 l-21 -166l-303 -39q-51 12 -63 17q-33 12 -52 36q-23 33 -50 123t-27 133zM477 434l250 -20q-80 287 -133 526q-37 -188 -117 -506zM574 1702q0 -6 29 -154h98l-14 330q-43 0 -74 4q-39 -158 -39 -180z" />
+<glyph unicode="&#xe6;" horiz-adv-x="1914" d="M84 4l16 55q18 70 111 263q68 137 520 991h518q117 0 103 0q158 -4 469 -19v-309l-557 29l-17 -215v-37q217 16 404 16q135 0 141 -10q20 -37 20 -115q0 -16 -6 -73q-4 -45 -2 -72q-102 -8 -278 -10q-205 -2 -279 -6v-242q190 -16 574 -45v-260l-576 30v-16q-39 2 -90 2 q-55 0 -151 -2q-109 -4 -154 -4q4 86 4 203v6q-215 12 -375 22q-49 -104 -84 -184q-139 6 -202 6q-59 0 -109 -4zM606 434q98 -8 244 -20v139q0 188 10 387q-88 -188 -254 -506z" />
+<glyph unicode="&#xe7;" horiz-adv-x="1302" d="M61 713q0 201 218 553q225 25 780 47q14 -29 55 -148q49 -143 82 -219l-397 -69l-49 190q-102 0 -175 12q-33 -129 -65 -282q-27 -123 -27 -140q0 -16 21 -114q16 -80 49 -242l231 -61l31 204l447 -32q-14 -131 -43 -394l-504 -22v-80q61 -12 106 -49q55 -45 56 -100 q0 -82 -84 -125q-68 -33 -160 -33q-20 0 -55 4v125q55 -16 84 -17q80 0 79 41q0 45 -149 43v187l-86 -4l-45 10q-164 39 -217 115q-59 84 -121 289.5t-62 310.5z" />
+<glyph unicode="&#xe8;" horiz-adv-x="1202" d="M73 1065v233l144 -2q0 10 51 11q35 0 106.5 -6.5t106.5 -6.5q6 0 92 4v-10q82 -6 189 -6q51 0 153.5 3t153.5 3q31 0 51 -2v-301l-557 29l-19 -254q217 18 406 18q135 0 141 -10q20 -39 21 -115q0 -16 -6 -73q-4 -45 -2 -72q-104 -8 -289 -10q-207 -4 -289 -9l-14 -235 q203 -18 608 -49v-260q-209 10 -625 35l-2 -3q-94 8 -286 23l2 6l-76 8q-20 272 -41 664l-12 252q-6 119 -7 135zM348 1839h285l350 -375q-35 2 -59 2q-37 0 -104 -2h-107q-57 74 -178 189q-139 133 -187 186z" />
+<glyph unicode="&#xe9;" horiz-adv-x="1214" d="M71 1065v233l144 -2q0 10 51 11q35 0 106.5 -6.5t106.5 -6.5q6 0 92 4v-10q82 -6 189 -6q51 0 153.5 3t153.5 3q31 0 51 -2v-301l-557 29l-19 -254q217 18 406 18q135 0 141 -10q20 -39 21 -115q0 -16 -6 -73q-4 -45 -2 -72q-104 -8 -289 -10q-207 -4 -289 -9l-14 -235 q203 -18 608 -49v-260q-209 10 -625 35l-2 -3q-94 8 -286 23l2 6l-76 8q-20 272 -41 664l-12 252q-6 119 -7 135zM488 1464l348 375h284q-47 -53 -184 -186q-123 -115 -180 -189q-287 0 -268 0z" />
+<glyph unicode="&#xea;" horiz-adv-x="1230" d="M75 1065v233l144 -2q0 10 51 11q35 0 106.5 -6.5t106.5 -6.5q6 0 92 4v-10q82 -6 189 -6q51 0 153.5 3t153.5 3q31 0 51 -2v-301l-557 29l-19 -254q217 18 406 18q135 0 141 -10q20 -39 21 -115q0 -16 -6 -73q-4 -45 -2 -72q-104 -8 -289 -10q-207 -4 -289 -9l-14 -235 q203 -18 608 -49v-260q-209 10 -625 35l-2 -3q-94 8 -286 23l2 6l-76 8q-20 272 -41 664l-12 252q-6 119 -7 135zM301 1470q41 92 123 275q37 72 86 201h233l281 -494q-45 4 -66 4q-29 0 -84 -2h-82q-55 117 -169 346q-41 -109 -119 -327q-127 2 -123 2q-37 0 -80 -5z" />
+<glyph unicode="&#xeb;" horiz-adv-x="1183" d="M57 1065v233l144 -2q0 10 51 11q35 0 106.5 -6.5t106.5 -6.5q6 0 92 4v-10q82 -6 189 -6q51 0 153.5 3t153.5 3q31 0 51 -2v-301l-557 29l-19 -254q217 18 406 18q135 0 141 -10q20 -39 21 -115q0 -16 -6 -73q-4 -45 -2 -72q-104 -8 -289 -10q-207 -4 -289 -9l-14 -235 q203 -18 608 -49v-260q-209 10 -625 35l-2 -3q-94 8 -286 23l2 6l-76 8q-20 272 -41 664l-12 252q-6 119 -7 135zM109 1749q138 11 417 27q-12 -100 -30 -303q-121 12 -361 36q-10 80 -26 240zM784 1749q139 11 418 27q-12 -100 -31 -303q-121 12 -360 36q-10 80 -27 240z " />
+<glyph unicode="&#xec;" horiz-adv-x="753" d="M146 1065v233q203 -4 299 -4q78 0 200 4v-124q0 -10 -8 -125l-20 -285q-18 -262 -51 -787q-121 12 -361 37q-18 244 -43 693q-16 330 -16 358zM202 1839h285l350 -375q-35 2 -59 2q-37 0 -104 -2h-107q-57 74 -178 189q-139 133 -187 186z" />
+<glyph unicode="&#xed;" horiz-adv-x="659" d="M92 1065v233q203 -4 299 -4q78 0 200 4v-124q0 -10 -8 -125l-20 -285q-18 -262 -51 -787q-121 12 -361 37q-18 244 -43 693q-16 330 -16 358zM291 1464l348 375h284q-47 -53 -184 -186q-123 -115 -180 -189q-287 0 -268 0z" />
+<glyph unicode="&#xee;" horiz-adv-x="700" d="M64 1470q41 92 123 275q37 72 86 201h233l281 -494q-45 4 -66 4q-29 0 -84 -2h-82q-55 117 -169 346q-41 -109 -119 -327q-127 2 -123 2q-37 0 -80 -5zM117 1065v233q203 -4 299 -4q78 0 200 4v-124q0 -10 -8 -125l-20 -285q-18 -262 -51 -787q-121 12 -361 37 q-18 244 -43 693q-16 330 -16 358z" />
+<glyph unicode="&#xef;" horiz-adv-x="712" d="M-131 1749q138 11 417 27q-12 -100 -30 -303q-121 12 -361 36q-10 80 -26 240zM96 1065v233q203 -4 299 -4q78 0 200 4v-124q0 -10 -8 -125l-20 -285q-18 -262 -51 -787q-121 12 -361 37q-18 244 -43 693q-16 330 -16 358zM544 1749q139 11 418 27q-12 -100 -31 -303 q-121 12 -360 36q-10 80 -27 240z" />
+<glyph unicode="&#xf0;" horiz-adv-x="1511" d="M76 676q0 78 18 112q4 6 41 7q41 0 127 -7q4 246 37 531q399 -16 444 -21q256 -12 447 -32q217 -352 217 -553q0 -104 -61.5 -310t-118 -287t-223.5 -118q-43 -10 -41 -10l-652 30q-10 86 -28 263q-6 43 -17 131q2 -8 2 28q0 27 -2 74l-184 14q2 6 2 15q0 23 -4 66.5 t-4 66.5zM672 485q0 -66 12 -245l231 61l48 240q20 100 20 116t-25 134q-33 156 -67 288q-70 -12 -174 -12l-29 -317q123 -12 184 -17v-260z" />
+<glyph unicode="&#xf1;" horiz-adv-x="1486" d="M113 1106v233q203 -4 301 -4q33 0 99.5 2t98.5 2q6 0 27 -39q45 -86 141 -303q109 -242 191 -448q6 84 6 213q0 92 -6 275.5t-6 273.5q0 31 2 51q121 -12 360 -37q20 -268 41 -686l12 -264q7 -124 7 -142v-233q-203 6 -299 6q-78 0 -201 -6q-61 119 -158 344 q-88 211 -186 463q-10 -147 -17 -414q-6 -291 -12 -416q-115 12 -342 37q-18 270 -39 686l-14 265q-6 123 -6 141zM234 1769q0 16 43 156q53 0 201 -4q129 -4 200 -4q37 -92 74 -182q57 -117 135 -117q70 0 90 8q33 14 33 68v8q0 20 -14.5 121.5t-20.5 118.5l166 4 q18 -74 39 -213q12 -85 12 -93q0 -23 -16 -59q-63 -145 -207 -145q-45 0 -153 16q-125 18 -140 35q-41 43 -80 139q-59 143 -61 150q-51 -4 -152 -13q6 -94 15 -192q2 -31 8 -94q-41 2 -125 10q-16 45 -39 133q-8 35 -8 149z" />
+<glyph unicode="&#xf2;" d="M92 713q0 201 217 553q242 25 762 47q78 -164 158 -328q90 -205 90 -344q0 -14 -20 -172l-50 -389l-710 -92q-119 29 -146 39q-76 29 -118 86q-18 25 -52 100q-131 307 -131 500zM362 1839h285l350 -375q-35 2 -59 2q-37 0 -104 -2h-107q-57 74 -178 189 q-139 133 -187 186zM516 657q0 -16 21 -122q16 -78 47 -234h231l-33 766q-104 0 -174 12q-33 -131 -67 -286q-25 -119 -25 -136z" />
+<glyph unicode="&#xf3;" horiz-adv-x="1406" d="M92 713q0 201 217 553q242 25 762 47q78 -164 158 -328q90 -205 90 -344q0 -14 -20 -172l-50 -389l-710 -92q-119 29 -146 39q-76 29 -118 86q-18 25 -52 100q-131 307 -131 500zM504 1464l348 375h284q-47 -53 -184 -186q-123 -115 -180 -189q-287 0 -268 0zM516 657 q0 -16 21 -122q16 -78 47 -234h231l-33 766q-104 0 -174 12q-33 -131 -67 -286q-25 -119 -25 -136z" />
+<glyph unicode="&#xf4;" d="M92 713q0 201 217 553q242 25 762 47q78 -164 158 -328q90 -205 90 -344q0 -14 -20 -172l-50 -389l-710 -92q-119 29 -146 39q-76 29 -118 86q-18 25 -52 100q-131 307 -131 500zM313 1470q41 92 123 275q37 72 86 201h233l281 -494q-45 4 -66 4q-29 0 -84 -2h-82 q-55 117 -169 346q-41 -109 -119 -327q-127 2 -123 2q-37 0 -80 -5zM516 657q0 -16 21 -122q16 -78 47 -234h231l-33 766q-104 0 -174 12q-33 -131 -67 -286q-25 -119 -25 -136z" />
+<glyph unicode="&#xf5;" horiz-adv-x="1386" d="M98 713q0 201 217 553q242 25 762 47q78 -164 158 -328q90 -205 90 -344q0 -14 -20 -172l-50 -389l-710 -92q-119 29 -146 39q-76 29 -118 86q-18 25 -52 100q-131 307 -131 500zM234 1769q0 16 43 156q53 0 201 -4q129 -4 200 -4q37 -92 74 -182q57 -117 135 -117 q70 0 90 8q33 14 33 68v8q0 20 -14.5 121.5t-20.5 118.5l166 4q18 -74 39 -213q12 -85 12 -93q0 -23 -16 -59q-63 -145 -207 -145q-45 0 -153 16q-125 18 -140 35q-41 43 -80 139q-59 143 -61 150q-51 -4 -152 -13q6 -94 15 -192q2 -31 8 -94q-41 2 -125 10q-16 45 -39 133 q-8 35 -8 149zM522 657q0 -16 21 -122q16 -78 47 -234h231l-33 766q-104 0 -174 12q-33 -131 -67 -286q-25 -119 -25 -136z" />
+<glyph unicode="&#xf6;" horiz-adv-x="1368" d="M82 713q0 201 217 553q242 25 762 47q78 -164 158 -328q90 -205 90 -344q0 -14 -20 -172l-50 -389l-710 -92q-119 29 -146 39q-76 29 -118 86q-18 25 -52 100q-131 307 -131 500zM129 1749q138 11 417 27q-12 -100 -30 -303q-121 12 -361 36q-10 80 -26 240zM506 657 q0 -16 21 -122q16 -78 47 -234h231l-33 766q-104 0 -174 12q-33 -131 -67 -286q-25 -119 -25 -136zM804 1749q139 11 418 27q-12 -100 -31 -303q-121 12 -360 36q-10 80 -27 240z" />
+<glyph unicode="&#xf7;" horiz-adv-x="1167" d="M74 602q0 82 20 115q4 4 56 4q84 0 311 -14q213 -16 637 -45v-261q-338 12 -1016 54q2 8 2 16q0 23 -5 66t-5 65zM360 233q139 11 418 27q-12 -92 -30 -283q-119 12 -361 37q-10 74 -27 219zM401 1073q139 11 418 27q-12 -100 -31 -303q-119 12 -360 37q-10 80 -27 239z " />
+<glyph unicode="&#xf8;" horiz-adv-x="1421" d="M102 713q0 199 215 549q199 20 498 36l70 187q70 -4 106 -4q29 0 58 2q-39 -102 -68 -176l98 4q80 -164 158 -328q90 -207 90 -344q0 -12 -22 -190l-45 -367l-715 -90l-64 14l-67 -174q-33 8 -101 27l62 180q-59 31 -88 74q-59 84 -122 289.5t-63 310.5zM504 657 q0 -16 31 -161l206 596q-76 4 -139 14q-35 -139 -67 -295q-31 -135 -31 -154zM588 279h256l-27 600z" />
+<glyph unicode="&#xf9;" horiz-adv-x="1390" d="M102 592q0 10 17 219q12 147 31 438h342q-14 -352 -56 -1056q8 -8 10 -9q43 0 126 12.5t124 12.5q86 211 86 483q0 291 -75 643h542q16 -106 39 -329q19 -178 19 -203q0 -8 -11 -68q-57 -381 -116 -682q-154 -102 -336 -102q-25 0 -215 24q-246 31 -400 58 q-127 408 -127 559zM372 1839h285l350 -375q-35 2 -59 2q-37 0 -104 -2h-107q-57 74 -178 189q-139 133 -187 186z" />
+<glyph unicode="&#xfa;" horiz-adv-x="1363" d="M102 592q0 10 17 219q12 147 31 438h342q-14 -352 -56 -1056q8 -8 10 -9q43 0 126 12.5t124 12.5q86 211 86 483q0 291 -75 643h542q16 -106 39 -329q19 -178 19 -203q0 -8 -11 -68q-57 -381 -116 -682q-154 -102 -336 -102q-25 0 -215 24q-246 31 -400 58 q-127 408 -127 559zM515 1464l348 375h284q-47 -53 -184 -186q-123 -115 -180 -189q-287 0 -268 0z" />
+<glyph unicode="&#xfb;" horiz-adv-x="1361" d="M102 592q0 10 17 219q12 147 31 438h342q-14 -352 -56 -1056q8 -8 10 -9q43 0 126 12.5t124 12.5q86 211 86 483q0 291 -75 643h542q16 -106 39 -329q19 -178 19 -203q0 -8 -11 -68q-57 -381 -116 -682q-154 -102 -336 -102q-25 0 -215 24q-246 31 -400 58 q-127 408 -127 559zM324 1470q41 92 123 275q37 72 86 201h233l281 -494q-45 4 -66 4q-29 0 -84 -2h-82q-55 117 -169 346q-41 -109 -119 -327q-127 2 -123 2q-37 0 -80 -5z" />
+<glyph unicode="&#xfc;" horiz-adv-x="1341" d="M90 592q0 10 17 219q12 147 31 438h342q-14 -352 -56 -1056q8 -8 10 -9q43 0 126 12.5t124 12.5q86 211 86 483q0 291 -75 643h542q16 -106 39 -329q19 -178 19 -203q0 -8 -11 -68q-57 -381 -116 -682q-154 -102 -336 -102q-25 0 -215 24q-246 31 -400 58 q-127 408 -127 559zM138 1749q138 11 417 27q-12 -100 -30 -303q-121 12 -361 36q-10 80 -26 240zM813 1749q139 11 418 27q-12 -100 -31 -303q-121 12 -360 36q-10 80 -27 240z" />
+<glyph unicode="&#xfd;" horiz-adv-x="1325" d="M74 1356q45 -4 123 -4q68 0 188 2q131 2 187 2q55 -184 196 -701q90 348 154 666q152 -4 211 -4q68 0 119 4v-55q0 -119 -258 -674q-37 -80 -76 -168q-6 -70 -17 -207q-14 -80 -43 -252q-119 8 -360 23q-8 72 -8 112q0 29 9 52.5t7 29.5v8q-2 33 -27 234zM502 1464 l348 375h284q-47 -53 -184 -186q-123 -115 -180 -189q-287 0 -268 0z" />
+<glyph unicode="&#xfe;" horiz-adv-x="1345" d="M74 1309q330 4 450 4q0 -63 -2 -178q14 0 53 2h54q217 0 282 -17q27 -6 74 -41q70 -51 72 -53q184 -115 211 -207q16 -55 16 -102q0 -180 -295 -389q-55 -39 -209 -76q-141 -33 -223 -33q-23 0 -37 2q-29 -14 -28 -39q0 4 6 -63q4 -47 4 -101v-43q-150 8 -254 9 q-106 0 -168 -9q0 221 -3 666.5t-3 667.5zM500 492q217 12 258 10q-41 209 -56 354h-188q-4 -82 -10 -244q0 -41 -4 -120z" />
+<glyph unicode="&#xff;" horiz-adv-x="1308" d="M64 1356q45 -4 123 -4q68 0 188 2q131 2 187 2q55 -184 196 -701q90 348 154 666q152 -4 211 -4q68 0 119 4v-55q0 -119 -258 -674q-37 -80 -76 -168q-6 -70 -17 -207q-14 -80 -43 -252q-119 8 -360 23q-8 72 -8 112q0 29 9 52.5t7 29.5v8q-2 33 -27 234zM129 1761 q138 11 417 27q-12 -100 -30 -303q-121 12 -361 36q-10 80 -26 240zM804 1761q139 11 418 27q-12 -100 -31 -303q-121 12 -360 36q-10 80 -27 240z" />
+<glyph unicode="&#x152;" horiz-adv-x="1849" d="M90 713q0 201 217 553q293 31 678 47l6 -10q150 -8 123 -9q6 0 92 4v-10q82 -6 189 -6q51 0 153.5 3t153.5 3q31 0 51 -2v-301l-557 29l-10 -140q20 -59 33 -110q199 14 364 14q135 0 141 -10q20 -39 21 -115q0 -16 -6 -73q-4 -45 -2 -72q-172 -4 -520 -14l-31 -244 q190 -16 567 -45v-260q-209 10 -625 35l-2 -3q-68 8 -204 23l2 6l-76 8v15l-313 -41q-127 33 -144 39q-80 29 -119 86q-59 84 -120.5 289.5t-61.5 310.5zM514 657q0 -16 21 -122q16 -78 47 -234h231l-35 766q-102 0 -174 12q-33 -131 -65 -286q-25 -119 -25 -136z" />
+<glyph unicode="&#x153;" horiz-adv-x="1849" d="M90 713q0 201 217 553q293 31 678 47l6 -10q150 -8 123 -9q6 0 92 4v-10q82 -6 189 -6q51 0 153.5 3t153.5 3q31 0 51 -2v-301l-557 29l-10 -140q20 -59 33 -110q199 14 364 14q135 0 141 -10q20 -39 21 -115q0 -16 -6 -73q-4 -45 -2 -72q-172 -4 -520 -14l-31 -244 q190 -16 567 -45v-260q-209 10 -625 35l-2 -3q-68 8 -204 23l2 6l-76 8v15l-313 -41q-127 33 -144 39q-80 29 -119 86q-59 84 -120.5 289.5t-61.5 310.5zM514 657q0 -16 21 -122q16 -78 47 -234h231l-35 766q-102 0 -174 12q-33 -131 -65 -286q-25 -119 -25 -136z" />
+<glyph unicode="&#x178;" horiz-adv-x="1337" d="M74 1356q45 -4 123 -4q68 0 188 2q131 2 187 2q55 -184 196 -701q90 348 154 666q152 -4 211 -4q68 0 119 4v-55q0 -119 -258 -674q-37 -80 -76 -168q-6 -70 -17 -207q-14 -80 -43 -252q-119 8 -360 23q-8 72 -8 112q0 29 9 52.5t7 29.5v8q-2 33 -27 234zM138 1749 q138 11 417 27q-12 -100 -30 -303q-121 12 -361 36q-10 80 -26 240zM813 1749q139 11 418 27q-12 -100 -31 -303q-121 12 -360 36q-10 80 -27 240z" />
+<glyph unicode="&#x2c6;" horiz-adv-x="929" d="M127 1470q41 92 123 275q37 72 86 201h233l281 -494q-45 4 -66 4q-29 0 -84 -2h-82q-55 117 -169 346q-41 -109 -119 -327q-127 2 -123 2q-37 0 -80 -5z" />
+<glyph unicode="&#x2dc;" horiz-adv-x="1101" d="M84 1769q0 16 43 156q53 0 201 -4q129 -4 200 -4q37 -92 74 -182q57 -117 135 -117q70 0 90 8q33 14 33 68v8q0 20 -14.5 121.5t-20.5 118.5l166 4q18 -74 39 -213q12 -85 12 -93q0 -23 -16 -59q-63 -145 -207 -145q-45 0 -153 16q-125 18 -140 35q-41 43 -80 139 q-59 143 -61 150q-51 -4 -152 -13q6 -94 15 -192q2 -31 8 -94q-41 2 -125 10q-16 45 -39 133q-8 35 -8 149z" />
+<glyph unicode="&#x2000;" horiz-adv-x="991" />
+<glyph unicode="&#x2001;" horiz-adv-x="1982" />
+<glyph unicode="&#x2002;" horiz-adv-x="991" />
+<glyph unicode="&#x2003;" horiz-adv-x="1982" />
+<glyph unicode="&#x2004;" horiz-adv-x="660" />
+<glyph unicode="&#x2005;" horiz-adv-x="495" />
+<glyph unicode="&#x2006;" horiz-adv-x="330" />
+<glyph unicode="&#x2007;" horiz-adv-x="330" />
+<glyph unicode="&#x2008;" horiz-adv-x="247" />
+<glyph unicode="&#x2009;" horiz-adv-x="396" />
+<glyph unicode="&#x200a;" horiz-adv-x="110" />
+<glyph unicode="&#x2010;" horiz-adv-x="1159" d="M113 643q0 80 20 115q2 4 47 4q74 0 275 -14q193 -18 579 -46v-260q-305 14 -913 54v16q0 23 -4 66t-4 65z" />
+<glyph unicode="&#x2011;" horiz-adv-x="1159" d="M113 643q0 80 20 115q2 4 47 4q74 0 275 -14q193 -18 579 -46v-260q-305 14 -913 54v16q0 23 -4 66t-4 65z" />
+<glyph unicode="&#x2012;" horiz-adv-x="1159" d="M113 643q0 80 20 115q2 4 47 4q74 0 275 -14q193 -18 579 -46v-260q-305 14 -913 54v16q0 23 -4 66t-4 65z" />
+<glyph unicode="&#x2013;" horiz-adv-x="1538" d="M100 676q0 63 21 100q2 4 74 4q117 0 423 -14q270 -16 814 -45v-219q-152 6 -795 28q-176 6 -528 25v14q0 18 -4.5 53t-4.5 54z" />
+<glyph unicode="&#x2014;" horiz-adv-x="1742" d="M78 635q0 68 20 100q4 6 88 6q154 0 566 -18q354 -14 882 -43v-219q-158 8 -979 31q-190 4 -569 24v14q0 16 -4 51t-4 54z" />
+<glyph unicode="&#x2018;" horiz-adv-x="643" d="M102 557q20 297 29 467h2q10 141 129 236q111 88 258 88l-6 -150q-217 0 -233 -188q61 -6 213 -23q10 -152 24 -403q-137 -10 -416 -27z" />
+<glyph unicode="&#x2019;" horiz-adv-x="636" d="M109 567l6 150q215 0 231 188q-61 6 -211 25q-12 152 -26 403q138 11 417 27q-20 -297 -30 -467q-12 -143 -127 -234.5t-260 -91.5z" />
+<glyph unicode="&#x201a;" horiz-adv-x="655" d="M131 -346l6 149q217 0 234 189q-61 6 -213 22q-10 154 -25 404q137 10 416 26q-20 -297 -29 -467l-2 3q-10 -143 -129 -238q-111 -88 -258 -88z" />
+<glyph unicode="&#x201c;" horiz-adv-x="1134" d="M102 557q20 297 29 467h2q10 141 129 236q111 88 258 88l-6 -150q-217 0 -233 -188q61 -6 213 -23q10 -152 24 -403q-137 -10 -416 -27zM594 557q20 297 29 467h2q10 141 129 236q111 88 258 88l-6 -150q-217 0 -234 -188q61 -6 213 -23q10 -152 25 -403 q-137 -10 -416 -27z" />
+<glyph unicode="&#x201d;" horiz-adv-x="1148" d="M109 567l6 150q215 0 231 188q-61 6 -211 25q-12 152 -26 403q138 11 417 27q-20 -297 -30 -467q-12 -143 -127 -234.5t-260 -91.5zM621 567l6 150q215 0 231 188q-61 6 -211 25q-12 152 -26 403q138 11 417 27q-20 -297 -30 -467q-12 -143 -127 -234.5t-260 -91.5z" />
+<glyph unicode="&#x201e;" horiz-adv-x="1167" d="M131 -346l6 149q217 0 234 189q-61 6 -213 22q-10 154 -25 404q137 10 416 26q-20 -297 -29 -467l-2 3q-10 -143 -129 -238q-111 -88 -258 -88zM643 -346l6 149q217 0 234 189q-61 6 -213 22q-10 154 -25 404q137 10 416 26q-20 -297 -29 -467l-2 3q-10 -143 -129 -238 q-111 -88 -258 -88z" />
+<glyph unicode="&#x2022;" horiz-adv-x="948" d="M94 969q244 18 729 47q-35 -518 -51 -817q-211 20 -633 65q-18 264 -45 705z" />
+<glyph unicode="&#x2026;" horiz-adv-x="2183" d="M125 418q137 10 416 26q-20 -297 -29 -467q-121 12 -362 37q-10 154 -25 404zM883 418q136 10 415 26q-20 -297 -28 -467q-121 12 -363 37q-10 154 -24 404zM1640 418q137 10 416 26q-20 -297 -28 -467q-121 12 -363 37q-10 154 -25 404z" />
+<glyph unicode="&#x202f;" horiz-adv-x="396" />
+<glyph unicode="&#x2039;" horiz-adv-x="851" d="M84 438v293l661 436q-4 -43 -4 -75q0 -37 2 -105q2 -73 2 -106q-117 -68 -352 -201q-57 -33 -176 -88q94 -43 260 -137q158 -92 242 -148q-2 -154 -2 -151q0 -43 2 -95l-41 21q-41 23 -162 96q-88 55 -266 166q-59 39 -166 94z" />
+<glyph unicode="&#x203a;" horiz-adv-x="829" d="M86 881q0 33 2 106q2 68 2 105q0 33 -2 75l660 -436v-293q-25 -8 -166 -94q-88 -55 -267 -166q-53 -33 -161 -96l-41 -21q4 51 4 95q0 -2 -4 151q84 55 241 148q166 94 260 137q-59 23 -175.5 90.5t-352.5 198.5z" />
+<glyph unicode="&#x205f;" horiz-adv-x="495" />
+<glyph unicode="&#x20ac;" horiz-adv-x="1372" d="M39 762q0 51 16 69q4 4 70 5q47 184 199 430q225 25 780 47q14 -29 51 -137q53 -154 86 -230l-395 -69l-51 190q-102 0 -174 12q-29 -119 -62 -268q78 -4 232 -12v-158l-261 8q2 -23 17 -98q86 -6 256 -16v-175l-217 9l12 -68l231 -61l31 204l449 -32q-14 -131 -45 -394 l-713 -30l-45 12q-166 37 -217 112.5t-117 276.5l-115 8v11q0 14 -3 43.5t-3 44.5q0 55 17 77q2 4 55 2q-10 51 -14 95l-64 4v8q0 14 -3 41t-3 39z" />
+<glyph unicode="&#x2122;" horiz-adv-x="1830" d="M90 1223v143q72 2 318 20q197 12 315 13q35 0 37 -2q14 -20 14 -64q0 -8 -4 -37t-2 -43q-109 -6 -209 -12l-39 -592q-66 6 -198 21q-18 256 -33 561zM844 772q0 102 6 311q4 197 4 310q29 8 66 8q33 0 94 -6t90 -6l47 -121q2 -6 33 -119q41 -162 67 -258l115 358 q12 37 39 107q2 4 6 8q27 0 84 -3t86 -3h102q11 -152 11 -338v-152q0 -113 -2 -215q-66 -4 -199 -16q-12 123 -45 377q-72 -236 -127 -361q-20 -10 -43 -10q-39 -2 -41 -4l-74 -10q-53 129 -168 385q0 -119 -4 -355h-10q-10 0 -31.5 -2t-34.5 -2q-41 0 -67 13q-4 4 -4 104z " />
+<glyph unicode="&#x25fc;" horiz-adv-x="1351" d="M0 0v1352h1352v-1352h-1352z" />
+<hkern u1="&#x22;" u2="&#x2026;" k="1024" />
+<hkern u1="&#x22;" u2="&#x201e;" k="1032" />
+<hkern u1="&#x22;" u2="&#x201a;" k="676" />
+<hkern u1="&#x22;" u2="&#xbf;" k="573" />
+<hkern u1="&#x22;" u2="_" k="915" />
+<hkern u1="&#x22;" u2="&#x2e;" k="678" />
+<hkern u1="&#x22;" u2="&#x2c;" k="676" />
+<hkern u1="&#x27;" u2="&#x2026;" k="553" />
+<hkern u1="&#x27;" u2="&#x201e;" k="561" />
+<hkern u1="&#x27;" u2="&#x201a;" k="561" />
+<hkern u1="&#x27;" u2="&#xbf;" k="571" />
+<hkern u1="&#x27;" u2="j" k="627" />
+<hkern u1="&#x27;" u2="J" k="625" />
+<hkern u1="&#x27;" u2="&#x2e;" k="563" />
+<hkern u1="&#x27;" u2="&#x2c;" k="561" />
+<hkern u1="&#x2a;" u2="&#x2026;" k="1102" />
+<hkern u1="&#x2a;" u2="&#x201e;" k="1110" />
+<hkern u1="&#x2a;" u2="&#x201a;" k="643" />
+<hkern u1="&#x2a;" u2="&#xbf;" k="532" />
+<hkern u1="&#x2a;" u2="_" k="991" />
+<hkern u1="&#x2a;" u2="&#x2e;" k="645" />
+<hkern u1="&#x2a;" u2="&#x2c;" k="643" />
+<hkern u1="&#x2b;" u2="_" k="1028" />
+<hkern u1="&#x2c;" u2="&#x2122;" k="614" />
+<hkern u1="&#x2c;" u2="&#x201d;" k="633" />
+<hkern u1="&#x2c;" u2="&#x201c;" k="627" />
+<hkern u1="&#x2c;" u2="&#x2019;" k="633" />
+<hkern u1="&#x2c;" u2="&#x2018;" k="627" />
+<hkern u1="&#x2c;" u2="&#x2014;" k="602" />
+<hkern u1="&#x2c;" u2="&#x2013;" k="625" />
+<hkern u1="&#x2c;" u2="&#xb9;" k="651" />
+<hkern u1="&#x2c;" u2="&#xb3;" k="618" />
+<hkern u1="&#x2c;" u2="&#xb2;" k="631" />
+<hkern u1="&#x2c;" u2="&#xb0;" k="598" />
+<hkern u1="&#x2c;" u2="&#xac;" k="756" />
+<hkern u1="&#x2c;" u2="&#x7e;" k="618" />
+<hkern u1="&#x2c;" u2="^" k="614" />
+<hkern u1="&#x2c;" u2="&#x31;" k="657" />
+<hkern u1="&#x2c;" u2="&#x2d;" k="637" />
+<hkern u1="&#x2c;" u2="&#x2a;" k="618" />
+<hkern u1="&#x2c;" u2="&#x27;" k="526" />
+<hkern u1="&#x2c;" u2="&#x22;" k="641" />
+<hkern u1="&#x2d;" u2="&#x7e;" k="1141" />
+<hkern u1="&#x2d;" u2="_" k="1063" />
+<hkern u1="&#x2d;" u2="^" k="1137" />
+<hkern u1="&#x2d;" u2="&#x37;" k="264" />
+<hkern u1="&#x2d;" u2="&#x32;" k="172" />
+<hkern u1="&#x2e;" u2="&#x2122;" k="633" />
+<hkern u1="&#x2e;" u2="&#x201d;" k="651" />
+<hkern u1="&#x2e;" u2="&#x201c;" k="645" />
+<hkern u1="&#x2e;" u2="&#x2019;" k="651" />
+<hkern u1="&#x2e;" u2="&#x2018;" k="645" />
+<hkern u1="&#x2e;" u2="&#x2014;" k="621" />
+<hkern u1="&#x2e;" u2="&#x2013;" k="643" />
+<hkern u1="&#x2e;" u2="&#xb9;" k="668" />
+<hkern u1="&#x2e;" u2="&#xb3;" k="637" />
+<hkern u1="&#x2e;" u2="&#xb2;" k="649" />
+<hkern u1="&#x2e;" u2="&#xb0;" k="616" />
+<hkern u1="&#x2e;" u2="&#xac;" k="774" />
+<hkern u1="&#x2e;" u2="&#x7e;" k="635" />
+<hkern u1="&#x2e;" u2="^" k="633" />
+<hkern u1="&#x2e;" u2="&#x31;" k="676" />
+<hkern u1="&#x2e;" u2="&#x2d;" k="655" />
+<hkern u1="&#x2e;" u2="&#x2a;" k="637" />
+<hkern u1="&#x2e;" u2="&#x27;" k="545" />
+<hkern u1="&#x2e;" u2="&#x22;" k="659" />
+<hkern u1="&#x30;" u2="&#x2e;" k="43" />
+<hkern u1="&#x3c;" u2="_" k="1044" />
+<hkern u1="&#x3d;" u2="_" k="1020" />
+<hkern u1="&#x3e;" u2="&#xb8;" k="725" />
+<hkern u1="&#x3e;" u2="_" k="1012" />
+<hkern u1="&#x3f;" u2="&#x2026;" k="545" />
+<hkern u1="&#x3f;" u2="&#x201e;" k="553" />
+<hkern u1="&#x3f;" u2="&#x201a;" k="553" />
+<hkern u1="&#x3f;" u2="&#x2e;" k="555" />
+<hkern u1="&#x3f;" u2="&#x2c;" k="553" />
+<hkern u1="A" u2="&#x201d;" k="117" />
+<hkern u1="A" u2="&#x2019;" k="117" />
+<hkern u1="A" u2="y" k="293" />
+<hkern u1="A" u2="w" k="215" />
+<hkern u1="A" u2="v" k="233" />
+<hkern u1="A" u2="Y" k="293" />
+<hkern u1="A" u2="W" k="215" />
+<hkern u1="A" u2="V" k="233" />
+<hkern u1="A" u2="T" k="215" />
+<hkern u1="C" u2="&#x2014;" k="682" />
+<hkern u1="C" u2="&#x2013;" k="713" />
+<hkern u1="C" u2="&#xac;" k="709" />
+<hkern u1="C" u2="&#x2d;" k="694" />
+<hkern u1="D" u2="&#x2e;" k="66" />
+<hkern u1="D" u2="&#x2c;" k="63" />
+<hkern u1="F" u2="&#x2026;" k="553" />
+<hkern u1="F" u2="&#x201e;" k="561" />
+<hkern u1="F" u2="&#x201a;" k="561" />
+<hkern u1="F" u2="&#x2e;" k="563" />
+<hkern u1="F" u2="&#x2c;" k="561" />
+<hkern u1="K" u2="&#xac;" k="524" />
+<hkern u1="K" u2="o" k="188" />
+<hkern u1="L" u2="&#x201d;" k="461" />
+<hkern u1="L" u2="&#x2019;" k="461" />
+<hkern u1="L" u2="&#xac;" k="580" />
+<hkern u1="L" u2="Y" k="352" />
+<hkern u1="L" u2="V" k="213" />
+<hkern u1="L" u2="O" k="102" />
+<hkern u1="P" u2="&#xb8;" k="627" />
+<hkern u1="P" u2="a" k="72" />
+<hkern u1="P" u2="_" k="625" />
+<hkern u1="P" u2="A" k="106" />
+<hkern u1="P" u2="&#x2e;" k="414" />
+<hkern u1="P" u2="&#x2c;" k="412" />
+<hkern u1="T" u2="o" k="98" />
+<hkern u1="T" u2="a" k="131" />
+<hkern u1="T" u2="A" k="164" />
+<hkern u1="T" u2="&#x3b;" k="49" />
+<hkern u1="T" u2="&#x3a;" k="49" />
+<hkern u1="T" u2="&#x2e;" k="393" />
+<hkern u1="T" u2="&#x2d;" k="369" />
+<hkern u1="T" u2="&#x2c;" k="391" />
+<hkern u1="U" u2="A" k="66" />
+<hkern u1="U" u2="&#x2e;" k="76" />
+<hkern u1="U" u2="&#x2c;" k="78" />
+<hkern u1="V" u2="r" k="-59" />
+<hkern u1="V" u2="a" k="74" />
+<hkern u1="V" u2="A" k="109" />
+<hkern u1="V" u2="&#x2e;" k="123" />
+<hkern u1="V" u2="&#x2d;" k="55" />
+<hkern u1="V" u2="&#x2c;" k="121" />
+<hkern u1="W" u2="r" k="-59" />
+<hkern u1="W" u2="a" k="59" />
+<hkern u1="W" u2="A" k="94" />
+<hkern u1="W" u2="&#x2e;" k="106" />
+<hkern u1="W" u2="&#x2d;" k="45" />
+<hkern u1="W" u2="&#x2c;" k="104" />
+<hkern u1="Y" u2="o" k="121" />
+<hkern u1="Y" u2="a" k="158" />
+<hkern u1="Y" u2="A" k="193" />
+<hkern u1="Y" u2="&#x3b;" k="74" />
+<hkern u1="Y" u2="&#x3a;" k="72" />
+<hkern u1="Y" u2="&#x2e;" k="313" />
+<hkern u1="Y" u2="&#x2d;" k="178" />
+<hkern u1="Y" u2="&#x2c;" k="313" />
+<hkern u1="^" u2="&#x2026;" k="1151" />
+<hkern u1="^" u2="&#x201e;" k="1159" />
+<hkern u1="^" u2="&#x201a;" k="653" />
+<hkern u1="^" u2="&#x2014;" k="1106" />
+<hkern u1="^" u2="&#x2013;" k="1126" />
+<hkern u1="^" u2="&#xbf;" k="524" />
+<hkern u1="^" u2="&#xac;" k="1128" />
+<hkern u1="^" u2="j" k="600" />
+<hkern u1="^" u2="_" k="1040" />
+<hkern u1="^" u2="J" k="598" />
+<hkern u1="^" u2="&#x2e;" k="655" />
+<hkern u1="^" u2="&#x2d;" k="1139" />
+<hkern u1="^" u2="&#x2c;" k="653" />
+<hkern u1="_" u2="&#x2122;" k="1090" />
+<hkern u1="_" u2="&#x203a;" k="825" />
+<hkern u1="_" u2="&#x2039;" k="823" />
+<hkern u1="_" u2="&#x2022;" k="901" />
+<hkern u1="_" u2="&#x201d;" k="1106" />
+<hkern u1="_" u2="&#x201c;" k="1087" />
+<hkern u1="_" u2="&#x2019;" k="602" />
+<hkern u1="_" u2="&#x2018;" k="596" />
+<hkern u1="_" u2="&#x2014;" k="1075" />
+<hkern u1="_" u2="&#x2013;" k="1098" />
+<hkern u1="_" u2="&#xd7;" k="1057" />
+<hkern u1="_" u2="&#xbb;" k="1090" />
+<hkern u1="_" u2="&#xba;" k="1010" />
+<hkern u1="_" u2="&#xb9;" k="719" />
+<hkern u1="_" u2="&#xb7;" k="623" />
+<hkern u1="_" u2="&#xb6;" k="604" />
+<hkern u1="_" u2="&#xb3;" k="805" />
+<hkern u1="_" u2="&#xb2;" k="813" />
+<hkern u1="_" u2="&#xb0;" k="793" />
+<hkern u1="_" u2="&#xac;" k="1100" />
+<hkern u1="_" u2="&#xab;" k="1081" />
+<hkern u1="_" u2="&#xaa;" k="1026" />
+<hkern u1="_" u2="&#x7e;" k="1092" />
+<hkern u1="_" u2="^" k="1087" />
+<hkern u1="_" u2="&#x3e;" k="1085" />
+<hkern u1="_" u2="&#x3d;" k="1085" />
+<hkern u1="_" u2="&#x3c;" k="1083" />
+<hkern u1="_" u2="&#x34;" k="582" />
+<hkern u1="_" u2="&#x2d;" k="1110" />
+<hkern u1="_" u2="&#x2b;" k="1100" />
+<hkern u1="_" u2="&#x2a;" k="1053" />
+<hkern u1="_" u2="&#x22;" k="967" />
+<hkern u1="a" u2="&#x201d;" k="109" />
+<hkern u1="a" u2="&#x2019;" k="109" />
+<hkern u1="c" u2="&#x201d;" k="90" />
+<hkern u1="c" u2="&#x2019;" k="90" />
+<hkern u1="c" u2="&#x2014;" k="682" />
+<hkern u1="c" u2="&#x2013;" k="713" />
+<hkern u1="c" u2="&#xac;" k="709" />
+<hkern u1="c" u2="&#x2d;" k="694" />
+<hkern u1="f" u2="&#x2026;" k="553" />
+<hkern u1="f" u2="&#x201e;" k="561" />
+<hkern u1="f" u2="&#x201a;" k="561" />
+<hkern u1="f" u2="&#x2e;" k="563" />
+<hkern u1="f" u2="&#x2c;" k="561" />
+<hkern u1="k" u2="o" k="147" />
+<hkern u1="k" u2="e" k="-49" />
+<hkern u1="l" u2="&#xac;" k="580" />
+<hkern u1="p" u2="&#xb8;" k="627" />
+<hkern u1="p" u2="_" k="625" />
+<hkern u1="r" u2="&#x2d;" k="53" />
+<hkern u1="v" u2="&#x2e;" k="121" />
+<hkern u1="v" u2="&#x2c;" k="119" />
+<hkern u1="w" u2="&#x2e;" k="100" />
+<hkern u1="w" u2="&#x2c;" k="98" />
+<hkern u1="y" u2="&#x2e;" k="315" />
+<hkern u1="y" u2="&#x2c;" k="315" />
+<hkern u1="&#x7e;" u2="&#x2026;" k="1413" />
+<hkern u1="&#x7e;" u2="&#x201e;" k="1159" />
+<hkern u1="&#x7e;" u2="&#x201a;" k="647" />
+<hkern u1="&#x7e;" u2="&#x2014;" k="1368" />
+<hkern u1="&#x7e;" u2="&#xbf;" k="537" />
+<hkern u1="&#x7e;" u2="&#xac;" k="1391" />
+<hkern u1="&#x7e;" u2="_" k="1034" />
+<hkern u1="&#x7e;" u2="&#x2e;" k="649" />
+<hkern u1="&#x7e;" u2="&#x2d;" k="1133" />
+<hkern u1="&#x7e;" u2="&#x2c;" k="647" />
+<hkern u1="&#xa2;" u2="&#xac;" k="530" />
+<hkern u1="&#xaa;" u2="_" k="979" />
+<hkern u1="&#xab;" u2="_" k="1042" />
+<hkern u1="&#xac;" u2="&#x2122;" k="1044" />
+<hkern u1="&#xac;" u2="&#xb0;" k="848" />
+<hkern u1="&#xac;" u2="&#x7e;" k="1417" />
+<hkern u1="&#xac;" u2="_" k="1067" />
+<hkern u1="&#xac;" u2="^" k="1143" />
+<hkern u1="&#xb0;" u2="&#x2026;" k="887" />
+<hkern u1="&#xb0;" u2="&#x201e;" k="895" />
+<hkern u1="&#xb0;" u2="&#x201a;" k="668" />
+<hkern u1="&#xb0;" u2="&#xbf;" k="563" />
+<hkern u1="&#xb0;" u2="&#xac;" k="864" />
+<hkern u1="&#xb0;" u2="_" k="778" />
+<hkern u1="&#xb0;" u2="&#x2e;" k="670" />
+<hkern u1="&#xb0;" u2="&#x2c;" k="668" />
+<hkern u1="&#xb2;" u2="&#x2026;" k="881" />
+<hkern u1="&#xb2;" u2="&#x201e;" k="889" />
+<hkern u1="&#xb2;" u2="&#x201a;" k="674" />
+<hkern u1="&#xb2;" u2="&#xbf;" k="551" />
+<hkern u1="&#xb2;" u2="_" k="772" />
+<hkern u1="&#xb2;" u2="&#x2e;" k="676" />
+<hkern u1="&#xb2;" u2="&#x2c;" k="674" />
+<hkern u1="&#xb3;" u2="&#x2026;" k="866" />
+<hkern u1="&#xb3;" u2="&#x201e;" k="874" />
+<hkern u1="&#xb3;" u2="&#x201a;" k="657" />
+<hkern u1="&#xb3;" u2="&#xbf;" k="537" />
+<hkern u1="&#xb3;" u2="_" k="758" />
+<hkern u1="&#xb3;" u2="&#x2e;" k="659" />
+<hkern u1="&#xb3;" u2="&#x2c;" k="657" />
+<hkern u1="&#xb7;" u2="_" k="559" />
+<hkern u1="&#xb8;" u2="&#xac;" k="563" />
+<hkern u1="&#xb9;" u2="&#x2026;" k="768" />
+<hkern u1="&#xb9;" u2="&#x201e;" k="776" />
+<hkern u1="&#xb9;" u2="&#x201a;" k="676" />
+<hkern u1="&#xb9;" u2="&#xbf;" k="743" />
+<hkern u1="&#xb9;" u2="_" k="659" />
+<hkern u1="&#xb9;" u2="&#x2e;" k="678" />
+<hkern u1="&#xb9;" u2="&#x2c;" k="676" />
+<hkern u1="&#xba;" u2="_" k="967" />
+<hkern u1="&#xbb;" u2="_" k="1020" />
+<hkern u1="&#xc7;" u2="&#x2014;" k="655" />
+<hkern u1="&#xc7;" u2="&#x2013;" k="686" />
+<hkern u1="&#xc7;" u2="&#xac;" k="682" />
+<hkern u1="&#xc7;" u2="&#x2d;" k="670" />
+<hkern u1="&#xd7;" u2="_" k="999" />
+<hkern u1="&#xde;" u2="&#xb8;" k="627" />
+<hkern u1="&#xde;" u2="_" k="623" />
+<hkern u1="&#xe7;" u2="&#x2014;" k="655" />
+<hkern u1="&#xe7;" u2="&#x2013;" k="686" />
+<hkern u1="&#xe7;" u2="&#xac;" k="682" />
+<hkern u1="&#xe7;" u2="&#x2d;" k="670" />
+<hkern u1="&#xfe;" u2="&#xb8;" k="627" />
+<hkern u1="&#xfe;" u2="_" k="623" />
+<hkern u1="&#x2013;" u2="&#x2026;" k="1563" />
+<hkern u1="&#x2013;" u2="&#x201e;" k="1169" />
+<hkern u1="&#x2013;" u2="&#x201a;" k="657" />
+<hkern u1="&#x2013;" u2="&#x7e;" k="1532" />
+<hkern u1="&#x2013;" u2="_" k="1044" />
+<hkern u1="&#x2013;" u2="^" k="1120" />
+<hkern u1="&#x2013;" u2="&#x2e;" k="659" />
+<hkern u1="&#x2013;" u2="&#x2c;" k="657" />
+<hkern u1="&#x2014;" u2="&#x2026;" k="1788" />
+<hkern u1="&#x2014;" u2="&#x201e;" k="1169" />
+<hkern u1="&#x2014;" u2="&#x201a;" k="657" />
+<hkern u1="&#x2014;" u2="&#xb0;" k="627" />
+<hkern u1="&#x2014;" u2="&#x7e;" k="1393" />
+<hkern u1="&#x2014;" u2="_" k="1044" />
+<hkern u1="&#x2014;" u2="^" k="1120" />
+<hkern u1="&#x2014;" u2="&#x2e;" k="659" />
+<hkern u1="&#x2014;" u2="&#x2c;" k="657" />
+<hkern u1="&#x2018;" u2="&#x2026;" k="666" />
+<hkern u1="&#x2018;" u2="&#x201e;" k="674" />
+<hkern u1="&#x2018;" u2="&#x201a;" k="674" />
+<hkern u1="&#x2018;" u2="&#xbf;" k="662" />
+<hkern u1="&#x2018;" u2="j" k="446" />
+<hkern u1="&#x2018;" u2="_" k="555" />
+<hkern u1="&#x2018;" u2="A" k="72" />
+<hkern u1="&#x2018;" u2="&#x2e;" k="676" />
+<hkern u1="&#x2018;" u2="&#x2c;" k="674" />
+<hkern u1="&#x2019;" u2="&#x2026;" k="651" />
+<hkern u1="&#x2019;" u2="&#x201e;" k="659" />
+<hkern u1="&#x2019;" u2="&#x201a;" k="659" />
+<hkern u1="&#x2019;" u2="&#xbf;" k="655" />
+<hkern u1="&#x2019;" u2="j" k="711" />
+<hkern u1="&#x2019;" u2="_" k="543" />
+<hkern u1="&#x2019;" u2="J" k="709" />
+<hkern u1="&#x2019;" u2="&#x2e;" k="662" />
+<hkern u1="&#x2019;" u2="&#x2c;" k="659" />
+<hkern u1="&#x201a;" u2="&#x2122;" k="614" />
+<hkern u1="&#x201a;" u2="&#x201d;" k="633" />
+<hkern u1="&#x201a;" u2="&#x201c;" k="627" />
+<hkern u1="&#x201a;" u2="&#x2019;" k="633" />
+<hkern u1="&#x201a;" u2="&#x2018;" k="627" />
+<hkern u1="&#x201a;" u2="&#x2014;" k="602" />
+<hkern u1="&#x201a;" u2="&#x2013;" k="625" />
+<hkern u1="&#x201a;" u2="&#xb9;" k="651" />
+<hkern u1="&#x201a;" u2="&#xb3;" k="618" />
+<hkern u1="&#x201a;" u2="&#xb2;" k="631" />
+<hkern u1="&#x201a;" u2="&#xb0;" k="598" />
+<hkern u1="&#x201a;" u2="&#xac;" k="756" />
+<hkern u1="&#x201a;" u2="&#x7e;" k="618" />
+<hkern u1="&#x201a;" u2="^" k="614" />
+<hkern u1="&#x201a;" u2="&#x31;" k="657" />
+<hkern u1="&#x201a;" u2="&#x2d;" k="637" />
+<hkern u1="&#x201a;" u2="&#x2a;" k="618" />
+<hkern u1="&#x201a;" u2="&#x27;" k="526" />
+<hkern u1="&#x201a;" u2="&#x22;" k="641" />
+<hkern u1="&#x201c;" u2="&#x2026;" k="1157" />
+<hkern u1="&#x201c;" u2="&#x201e;" k="1165" />
+<hkern u1="&#x201c;" u2="&#x201a;" k="674" />
+<hkern u1="&#x201c;" u2="&#xbf;" k="526" />
+<hkern u1="&#x201c;" u2="j" k="446" />
+<hkern u1="&#x201c;" u2="_" k="1047" />
+<hkern u1="&#x201c;" u2="A" k="72" />
+<hkern u1="&#x201c;" u2="&#x2e;" k="676" />
+<hkern u1="&#x201c;" u2="&#x2c;" k="674" />
+<hkern u1="&#x201d;" u2="&#x2026;" k="1163" />
+<hkern u1="&#x201d;" u2="&#x201e;" k="1171" />
+<hkern u1="&#x201d;" u2="&#x201a;" k="659" />
+<hkern u1="&#x201d;" u2="&#xbf;" k="573" />
+<hkern u1="&#x201d;" u2="_" k="1047" />
+<hkern u1="&#x201d;" u2="&#x2e;" k="662" />
+<hkern u1="&#x201d;" u2="&#x2c;" k="659" />
+<hkern u1="&#x201e;" u2="&#x2122;" k="1126" />
+<hkern u1="&#x201e;" u2="&#x201d;" k="1145" />
+<hkern u1="&#x201e;" u2="&#x201c;" k="1118" />
+<hkern u1="&#x201e;" u2="&#x2019;" k="633" />
+<hkern u1="&#x201e;" u2="&#x2018;" k="627" />
+<hkern u1="&#x201e;" u2="&#x2014;" k="1114" />
+<hkern u1="&#x201e;" u2="&#x2013;" k="1137" />
+<hkern u1="&#x201e;" u2="&#xb9;" k="750" />
+<hkern u1="&#x201e;" u2="&#xb3;" k="836" />
+<hkern u1="&#x201e;" u2="&#xb2;" k="844" />
+<hkern u1="&#x201e;" u2="&#xb0;" k="823" />
+<hkern u1="&#x201e;" u2="&#xac;" k="1165" />
+<hkern u1="&#x201e;" u2="&#x7e;" k="1130" />
+<hkern u1="&#x201e;" u2="^" k="1120" />
+<hkern u1="&#x201e;" u2="&#x2d;" k="776" />
+<hkern u1="&#x201e;" u2="&#x2a;" k="1083" />
+<hkern u1="&#x201e;" u2="&#x27;" k="526" />
+<hkern u1="&#x201e;" u2="&#x22;" k="997" />
+<hkern u1="&#x2022;" u2="_" k="868" />
+<hkern u1="&#x2026;" u2="&#x2122;" k="1819" />
+<hkern u1="&#x2026;" u2="&#x201d;" k="1163" />
+<hkern u1="&#x2026;" u2="&#x201c;" k="1137" />
+<hkern u1="&#x2026;" u2="&#x2019;" k="651" />
+<hkern u1="&#x2026;" u2="&#x2018;" k="645" />
+<hkern u1="&#x2026;" u2="&#x2014;" k="1761" />
+<hkern u1="&#x2026;" u2="&#x2013;" k="1556" />
+<hkern u1="&#x2026;" u2="&#xb9;" k="768" />
+<hkern u1="&#x2026;" u2="&#xb3;" k="856" />
+<hkern u1="&#x2026;" u2="&#xb2;" k="862" />
+<hkern u1="&#x2026;" u2="&#xb0;" k="844" />
+<hkern u1="&#x2026;" u2="&#xac;" k="1040" />
+<hkern u1="&#x2026;" u2="&#x7e;" k="1411" />
+<hkern u1="&#x2026;" u2="^" k="1139" />
+<hkern u1="&#x2026;" u2="&#x2d;" k="795" />
+<hkern u1="&#x2026;" u2="&#x2a;" k="1102" />
+<hkern u1="&#x2026;" u2="&#x27;" k="545" />
+<hkern u1="&#x2026;" u2="&#x22;" k="1016" />
+<hkern u1="&#x2039;" u2="_" k="782" />
+<hkern u1="&#x203a;" u2="_" k="760" />
+<hkern u1="&#x2122;" u2="&#x2026;" k="1864" />
+<hkern u1="&#x2122;" u2="&#x201e;" k="1198" />
+<hkern u1="&#x2122;" u2="&#x201a;" k="686" />
+<hkern u1="&#x2122;" u2="&#xbf;" k="557" />
+<hkern u1="&#x2122;" u2="_" k="1073" />
+<hkern u1="&#x2122;" u2="&#x2e;" k="688" />
+<hkern u1="&#x2122;" u2="&#x2c;" k="686" />
+</font>
+</defs></svg> 

BIN
WebChallenge/WebChallenge/wwwroot/games/G11/css/survivant-webfont.ttf


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/css/survivant-webfont.woff


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/css/survivant-webfont.woff2


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/icon..jpg


+ 610 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/index.html

@@ -0,0 +1,610 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <title></title>
+        <link rel="stylesheet" href="css/reset.css" type="text/css">
+        <link rel="stylesheet" href="css/main.css" type="text/css">
+        <link rel="stylesheet" href="css/orientation_utils.css" type="text/css">
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+
+        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui" />
+	<meta name="msapplication-tap-highlight" content="no"/>
+
+        <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
+        <script type="text/javascript" src="js/createjs-2015.11.26.min.js"></script>
+        <script type="text/javascript" src="js/howler.min.js"></script>
+        <script type="text/javascript" src="js/screenfull.js"></script>
+        <script type="text/javascript" src="js/CMain.js"></script>
+        <script type="text/javascript" src="js/ctl_utils.js"></script>
+        <script type="text/javascript" src="js/sprite_lib.js"></script>
+        <script type="text/javascript" src="js/settings.js"></script>
+        <script type="text/javascript" src="js/CLang.js"></script>
+        <script type="text/javascript" src="js/CPreloader.js"></script>
+        <script type="text/javascript" src="js/CToggle.js"></script>
+        <script type="text/javascript" src="js/CGfxButton.js"></script>
+        <script type="text/javascript" src="js/CMenu.js"></script>
+        <script type="text/javascript" src="js/CTextButton.js"></script>
+        <script type="text/javascript" src="js/CGame.js"></script>
+        <script type="text/javascript" src="js/CInterface.js"></script>
+        <script type="text/javascript" src="js/Box2D.js"></script>
+        <script type="text/javascript" src="js/CHelp.js"></script>
+        <script type="text/javascript" src="js/CEndPanel.js"></script>
+        <script type="text/javascript" src="js/CPhysicsController.js"></script>
+        <script type="text/javascript" src="js/CPhysicsObject.js"></script>
+        <script type="text/javascript" src="js/CBasket.js"></script>
+        <script type="text/javascript" src="js/CPlayer.js"></script>
+        <script type="text/javascript" src="js/CObjectToPick.js"></script>
+        <script type="text/javascript" src="js/CLevelMenu.js"></script>
+        <script type="text/javascript" src="js/CLevelBut.js"></script>
+        <script type="text/javascript" src="js/CConfirmPanel.js"></script>
+        <script type="text/javascript" src="js/CCreditsPanel.js"></script>
+        <script type="text/javascript" src="js/CFormatText.js"></script>
+        <script type="text/javascript" src="js/CRollingTextController.js"></script>
+        <script type="text/javascript" src="js/CRollingTextManager.js"></script>
+        <script type="text/javascript" src="js/CTweenController.js"></script>
+        <script type="text/javascript" src="js/CMsgBox.js"></script>
+		<script type="text/javascript" src="../common.js"></script>
+        
+    </head>
+    <body ondragstart="return false;" ondrop="return false;" >
+	<div style="position: fixed; background-color: transparent; top: 0px; left: 0px; width: 100%; height: 100%"></div>
+          <script>
+            $(document).ready(function(){
+				console.log("Ready");
+				//
+				startGame();
+				//
+                     var oMain = new CMain({                                                
+                                           "levels" :     
+                                                [{  //level 1
+                                                    "num_balls" : 5, 
+                                                    "objects_to_pick_to_win" : 25,
+                                                    "objects" : [
+                                                        { "type" : RECTANGLE, "sprite": 0, "x" : 143, "y" : 500, "angle": 90, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 0, "x" : 263, "y" : 500, "angle": 90, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 0, "x" : 383, "y" : 500, "angle": 90, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 0, "x" : 503, "y" : 500, "angle": 90, "density": 3, "friction":1 , "restitution":0.5 }
+                                                    ],
+                                                    "objectsToPick" : [
+                                                        { "type" : 0, "x" : 65, "y" : 320 },
+                                                        { "type" : 1, "x" : 65, "y" : 400 },
+                                                        { "type" : 3, "x" : 65, "y" : 480 },
+                                                        { "type" : 4, "x" : 65, "y" : 560 },
+                                                        { "type" : 5, "x" : 65, "y" : 640 },
+                                                        { "type" : 0, "x" : 187, "y" : 320 },
+                                                        { "type" : 1, "x" : 187, "y" : 400 },
+                                                        { "type" : 5, "x" : 187, "y" : 480 },
+                                                        { "type" : 4, "x" : 187, "y" : 560 },
+                                                        { "type" : 2, "x" : 187, "y" : 640 },
+                                                        { "type" : 0, "x" : 307, "y" : 320 },
+                                                        { "type" : 1, "x" : 307, "y" : 400 },
+                                                        { "type" : 2, "x" : 307, "y" : 480 },
+                                                        { "type" : 4, "x" : 307, "y" : 560 },
+                                                        { "type" : 3, "x" : 307, "y" : 640 },
+                                                        { "type" : 0, "x" : 427, "y" : 320 },
+                                                        { "type" : 1, "x" : 427, "y" : 400 },
+                                                        { "type" : 5, "x" : 427, "y" : 480 },
+                                                        { "type" : 3, "x" : 427, "y" : 560 },
+                                                        { "type" : 5, "x" : 427, "y" : 640 },
+                                                        { "type" : 0, "x" : 547, "y" : 320 },
+                                                        { "type" : 1, "x" : 547, "y" : 400 },
+                                                        { "type" : 1, "x" : 547, "y" : 480 },
+                                                        { "type" : 3, "x" : 547, "y" : 560 },
+                                                        { "type" : 2, "x" : 547, "y" : 640 }
+                                                    ]
+                                                },
+                                                {   //level 2
+                                                    "num_balls" : 5,  
+                                                    "objects_to_pick_to_win" : 12, 
+                                                    "objects" : [
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 143, "y" : 400, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 263, "y" : 400, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 383, "y" : 400, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 503, "y" : 400, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 90,  "y" : 520, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 200, "y" : 520, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 320, "y" : 520, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 440, "y" : 520, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 548, "y" : 520, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 143, "y" : 640, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 263, "y" : 640, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 383, "y" : 640, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 503, "y" : 640, "density": 3, "friction":1 , "restitution":0.5 }
+                                                    ],
+                                                    "objectsToPick" : [
+                                                        { "type" : 0, "x" : 129, "y" : 320 },
+                                                        { "type" : 1, "x" : 249, "y" : 320 },
+                                                        { "type" : 3, "x" : 368, "y" : 320 },
+                                                        { "type" : 3, "x" : 489, "y" : 320 },
+                                                        { "type" : 3, "x" : 75,  "y" : 440 },
+                                                        { "type" : 0, "x" : 185, "y" : 440 },
+                                                        { "type" : 1, "x" : 305, "y" : 440 },
+                                                        { "type" : 3, "x" : 425, "y" : 440 },
+                                                        { "type" : 3, "x" : 540, "y" : 440 },
+                                                        { "type" : 0, "x" : 129, "y" : 560 },
+                                                        { "type" : 1, "x" : 249, "y" : 560 },
+                                                        { "type" : 3, "x" : 368, "y" : 560 },
+                                                        { "type" : 3, "x" : 489, "y" : 560 },
+                                                        { "type" : 3, "x" : 75,  "y" : 690 },
+                                                        { "type" : 0, "x" : 185, "y" : 690 },
+                                                        { "type" : 1, "x" : 305, "y" : 690 },
+                                                        { "type" : 3, "x" : 425, "y" : 690 },
+                                                        { "type" : 3, "x" : 540, "y" : 690 }
+                                                    ]
+                                                },
+                                                {   //level 3
+                                                    "num_balls" : 5, 
+                                                    "objects_to_pick_to_win" : 18,  
+                                                    "objects" : [
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 143, "y" : 350, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 503, "y" : 350, "angle": -45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 220, "y" : 500, "angle": -45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 420, "y" : 500, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 143, "y" : 650, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 503, "y" : 650, "angle": -45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 320, "y" : 590, "density": 3, "friction":1 , "restitution":0.5 }
+                                                    ],
+                                                    "objectsToPick" : [
+                                                        { "type" : 0, "x" : 160, "y" : 290 },
+                                                        { "type" : 1, "x" : 220, "y" : 290 },
+                                                        { "type" : 3, "x" : 305, "y" : 290 },
+                                                        { "type" : 2, "x" : 370, "y" : 290 },
+                                                        { "type" : 3, "x" : 450, "y" : 290 },
+                                                        { "type" : 1, "x" : 305, "y" : 360 },
+                                                        { "type" : 0, "x" : 255, "y" : 430 },
+                                                        { "type" : 1, "x" : 350, "y" : 430 },
+                                                        { "type" : 3, "x" : 455, "y" : 470 },
+                                                        { "type" : 3, "x" : 540, "y" : 510 },
+                                                        { "type" : 0, "x" : 70,  "y" : 510 },
+                                                        { "type" : 1, "x" : 155, "y" : 470 },
+                                                        { "type" : 3, "x" : 305, "y" : 470 },
+                                                        { "type" : 3, "x" : 305, "y" : 520 },
+                                                        { "type" : 3, "x" : 220, "y" : 520 },
+                                                        { "type" : 0, "x" : 380, "y" : 520 },
+                                                        { "type" : 1, "x" : 160, "y" : 610 },
+                                                        { "type" : 3, "x" : 450, "y" : 610 },
+                                                        { "type" : 3, "x" : 75,  "y" : 680 },
+                                                        { "type" : 0, "x" : 185, "y" : 680 },
+                                                        { "type" : 1, "x" : 305, "y" : 680 },
+                                                        { "type" : 3, "x" : 425, "y" : 680 },
+                                                        { "type" : 3, "x" : 540, "y" : 680 }
+                                                    ]
+                                                },
+                                                {   //level 4
+                                                    "num_balls" : 5, 
+                                                    "objects_to_pick_to_win" : 15,  
+                                                    "objects" : [
+                                                        { "type" : RECTANGLE, "sprite": 0, "x" : 503, "y" : 380, "angle": 90, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 0, "x" : 143, "y" : 380, "angle": 90, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 20,  "y" : 480, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 620, "y" : 480, "angle": -45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE, "sprite": 0, "x" : 320, "y" : 480, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE_MOVING, "sprite": 0, "x" : 133, "y" : 650, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE_MOVING, "sprite": 0, "x" : 503, "y" : 650, "angle": -45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 220, "y" : 540, "angle": -55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 242, "y" : 540, "angle": 55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 390, "y" : 540, "angle": -55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 412, "y" : 540, "angle": 55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                    ],
+                                                    "objectsToPick" : [
+                                                        { "type" : 0, "x" : 170, "y" : 290 },
+                                                        { "type" : 1, "x" : 305, "y" : 290 },
+                                                        { "type" : 3, "x" : 445, "y" : 290 },
+                                                        { "type" : 0, "x" : 170, "y" : 350 },
+                                                        { "type" : 1, "x" : 305, "y" : 350 },
+                                                        { "type" : 3, "x" : 445, "y" : 350 },
+                                                        { "type" : 0, "x" : 170, "y" : 410 },
+                                                        { "type" : 1, "x" : 305, "y" : 410 },
+                                                        { "type" : 3, "x" : 445, "y" : 410 },
+                                                        { "type" : 2, "x" : 170, "y" : 470 },
+                                                        { "type" : 3, "x" : 445, "y" : 470 },
+                                                        { "type" : 1, "x" : 60,  "y" : 320 },
+                                                        { "type" : 0, "x" : 60,  "y" : 410 },
+                                                        { "type" : 1, "x" : 550, "y" : 320 },
+                                                        { "type" : 3, "x" : 550, "y" : 410 },
+                                                        { "type" : 3, "x" : 430, "y" : 570 },
+                                                        { "type" : 0, "x" : 460, "y" : 600 },
+                                                        { "type" : 1, "x" : 165, "y" : 570 },
+                                                        { "type" : 3, "x" : 135, "y" : 600 },
+                                                        { "type" : 1, "x" : 260, "y" : 570 },
+                                                        { "type" : 1, "x" : 340, "y" : 570 },
+                                                        { "type" : 3, "x" : 260, "y" : 610 },
+                                                        { "type" : 3, "x" : 340, "y" : 610 },
+                                                        { "type" : 0, "x" : 260, "y" : 650 },
+                                                        { "type" : 1, "x" : 340, "y" : 650 },
+                                                        { "type" : 3, "x" : 300, "y" : 690 }
+                                                    ]
+                                                },
+                                                {   //level 5
+                                                    "num_balls" : 5,   
+                                                    "objects_to_pick_to_win" : 15,
+                                                    "objects" : [
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 100, "y" : 320, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 191, "y" : 322, "angle": -55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 212, "y" : 320, "angle": 55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 313, "y" : 322, "angle": -55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 335, "y" : 320, "angle": 55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 430, "y" : 322, "angle": -55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 452, "y" : 320, "angle": 55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 545, "y" : 322, "angle": -45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 135, "y" : 422, "angle": -55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 157, "y" : 420, "angle": 55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 252, "y" : 422, "angle": -55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 275, "y" : 420, "angle": 55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 368, "y" : 422, "angle": -55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 392, "y" : 420, "angle": 55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 486, "y" : 422, "angle": -55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 509, "y" : 420, "angle": 55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 100, "y" : 520, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 191, "y" : 522, "angle": -55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 212, "y" : 520, "angle": 55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 313, "y" : 522, "angle": -55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 335, "y" : 520, "angle": 55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 430, "y" : 522, "angle": -55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 452, "y" : 520, "angle": 55, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 545, "y" : 522, "angle": -45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 3, "x" : 30, "y" : 370, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 3, "x" : 610, "y" : 370, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 3, "x" : 30, "y" : 470, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 3, "x" : 610, "y" : 470, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 3, "x" : 30, "y" : 570, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 3, "x" : 610, "y" : 570, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 145, "y" : 610, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 268, "y" : 610, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 380, "y" : 610, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 500, "y" : 610, "density": 3, "friction":1 , "restitution":0.5 }
+                                                    ],
+                                                    "objectsToPick" : [
+                                                        { "type" : 0, "x" : 110, "y" : 290 },
+                                                        { "type" : 0, "x" : 155, "y" : 290 },
+                                                        { "type" : 1, "x" : 225, "y" : 290 },
+                                                        { "type" : 3, "x" : 270, "y" : 290 },
+                                                        { "type" : 1, "x" : 344, "y" : 290 },
+                                                        { "type" : 3, "x" : 389, "y" : 290 },
+                                                        { "type" : 0, "x" : 461, "y" : 290 },
+                                                        { "type" : 1, "x" : 506, "y" : 290 },
+                                                        { "type" : 1, "x" : 60,  "y" : 325 },
+                                                        { "type" : 1, "x" : 555, "y" : 325 },
+                                                        { "type" : 1, "x" : 95, "y" : 395 },
+                                                        { "type" : 0, "x" : 170, "y" : 395 },
+                                                        { "type" : 0, "x" : 215, "y" : 395 },
+                                                        { "type" : 1, "x" : 285, "y" : 395 },
+                                                        { "type" : 3, "x" : 330, "y" : 395 },
+                                                        { "type" : 1, "x" : 404, "y" : 395 },
+                                                        { "type" : 3, "x" : 449, "y" : 395 },
+                                                        { "type" : 0, "x" : 521, "y" : 395 },
+                                                        { "type" : 0, "x" : 110, "y" : 490 },
+                                                        { "type" : 0, "x" : 155, "y" : 490 },
+                                                        { "type" : 1, "x" : 225, "y" : 490 },
+                                                        { "type" : 3, "x" : 270, "y" : 490 },
+                                                        { "type" : 1, "x" : 344, "y" : 490 },
+                                                        { "type" : 3, "x" : 389, "y" : 490 },
+                                                        { "type" : 0, "x" : 461, "y" : 490 },
+                                                        { "type" : 1, "x" : 506, "y" : 490 },
+                                                        { "type" : 1, "x" : 60,  "y" : 525 },
+                                                        { "type" : 1, "x" : 555, "y" : 525 },
+                                                        { "type" : 3, "x" : 75,  "y" : 680 },
+                                                        { "type" : 0, "x" : 185, "y" : 680 },
+                                                        { "type" : 1, "x" : 305, "y" : 680 },
+                                                        { "type" : 3, "x" : 425, "y" : 680 },
+                                                        { "type" : 3, "x" : 540, "y" : 680 }
+                                                    ]
+                                                },
+                                                {   //level 6
+                                                    "num_balls" : 5,   
+                                                    "objects_to_pick_to_win" : 20,
+                                                    "objects" : [
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 97,  "y" : 320, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 197, "y" : 320, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 297, "y" : 320, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 397, "y" : 320, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 497, "y" : 320, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 147, "y" : 400, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 247, "y" : 400, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 347, "y" : 400, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 447, "y" : 400, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 0, "x" : 547, "y" : 400, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 3, "x" : 323, "y" : 520, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 3, "x" : 167, "y" : 620, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 3, "x" : 477, "y" : 620, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                    ],
+                                                    "objectsToPick" : [
+                                                        { "type" : 0, "x" : 133, "y" : 307 },
+                                                        { "type" : 1, "x" : 233, "y" : 307 },
+                                                        { "type" : 2, "x" : 333, "y" : 307 },
+                                                        { "type" : 3, "x" : 433, "y" : 307 },
+                                                        { "type" : 0, "x" : 533, "y" : 307 },
+                                                        { "type" : 0, "x" : 85,  "y" : 387 },
+                                                        { "type" : 1, "x" : 185, "y" : 387 },
+                                                        { "type" : 2, "x" : 285, "y" : 387 },
+                                                        { "type" : 3, "x" : 385, "y" : 387 },
+                                                        { "type" : 0, "x" : 485, "y" : 387 },
+                                                        { "type" : 0, "x" : 133, "y" : 467 },
+                                                        { "type" : 1, "x" : 233, "y" : 467 },
+                                                        { "type" : 2, "x" : 333, "y" : 467 },
+                                                        { "type" : 3, "x" : 433, "y" : 467 },
+                                                        { "type" : 0, "x" : 533, "y" : 467 },
+                                                        { "type" : 0, "x" : 85,  "y" : 567 },
+                                                        { "type" : 1, "x" : 185, "y" : 567 },
+                                                        { "type" : 3, "x" : 433, "y" : 567 },
+                                                        { "type" : 0, "x" : 533, "y" : 567 },
+                                                        { "type" : 1, "x" : 305, "y" : 610 },
+                                                        { "type" : 3, "x" : 75,  "y" : 680 },
+                                                        { "type" : 0, "x" : 185, "y" : 710 },
+                                                        { "type" : 1, "x" : 305, "y" : 680 },
+                                                        { "type" : 3, "x" : 425, "y" : 710 },
+                                                        { "type" : 3, "x" : 540, "y" : 680 }
+                                                    ]
+                                                },
+                                                {   //level 7
+                                                    "num_balls" : 5,   
+                                                    "objects_to_pick_to_win" : 20,
+                                                    "objects" : [
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 220, "y" : 360, "angle": 90, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 421, "y" : 360, "angle": 90, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE, "sprite": 1, "x" : 120, "y" : 380, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE, "sprite": 1, "x" : 320, "y" : 380, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE, "sprite": 1, "x" : 520, "y" : 380, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 220, "y" : 560, "angle": 90, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 421, "y" : 560, "angle": 90, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE, "sprite": 1, "x" : 120, "y" : 540, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE, "sprite": 1, "x" : 320, "y" : 540, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE, "sprite": 1, "x" : 520, "y" : 540, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 40, "y" : 650, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 2, "x" : 600, "y" : 650, "angle": -45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 1, "x" : 320, "y" : 680, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 }
+                                                    ],
+                                                    "objectsToPick" : [
+                                                        { "type" : 1, "x" : 108, "y" : 300 },
+                                                        { "type" : 2, "x" : 308, "y" : 300 },
+                                                        { "type" : 3, "x" : 508, "y" : 300 },
+                                                        { "type" : 0, "x" : 60,  "y" : 330 },
+                                                        { "type" : 3, "x" : 155, "y" : 330 },
+                                                        { "type" : 1, "x" : 260, "y" : 330 },
+                                                        { "type" : 0, "x" : 355, "y" : 330 },
+                                                        { "type" : 2, "x" : 460, "y" : 330 },
+                                                        { "type" : 0, "x" : 555, "y" : 330 },
+                                                        { "type" : 0, "x" : 60,  "y" : 410 },
+                                                        { "type" : 3, "x" : 155, "y" : 410 },
+                                                        { "type" : 1, "x" : 260, "y" : 410 },
+                                                        { "type" : 0, "x" : 355, "y" : 410 },
+                                                        { "type" : 2, "x" : 460, "y" : 410 },
+                                                        { "type" : 0, "x" : 555, "y" : 410 },
+                                                        { "type" : 0, "x" : 60,  "y" : 465 },
+                                                        { "type" : 3, "x" : 155, "y" : 465 },
+                                                        { "type" : 1, "x" : 260, "y" : 465 },
+                                                        { "type" : 0, "x" : 355, "y" : 465 },
+                                                        { "type" : 2, "x" : 460, "y" : 465 },
+                                                        { "type" : 0, "x" : 555, "y" : 465 },
+                                                        { "type" : 1, "x" : 108, "y" : 490 },
+                                                        { "type" : 2, "x" : 308, "y" : 490 },
+                                                        { "type" : 3, "x" : 508, "y" : 490 },
+                                                        { "type" : 1, "x" : 108, "y" : 670 },
+                                                        { "type" : 2, "x" : 308, "y" : 620 },
+                                                        { "type" : 3, "x" : 508, "y" : 670 },
+                                                        { "type" : 1, "x" : 260, "y" : 670 },
+                                                        { "type" : 0, "x" : 355, "y" : 670 },
+                                                    ]
+                                                },
+                                                {   //level 8
+                                                    "num_balls" : 5,   
+                                                    "objects_to_pick_to_win" : 18,
+                                                    "objects" : [
+                                                        { "type" : RECTANGLE_MOVING, "sprite": 0, "x" : 320, "y" : 360, "angle": 0, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE_MOVING, "sprite": 0, "x" : 220, "y" : 500, "angle": 0, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE_MOVING, "sprite": 0, "x" : 420, "y" : 500, "angle": 0, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE_MOVING, "sprite": 0, "x" : 170, "y" : 610, "angle": 0, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE_MOVING, "sprite": 2, "x" : 320, "y" : 610, "angle": 0, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE_MOVING, "sprite": 0, "x" : 470, "y" : 610, "angle": 0, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 1, "x" : 142, "y" : 700, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 1, "x" : 262, "y" : 700, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 1, "x" : 382, "y" : 700, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 1, "x" : 502, "y" : 700, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 }
+                                                    ],
+                                                    "objectsToPick" : [
+                                                        { "type" : 3, "x" : 75,  "y" : 320 },
+                                                        { "type" : 0, "x" : 185, "y" : 320 },
+                                                        { "type" : 3, "x" : 425, "y" : 320 },
+                                                        { "type" : 3, "x" : 540, "y" : 320 },
+                                                        { "type" : 0, "x" : 129, "y" : 380 },
+                                                        { "type" : 1, "x" : 249, "y" : 380 },
+                                                        { "type" : 3, "x" : 368, "y" : 380 },
+                                                        { "type" : 3, "x" : 489, "y" : 380 },
+                                                        { "type" : 3, "x" : 75,  "y" : 420 },
+                                                        { "type" : 0, "x" : 185, "y" : 420 },
+                                                        { "type" : 1, "x" : 305, "y" : 420 },
+                                                        { "type" : 3, "x" : 425, "y" : 420 },
+                                                        { "type" : 3, "x" : 540, "y" : 420 },
+                                                        { "type" : 0, "x" : 129, "y" : 545 },
+                                                        { "type" : 1, "x" : 249, "y" : 545 },
+                                                        { "type" : 3, "x" : 368, "y" : 545 },
+                                                        { "type" : 3, "x" : 489, "y" : 545 },
+                                                        { "type" : 3, "x" : 75,  "y" : 660 },
+                                                        { "type" : 0, "x" : 185, "y" : 660 },
+                                                        { "type" : 1, "x" : 305, "y" : 660 },
+                                                        { "type" : 3, "x" : 425, "y" : 660 },
+                                                        { "type" : 3, "x" : 540, "y" : 660 }
+                                                    ]
+                                                },
+                                                {   //level 9
+                                                    "num_balls" : 5, 
+                                                    "objects_to_pick_to_win" : 35,  
+                                                    "objects" : [
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 160, "y" : 360, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 320, "y" : 360, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 480, "y" : 360, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 160, "y" : 480, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 320, "y" : 480, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 480, "y" : 480, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 280, "y" : 600, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : RECTANGLE, "sprite": 1, "x" : 440, "y" : 600, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 }
+                                                    ],
+                                                    "objectsToPick" : [
+                                                        { "type" : 0, "x" : 65,  "y" : 320 },
+                                                        { "type" : 2, "x" : 175, "y" : 320 },
+                                                        { "type" : 1, "x" : 230, "y" : 320 },
+                                                        { "type" : 0, "x" : 330, "y" : 320 },
+                                                        { "type" : 3, "x" : 390, "y" : 320 },
+                                                        { "type" : 1, "x" : 490, "y" : 320 },
+                                                        { "type" : 2, "x" : 550, "y" : 320 },
+                                                        { "type" : 0, "x" : 65,  "y" : 380 },
+                                                        { "type" : 3, "x" : 125, "y" : 380 },
+                                                        { "type" : 2, "x" : 225, "y" : 380 },
+                                                        { "type" : 0, "x" : 280, "y" : 380 },
+                                                        { "type" : 1, "x" : 380, "y" : 380 },
+                                                        { "type" : 2, "x" : 440, "y" : 380 },
+                                                        { "type" : 1, "x" : 550, "y" : 380 },
+                                                        { "type" : 3, "x" : 65,  "y" : 440 },
+                                                        { "type" : 0, "x" : 175, "y" : 440 },
+                                                        { "type" : 1, "x" : 230, "y" : 440 },
+                                                        { "type" : 2, "x" : 330, "y" : 440 },
+                                                        { "type" : 2, "x" : 390, "y" : 440 },
+                                                        { "type" : 3, "x" : 490, "y" : 440 },
+                                                        { "type" : 1, "x" : 550, "y" : 440 },
+                                                        { "type" : 0, "x" : 65,  "y" : 500 },
+                                                        { "type" : 3, "x" : 125, "y" : 500 },
+                                                        { "type" : 1, "x" : 225, "y" : 500 },
+                                                        { "type" : 3, "x" : 280, "y" : 500 },
+                                                        { "type" : 0, "x" : 380, "y" : 500 },
+                                                        { "type" : 2, "x" : 440, "y" : 500 },
+                                                        { "type" : 1, "x" : 550, "y" : 500 },
+                                                        { "type" : 3, "x" : 65,  "y" : 560 },
+                                                        { "type" : 0, "x" : 125, "y" : 560 },
+                                                        { "type" : 2, "x" : 180, "y" : 560 },
+                                                        { "type" : 3, "x" : 290, "y" : 560 },
+                                                        { "type" : 0, "x" : 350, "y" : 560 },
+                                                        { "type" : 1, "x" : 450, "y" : 560 },
+                                                        { "type" : 0, "x" : 500, "y" : 560 },
+                                                        { "type" : 3, "x" : 550, "y" : 560 },
+                                                        { "type" : 2, "x" : 65,  "y" : 620 },
+                                                        { "type" : 0, "x" : 125, "y" : 620 },
+                                                        { "type" : 1, "x" : 180, "y" : 620 },
+                                                        { "type" : 2, "x" : 240, "y" : 620 },
+                                                        { "type" : 0, "x" : 350, "y" : 620 },
+                                                        { "type" : 3, "x" : 410, "y" : 620 },
+                                                        { "type" : 0, "x" : 500, "y" : 620 },
+                                                        { "type" : 1, "x" : 550, "y" : 620 },
+                                                        { "type" : 3, "x" : 65,  "y" : 680 },
+                                                        { "type" : 2, "x" : 125, "y" : 680 },
+                                                        { "type" : 1, "x" : 180, "y" : 680 },
+                                                        { "type" : 0, "x" : 240, "y" : 680 },
+                                                        { "type" : 1, "x" : 300, "y" : 680 },
+                                                        { "type" : 2, "x" : 350, "y" : 680 },
+                                                        { "type" : 0, "x" : 410, "y" : 680 },
+                                                        { "type" : 3, "x" : 455, "y" : 680 },
+                                                        { "type" : 1, "x" : 500, "y" : 680 },
+                                                        { "type" : 2, "x" : 550, "y" : 680 }
+                                                    ]
+                                                },
+                                                {   //level 10
+                                                    "num_balls" : 5,   
+                                                    "objects_to_pick_to_win" : 10,
+                                                    "objects" : [
+                                                        { "type" : RECTANGLE_MOVING, "sprite": 1, "x" : 320, "y" : 360, "angle": 0, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE, "sprite": 0, "x" : 160, "y" : 460, "angle": 0, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : REVOLUTE_RECTANGLE, "sprite": 0, "x" : 480, "y" : 460, "angle": 0, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 1, "x" : 235, "y" : 650, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 },
+                                                        { "type" : CIRCLE, "sprite": 1, "x" : 400, "y" : 650, "angle": 45, "density": 3, "friction":1 , "restitution":0.5 }
+                                                    ],
+                                                    "objectsToPick" : [
+                                                        { "type" : 0, "x" : 305,  "y" : 300 },
+                                                        { "type" : 1, "x" : 148,  "y" : 410 },
+                                                        { "type" : 2, "x" : 468,  "y" : 410 },
+                                                        { "type" : 0, "x" : 50,  "y" : 560 },
+                                                        { "type" : 2, "x" : 50,  "y" : 630 },
+                                                        { "type" : 1, "x" : 50,  "y" : 700 },
+                                                        { "type" : 3, "x" : 305,  "y" : 670 },
+                                                        { "type" : 1, "x" : 570,  "y" : 560 },
+                                                        { "type" : 0, "x" : 570,  "y" : 630 },
+                                                        { "type" : 2, "x" : 570,  "y" : 700 },
+                                                    ]
+                                                }
+                                                ],
+                                                fullscreen:true,        //SET THIS TO FALSE IF YOU DON'T WANT TO SHOW FULLSCREEN BUTTON
+                                                check_orientation:true, //SET TO FALSE IF YOU DON'T WANT TO SHOW ORIENTATION ALERT ON MOBILE DEVICES
+                                           });
+                                           
+                                           
+                    $(oMain).on("start_session", function(evt) {
+						console.log("start_session " );
+                        if(getParamValue('ctl-arcade') === "true"){
+							console.log("start_session " );
+                                parent.__ctlArcadeStartSession();
+                        }   
+                    });
+
+                    $(oMain).on("end_session", function(evt) {
+                           if(getParamValue('ctl-arcade') === "true"){
+                               parent.__ctlArcadeEndSession();
+                           }
+						   console.log("end_session " );
+                    });
+
+                    $(oMain).on("save_score", function(evt,iScore, szMode) {
+						   console.log("save_score " );
+                           if(getParamValue('ctl-arcade') === "true"){
+						   console.log("save_score " );
+                               parent.__ctlArcadeSaveScore({score:iScore, mode: szMode});
+                           }
+                    });
+					
+                    $(oMain).on("restart_level", function(evt, iLevel) {
+						   console.log("restart_level " );
+                           if(getParamValue('ctl-arcade') === "true"){
+                               parent.__ctlArcadeRestartLevel({level:iLevel});
+                           }
+						   
+                    });
+					
+                    $(oMain).on("start_level", function(evt, iLevel) {
+						   console.log("start_level " );
+                           if(getParamValue('ctl-arcade') === "true"){
+                               parent.__ctlArcadeStartLevel({level:iLevel});
+                           } 
+                    });
+
+                    $(oMain).on("end_level", function(evt,iLevel) {
+					
+						   console.log("end_level " );
+						   
+                           if(getParamValue('ctl-arcade') === "true"){
+						    
+                               parent.__ctlArcadeEndLevel({level:iLevel});
+                           }
+						   
+                    });
+
+                    $(oMain).on("show_interlevel_ad", function(evt) {
+                           if(getParamValue('ctl-arcade') === "true"){
+                               parent.__ctlArcadeShowInterlevelAD();
+                           }
+                    });
+                    
+                    $(oMain).on("share_event", function(evt, iScore) {
+                           if(getParamValue('ctl-arcade') === "true"){
+                               parent.__ctlArcadeShareEvent({   img: TEXT_SHARE_IMAGE,
+                                                                title: TEXT_SHARE_TITLE,
+                                                                msg: TEXT_SHARE_MSG1 + iScore + TEXT_SHARE_MSG2,
+                                                                msg_share: TEXT_SHARE_SHARE1 + iScore + TEXT_SHARE_SHARE1});
+                           }
+                    });
+
+                    if(isIOS()){
+                        setTimeout(function(){sizeHandler();},200);
+                    }else{
+                        sizeHandler();
+                    }
+           });
+
+        </script>
+        
+        <div class="check-fonts">
+            <p class="check-font-1">test 1</p>
+        </div> 
+        
+        <canvas id="canvas" class='ani_hack' width="640" height="960"> </canvas>
+        <div data-orientation="portrait" class="orientation-msg-container"><p class="orientation-msg-text">Please rotate your device</p></div>
+        <div id="block_game" style="position: fixed; background-color: transparent; top: 0px; left: 0px; width: 100%; height: 100%; display:none"></div>
+
+    </body>
+</html>

+ 10866 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/Box2D.js

@@ -0,0 +1,10866 @@
+/*
+* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+* 1. The origin of this software must not be misrepresented; you must not
+* claim that you wrote the original software. If you use this software
+* in a product, an acknowledgment in the product documentation would be
+* appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+* misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+*/
+var Box2D = {};
+
+(function (a2j, undefined) {
+
+   if(!(Object.prototype.defineProperty instanceof Function)
+      && Object.prototype.__defineGetter__ instanceof Function
+      && Object.prototype.__defineSetter__ instanceof Function)
+   {
+      Object.defineProperty = function(obj, p, cfg) {
+         if(cfg.get instanceof Function)
+            obj.__defineGetter__(p, cfg.get);
+         if(cfg.set instanceof Function)
+            obj.__defineSetter__(p, cfg.set);
+      }
+   }
+   
+   function emptyFn() {};
+   a2j.inherit = function(cls, base) {
+      var tmpCtr = cls;
+      emptyFn.prototype = base.prototype;
+      cls.prototype = new emptyFn;
+      cls.prototype.constructor = tmpCtr;
+   };
+   
+   a2j.generateCallback = function generateCallback(context, cb) {
+      return function () {
+         cb.apply(context, arguments);
+      };
+   };
+   
+   a2j.NVector = function NVector(length) {
+      if (length === undefined) length = 0;
+      var tmp = new Array(length || 0);
+      for (var i = 0; i < length; ++i)
+      tmp[i] = 0;
+      return tmp;
+   };
+   
+   a2j.is = function is(o1, o2) {
+      if (o1 === null) return false;
+      if ((o2 instanceof Function) && (o1 instanceof o2)) return true;
+      if ((o1.constructor.__implements != undefined) && (o1.constructor.__implements[o2])) return true;
+      return false;
+   };
+   
+   a2j.parseUInt = function(v) {
+      return Math.abs(parseInt(v));
+   }
+   
+})(Box2D);
+
+//#TODO remove assignments from global namespace
+var Vector = Array;
+var Vector_a2j_Number = Box2D.NVector;
+//package structure
+if (typeof(Box2D) === "undefined") Box2D = {};
+if (typeof(Box2D.Collision) === "undefined") Box2D.Collision = {};
+if (typeof(Box2D.Collision.Shapes) === "undefined") Box2D.Collision.Shapes = {};
+if (typeof(Box2D.Common) === "undefined") Box2D.Common = {};
+if (typeof(Box2D.Common.Math) === "undefined") Box2D.Common.Math = {};
+if (typeof(Box2D.Dynamics) === "undefined") Box2D.Dynamics = {};
+if (typeof(Box2D.Dynamics.Contacts) === "undefined") Box2D.Dynamics.Contacts = {};
+if (typeof(Box2D.Dynamics.Controllers) === "undefined") Box2D.Dynamics.Controllers = {};
+if (typeof(Box2D.Dynamics.Joints) === "undefined") Box2D.Dynamics.Joints = {};
+//pre-definitions
+(function () {
+   Box2D.Collision.IBroadPhase = 'Box2D.Collision.IBroadPhase';
+
+   function b2AABB() {
+      b2AABB.b2AABB.apply(this, arguments);
+   };
+   Box2D.Collision.b2AABB = b2AABB;
+
+   function b2Bound() {
+      b2Bound.b2Bound.apply(this, arguments);
+   };
+   Box2D.Collision.b2Bound = b2Bound;
+
+   function b2BoundValues() {
+      b2BoundValues.b2BoundValues.apply(this, arguments);
+      if (this.constructor === b2BoundValues) this.b2BoundValues.apply(this, arguments);
+   };
+   Box2D.Collision.b2BoundValues = b2BoundValues;
+
+   function b2Collision() {
+      b2Collision.b2Collision.apply(this, arguments);
+   };
+   Box2D.Collision.b2Collision = b2Collision;
+
+   function b2ContactID() {
+      b2ContactID.b2ContactID.apply(this, arguments);
+      if (this.constructor === b2ContactID) this.b2ContactID.apply(this, arguments);
+   };
+   Box2D.Collision.b2ContactID = b2ContactID;
+
+   function b2ContactPoint() {
+      b2ContactPoint.b2ContactPoint.apply(this, arguments);
+   };
+   Box2D.Collision.b2ContactPoint = b2ContactPoint;
+
+   function b2Distance() {
+      b2Distance.b2Distance.apply(this, arguments);
+   };
+   Box2D.Collision.b2Distance = b2Distance;
+
+   function b2DistanceInput() {
+      b2DistanceInput.b2DistanceInput.apply(this, arguments);
+   };
+   Box2D.Collision.b2DistanceInput = b2DistanceInput;
+
+   function b2DistanceOutput() {
+      b2DistanceOutput.b2DistanceOutput.apply(this, arguments);
+   };
+   Box2D.Collision.b2DistanceOutput = b2DistanceOutput;
+
+   function b2DistanceProxy() {
+      b2DistanceProxy.b2DistanceProxy.apply(this, arguments);
+   };
+   Box2D.Collision.b2DistanceProxy = b2DistanceProxy;
+
+   function b2DynamicTree() {
+      b2DynamicTree.b2DynamicTree.apply(this, arguments);
+      if (this.constructor === b2DynamicTree) this.b2DynamicTree.apply(this, arguments);
+   };
+   Box2D.Collision.b2DynamicTree = b2DynamicTree;
+
+   function b2DynamicTreeBroadPhase() {
+      b2DynamicTreeBroadPhase.b2DynamicTreeBroadPhase.apply(this, arguments);
+   };
+   Box2D.Collision.b2DynamicTreeBroadPhase = b2DynamicTreeBroadPhase;
+
+   function b2DynamicTreeNode() {
+      b2DynamicTreeNode.b2DynamicTreeNode.apply(this, arguments);
+   };
+   Box2D.Collision.b2DynamicTreeNode = b2DynamicTreeNode;
+
+   function b2DynamicTreePair() {
+      b2DynamicTreePair.b2DynamicTreePair.apply(this, arguments);
+   };
+   Box2D.Collision.b2DynamicTreePair = b2DynamicTreePair;
+
+   function b2Manifold() {
+      b2Manifold.b2Manifold.apply(this, arguments);
+      if (this.constructor === b2Manifold) this.b2Manifold.apply(this, arguments);
+   };
+   Box2D.Collision.b2Manifold = b2Manifold;
+
+   function b2ManifoldPoint() {
+      b2ManifoldPoint.b2ManifoldPoint.apply(this, arguments);
+      if (this.constructor === b2ManifoldPoint) this.b2ManifoldPoint.apply(this, arguments);
+   };
+   Box2D.Collision.b2ManifoldPoint = b2ManifoldPoint;
+
+   function b2Point() {
+      b2Point.b2Point.apply(this, arguments);
+   };
+   Box2D.Collision.b2Point = b2Point;
+
+   function b2RayCastInput() {
+      b2RayCastInput.b2RayCastInput.apply(this, arguments);
+      if (this.constructor === b2RayCastInput) this.b2RayCastInput.apply(this, arguments);
+   };
+   Box2D.Collision.b2RayCastInput = b2RayCastInput;
+
+   function b2RayCastOutput() {
+      b2RayCastOutput.b2RayCastOutput.apply(this, arguments);
+   };
+   Box2D.Collision.b2RayCastOutput = b2RayCastOutput;
+
+   function b2Segment() {
+      b2Segment.b2Segment.apply(this, arguments);
+   };
+   Box2D.Collision.b2Segment = b2Segment;
+
+   function b2SeparationFunction() {
+      b2SeparationFunction.b2SeparationFunction.apply(this, arguments);
+   };
+   Box2D.Collision.b2SeparationFunction = b2SeparationFunction;
+
+   function b2Simplex() {
+      b2Simplex.b2Simplex.apply(this, arguments);
+      if (this.constructor === b2Simplex) this.b2Simplex.apply(this, arguments);
+   };
+   Box2D.Collision.b2Simplex = b2Simplex;
+
+   function b2SimplexCache() {
+      b2SimplexCache.b2SimplexCache.apply(this, arguments);
+   };
+   Box2D.Collision.b2SimplexCache = b2SimplexCache;
+
+   function b2SimplexVertex() {
+      b2SimplexVertex.b2SimplexVertex.apply(this, arguments);
+   };
+   Box2D.Collision.b2SimplexVertex = b2SimplexVertex;
+
+   function b2TimeOfImpact() {
+      b2TimeOfImpact.b2TimeOfImpact.apply(this, arguments);
+   };
+   Box2D.Collision.b2TimeOfImpact = b2TimeOfImpact;
+
+   function b2TOIInput() {
+      b2TOIInput.b2TOIInput.apply(this, arguments);
+   };
+   Box2D.Collision.b2TOIInput = b2TOIInput;
+
+   function b2WorldManifold() {
+      b2WorldManifold.b2WorldManifold.apply(this, arguments);
+      if (this.constructor === b2WorldManifold) this.b2WorldManifold.apply(this, arguments);
+   };
+   Box2D.Collision.b2WorldManifold = b2WorldManifold;
+
+   function ClipVertex() {
+      ClipVertex.ClipVertex.apply(this, arguments);
+   };
+   Box2D.Collision.ClipVertex = ClipVertex;
+
+   function Features() {
+      Features.Features.apply(this, arguments);
+   };
+   Box2D.Collision.Features = Features;
+
+   function b2CircleShape() {
+      b2CircleShape.b2CircleShape.apply(this, arguments);
+      if (this.constructor === b2CircleShape) this.b2CircleShape.apply(this, arguments);
+   };
+   Box2D.Collision.Shapes.b2CircleShape = b2CircleShape;
+
+   function b2EdgeChainDef() {
+      b2EdgeChainDef.b2EdgeChainDef.apply(this, arguments);
+      if (this.constructor === b2EdgeChainDef) this.b2EdgeChainDef.apply(this, arguments);
+   };
+   Box2D.Collision.Shapes.b2EdgeChainDef = b2EdgeChainDef;
+
+   function b2EdgeShape() {
+      b2EdgeShape.b2EdgeShape.apply(this, arguments);
+      if (this.constructor === b2EdgeShape) this.b2EdgeShape.apply(this, arguments);
+   };
+   Box2D.Collision.Shapes.b2EdgeShape = b2EdgeShape;
+
+   function b2MassData() {
+      b2MassData.b2MassData.apply(this, arguments);
+   };
+   Box2D.Collision.Shapes.b2MassData = b2MassData;
+
+   function b2PolygonShape() {
+      b2PolygonShape.b2PolygonShape.apply(this, arguments);
+      if (this.constructor === b2PolygonShape) this.b2PolygonShape.apply(this, arguments);
+   };
+   Box2D.Collision.Shapes.b2PolygonShape = b2PolygonShape;
+
+   function b2Shape() {
+      b2Shape.b2Shape.apply(this, arguments);
+      if (this.constructor === b2Shape) this.b2Shape.apply(this, arguments);
+   };
+   Box2D.Collision.Shapes.b2Shape = b2Shape;
+   Box2D.Common.b2internal = 'Box2D.Common.b2internal';
+
+   function b2Color() {
+      b2Color.b2Color.apply(this, arguments);
+      if (this.constructor === b2Color) this.b2Color.apply(this, arguments);
+   };
+   Box2D.Common.b2Color = b2Color;
+
+   function b2Settings() {
+      b2Settings.b2Settings.apply(this, arguments);
+   };
+   Box2D.Common.b2Settings = b2Settings;
+
+   function b2Mat22() {
+      b2Mat22.b2Mat22.apply(this, arguments);
+      if (this.constructor === b2Mat22) this.b2Mat22.apply(this, arguments);
+   };
+   Box2D.Common.Math.b2Mat22 = b2Mat22;
+
+   function b2Mat33() {
+      b2Mat33.b2Mat33.apply(this, arguments);
+      if (this.constructor === b2Mat33) this.b2Mat33.apply(this, arguments);
+   };
+   Box2D.Common.Math.b2Mat33 = b2Mat33;
+
+   function b2Math() {
+      b2Math.b2Math.apply(this, arguments);
+   };
+   Box2D.Common.Math.b2Math = b2Math;
+
+   function b2Sweep() {
+      b2Sweep.b2Sweep.apply(this, arguments);
+   };
+   Box2D.Common.Math.b2Sweep = b2Sweep;
+
+   function b2Transform() {
+      b2Transform.b2Transform.apply(this, arguments);
+      if (this.constructor === b2Transform) this.b2Transform.apply(this, arguments);
+   };
+   Box2D.Common.Math.b2Transform = b2Transform;
+
+   function b2Vec2() {
+      b2Vec2.b2Vec2.apply(this, arguments);
+      if (this.constructor === b2Vec2) this.b2Vec2.apply(this, arguments);
+   };
+   Box2D.Common.Math.b2Vec2 = b2Vec2;
+
+   function b2Vec3() {
+      b2Vec3.b2Vec3.apply(this, arguments);
+      if (this.constructor === b2Vec3) this.b2Vec3.apply(this, arguments);
+   };
+   Box2D.Common.Math.b2Vec3 = b2Vec3;
+
+   function b2Body() {
+      b2Body.b2Body.apply(this, arguments);
+      if (this.constructor === b2Body) this.b2Body.apply(this, arguments);
+   };
+   Box2D.Dynamics.b2Body = b2Body;
+
+   function b2BodyDef() {
+      b2BodyDef.b2BodyDef.apply(this, arguments);
+      if (this.constructor === b2BodyDef) this.b2BodyDef.apply(this, arguments);
+   };
+   Box2D.Dynamics.b2BodyDef = b2BodyDef;
+
+   function b2ContactFilter() {
+      b2ContactFilter.b2ContactFilter.apply(this, arguments);
+   };
+   Box2D.Dynamics.b2ContactFilter = b2ContactFilter;
+
+   function b2ContactImpulse() {
+      b2ContactImpulse.b2ContactImpulse.apply(this, arguments);
+   };
+   Box2D.Dynamics.b2ContactImpulse = b2ContactImpulse;
+
+   function b2ContactListener() {
+      b2ContactListener.b2ContactListener.apply(this, arguments);
+   };
+   Box2D.Dynamics.b2ContactListener = b2ContactListener;
+
+   function b2ContactManager() {
+      b2ContactManager.b2ContactManager.apply(this, arguments);
+      if (this.constructor === b2ContactManager) this.b2ContactManager.apply(this, arguments);
+   };
+   Box2D.Dynamics.b2ContactManager = b2ContactManager;
+
+   function b2DebugDraw() {
+      b2DebugDraw.b2DebugDraw.apply(this, arguments);
+      if (this.constructor === b2DebugDraw) this.b2DebugDraw.apply(this, arguments);
+   };
+   Box2D.Dynamics.b2DebugDraw = b2DebugDraw;
+
+   function b2DestructionListener() {
+      b2DestructionListener.b2DestructionListener.apply(this, arguments);
+   };
+   Box2D.Dynamics.b2DestructionListener = b2DestructionListener;
+
+   function b2FilterData() {
+      b2FilterData.b2FilterData.apply(this, arguments);
+   };
+   Box2D.Dynamics.b2FilterData = b2FilterData;
+
+   function b2Fixture() {
+      b2Fixture.b2Fixture.apply(this, arguments);
+      if (this.constructor === b2Fixture) this.b2Fixture.apply(this, arguments);
+   };
+   Box2D.Dynamics.b2Fixture = b2Fixture;
+
+   function b2FixtureDef() {
+      b2FixtureDef.b2FixtureDef.apply(this, arguments);
+      if (this.constructor === b2FixtureDef) this.b2FixtureDef.apply(this, arguments);
+   };
+   Box2D.Dynamics.b2FixtureDef = b2FixtureDef;
+
+   function b2Island() {
+      b2Island.b2Island.apply(this, arguments);
+      if (this.constructor === b2Island) this.b2Island.apply(this, arguments);
+   };
+   Box2D.Dynamics.b2Island = b2Island;
+
+   function b2TimeStep() {
+      b2TimeStep.b2TimeStep.apply(this, arguments);
+   };
+   Box2D.Dynamics.b2TimeStep = b2TimeStep;
+
+   function b2World() {
+      b2World.b2World.apply(this, arguments);
+      if (this.constructor === b2World) this.b2World.apply(this, arguments);
+   };
+   Box2D.Dynamics.b2World = b2World;
+
+   function b2CircleContact() {
+      b2CircleContact.b2CircleContact.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2CircleContact = b2CircleContact;
+
+   function b2Contact() {
+      b2Contact.b2Contact.apply(this, arguments);
+      if (this.constructor === b2Contact) this.b2Contact.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2Contact = b2Contact;
+
+   function b2ContactConstraint() {
+      b2ContactConstraint.b2ContactConstraint.apply(this, arguments);
+      if (this.constructor === b2ContactConstraint) this.b2ContactConstraint.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2ContactConstraint = b2ContactConstraint;
+
+   function b2ContactConstraintPoint() {
+      b2ContactConstraintPoint.b2ContactConstraintPoint.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2ContactConstraintPoint = b2ContactConstraintPoint;
+
+   function b2ContactEdge() {
+      b2ContactEdge.b2ContactEdge.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2ContactEdge = b2ContactEdge;
+
+   function b2ContactFactory() {
+      b2ContactFactory.b2ContactFactory.apply(this, arguments);
+      if (this.constructor === b2ContactFactory) this.b2ContactFactory.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2ContactFactory = b2ContactFactory;
+
+   function b2ContactRegister() {
+      b2ContactRegister.b2ContactRegister.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2ContactRegister = b2ContactRegister;
+
+   function b2ContactResult() {
+      b2ContactResult.b2ContactResult.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2ContactResult = b2ContactResult;
+
+   function b2ContactSolver() {
+      b2ContactSolver.b2ContactSolver.apply(this, arguments);
+      if (this.constructor === b2ContactSolver) this.b2ContactSolver.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2ContactSolver = b2ContactSolver;
+
+   function b2EdgeAndCircleContact() {
+      b2EdgeAndCircleContact.b2EdgeAndCircleContact.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2EdgeAndCircleContact = b2EdgeAndCircleContact;
+
+   function b2NullContact() {
+      b2NullContact.b2NullContact.apply(this, arguments);
+      if (this.constructor === b2NullContact) this.b2NullContact.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2NullContact = b2NullContact;
+
+   function b2PolyAndCircleContact() {
+      b2PolyAndCircleContact.b2PolyAndCircleContact.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2PolyAndCircleContact = b2PolyAndCircleContact;
+
+   function b2PolyAndEdgeContact() {
+      b2PolyAndEdgeContact.b2PolyAndEdgeContact.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2PolyAndEdgeContact = b2PolyAndEdgeContact;
+
+   function b2PolygonContact() {
+      b2PolygonContact.b2PolygonContact.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2PolygonContact = b2PolygonContact;
+
+   function b2PositionSolverManifold() {
+      b2PositionSolverManifold.b2PositionSolverManifold.apply(this, arguments);
+      if (this.constructor === b2PositionSolverManifold) this.b2PositionSolverManifold.apply(this, arguments);
+   };
+   Box2D.Dynamics.Contacts.b2PositionSolverManifold = b2PositionSolverManifold;
+
+   function b2BuoyancyController() {
+      b2BuoyancyController.b2BuoyancyController.apply(this, arguments);
+   };
+   Box2D.Dynamics.Controllers.b2BuoyancyController = b2BuoyancyController;
+
+   function b2ConstantAccelController() {
+      b2ConstantAccelController.b2ConstantAccelController.apply(this, arguments);
+   };
+   Box2D.Dynamics.Controllers.b2ConstantAccelController = b2ConstantAccelController;
+
+   function b2ConstantForceController() {
+      b2ConstantForceController.b2ConstantForceController.apply(this, arguments);
+   };
+   Box2D.Dynamics.Controllers.b2ConstantForceController = b2ConstantForceController;
+
+   function b2Controller() {
+      b2Controller.b2Controller.apply(this, arguments);
+   };
+   Box2D.Dynamics.Controllers.b2Controller = b2Controller;
+
+   function b2ControllerEdge() {
+      b2ControllerEdge.b2ControllerEdge.apply(this, arguments);
+   };
+   Box2D.Dynamics.Controllers.b2ControllerEdge = b2ControllerEdge;
+
+   function b2GravityController() {
+      b2GravityController.b2GravityController.apply(this, arguments);
+   };
+   Box2D.Dynamics.Controllers.b2GravityController = b2GravityController;
+
+   function b2TensorDampingController() {
+      b2TensorDampingController.b2TensorDampingController.apply(this, arguments);
+   };
+   Box2D.Dynamics.Controllers.b2TensorDampingController = b2TensorDampingController;
+
+   function b2DistanceJoint() {
+      b2DistanceJoint.b2DistanceJoint.apply(this, arguments);
+      if (this.constructor === b2DistanceJoint) this.b2DistanceJoint.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2DistanceJoint = b2DistanceJoint;
+
+   function b2DistanceJointDef() {
+      b2DistanceJointDef.b2DistanceJointDef.apply(this, arguments);
+      if (this.constructor === b2DistanceJointDef) this.b2DistanceJointDef.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2DistanceJointDef = b2DistanceJointDef;
+
+   function b2FrictionJoint() {
+      b2FrictionJoint.b2FrictionJoint.apply(this, arguments);
+      if (this.constructor === b2FrictionJoint) this.b2FrictionJoint.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2FrictionJoint = b2FrictionJoint;
+
+   function b2FrictionJointDef() {
+      b2FrictionJointDef.b2FrictionJointDef.apply(this, arguments);
+      if (this.constructor === b2FrictionJointDef) this.b2FrictionJointDef.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2FrictionJointDef = b2FrictionJointDef;
+
+   function b2GearJoint() {
+      b2GearJoint.b2GearJoint.apply(this, arguments);
+      if (this.constructor === b2GearJoint) this.b2GearJoint.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2GearJoint = b2GearJoint;
+
+   function b2GearJointDef() {
+      b2GearJointDef.b2GearJointDef.apply(this, arguments);
+      if (this.constructor === b2GearJointDef) this.b2GearJointDef.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2GearJointDef = b2GearJointDef;
+
+   function b2Jacobian() {
+      b2Jacobian.b2Jacobian.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2Jacobian = b2Jacobian;
+
+   function b2Joint() {
+      b2Joint.b2Joint.apply(this, arguments);
+      if (this.constructor === b2Joint) this.b2Joint.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2Joint = b2Joint;
+
+   function b2JointDef() {
+      b2JointDef.b2JointDef.apply(this, arguments);
+      if (this.constructor === b2JointDef) this.b2JointDef.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2JointDef = b2JointDef;
+
+   function b2JointEdge() {
+      b2JointEdge.b2JointEdge.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2JointEdge = b2JointEdge;
+
+   function b2LineJoint() {
+      b2LineJoint.b2LineJoint.apply(this, arguments);
+      if (this.constructor === b2LineJoint) this.b2LineJoint.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2LineJoint = b2LineJoint;
+
+   function b2LineJointDef() {
+      b2LineJointDef.b2LineJointDef.apply(this, arguments);
+      if (this.constructor === b2LineJointDef) this.b2LineJointDef.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2LineJointDef = b2LineJointDef;
+
+   function b2MouseJoint() {
+      b2MouseJoint.b2MouseJoint.apply(this, arguments);
+      if (this.constructor === b2MouseJoint) this.b2MouseJoint.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2MouseJoint = b2MouseJoint;
+
+   function b2MouseJointDef() {
+      b2MouseJointDef.b2MouseJointDef.apply(this, arguments);
+      if (this.constructor === b2MouseJointDef) this.b2MouseJointDef.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2MouseJointDef = b2MouseJointDef;
+
+   function b2PrismaticJoint() {
+      b2PrismaticJoint.b2PrismaticJoint.apply(this, arguments);
+      if (this.constructor === b2PrismaticJoint) this.b2PrismaticJoint.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2PrismaticJoint = b2PrismaticJoint;
+
+   function b2PrismaticJointDef() {
+      b2PrismaticJointDef.b2PrismaticJointDef.apply(this, arguments);
+      if (this.constructor === b2PrismaticJointDef) this.b2PrismaticJointDef.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2PrismaticJointDef = b2PrismaticJointDef;
+
+   function b2PulleyJoint() {
+      b2PulleyJoint.b2PulleyJoint.apply(this, arguments);
+      if (this.constructor === b2PulleyJoint) this.b2PulleyJoint.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2PulleyJoint = b2PulleyJoint;
+
+   function b2PulleyJointDef() {
+      b2PulleyJointDef.b2PulleyJointDef.apply(this, arguments);
+      if (this.constructor === b2PulleyJointDef) this.b2PulleyJointDef.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2PulleyJointDef = b2PulleyJointDef;
+
+   function b2RevoluteJoint() {
+      b2RevoluteJoint.b2RevoluteJoint.apply(this, arguments);
+      if (this.constructor === b2RevoluteJoint) this.b2RevoluteJoint.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2RevoluteJoint = b2RevoluteJoint;
+
+   function b2RevoluteJointDef() {
+      b2RevoluteJointDef.b2RevoluteJointDef.apply(this, arguments);
+      if (this.constructor === b2RevoluteJointDef) this.b2RevoluteJointDef.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2RevoluteJointDef = b2RevoluteJointDef;
+
+   function b2WeldJoint() {
+      b2WeldJoint.b2WeldJoint.apply(this, arguments);
+      if (this.constructor === b2WeldJoint) this.b2WeldJoint.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2WeldJoint = b2WeldJoint;
+
+   function b2WeldJointDef() {
+      b2WeldJointDef.b2WeldJointDef.apply(this, arguments);
+      if (this.constructor === b2WeldJointDef) this.b2WeldJointDef.apply(this, arguments);
+   };
+   Box2D.Dynamics.Joints.b2WeldJointDef = b2WeldJointDef;
+})(); //definitions
+Box2D.postDefs = [];
+(function () {
+   var b2CircleShape = Box2D.Collision.Shapes.b2CircleShape,
+      b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef,
+      b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape,
+      b2MassData = Box2D.Collision.Shapes.b2MassData,
+      b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape,
+      b2Shape = Box2D.Collision.Shapes.b2Shape,
+      b2Color = Box2D.Common.b2Color,
+      b2internal = Box2D.Common.b2internal,
+      b2Settings = Box2D.Common.b2Settings,
+      b2Mat22 = Box2D.Common.Math.b2Mat22,
+      b2Mat33 = Box2D.Common.Math.b2Mat33,
+      b2Math = Box2D.Common.Math.b2Math,
+      b2Sweep = Box2D.Common.Math.b2Sweep,
+      b2Transform = Box2D.Common.Math.b2Transform,
+      b2Vec2 = Box2D.Common.Math.b2Vec2,
+      b2Vec3 = Box2D.Common.Math.b2Vec3,
+      b2AABB = Box2D.Collision.b2AABB,
+      b2Bound = Box2D.Collision.b2Bound,
+      b2BoundValues = Box2D.Collision.b2BoundValues,
+      b2Collision = Box2D.Collision.b2Collision,
+      b2ContactID = Box2D.Collision.b2ContactID,
+      b2ContactPoint = Box2D.Collision.b2ContactPoint,
+      b2Distance = Box2D.Collision.b2Distance,
+      b2DistanceInput = Box2D.Collision.b2DistanceInput,
+      b2DistanceOutput = Box2D.Collision.b2DistanceOutput,
+      b2DistanceProxy = Box2D.Collision.b2DistanceProxy,
+      b2DynamicTree = Box2D.Collision.b2DynamicTree,
+      b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase,
+      b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode,
+      b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair,
+      b2Manifold = Box2D.Collision.b2Manifold,
+      b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint,
+      b2Point = Box2D.Collision.b2Point,
+      b2RayCastInput = Box2D.Collision.b2RayCastInput,
+      b2RayCastOutput = Box2D.Collision.b2RayCastOutput,
+      b2Segment = Box2D.Collision.b2Segment,
+      b2SeparationFunction = Box2D.Collision.b2SeparationFunction,
+      b2Simplex = Box2D.Collision.b2Simplex,
+      b2SimplexCache = Box2D.Collision.b2SimplexCache,
+      b2SimplexVertex = Box2D.Collision.b2SimplexVertex,
+      b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact,
+      b2TOIInput = Box2D.Collision.b2TOIInput,
+      b2WorldManifold = Box2D.Collision.b2WorldManifold,
+      ClipVertex = Box2D.Collision.ClipVertex,
+      Features = Box2D.Collision.Features,
+      IBroadPhase = Box2D.Collision.IBroadPhase;
+
+   b2AABB.b2AABB = function () {
+      this.lowerBound = new b2Vec2();
+      this.upperBound = new b2Vec2();
+   };
+   b2AABB.prototype.IsValid = function () {
+      var dX = this.upperBound.x - this.lowerBound.x;
+      var dY = this.upperBound.y - this.lowerBound.y;
+      var valid = dX >= 0.0 && dY >= 0.0;
+      valid = valid && this.lowerBound.IsValid() && this.upperBound.IsValid();
+      return valid;
+   }
+   b2AABB.prototype.GetCenter = function () {
+      return new b2Vec2((this.lowerBound.x + this.upperBound.x) / 2, (this.lowerBound.y + this.upperBound.y) / 2);
+   }
+   b2AABB.prototype.GetExtents = function () {
+      return new b2Vec2((this.upperBound.x - this.lowerBound.x) / 2, (this.upperBound.y - this.lowerBound.y) / 2);
+   }
+   b2AABB.prototype.Contains = function (aabb) {
+      var result = true;
+      result = result && this.lowerBound.x <= aabb.lowerBound.x;
+      result = result && this.lowerBound.y <= aabb.lowerBound.y;
+      result = result && aabb.upperBound.x <= this.upperBound.x;
+      result = result && aabb.upperBound.y <= this.upperBound.y;
+      return result;
+   }
+   b2AABB.prototype.RayCast = function (output, input) {
+      var tmin = (-Number.MAX_VALUE);
+      var tmax = Number.MAX_VALUE;
+      var pX = input.p1.x;
+      var pY = input.p1.y;
+      var dX = input.p2.x - input.p1.x;
+      var dY = input.p2.y - input.p1.y;
+      var absDX = Math.abs(dX);
+      var absDY = Math.abs(dY);
+      var normal = output.normal;
+      var inv_d = 0;
+      var t1 = 0;
+      var t2 = 0;
+      var t3 = 0;
+      var s = 0; {
+         if (absDX < Number.MIN_VALUE) {
+            if (pX < this.lowerBound.x || this.upperBound.x < pX) return false;
+         }
+         else {
+            inv_d = 1.0 / dX;
+            t1 = (this.lowerBound.x - pX) * inv_d;
+            t2 = (this.upperBound.x - pX) * inv_d;
+            s = (-1.0);
+            if (t1 > t2) {
+               t3 = t1;
+               t1 = t2;
+               t2 = t3;
+               s = 1.0;
+            }
+            if (t1 > tmin) {
+               normal.x = s;
+               normal.y = 0;
+               tmin = t1;
+            }
+            tmax = Math.min(tmax, t2);
+            if (tmin > tmax) return false;
+         }
+      } {
+         if (absDY < Number.MIN_VALUE) {
+            if (pY < this.lowerBound.y || this.upperBound.y < pY) return false;
+         }
+         else {
+            inv_d = 1.0 / dY;
+            t1 = (this.lowerBound.y - pY) * inv_d;
+            t2 = (this.upperBound.y - pY) * inv_d;
+            s = (-1.0);
+            if (t1 > t2) {
+               t3 = t1;
+               t1 = t2;
+               t2 = t3;
+               s = 1.0;
+            }
+            if (t1 > tmin) {
+               normal.y = s;
+               normal.x = 0;
+               tmin = t1;
+            }
+            tmax = Math.min(tmax, t2);
+            if (tmin > tmax) return false;
+         }
+      }
+      output.fraction = tmin;
+      return true;
+   }
+   b2AABB.prototype.TestOverlap = function (other) {
+      var d1X = other.lowerBound.x - this.upperBound.x;
+      var d1Y = other.lowerBound.y - this.upperBound.y;
+      var d2X = this.lowerBound.x - other.upperBound.x;
+      var d2Y = this.lowerBound.y - other.upperBound.y;
+      if (d1X > 0.0 || d1Y > 0.0) return false;
+      if (d2X > 0.0 || d2Y > 0.0) return false;
+      return true;
+   }
+   b2AABB.Combine = function (aabb1, aabb2) {
+      var aabb = new b2AABB();
+      aabb.Combine(aabb1, aabb2);
+      return aabb;
+   }
+   b2AABB.prototype.Combine = function (aabb1, aabb2) {
+      this.lowerBound.x = Math.min(aabb1.lowerBound.x, aabb2.lowerBound.x);
+      this.lowerBound.y = Math.min(aabb1.lowerBound.y, aabb2.lowerBound.y);
+      this.upperBound.x = Math.max(aabb1.upperBound.x, aabb2.upperBound.x);
+      this.upperBound.y = Math.max(aabb1.upperBound.y, aabb2.upperBound.y);
+   }
+   b2Bound.b2Bound = function () {};
+   b2Bound.prototype.IsLower = function () {
+      return (this.value & 1) == 0;
+   }
+   b2Bound.prototype.IsUpper = function () {
+      return (this.value & 1) == 1;
+   }
+   b2Bound.prototype.Swap = function (b) {
+      var tempValue = this.value;
+      var tempProxy = this.proxy;
+      var tempStabbingCount = this.stabbingCount;
+      this.value = b.value;
+      this.proxy = b.proxy;
+      this.stabbingCount = b.stabbingCount;
+      b.value = tempValue;
+      b.proxy = tempProxy;
+      b.stabbingCount = tempStabbingCount;
+   }
+   b2BoundValues.b2BoundValues = function () {};
+   b2BoundValues.prototype.b2BoundValues = function () {
+      this.lowerValues = new Vector_a2j_Number();
+      this.lowerValues[0] = 0.0;
+      this.lowerValues[1] = 0.0;
+      this.upperValues = new Vector_a2j_Number();
+      this.upperValues[0] = 0.0;
+      this.upperValues[1] = 0.0;
+   }
+   b2Collision.b2Collision = function () {};
+   b2Collision.ClipSegmentToLine = function (vOut, vIn, normal, offset) {
+      if (offset === undefined) offset = 0;
+      var cv;
+      var numOut = 0;
+      cv = vIn[0];
+      var vIn0 = cv.v;
+      cv = vIn[1];
+      var vIn1 = cv.v;
+      var distance0 = normal.x * vIn0.x + normal.y * vIn0.y - offset;
+      var distance1 = normal.x * vIn1.x + normal.y * vIn1.y - offset;
+      if (distance0 <= 0.0) vOut[numOut++].Set(vIn[0]);
+      if (distance1 <= 0.0) vOut[numOut++].Set(vIn[1]);
+      if (distance0 * distance1 < 0.0) {
+         var interp = distance0 / (distance0 - distance1);
+         cv = vOut[numOut];
+         var tVec = cv.v;
+         tVec.x = vIn0.x + interp * (vIn1.x - vIn0.x);
+         tVec.y = vIn0.y + interp * (vIn1.y - vIn0.y);
+         cv = vOut[numOut];
+         var cv2;
+         if (distance0 > 0.0) {
+            cv2 = vIn[0];
+            cv.id = cv2.id;
+         }
+         else {
+            cv2 = vIn[1];
+            cv.id = cv2.id;
+         }++numOut;
+      }
+      return numOut;
+   }
+   b2Collision.EdgeSeparation = function (poly1, xf1, edge1, poly2, xf2) {
+      if (edge1 === undefined) edge1 = 0;
+      var count1 = parseInt(poly1.m_vertexCount);
+      var vertices1 = poly1.m_vertices;
+      var normals1 = poly1.m_normals;
+      var count2 = parseInt(poly2.m_vertexCount);
+      var vertices2 = poly2.m_vertices;
+      var tMat;
+      var tVec;
+      tMat = xf1.R;
+      tVec = normals1[edge1];
+      var normal1WorldX = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      var normal1WorldY = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      tMat = xf2.R;
+      var normal1X = (tMat.col1.x * normal1WorldX + tMat.col1.y * normal1WorldY);
+      var normal1Y = (tMat.col2.x * normal1WorldX + tMat.col2.y * normal1WorldY);
+      var index = 0;
+      var minDot = Number.MAX_VALUE;
+      for (var i = 0; i < count2; ++i) {
+         tVec = vertices2[i];
+         var dot = tVec.x * normal1X + tVec.y * normal1Y;
+         if (dot < minDot) {
+            minDot = dot;
+            index = i;
+         }
+      }
+      tVec = vertices1[edge1];
+      tMat = xf1.R;
+      var v1X = xf1.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      var v1Y = xf1.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      tVec = vertices2[index];
+      tMat = xf2.R;
+      var v2X = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      var v2Y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      v2X -= v1X;
+      v2Y -= v1Y;
+      var separation = v2X * normal1WorldX + v2Y * normal1WorldY;
+      return separation;
+   }
+   b2Collision.FindMaxSeparation = function (edgeIndex, poly1, xf1, poly2, xf2) {
+      var count1 = parseInt(poly1.m_vertexCount);
+      var normals1 = poly1.m_normals;
+      var tVec;
+      var tMat;
+      tMat = xf2.R;
+      tVec = poly2.m_centroid;
+      var dX = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      var dY = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      tMat = xf1.R;
+      tVec = poly1.m_centroid;
+      dX -= xf1.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      dY -= xf1.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      var dLocal1X = (dX * xf1.R.col1.x + dY * xf1.R.col1.y);
+      var dLocal1Y = (dX * xf1.R.col2.x + dY * xf1.R.col2.y);
+      var edge = 0;
+      var maxDot = (-Number.MAX_VALUE);
+      for (var i = 0; i < count1; ++i) {
+         tVec = normals1[i];
+         var dot = (tVec.x * dLocal1X + tVec.y * dLocal1Y);
+         if (dot > maxDot) {
+            maxDot = dot;
+            edge = i;
+         }
+      }
+      var s = b2Collision.EdgeSeparation(poly1, xf1, edge, poly2, xf2);
+      var prevEdge = parseInt(edge - 1 >= 0 ? edge - 1 : count1 - 1);
+      var sPrev = b2Collision.EdgeSeparation(poly1, xf1, prevEdge, poly2, xf2);
+      var nextEdge = parseInt(edge + 1 < count1 ? edge + 1 : 0);
+      var sNext = b2Collision.EdgeSeparation(poly1, xf1, nextEdge, poly2, xf2);
+      var bestEdge = 0;
+      var bestSeparation = 0;
+      var increment = 0;
+      if (sPrev > s && sPrev > sNext) {
+         increment = (-1);
+         bestEdge = prevEdge;
+         bestSeparation = sPrev;
+      }
+      else if (sNext > s) {
+         increment = 1;
+         bestEdge = nextEdge;
+         bestSeparation = sNext;
+      }
+      else {
+         edgeIndex[0] = edge;
+         return s;
+      }
+      while (true) {
+         if (increment == (-1)) edge = bestEdge - 1 >= 0 ? bestEdge - 1 : count1 - 1;
+         else edge = bestEdge + 1 < count1 ? bestEdge + 1 : 0;s = b2Collision.EdgeSeparation(poly1, xf1, edge, poly2, xf2);
+         if (s > bestSeparation) {
+            bestEdge = edge;
+            bestSeparation = s;
+         }
+         else {
+            break;
+         }
+      }
+      edgeIndex[0] = bestEdge;
+      return bestSeparation;
+   }
+   b2Collision.FindIncidentEdge = function (c, poly1, xf1, edge1, poly2, xf2) {
+      if (edge1 === undefined) edge1 = 0;
+      var count1 = parseInt(poly1.m_vertexCount);
+      var normals1 = poly1.m_normals;
+      var count2 = parseInt(poly2.m_vertexCount);
+      var vertices2 = poly2.m_vertices;
+      var normals2 = poly2.m_normals;
+      var tMat;
+      var tVec;
+      tMat = xf1.R;
+      tVec = normals1[edge1];
+      var normal1X = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      var normal1Y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      tMat = xf2.R;
+      var tX = (tMat.col1.x * normal1X + tMat.col1.y * normal1Y);
+      normal1Y = (tMat.col2.x * normal1X + tMat.col2.y * normal1Y);
+      normal1X = tX;
+      var index = 0;
+      var minDot = Number.MAX_VALUE;
+      for (var i = 0; i < count2; ++i) {
+         tVec = normals2[i];
+         var dot = (normal1X * tVec.x + normal1Y * tVec.y);
+         if (dot < minDot) {
+            minDot = dot;
+            index = i;
+         }
+      }
+      var tClip;
+      var i1 = parseInt(index);
+      var i2 = parseInt(i1 + 1 < count2 ? i1 + 1 : 0);
+      tClip = c[0];
+      tVec = vertices2[i1];
+      tMat = xf2.R;
+      tClip.v.x = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      tClip.v.y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      tClip.id.features.referenceEdge = edge1;
+      tClip.id.features.incidentEdge = i1;
+      tClip.id.features.incidentVertex = 0;
+      tClip = c[1];
+      tVec = vertices2[i2];
+      tMat = xf2.R;
+      tClip.v.x = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      tClip.v.y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      tClip.id.features.referenceEdge = edge1;
+      tClip.id.features.incidentEdge = i2;
+      tClip.id.features.incidentVertex = 1;
+   }
+   b2Collision.MakeClipPointVector = function () {
+      var r = new Vector(2);
+      r[0] = new ClipVertex();
+      r[1] = new ClipVertex();
+      return r;
+   }
+   b2Collision.CollidePolygons = function (manifold, polyA, xfA, polyB, xfB) {
+      var cv;
+      manifold.m_pointCount = 0;
+      var totalRadius = polyA.m_radius + polyB.m_radius;
+      var edgeA = 0;
+      b2Collision.s_edgeAO[0] = edgeA;
+      var separationA = b2Collision.FindMaxSeparation(b2Collision.s_edgeAO, polyA, xfA, polyB, xfB);
+      edgeA = b2Collision.s_edgeAO[0];
+      if (separationA > totalRadius) return;
+      var edgeB = 0;
+      b2Collision.s_edgeBO[0] = edgeB;
+      var separationB = b2Collision.FindMaxSeparation(b2Collision.s_edgeBO, polyB, xfB, polyA, xfA);
+      edgeB = b2Collision.s_edgeBO[0];
+      if (separationB > totalRadius) return;
+      var poly1;
+      var poly2;
+      var xf1;
+      var xf2;
+      var edge1 = 0;
+      var flip = 0;
+      var k_relativeTol = 0.98;
+      var k_absoluteTol = 0.001;
+      var tMat;
+      if (separationB > k_relativeTol * separationA + k_absoluteTol) {
+         poly1 = polyB;
+         poly2 = polyA;
+         xf1 = xfB;
+         xf2 = xfA;
+         edge1 = edgeB;
+         manifold.m_type = b2Manifold.e_faceB;
+         flip = 1;
+      }
+      else {
+         poly1 = polyA;
+         poly2 = polyB;
+         xf1 = xfA;
+         xf2 = xfB;
+         edge1 = edgeA;
+         manifold.m_type = b2Manifold.e_faceA;
+         flip = 0;
+      }
+      var incidentEdge = b2Collision.s_incidentEdge;
+      b2Collision.FindIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2);
+      var count1 = parseInt(poly1.m_vertexCount);
+      var vertices1 = poly1.m_vertices;
+      var local_v11 = vertices1[edge1];
+      var local_v12;
+      if (edge1 + 1 < count1) {
+         local_v12 = vertices1[parseInt(edge1 + 1)];
+      }
+      else {
+         local_v12 = vertices1[0];
+      }
+      var localTangent = b2Collision.s_localTangent;
+      localTangent.Set(local_v12.x - local_v11.x, local_v12.y - local_v11.y);
+      localTangent.Normalize();
+      var localNormal = b2Collision.s_localNormal;
+      localNormal.x = localTangent.y;
+      localNormal.y = (-localTangent.x);
+      var planePoint = b2Collision.s_planePoint;
+      planePoint.Set(0.5 * (local_v11.x + local_v12.x), 0.5 * (local_v11.y + local_v12.y));
+      var tangent = b2Collision.s_tangent;
+      tMat = xf1.R;
+      tangent.x = (tMat.col1.x * localTangent.x + tMat.col2.x * localTangent.y);
+      tangent.y = (tMat.col1.y * localTangent.x + tMat.col2.y * localTangent.y);
+      var tangent2 = b2Collision.s_tangent2;
+      tangent2.x = (-tangent.x);
+      tangent2.y = (-tangent.y);
+      var normal = b2Collision.s_normal;
+      normal.x = tangent.y;
+      normal.y = (-tangent.x);
+      var v11 = b2Collision.s_v11;
+      var v12 = b2Collision.s_v12;
+      v11.x = xf1.position.x + (tMat.col1.x * local_v11.x + tMat.col2.x * local_v11.y);
+      v11.y = xf1.position.y + (tMat.col1.y * local_v11.x + tMat.col2.y * local_v11.y);
+      v12.x = xf1.position.x + (tMat.col1.x * local_v12.x + tMat.col2.x * local_v12.y);
+      v12.y = xf1.position.y + (tMat.col1.y * local_v12.x + tMat.col2.y * local_v12.y);
+      var frontOffset = normal.x * v11.x + normal.y * v11.y;
+      var sideOffset1 = (-tangent.x * v11.x) - tangent.y * v11.y + totalRadius;
+      var sideOffset2 = tangent.x * v12.x + tangent.y * v12.y + totalRadius;
+      var clipPoints1 = b2Collision.s_clipPoints1;
+      var clipPoints2 = b2Collision.s_clipPoints2;
+      var np = 0;
+      np = b2Collision.ClipSegmentToLine(clipPoints1, incidentEdge, tangent2, sideOffset1);
+      if (np < 2) return;
+      np = b2Collision.ClipSegmentToLine(clipPoints2, clipPoints1, tangent, sideOffset2);
+      if (np < 2) return;
+      manifold.m_localPlaneNormal.SetV(localNormal);
+      manifold.m_localPoint.SetV(planePoint);
+      var pointCount = 0;
+      for (var i = 0; i < b2Settings.b2_maxManifoldPoints; ++i) {
+         cv = clipPoints2[i];
+         var separation = normal.x * cv.v.x + normal.y * cv.v.y - frontOffset;
+         if (separation <= totalRadius) {
+            var cp = manifold.m_points[pointCount];
+            tMat = xf2.R;
+            var tX = cv.v.x - xf2.position.x;
+            var tY = cv.v.y - xf2.position.y;
+            cp.m_localPoint.x = (tX * tMat.col1.x + tY * tMat.col1.y);
+            cp.m_localPoint.y = (tX * tMat.col2.x + tY * tMat.col2.y);
+            cp.m_id.Set(cv.id);
+            cp.m_id.features.flip = flip;
+            ++pointCount;
+         }
+      }
+      manifold.m_pointCount = pointCount;
+   }
+   b2Collision.CollideCircles = function (manifold, circle1, xf1, circle2, xf2) {
+      manifold.m_pointCount = 0;
+      var tMat;
+      var tVec;
+      tMat = xf1.R;
+      tVec = circle1.m_p;
+      var p1X = xf1.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      var p1Y = xf1.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      tMat = xf2.R;
+      tVec = circle2.m_p;
+      var p2X = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      var p2Y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      var dX = p2X - p1X;
+      var dY = p2Y - p1Y;
+      var distSqr = dX * dX + dY * dY;
+      var radius = circle1.m_radius + circle2.m_radius;
+      if (distSqr > radius * radius) {
+         return;
+      }
+      manifold.m_type = b2Manifold.e_circles;
+      manifold.m_localPoint.SetV(circle1.m_p);
+      manifold.m_localPlaneNormal.SetZero();
+      manifold.m_pointCount = 1;
+      manifold.m_points[0].m_localPoint.SetV(circle2.m_p);
+      manifold.m_points[0].m_id.key = 0;
+   }
+   b2Collision.CollidePolygonAndCircle = function (manifold, polygon, xf1, circle, xf2) {
+      manifold.m_pointCount = 0;
+      var tPoint;
+      var dX = 0;
+      var dY = 0;
+      var positionX = 0;
+      var positionY = 0;
+      var tVec;
+      var tMat;
+      tMat = xf2.R;
+      tVec = circle.m_p;
+      var cX = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      var cY = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      dX = cX - xf1.position.x;
+      dY = cY - xf1.position.y;
+      tMat = xf1.R;
+      var cLocalX = (dX * tMat.col1.x + dY * tMat.col1.y);
+      var cLocalY = (dX * tMat.col2.x + dY * tMat.col2.y);
+      var dist = 0;
+      var normalIndex = 0;
+      var separation = (-Number.MAX_VALUE);
+      var radius = polygon.m_radius + circle.m_radius;
+      var vertexCount = parseInt(polygon.m_vertexCount);
+      var vertices = polygon.m_vertices;
+      var normals = polygon.m_normals;
+      for (var i = 0; i < vertexCount; ++i) {
+         tVec = vertices[i];
+         dX = cLocalX - tVec.x;
+         dY = cLocalY - tVec.y;
+         tVec = normals[i];
+         var s = tVec.x * dX + tVec.y * dY;
+         if (s > radius) {
+            return;
+         }
+         if (s > separation) {
+            separation = s;
+            normalIndex = i;
+         }
+      }
+      var vertIndex1 = parseInt(normalIndex);
+      var vertIndex2 = parseInt(vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0);
+      var v1 = vertices[vertIndex1];
+      var v2 = vertices[vertIndex2];
+      if (separation < Number.MIN_VALUE) {
+         manifold.m_pointCount = 1;
+         manifold.m_type = b2Manifold.e_faceA;
+         manifold.m_localPlaneNormal.SetV(normals[normalIndex]);
+         manifold.m_localPoint.x = 0.5 * (v1.x + v2.x);
+         manifold.m_localPoint.y = 0.5 * (v1.y + v2.y);
+         manifold.m_points[0].m_localPoint.SetV(circle.m_p);
+         manifold.m_points[0].m_id.key = 0;
+         return;
+      }
+      var u1 = (cLocalX - v1.x) * (v2.x - v1.x) + (cLocalY - v1.y) * (v2.y - v1.y);
+      var u2 = (cLocalX - v2.x) * (v1.x - v2.x) + (cLocalY - v2.y) * (v1.y - v2.y);
+      if (u1 <= 0.0) {
+         if ((cLocalX - v1.x) * (cLocalX - v1.x) + (cLocalY - v1.y) * (cLocalY - v1.y) > radius * radius) return;
+         manifold.m_pointCount = 1;
+         manifold.m_type = b2Manifold.e_faceA;
+         manifold.m_localPlaneNormal.x = cLocalX - v1.x;
+         manifold.m_localPlaneNormal.y = cLocalY - v1.y;
+         manifold.m_localPlaneNormal.Normalize();
+         manifold.m_localPoint.SetV(v1);
+         manifold.m_points[0].m_localPoint.SetV(circle.m_p);
+         manifold.m_points[0].m_id.key = 0;
+      }
+      else if (u2 <= 0) {
+         if ((cLocalX - v2.x) * (cLocalX - v2.x) + (cLocalY - v2.y) * (cLocalY - v2.y) > radius * radius) return;
+         manifold.m_pointCount = 1;
+         manifold.m_type = b2Manifold.e_faceA;
+         manifold.m_localPlaneNormal.x = cLocalX - v2.x;
+         manifold.m_localPlaneNormal.y = cLocalY - v2.y;
+         manifold.m_localPlaneNormal.Normalize();
+         manifold.m_localPoint.SetV(v2);
+         manifold.m_points[0].m_localPoint.SetV(circle.m_p);
+         manifold.m_points[0].m_id.key = 0;
+      }
+      else {
+         var faceCenterX = 0.5 * (v1.x + v2.x);
+         var faceCenterY = 0.5 * (v1.y + v2.y);
+         separation = (cLocalX - faceCenterX) * normals[vertIndex1].x + (cLocalY - faceCenterY) * normals[vertIndex1].y;
+         if (separation > radius) return;
+         manifold.m_pointCount = 1;
+         manifold.m_type = b2Manifold.e_faceA;
+         manifold.m_localPlaneNormal.x = normals[vertIndex1].x;
+         manifold.m_localPlaneNormal.y = normals[vertIndex1].y;
+         manifold.m_localPlaneNormal.Normalize();
+         manifold.m_localPoint.Set(faceCenterX, faceCenterY);
+         manifold.m_points[0].m_localPoint.SetV(circle.m_p);
+         manifold.m_points[0].m_id.key = 0;
+      }
+   }
+   b2Collision.TestOverlap = function (a, b) {
+      var t1 = b.lowerBound;
+      var t2 = a.upperBound;
+      var d1X = t1.x - t2.x;
+      var d1Y = t1.y - t2.y;
+      t1 = a.lowerBound;
+      t2 = b.upperBound;
+      var d2X = t1.x - t2.x;
+      var d2Y = t1.y - t2.y;
+      if (d1X > 0.0 || d1Y > 0.0) return false;
+      if (d2X > 0.0 || d2Y > 0.0) return false;
+      return true;
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Collision.b2Collision.s_incidentEdge = b2Collision.MakeClipPointVector();
+      Box2D.Collision.b2Collision.s_clipPoints1 = b2Collision.MakeClipPointVector();
+      Box2D.Collision.b2Collision.s_clipPoints2 = b2Collision.MakeClipPointVector();
+      Box2D.Collision.b2Collision.s_edgeAO = new Vector_a2j_Number(1);
+      Box2D.Collision.b2Collision.s_edgeBO = new Vector_a2j_Number(1);
+      Box2D.Collision.b2Collision.s_localTangent = new b2Vec2();
+      Box2D.Collision.b2Collision.s_localNormal = new b2Vec2();
+      Box2D.Collision.b2Collision.s_planePoint = new b2Vec2();
+      Box2D.Collision.b2Collision.s_normal = new b2Vec2();
+      Box2D.Collision.b2Collision.s_tangent = new b2Vec2();
+      Box2D.Collision.b2Collision.s_tangent2 = new b2Vec2();
+      Box2D.Collision.b2Collision.s_v11 = new b2Vec2();
+      Box2D.Collision.b2Collision.s_v12 = new b2Vec2();
+      Box2D.Collision.b2Collision.b2CollidePolyTempVec = new b2Vec2();
+      Box2D.Collision.b2Collision.b2_nullFeature = 0x000000ff;
+   });
+   b2ContactID.b2ContactID = function () {
+      this.features = new Features();
+   };
+   b2ContactID.prototype.b2ContactID = function () {
+      this.features._m_id = this;
+   }
+   b2ContactID.prototype.Set = function (id) {
+      this.key = id._key;
+   }
+   b2ContactID.prototype.Copy = function () {
+      var id = new b2ContactID();
+      id.key = this.key;
+      return id;
+   }
+   Object.defineProperty(b2ContactID.prototype, 'key', {
+      enumerable: false,
+      configurable: true,
+      get: function () {
+         return this._key;
+      }
+   });
+   Object.defineProperty(b2ContactID.prototype, 'key', {
+      enumerable: false,
+      configurable: true,
+      set: function (value) {
+         if (value === undefined) value = 0;
+         this._key = value;
+         this.features._referenceEdge = this._key & 0x000000ff;
+         this.features._incidentEdge = ((this._key & 0x0000ff00) >> 8) & 0x000000ff;
+         this.features._incidentVertex = ((this._key & 0x00ff0000) >> 16) & 0x000000ff;
+         this.features._flip = ((this._key & 0xff000000) >> 24) & 0x000000ff;
+      }
+   });
+   b2ContactPoint.b2ContactPoint = function () {
+      this.position = new b2Vec2();
+      this.velocity = new b2Vec2();
+      this.normal = new b2Vec2();
+      this.id = new b2ContactID();
+   };
+   b2Distance.b2Distance = function () {};
+   b2Distance.Distance = function (output, cache, input) {
+      ++b2Distance.b2_gjkCalls;
+      var proxyA = input.proxyA;
+      var proxyB = input.proxyB;
+      var transformA = input.transformA;
+      var transformB = input.transformB;
+      var simplex = b2Distance.s_simplex;
+      simplex.ReadCache(cache, proxyA, transformA, proxyB, transformB);
+      var vertices = simplex.m_vertices;
+      var k_maxIters = 20;
+      var saveA = b2Distance.s_saveA;
+      var saveB = b2Distance.s_saveB;
+      var saveCount = 0;
+      var closestPoint = simplex.GetClosestPoint();
+      var distanceSqr1 = closestPoint.LengthSquared();
+      var distanceSqr2 = distanceSqr1;
+      var i = 0;
+      var p;
+      var iter = 0;
+      while (iter < k_maxIters) {
+         saveCount = simplex.m_count;
+         for (i = 0;
+         i < saveCount; i++) {
+            saveA[i] = vertices[i].indexA;
+            saveB[i] = vertices[i].indexB;
+         }
+         switch (simplex.m_count) {
+         case 1:
+            break;
+         case 2:
+            simplex.Solve2();
+            break;
+         case 3:
+            simplex.Solve3();
+            break;
+         default:
+            b2Settings.b2Assert(false);
+         }
+         if (simplex.m_count == 3) {
+            break;
+         }
+         p = simplex.GetClosestPoint();
+         distanceSqr2 = p.LengthSquared();
+         if (distanceSqr2 > distanceSqr1) {}
+         distanceSqr1 = distanceSqr2;
+         var d = simplex.GetSearchDirection();
+         if (d.LengthSquared() < Number.MIN_VALUE * Number.MIN_VALUE) {
+            break;
+         }
+         var vertex = vertices[simplex.m_count];
+         vertex.indexA = proxyA.GetSupport(b2Math.MulTMV(transformA.R, d.GetNegative()));
+         vertex.wA = b2Math.MulX(transformA, proxyA.GetVertex(vertex.indexA));
+         vertex.indexB = proxyB.GetSupport(b2Math.MulTMV(transformB.R, d));
+         vertex.wB = b2Math.MulX(transformB, proxyB.GetVertex(vertex.indexB));
+         vertex.w = b2Math.SubtractVV(vertex.wB, vertex.wA);
+         ++iter;
+         ++b2Distance.b2_gjkIters;
+         var duplicate = false;
+         for (i = 0;
+         i < saveCount; i++) {
+            if (vertex.indexA == saveA[i] && vertex.indexB == saveB[i]) {
+               duplicate = true;
+               break;
+            }
+         }
+         if (duplicate) {
+            break;
+         }++simplex.m_count;
+      }
+      b2Distance.b2_gjkMaxIters = b2Math.Max(b2Distance.b2_gjkMaxIters, iter);
+      simplex.GetWitnessPoints(output.pointA, output.pointB);
+      output.distance = b2Math.SubtractVV(output.pointA, output.pointB).Length();
+      output.iterations = iter;
+      simplex.WriteCache(cache);
+      if (input.useRadii) {
+         var rA = proxyA.m_radius;
+         var rB = proxyB.m_radius;
+         if (output.distance > rA + rB && output.distance > Number.MIN_VALUE) {
+            output.distance -= rA + rB;
+            var normal = b2Math.SubtractVV(output.pointB, output.pointA);
+            normal.Normalize();
+            output.pointA.x += rA * normal.x;
+            output.pointA.y += rA * normal.y;
+            output.pointB.x -= rB * normal.x;
+            output.pointB.y -= rB * normal.y;
+         }
+         else {
+            p = new b2Vec2();
+            p.x = .5 * (output.pointA.x + output.pointB.x);
+            p.y = .5 * (output.pointA.y + output.pointB.y);
+            output.pointA.x = output.pointB.x = p.x;
+            output.pointA.y = output.pointB.y = p.y;
+            output.distance = 0.0;
+         }
+      }
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Collision.b2Distance.s_simplex = new b2Simplex();
+      Box2D.Collision.b2Distance.s_saveA = new Vector_a2j_Number(3);
+      Box2D.Collision.b2Distance.s_saveB = new Vector_a2j_Number(3);
+   });
+   b2DistanceInput.b2DistanceInput = function () {};
+   b2DistanceOutput.b2DistanceOutput = function () {
+      this.pointA = new b2Vec2();
+      this.pointB = new b2Vec2();
+   };
+   b2DistanceProxy.b2DistanceProxy = function () {};
+   b2DistanceProxy.prototype.Set = function (shape) {
+      switch (shape.GetType()) {
+      case b2Shape.e_circleShape:
+         {
+            var circle = (shape instanceof b2CircleShape ? shape : null);
+            this.m_vertices = new Vector(1, true);
+            this.m_vertices[0] = circle.m_p;
+            this.m_count = 1;
+            this.m_radius = circle.m_radius;
+         }
+         break;
+      case b2Shape.e_polygonShape:
+         {
+            var polygon = (shape instanceof b2PolygonShape ? shape : null);
+            this.m_vertices = polygon.m_vertices;
+            this.m_count = polygon.m_vertexCount;
+            this.m_radius = polygon.m_radius;
+         }
+         break;
+      default:
+         b2Settings.b2Assert(false);
+      }
+   }
+   b2DistanceProxy.prototype.GetSupport = function (d) {
+      var bestIndex = 0;
+      var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y;
+      for (var i = 1; i < this.m_count; ++i) {
+         var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y;
+         if (value > bestValue) {
+            bestIndex = i;
+            bestValue = value;
+         }
+      }
+      return bestIndex;
+   }
+   b2DistanceProxy.prototype.GetSupportVertex = function (d) {
+      var bestIndex = 0;
+      var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y;
+      for (var i = 1; i < this.m_count; ++i) {
+         var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y;
+         if (value > bestValue) {
+            bestIndex = i;
+            bestValue = value;
+         }
+      }
+      return this.m_vertices[bestIndex];
+   }
+   b2DistanceProxy.prototype.GetVertexCount = function () {
+      return this.m_count;
+   }
+   b2DistanceProxy.prototype.GetVertex = function (index) {
+      if (index === undefined) index = 0;
+      b2Settings.b2Assert(0 <= index && index < this.m_count);
+      return this.m_vertices[index];
+   }
+   b2DynamicTree.b2DynamicTree = function () {};
+   b2DynamicTree.prototype.b2DynamicTree = function () {
+      this.m_root = null;
+      this.m_freeList = null;
+      this.m_path = 0;
+      this.m_insertionCount = 0;
+   }
+   b2DynamicTree.prototype.CreateProxy = function (aabb, userData) {
+      var node = this.AllocateNode();
+      var extendX = b2Settings.b2_aabbExtension;
+      var extendY = b2Settings.b2_aabbExtension;
+      node.aabb.lowerBound.x = aabb.lowerBound.x - extendX;
+      node.aabb.lowerBound.y = aabb.lowerBound.y - extendY;
+      node.aabb.upperBound.x = aabb.upperBound.x + extendX;
+      node.aabb.upperBound.y = aabb.upperBound.y + extendY;
+      node.userData = userData;
+      this.InsertLeaf(node);
+      return node;
+   }
+   b2DynamicTree.prototype.DestroyProxy = function (proxy) {
+      this.RemoveLeaf(proxy);
+      this.FreeNode(proxy);
+   }
+   b2DynamicTree.prototype.MoveProxy = function (proxy, aabb, displacement) {
+      b2Settings.b2Assert(proxy.IsLeaf());
+      if (proxy.aabb.Contains(aabb)) {
+         return false;
+      }
+      this.RemoveLeaf(proxy);
+      var extendX = b2Settings.b2_aabbExtension + b2Settings.b2_aabbMultiplier * (displacement.x > 0 ? displacement.x : (-displacement.x));
+      var extendY = b2Settings.b2_aabbExtension + b2Settings.b2_aabbMultiplier * (displacement.y > 0 ? displacement.y : (-displacement.y));
+      proxy.aabb.lowerBound.x = aabb.lowerBound.x - extendX;
+      proxy.aabb.lowerBound.y = aabb.lowerBound.y - extendY;
+      proxy.aabb.upperBound.x = aabb.upperBound.x + extendX;
+      proxy.aabb.upperBound.y = aabb.upperBound.y + extendY;
+      this.InsertLeaf(proxy);
+      return true;
+   }
+   b2DynamicTree.prototype.Rebalance = function (iterations) {
+      if (iterations === undefined) iterations = 0;
+      if (this.m_root == null) return;
+      for (var i = 0; i < iterations; i++) {
+         var node = this.m_root;
+         var bit = 0;
+         while (node.IsLeaf() == false) {
+            node = (this.m_path >> bit) & 1 ? node.child2 : node.child1;
+            bit = (bit + 1) & 31;
+         }++this.m_path;
+         this.RemoveLeaf(node);
+         this.InsertLeaf(node);
+      }
+   }
+   b2DynamicTree.prototype.GetFatAABB = function (proxy) {
+      return proxy.aabb;
+   }
+   b2DynamicTree.prototype.GetUserData = function (proxy) {
+      return proxy.userData;
+   }
+   b2DynamicTree.prototype.Query = function (callback, aabb) {
+      if (this.m_root == null) return;
+      var stack = new Vector();
+      var count = 0;
+      stack[count++] = this.m_root;
+      while (count > 0) {
+         var node = stack[--count];
+         if (node.aabb.TestOverlap(aabb)) {
+            if (node.IsLeaf()) {
+               var proceed = callback(node);
+               if (!proceed) return;
+            }
+            else {
+               stack[count++] = node.child1;
+               stack[count++] = node.child2;
+            }
+         }
+      }
+   }
+   b2DynamicTree.prototype.RayCast = function (callback, input) {
+      if (this.m_root == null) return;
+      var p1 = input.p1;
+      var p2 = input.p2;
+      var r = b2Math.SubtractVV(p1, p2);
+      r.Normalize();
+      var v = b2Math.CrossFV(1.0, r);
+      var abs_v = b2Math.AbsV(v);
+      var maxFraction = input.maxFraction;
+      var segmentAABB = new b2AABB();
+      var tX = 0;
+      var tY = 0; {
+         tX = p1.x + maxFraction * (p2.x - p1.x);
+         tY = p1.y + maxFraction * (p2.y - p1.y);
+         segmentAABB.lowerBound.x = Math.min(p1.x, tX);
+         segmentAABB.lowerBound.y = Math.min(p1.y, tY);
+         segmentAABB.upperBound.x = Math.max(p1.x, tX);
+         segmentAABB.upperBound.y = Math.max(p1.y, tY);
+      }
+      var stack = new Vector();
+      var count = 0;
+      stack[count++] = this.m_root;
+      while (count > 0) {
+         var node = stack[--count];
+         if (node.aabb.TestOverlap(segmentAABB) == false) {
+            continue;
+         }
+         var c = node.aabb.GetCenter();
+         var h = node.aabb.GetExtents();
+         var separation = Math.abs(v.x * (p1.x - c.x) + v.y * (p1.y - c.y)) - abs_v.x * h.x - abs_v.y * h.y;
+         if (separation > 0.0) continue;
+         if (node.IsLeaf()) {
+            var subInput = new b2RayCastInput();
+            subInput.p1 = input.p1;
+            subInput.p2 = input.p2;
+            subInput.maxFraction = input.maxFraction;
+            maxFraction = callback(subInput, node);
+            if (maxFraction == 0.0) return;
+            if (maxFraction > 0.0) {
+               tX = p1.x + maxFraction * (p2.x - p1.x);
+               tY = p1.y + maxFraction * (p2.y - p1.y);
+               segmentAABB.lowerBound.x = Math.min(p1.x, tX);
+               segmentAABB.lowerBound.y = Math.min(p1.y, tY);
+               segmentAABB.upperBound.x = Math.max(p1.x, tX);
+               segmentAABB.upperBound.y = Math.max(p1.y, tY);
+            }
+         }
+         else {
+            stack[count++] = node.child1;
+            stack[count++] = node.child2;
+         }
+      }
+   }
+   b2DynamicTree.prototype.AllocateNode = function () {
+      if (this.m_freeList) {
+         var node = this.m_freeList;
+         this.m_freeList = node.parent;
+         node.parent = null;
+         node.child1 = null;
+         node.child2 = null;
+         return node;
+      }
+      return new b2DynamicTreeNode();
+   }
+   b2DynamicTree.prototype.FreeNode = function (node) {
+      node.parent = this.m_freeList;
+      this.m_freeList = node;
+   }
+   b2DynamicTree.prototype.InsertLeaf = function (leaf) {
+      ++this.m_insertionCount;
+      if (this.m_root == null) {
+         this.m_root = leaf;
+         this.m_root.parent = null;
+         return;
+      }
+      var center = leaf.aabb.GetCenter();
+      var sibling = this.m_root;
+      if (sibling.IsLeaf() == false) {
+         do {
+            var child1 = sibling.child1;
+            var child2 = sibling.child2;
+            var norm1 = Math.abs((child1.aabb.lowerBound.x + child1.aabb.upperBound.x) / 2 - center.x) + Math.abs((child1.aabb.lowerBound.y + child1.aabb.upperBound.y) / 2 - center.y);
+            var norm2 = Math.abs((child2.aabb.lowerBound.x + child2.aabb.upperBound.x) / 2 - center.x) + Math.abs((child2.aabb.lowerBound.y + child2.aabb.upperBound.y) / 2 - center.y);
+            if (norm1 < norm2) {
+               sibling = child1;
+            }
+            else {
+               sibling = child2;
+            }
+         }
+         while (sibling.IsLeaf() == false)
+      }
+      var node1 = sibling.parent;
+      var node2 = this.AllocateNode();
+      node2.parent = node1;
+      node2.userData = null;
+      node2.aabb.Combine(leaf.aabb, sibling.aabb);
+      if (node1) {
+         if (sibling.parent.child1 == sibling) {
+            node1.child1 = node2;
+         }
+         else {
+            node1.child2 = node2;
+         }
+         node2.child1 = sibling;
+         node2.child2 = leaf;
+         sibling.parent = node2;
+         leaf.parent = node2;
+         do {
+            if (node1.aabb.Contains(node2.aabb)) break;
+            node1.aabb.Combine(node1.child1.aabb, node1.child2.aabb);
+            node2 = node1;
+            node1 = node1.parent;
+         }
+         while (node1)
+      }
+      else {
+         node2.child1 = sibling;
+         node2.child2 = leaf;
+         sibling.parent = node2;
+         leaf.parent = node2;
+         this.m_root = node2;
+      }
+   }
+   b2DynamicTree.prototype.RemoveLeaf = function (leaf) {
+      if (leaf == this.m_root) {
+         this.m_root = null;
+         return;
+      }
+      var node2 = leaf.parent;
+      var node1 = node2.parent;
+      var sibling;
+      if (node2.child1 == leaf) {
+         sibling = node2.child2;
+      }
+      else {
+         sibling = node2.child1;
+      }
+      if (node1) {
+         if (node1.child1 == node2) {
+            node1.child1 = sibling;
+         }
+         else {
+            node1.child2 = sibling;
+         }
+         sibling.parent = node1;
+         this.FreeNode(node2);
+         while (node1) {
+            var oldAABB = node1.aabb;
+            node1.aabb = b2AABB.Combine(node1.child1.aabb, node1.child2.aabb);
+            if (oldAABB.Contains(node1.aabb)) break;
+            node1 = node1.parent;
+         }
+      }
+      else {
+         this.m_root = sibling;
+         sibling.parent = null;
+         this.FreeNode(node2);
+      }
+   }
+   b2DynamicTreeBroadPhase.b2DynamicTreeBroadPhase = function () {
+      this.m_tree = new b2DynamicTree();
+      this.m_moveBuffer = new Vector();
+      this.m_pairBuffer = new Vector();
+      this.m_pairCount = 0;
+   };
+   b2DynamicTreeBroadPhase.prototype.CreateProxy = function (aabb, userData) {
+      var proxy = this.m_tree.CreateProxy(aabb, userData);
+      ++this.m_proxyCount;
+      this.BufferMove(proxy);
+      return proxy;
+   }
+   b2DynamicTreeBroadPhase.prototype.DestroyProxy = function (proxy) {
+      this.UnBufferMove(proxy);
+      --this.m_proxyCount;
+      this.m_tree.DestroyProxy(proxy);
+   }
+   b2DynamicTreeBroadPhase.prototype.MoveProxy = function (proxy, aabb, displacement) {
+      var buffer = this.m_tree.MoveProxy(proxy, aabb, displacement);
+      if (buffer) {
+         this.BufferMove(proxy);
+      }
+   }
+   b2DynamicTreeBroadPhase.prototype.TestOverlap = function (proxyA, proxyB) {
+      var aabbA = this.m_tree.GetFatAABB(proxyA);
+      var aabbB = this.m_tree.GetFatAABB(proxyB);
+      return aabbA.TestOverlap(aabbB);
+   }
+   b2DynamicTreeBroadPhase.prototype.GetUserData = function (proxy) {
+      return this.m_tree.GetUserData(proxy);
+   }
+   b2DynamicTreeBroadPhase.prototype.GetFatAABB = function (proxy) {
+      return this.m_tree.GetFatAABB(proxy);
+   }
+   b2DynamicTreeBroadPhase.prototype.GetProxyCount = function () {
+      return this.m_proxyCount;
+   }
+   b2DynamicTreeBroadPhase.prototype.UpdatePairs = function (callback) {
+      var __this = this;
+      __this.m_pairCount = 0;
+      var i = 0,
+         queryProxy;
+      for (i = 0;
+      i < __this.m_moveBuffer.length; ++i) {
+         queryProxy = __this.m_moveBuffer[i];
+
+         function QueryCallback(proxy) {
+            if (proxy == queryProxy) return true;
+            if (__this.m_pairCount == __this.m_pairBuffer.length) {
+               __this.m_pairBuffer[__this.m_pairCount] = new b2DynamicTreePair();
+            }
+            var pair = __this.m_pairBuffer[__this.m_pairCount];
+            pair.proxyA = proxy < queryProxy ? proxy : queryProxy;
+            pair.proxyB = proxy >= queryProxy ? proxy : queryProxy;++__this.m_pairCount;
+            return true;
+         };
+         var fatAABB = __this.m_tree.GetFatAABB(queryProxy);
+         __this.m_tree.Query(QueryCallback, fatAABB);
+      }
+      __this.m_moveBuffer.length = 0;
+      for (var i = 0; i < __this.m_pairCount;) {
+         var primaryPair = __this.m_pairBuffer[i];
+         var userDataA = __this.m_tree.GetUserData(primaryPair.proxyA);
+         var userDataB = __this.m_tree.GetUserData(primaryPair.proxyB);
+         callback(userDataA, userDataB);
+         ++i;
+         while (i < __this.m_pairCount) {
+            var pair = __this.m_pairBuffer[i];
+            if (pair.proxyA != primaryPair.proxyA || pair.proxyB != primaryPair.proxyB) {
+               break;
+            }++i;
+         }
+      }
+   }
+   b2DynamicTreeBroadPhase.prototype.Query = function (callback, aabb) {
+      this.m_tree.Query(callback, aabb);
+   }
+   b2DynamicTreeBroadPhase.prototype.RayCast = function (callback, input) {
+      this.m_tree.RayCast(callback, input);
+   }
+   b2DynamicTreeBroadPhase.prototype.Validate = function () {}
+   b2DynamicTreeBroadPhase.prototype.Rebalance = function (iterations) {
+      if (iterations === undefined) iterations = 0;
+      this.m_tree.Rebalance(iterations);
+   }
+   b2DynamicTreeBroadPhase.prototype.BufferMove = function (proxy) {
+      this.m_moveBuffer[this.m_moveBuffer.length] = proxy;
+   }
+   b2DynamicTreeBroadPhase.prototype.UnBufferMove = function (proxy) {
+      var i = parseInt(this.m_moveBuffer.indexOf(proxy));
+      this.m_moveBuffer.splice(i, 1);
+   }
+   b2DynamicTreeBroadPhase.prototype.ComparePairs = function (pair1, pair2) {
+      return 0;
+   }
+   b2DynamicTreeBroadPhase.__implements = {};
+   b2DynamicTreeBroadPhase.__implements[IBroadPhase] = true;
+   b2DynamicTreeNode.b2DynamicTreeNode = function () {
+      this.aabb = new b2AABB();
+   };
+   b2DynamicTreeNode.prototype.IsLeaf = function () {
+      return this.child1 == null;
+   }
+   b2DynamicTreePair.b2DynamicTreePair = function () {};
+   b2Manifold.b2Manifold = function () {
+      this.m_pointCount = 0;
+   };
+   b2Manifold.prototype.b2Manifold = function () {
+      this.m_points = new Vector(b2Settings.b2_maxManifoldPoints);
+      for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) {
+         this.m_points[i] = new b2ManifoldPoint();
+      }
+      this.m_localPlaneNormal = new b2Vec2();
+      this.m_localPoint = new b2Vec2();
+   }
+   b2Manifold.prototype.Reset = function () {
+      for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) {
+         ((this.m_points[i] instanceof b2ManifoldPoint ? this.m_points[i] : null)).Reset();
+      }
+      this.m_localPlaneNormal.SetZero();
+      this.m_localPoint.SetZero();
+      this.m_type = 0;
+      this.m_pointCount = 0;
+   }
+   b2Manifold.prototype.Set = function (m) {
+      this.m_pointCount = m.m_pointCount;
+      for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) {
+         ((this.m_points[i] instanceof b2ManifoldPoint ? this.m_points[i] : null)).Set(m.m_points[i]);
+      }
+      this.m_localPlaneNormal.SetV(m.m_localPlaneNormal);
+      this.m_localPoint.SetV(m.m_localPoint);
+      this.m_type = m.m_type;
+   }
+   b2Manifold.prototype.Copy = function () {
+      var copy = new b2Manifold();
+      copy.Set(this);
+      return copy;
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Collision.b2Manifold.e_circles = 0x0001;
+      Box2D.Collision.b2Manifold.e_faceA = 0x0002;
+      Box2D.Collision.b2Manifold.e_faceB = 0x0004;
+   });
+   b2ManifoldPoint.b2ManifoldPoint = function () {
+      this.m_localPoint = new b2Vec2();
+      this.m_id = new b2ContactID();
+   };
+   b2ManifoldPoint.prototype.b2ManifoldPoint = function () {
+      this.Reset();
+   }
+   b2ManifoldPoint.prototype.Reset = function () {
+      this.m_localPoint.SetZero();
+      this.m_normalImpulse = 0.0;
+      this.m_tangentImpulse = 0.0;
+      this.m_id.key = 0;
+   }
+   b2ManifoldPoint.prototype.Set = function (m) {
+      this.m_localPoint.SetV(m.m_localPoint);
+      this.m_normalImpulse = m.m_normalImpulse;
+      this.m_tangentImpulse = m.m_tangentImpulse;
+      this.m_id.Set(m.m_id);
+   }
+   b2Point.b2Point = function () {
+      this.p = new b2Vec2();
+   };
+   b2Point.prototype.Support = function (xf, vX, vY) {
+      if (vX === undefined) vX = 0;
+      if (vY === undefined) vY = 0;
+      return this.p;
+   }
+   b2Point.prototype.GetFirstVertex = function (xf) {
+      return this.p;
+   }
+   b2RayCastInput.b2RayCastInput = function () {
+      this.p1 = new b2Vec2();
+      this.p2 = new b2Vec2();
+   };
+   b2RayCastInput.prototype.b2RayCastInput = function (p1, p2, maxFraction) {
+      if (p1 === undefined) p1 = null;
+      if (p2 === undefined) p2 = null;
+      if (maxFraction === undefined) maxFraction = 1;
+      if (p1) this.p1.SetV(p1);
+      if (p2) this.p2.SetV(p2);
+      this.maxFraction = maxFraction;
+   }
+   b2RayCastOutput.b2RayCastOutput = function () {
+      this.normal = new b2Vec2();
+   };
+   b2Segment.b2Segment = function () {
+      this.p1 = new b2Vec2();
+      this.p2 = new b2Vec2();
+   };
+   b2Segment.prototype.TestSegment = function (lambda, normal, segment, maxLambda) {
+      if (maxLambda === undefined) maxLambda = 0;
+      var s = segment.p1;
+      var rX = segment.p2.x - s.x;
+      var rY = segment.p2.y - s.y;
+      var dX = this.p2.x - this.p1.x;
+      var dY = this.p2.y - this.p1.y;
+      var nX = dY;
+      var nY = (-dX);
+      var k_slop = 100.0 * Number.MIN_VALUE;
+      var denom = (-(rX * nX + rY * nY));
+      if (denom > k_slop) {
+         var bX = s.x - this.p1.x;
+         var bY = s.y - this.p1.y;
+         var a = (bX * nX + bY * nY);
+         if (0.0 <= a && a <= maxLambda * denom) {
+            var mu2 = (-rX * bY) + rY * bX;
+            if ((-k_slop * denom) <= mu2 && mu2 <= denom * (1.0 + k_slop)) {
+               a /= denom;
+               var nLen = Math.sqrt(nX * nX + nY * nY);
+               nX /= nLen;
+               nY /= nLen;
+               lambda[0] = a;
+               normal.Set(nX, nY);
+               return true;
+            }
+         }
+      }
+      return false;
+   }
+   b2Segment.prototype.Extend = function (aabb) {
+      this.ExtendForward(aabb);
+      this.ExtendBackward(aabb);
+   }
+   b2Segment.prototype.ExtendForward = function (aabb) {
+      var dX = this.p2.x - this.p1.x;
+      var dY = this.p2.y - this.p1.y;
+      var lambda = Math.min(dX > 0 ? (aabb.upperBound.x - this.p1.x) / dX : dX < 0 ? (aabb.lowerBound.x - this.p1.x) / dX : Number.POSITIVE_INFINITY,
+      dY > 0 ? (aabb.upperBound.y - this.p1.y) / dY : dY < 0 ? (aabb.lowerBound.y - this.p1.y) / dY : Number.POSITIVE_INFINITY);
+      this.p2.x = this.p1.x + dX * lambda;
+      this.p2.y = this.p1.y + dY * lambda;
+   }
+   b2Segment.prototype.ExtendBackward = function (aabb) {
+      var dX = (-this.p2.x) + this.p1.x;
+      var dY = (-this.p2.y) + this.p1.y;
+      var lambda = Math.min(dX > 0 ? (aabb.upperBound.x - this.p2.x) / dX : dX < 0 ? (aabb.lowerBound.x - this.p2.x) / dX : Number.POSITIVE_INFINITY,
+      dY > 0 ? (aabb.upperBound.y - this.p2.y) / dY : dY < 0 ? (aabb.lowerBound.y - this.p2.y) / dY : Number.POSITIVE_INFINITY);
+      this.p1.x = this.p2.x + dX * lambda;
+      this.p1.y = this.p2.y + dY * lambda;
+   }
+   b2SeparationFunction.b2SeparationFunction = function () {
+      this.m_localPoint = new b2Vec2();
+      this.m_axis = new b2Vec2();
+   };
+   b2SeparationFunction.prototype.Initialize = function (cache, proxyA, transformA, proxyB, transformB) {
+      this.m_proxyA = proxyA;
+      this.m_proxyB = proxyB;
+      var count = parseInt(cache.count);
+      b2Settings.b2Assert(0 < count && count < 3);
+      var localPointA;
+      var localPointA1;
+      var localPointA2;
+      var localPointB;
+      var localPointB1;
+      var localPointB2;
+      var pointAX = 0;
+      var pointAY = 0;
+      var pointBX = 0;
+      var pointBY = 0;
+      var normalX = 0;
+      var normalY = 0;
+      var tMat;
+      var tVec;
+      var s = 0;
+      var sgn = 0;
+      if (count == 1) {
+         this.m_type = b2SeparationFunction.e_points;
+         localPointA = this.m_proxyA.GetVertex(cache.indexA[0]);
+         localPointB = this.m_proxyB.GetVertex(cache.indexB[0]);
+         tVec = localPointA;
+         tMat = transformA.R;
+         pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+         pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+         tVec = localPointB;
+         tMat = transformB.R;
+         pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+         pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+         this.m_axis.x = pointBX - pointAX;
+         this.m_axis.y = pointBY - pointAY;
+         this.m_axis.Normalize();
+      }
+      else if (cache.indexB[0] == cache.indexB[1]) {
+         this.m_type = b2SeparationFunction.e_faceA;
+         localPointA1 = this.m_proxyA.GetVertex(cache.indexA[0]);
+         localPointA2 = this.m_proxyA.GetVertex(cache.indexA[1]);
+         localPointB = this.m_proxyB.GetVertex(cache.indexB[0]);
+         this.m_localPoint.x = 0.5 * (localPointA1.x + localPointA2.x);
+         this.m_localPoint.y = 0.5 * (localPointA1.y + localPointA2.y);
+         this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointA2, localPointA1), 1.0);
+         this.m_axis.Normalize();
+         tVec = this.m_axis;
+         tMat = transformA.R;
+         normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+         normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+         tVec = this.m_localPoint;
+         tMat = transformA.R;
+         pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+         pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+         tVec = localPointB;
+         tMat = transformB.R;
+         pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+         pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+         s = (pointBX - pointAX) * normalX + (pointBY - pointAY) * normalY;
+         if (s < 0.0) {
+            this.m_axis.NegativeSelf();
+         }
+      }
+      else if (cache.indexA[0] == cache.indexA[0]) {
+         this.m_type = b2SeparationFunction.e_faceB;
+         localPointB1 = this.m_proxyB.GetVertex(cache.indexB[0]);
+         localPointB2 = this.m_proxyB.GetVertex(cache.indexB[1]);
+         localPointA = this.m_proxyA.GetVertex(cache.indexA[0]);
+         this.m_localPoint.x = 0.5 * (localPointB1.x + localPointB2.x);
+         this.m_localPoint.y = 0.5 * (localPointB1.y + localPointB2.y);
+         this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointB2, localPointB1), 1.0);
+         this.m_axis.Normalize();
+         tVec = this.m_axis;
+         tMat = transformB.R;
+         normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+         normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+         tVec = this.m_localPoint;
+         tMat = transformB.R;
+         pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+         pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+         tVec = localPointA;
+         tMat = transformA.R;
+         pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+         pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+         s = (pointAX - pointBX) * normalX + (pointAY - pointBY) * normalY;
+         if (s < 0.0) {
+            this.m_axis.NegativeSelf();
+         }
+      }
+      else {
+         localPointA1 = this.m_proxyA.GetVertex(cache.indexA[0]);
+         localPointA2 = this.m_proxyA.GetVertex(cache.indexA[1]);
+         localPointB1 = this.m_proxyB.GetVertex(cache.indexB[0]);
+         localPointB2 = this.m_proxyB.GetVertex(cache.indexB[1]);
+         var pA = b2Math.MulX(transformA, localPointA);
+         var dA = b2Math.MulMV(transformA.R, b2Math.SubtractVV(localPointA2, localPointA1));
+         var pB = b2Math.MulX(transformB, localPointB);
+         var dB = b2Math.MulMV(transformB.R, b2Math.SubtractVV(localPointB2, localPointB1));
+         var a = dA.x * dA.x + dA.y * dA.y;
+         var e = dB.x * dB.x + dB.y * dB.y;
+         var r = b2Math.SubtractVV(dB, dA);
+         var c = dA.x * r.x + dA.y * r.y;
+         var f = dB.x * r.x + dB.y * r.y;
+         var b = dA.x * dB.x + dA.y * dB.y;
+         var denom = a * e - b * b;
+         s = 0.0;
+         if (denom != 0.0) {
+            s = b2Math.Clamp((b * f - c * e) / denom, 0.0, 1.0);
+         }
+         var t = (b * s + f) / e;
+         if (t < 0.0) {
+            t = 0.0;
+            s = b2Math.Clamp((b - c) / a, 0.0, 1.0);
+         }
+         localPointA = new b2Vec2();
+         localPointA.x = localPointA1.x + s * (localPointA2.x - localPointA1.x);
+         localPointA.y = localPointA1.y + s * (localPointA2.y - localPointA1.y);
+         localPointB = new b2Vec2();
+         localPointB.x = localPointB1.x + s * (localPointB2.x - localPointB1.x);
+         localPointB.y = localPointB1.y + s * (localPointB2.y - localPointB1.y);
+         if (s == 0.0 || s == 1.0) {
+            this.m_type = b2SeparationFunction.e_faceB;
+            this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointB2, localPointB1), 1.0);
+            this.m_axis.Normalize();
+            this.m_localPoint = localPointB;
+            tVec = this.m_axis;
+            tMat = transformB.R;
+            normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+            normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+            tVec = this.m_localPoint;
+            tMat = transformB.R;
+            pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+            pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+            tVec = localPointA;
+            tMat = transformA.R;
+            pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+            pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+            sgn = (pointAX - pointBX) * normalX + (pointAY - pointBY) * normalY;
+            if (s < 0.0) {
+               this.m_axis.NegativeSelf();
+            }
+         }
+         else {
+            this.m_type = b2SeparationFunction.e_faceA;
+            this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointA2, localPointA1), 1.0);
+            this.m_localPoint = localPointA;
+            tVec = this.m_axis;
+            tMat = transformA.R;
+            normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+            normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+            tVec = this.m_localPoint;
+            tMat = transformA.R;
+            pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+            pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+            tVec = localPointB;
+            tMat = transformB.R;
+            pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+            pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+            sgn = (pointBX - pointAX) * normalX + (pointBY - pointAY) * normalY;
+            if (s < 0.0) {
+               this.m_axis.NegativeSelf();
+            }
+         }
+      }
+   }
+   b2SeparationFunction.prototype.Evaluate = function (transformA, transformB) {
+      var axisA;
+      var axisB;
+      var localPointA;
+      var localPointB;
+      var pointA;
+      var pointB;
+      var seperation = 0;
+      var normal;
+      switch (this.m_type) {
+      case b2SeparationFunction.e_points:
+         {
+            axisA = b2Math.MulTMV(transformA.R, this.m_axis);
+            axisB = b2Math.MulTMV(transformB.R, this.m_axis.GetNegative());
+            localPointA = this.m_proxyA.GetSupportVertex(axisA);
+            localPointB = this.m_proxyB.GetSupportVertex(axisB);
+            pointA = b2Math.MulX(transformA, localPointA);
+            pointB = b2Math.MulX(transformB, localPointB);
+            seperation = (pointB.x - pointA.x) * this.m_axis.x + (pointB.y - pointA.y) * this.m_axis.y;
+            return seperation;
+         }
+      case b2SeparationFunction.e_faceA:
+         {
+            normal = b2Math.MulMV(transformA.R, this.m_axis);
+            pointA = b2Math.MulX(transformA, this.m_localPoint);
+            axisB = b2Math.MulTMV(transformB.R, normal.GetNegative());
+            localPointB = this.m_proxyB.GetSupportVertex(axisB);
+            pointB = b2Math.MulX(transformB, localPointB);
+            seperation = (pointB.x - pointA.x) * normal.x + (pointB.y - pointA.y) * normal.y;
+            return seperation;
+         }
+      case b2SeparationFunction.e_faceB:
+         {
+            normal = b2Math.MulMV(transformB.R, this.m_axis);
+            pointB = b2Math.MulX(transformB, this.m_localPoint);
+            axisA = b2Math.MulTMV(transformA.R, normal.GetNegative());
+            localPointA = this.m_proxyA.GetSupportVertex(axisA);
+            pointA = b2Math.MulX(transformA, localPointA);
+            seperation = (pointA.x - pointB.x) * normal.x + (pointA.y - pointB.y) * normal.y;
+            return seperation;
+         }
+      default:
+         b2Settings.b2Assert(false);
+         return 0.0;
+      }
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Collision.b2SeparationFunction.e_points = 0x01;
+      Box2D.Collision.b2SeparationFunction.e_faceA = 0x02;
+      Box2D.Collision.b2SeparationFunction.e_faceB = 0x04;
+   });
+   b2Simplex.b2Simplex = function () {
+      this.m_v1 = new b2SimplexVertex();
+      this.m_v2 = new b2SimplexVertex();
+      this.m_v3 = new b2SimplexVertex();
+      this.m_vertices = new Vector(3);
+   };
+   b2Simplex.prototype.b2Simplex = function () {
+      this.m_vertices[0] = this.m_v1;
+      this.m_vertices[1] = this.m_v2;
+      this.m_vertices[2] = this.m_v3;
+   }
+   b2Simplex.prototype.ReadCache = function (cache, proxyA, transformA, proxyB, transformB) {
+      b2Settings.b2Assert(0 <= cache.count && cache.count <= 3);
+      var wALocal;
+      var wBLocal;
+      this.m_count = cache.count;
+      var vertices = this.m_vertices;
+      for (var i = 0; i < this.m_count; i++) {
+         var v = vertices[i];
+         v.indexA = cache.indexA[i];
+         v.indexB = cache.indexB[i];
+         wALocal = proxyA.GetVertex(v.indexA);
+         wBLocal = proxyB.GetVertex(v.indexB);
+         v.wA = b2Math.MulX(transformA, wALocal);
+         v.wB = b2Math.MulX(transformB, wBLocal);
+         v.w = b2Math.SubtractVV(v.wB, v.wA);
+         v.a = 0;
+      }
+      if (this.m_count > 1) {
+         var metric1 = cache.metric;
+         var metric2 = this.GetMetric();
+         if (metric2 < .5 * metric1 || 2.0 * metric1 < metric2 || metric2 < Number.MIN_VALUE) {
+            this.m_count = 0;
+         }
+      }
+      if (this.m_count == 0) {
+         v = vertices[0];
+         v.indexA = 0;
+         v.indexB = 0;
+         wALocal = proxyA.GetVertex(0);
+         wBLocal = proxyB.GetVertex(0);
+         v.wA = b2Math.MulX(transformA, wALocal);
+         v.wB = b2Math.MulX(transformB, wBLocal);
+         v.w = b2Math.SubtractVV(v.wB, v.wA);
+         this.m_count = 1;
+      }
+   }
+   b2Simplex.prototype.WriteCache = function (cache) {
+      cache.metric = this.GetMetric();
+      cache.count = Box2D.parseUInt(this.m_count);
+      var vertices = this.m_vertices;
+      for (var i = 0; i < this.m_count; i++) {
+         cache.indexA[i] = Box2D.parseUInt(vertices[i].indexA);
+         cache.indexB[i] = Box2D.parseUInt(vertices[i].indexB);
+      }
+   }
+   b2Simplex.prototype.GetSearchDirection = function () {
+      switch (this.m_count) {
+      case 1:
+         return this.m_v1.w.GetNegative();
+      case 2:
+         {
+            var e12 = b2Math.SubtractVV(this.m_v2.w, this.m_v1.w);
+            var sgn = b2Math.CrossVV(e12, this.m_v1.w.GetNegative());
+            if (sgn > 0.0) {
+               return b2Math.CrossFV(1.0, e12);
+            }
+            else {
+               return b2Math.CrossVF(e12, 1.0);
+            }
+         }
+      default:
+         b2Settings.b2Assert(false);
+         return new b2Vec2();
+      }
+   }
+   b2Simplex.prototype.GetClosestPoint = function () {
+      switch (this.m_count) {
+      case 0:
+         b2Settings.b2Assert(false);
+         return new b2Vec2();
+      case 1:
+         return this.m_v1.w;
+      case 2:
+         return new b2Vec2(this.m_v1.a * this.m_v1.w.x + this.m_v2.a * this.m_v2.w.x, this.m_v1.a * this.m_v1.w.y + this.m_v2.a * this.m_v2.w.y);
+      default:
+         b2Settings.b2Assert(false);
+         return new b2Vec2();
+      }
+   }
+   b2Simplex.prototype.GetWitnessPoints = function (pA, pB) {
+      switch (this.m_count) {
+      case 0:
+         b2Settings.b2Assert(false);
+         break;
+      case 1:
+         pA.SetV(this.m_v1.wA);
+         pB.SetV(this.m_v1.wB);
+         break;
+      case 2:
+         pA.x = this.m_v1.a * this.m_v1.wA.x + this.m_v2.a * this.m_v2.wA.x;
+         pA.y = this.m_v1.a * this.m_v1.wA.y + this.m_v2.a * this.m_v2.wA.y;
+         pB.x = this.m_v1.a * this.m_v1.wB.x + this.m_v2.a * this.m_v2.wB.x;
+         pB.y = this.m_v1.a * this.m_v1.wB.y + this.m_v2.a * this.m_v2.wB.y;
+         break;
+      case 3:
+         pB.x = pA.x = this.m_v1.a * this.m_v1.wA.x + this.m_v2.a * this.m_v2.wA.x + this.m_v3.a * this.m_v3.wA.x;
+         pB.y = pA.y = this.m_v1.a * this.m_v1.wA.y + this.m_v2.a * this.m_v2.wA.y + this.m_v3.a * this.m_v3.wA.y;
+         break;
+      default:
+         b2Settings.b2Assert(false);
+         break;
+      }
+   }
+   b2Simplex.prototype.GetMetric = function () {
+      switch (this.m_count) {
+      case 0:
+         b2Settings.b2Assert(false);
+         return 0.0;
+      case 1:
+         return 0.0;
+      case 2:
+         return b2Math.SubtractVV(this.m_v1.w, this.m_v2.w).Length();
+      case 3:
+         return b2Math.CrossVV(b2Math.SubtractVV(this.m_v2.w, this.m_v1.w), b2Math.SubtractVV(this.m_v3.w, this.m_v1.w));
+      default:
+         b2Settings.b2Assert(false);
+         return 0.0;
+      }
+   }
+   b2Simplex.prototype.Solve2 = function () {
+      var w1 = this.m_v1.w;
+      var w2 = this.m_v2.w;
+      var e12 = b2Math.SubtractVV(w2, w1);
+      var d12_2 = (-(w1.x * e12.x + w1.y * e12.y));
+      if (d12_2 <= 0.0) {
+         this.m_v1.a = 1.0;
+         this.m_count = 1;
+         return;
+      }
+      var d12_1 = (w2.x * e12.x + w2.y * e12.y);
+      if (d12_1 <= 0.0) {
+         this.m_v2.a = 1.0;
+         this.m_count = 1;
+         this.m_v1.Set(this.m_v2);
+         return;
+      }
+      var inv_d12 = 1.0 / (d12_1 + d12_2);
+      this.m_v1.a = d12_1 * inv_d12;
+      this.m_v2.a = d12_2 * inv_d12;
+      this.m_count = 2;
+   }
+   b2Simplex.prototype.Solve3 = function () {
+      var w1 = this.m_v1.w;
+      var w2 = this.m_v2.w;
+      var w3 = this.m_v3.w;
+      var e12 = b2Math.SubtractVV(w2, w1);
+      var w1e12 = b2Math.Dot(w1, e12);
+      var w2e12 = b2Math.Dot(w2, e12);
+      var d12_1 = w2e12;
+      var d12_2 = (-w1e12);
+      var e13 = b2Math.SubtractVV(w3, w1);
+      var w1e13 = b2Math.Dot(w1, e13);
+      var w3e13 = b2Math.Dot(w3, e13);
+      var d13_1 = w3e13;
+      var d13_2 = (-w1e13);
+      var e23 = b2Math.SubtractVV(w3, w2);
+      var w2e23 = b2Math.Dot(w2, e23);
+      var w3e23 = b2Math.Dot(w3, e23);
+      var d23_1 = w3e23;
+      var d23_2 = (-w2e23);
+      var n123 = b2Math.CrossVV(e12, e13);
+      var d123_1 = n123 * b2Math.CrossVV(w2, w3);
+      var d123_2 = n123 * b2Math.CrossVV(w3, w1);
+      var d123_3 = n123 * b2Math.CrossVV(w1, w2);
+      if (d12_2 <= 0.0 && d13_2 <= 0.0) {
+         this.m_v1.a = 1.0;
+         this.m_count = 1;
+         return;
+      }
+      if (d12_1 > 0.0 && d12_2 > 0.0 && d123_3 <= 0.0) {
+         var inv_d12 = 1.0 / (d12_1 + d12_2);
+         this.m_v1.a = d12_1 * inv_d12;
+         this.m_v2.a = d12_2 * inv_d12;
+         this.m_count = 2;
+         return;
+      }
+      if (d13_1 > 0.0 && d13_2 > 0.0 && d123_2 <= 0.0) {
+         var inv_d13 = 1.0 / (d13_1 + d13_2);
+         this.m_v1.a = d13_1 * inv_d13;
+         this.m_v3.a = d13_2 * inv_d13;
+         this.m_count = 2;
+         this.m_v2.Set(this.m_v3);
+         return;
+      }
+      if (d12_1 <= 0.0 && d23_2 <= 0.0) {
+         this.m_v2.a = 1.0;
+         this.m_count = 1;
+         this.m_v1.Set(this.m_v2);
+         return;
+      }
+      if (d13_1 <= 0.0 && d23_1 <= 0.0) {
+         this.m_v3.a = 1.0;
+         this.m_count = 1;
+         this.m_v1.Set(this.m_v3);
+         return;
+      }
+      if (d23_1 > 0.0 && d23_2 > 0.0 && d123_1 <= 0.0) {
+         var inv_d23 = 1.0 / (d23_1 + d23_2);
+         this.m_v2.a = d23_1 * inv_d23;
+         this.m_v3.a = d23_2 * inv_d23;
+         this.m_count = 2;
+         this.m_v1.Set(this.m_v3);
+         return;
+      }
+      var inv_d123 = 1.0 / (d123_1 + d123_2 + d123_3);
+      this.m_v1.a = d123_1 * inv_d123;
+      this.m_v2.a = d123_2 * inv_d123;
+      this.m_v3.a = d123_3 * inv_d123;
+      this.m_count = 3;
+   }
+   b2SimplexCache.b2SimplexCache = function () {
+      this.indexA = new Vector_a2j_Number(3);
+      this.indexB = new Vector_a2j_Number(3);
+   };
+   b2SimplexVertex.b2SimplexVertex = function () {};
+   b2SimplexVertex.prototype.Set = function (other) {
+      this.wA.SetV(other.wA);
+      this.wB.SetV(other.wB);
+      this.w.SetV(other.w);
+      this.a = other.a;
+      this.indexA = other.indexA;
+      this.indexB = other.indexB;
+   }
+   b2TimeOfImpact.b2TimeOfImpact = function () {};
+   b2TimeOfImpact.TimeOfImpact = function (input) {
+      ++b2TimeOfImpact.b2_toiCalls;
+      var proxyA = input.proxyA;
+      var proxyB = input.proxyB;
+      var sweepA = input.sweepA;
+      var sweepB = input.sweepB;
+      b2Settings.b2Assert(sweepA.t0 == sweepB.t0);
+      b2Settings.b2Assert(1.0 - sweepA.t0 > Number.MIN_VALUE);
+      var radius = proxyA.m_radius + proxyB.m_radius;
+      var tolerance = input.tolerance;
+      var alpha = 0.0;
+      var k_maxIterations = 1000;
+      var iter = 0;
+      var target = 0.0;
+      b2TimeOfImpact.s_cache.count = 0;
+      b2TimeOfImpact.s_distanceInput.useRadii = false;
+      for (;;) {
+         sweepA.GetTransform(b2TimeOfImpact.s_xfA, alpha);
+         sweepB.GetTransform(b2TimeOfImpact.s_xfB, alpha);
+         b2TimeOfImpact.s_distanceInput.proxyA = proxyA;
+         b2TimeOfImpact.s_distanceInput.proxyB = proxyB;
+         b2TimeOfImpact.s_distanceInput.transformA = b2TimeOfImpact.s_xfA;
+         b2TimeOfImpact.s_distanceInput.transformB = b2TimeOfImpact.s_xfB;
+         b2Distance.Distance(b2TimeOfImpact.s_distanceOutput, b2TimeOfImpact.s_cache, b2TimeOfImpact.s_distanceInput);
+         if (b2TimeOfImpact.s_distanceOutput.distance <= 0.0) {
+            alpha = 1.0;
+            break;
+         }
+         b2TimeOfImpact.s_fcn.Initialize(b2TimeOfImpact.s_cache, proxyA, b2TimeOfImpact.s_xfA, proxyB, b2TimeOfImpact.s_xfB);
+         var separation = b2TimeOfImpact.s_fcn.Evaluate(b2TimeOfImpact.s_xfA, b2TimeOfImpact.s_xfB);
+         if (separation <= 0.0) {
+            alpha = 1.0;
+            break;
+         }
+         if (iter == 0) {
+            if (separation > radius) {
+               target = b2Math.Max(radius - tolerance, 0.75 * radius);
+            }
+            else {
+               target = b2Math.Max(separation - tolerance, 0.02 * radius);
+            }
+         }
+         if (separation - target < 0.5 * tolerance) {
+            if (iter == 0) {
+               alpha = 1.0;
+               break;
+            }
+            break;
+         }
+         var newAlpha = alpha; {
+            var x1 = alpha;
+            var x2 = 1.0;
+            var f1 = separation;
+            sweepA.GetTransform(b2TimeOfImpact.s_xfA, x2);
+            sweepB.GetTransform(b2TimeOfImpact.s_xfB, x2);
+            var f2 = b2TimeOfImpact.s_fcn.Evaluate(b2TimeOfImpact.s_xfA, b2TimeOfImpact.s_xfB);
+            if (f2 >= target) {
+               alpha = 1.0;
+               break;
+            }
+            var rootIterCount = 0;
+            for (;;) {
+               var x = 0;
+               if (rootIterCount & 1) {
+                  x = x1 + (target - f1) * (x2 - x1) / (f2 - f1);
+               }
+               else {
+                  x = 0.5 * (x1 + x2);
+               }
+               sweepA.GetTransform(b2TimeOfImpact.s_xfA, x);
+               sweepB.GetTransform(b2TimeOfImpact.s_xfB, x);
+               var f = b2TimeOfImpact.s_fcn.Evaluate(b2TimeOfImpact.s_xfA, b2TimeOfImpact.s_xfB);
+               if (b2Math.Abs(f - target) < 0.025 * tolerance) {
+                  newAlpha = x;
+                  break;
+               }
+               if (f > target) {
+                  x1 = x;
+                  f1 = f;
+               }
+               else {
+                  x2 = x;
+                  f2 = f;
+               }++rootIterCount;
+               ++b2TimeOfImpact.b2_toiRootIters;
+               if (rootIterCount == 50) {
+                  break;
+               }
+            }
+            b2TimeOfImpact.b2_toiMaxRootIters = b2Math.Max(b2TimeOfImpact.b2_toiMaxRootIters, rootIterCount);
+         }
+         if (newAlpha < (1.0 + 100.0 * Number.MIN_VALUE) * alpha) {
+            break;
+         }
+         alpha = newAlpha;
+         iter++;
+         ++b2TimeOfImpact.b2_toiIters;
+         if (iter == k_maxIterations) {
+            break;
+         }
+      }
+      b2TimeOfImpact.b2_toiMaxIters = b2Math.Max(b2TimeOfImpact.b2_toiMaxIters, iter);
+      return alpha;
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Collision.b2TimeOfImpact.b2_toiCalls = 0;
+      Box2D.Collision.b2TimeOfImpact.b2_toiIters = 0;
+      Box2D.Collision.b2TimeOfImpact.b2_toiMaxIters = 0;
+      Box2D.Collision.b2TimeOfImpact.b2_toiRootIters = 0;
+      Box2D.Collision.b2TimeOfImpact.b2_toiMaxRootIters = 0;
+      Box2D.Collision.b2TimeOfImpact.s_cache = new b2SimplexCache();
+      Box2D.Collision.b2TimeOfImpact.s_distanceInput = new b2DistanceInput();
+      Box2D.Collision.b2TimeOfImpact.s_xfA = new b2Transform();
+      Box2D.Collision.b2TimeOfImpact.s_xfB = new b2Transform();
+      Box2D.Collision.b2TimeOfImpact.s_fcn = new b2SeparationFunction();
+      Box2D.Collision.b2TimeOfImpact.s_distanceOutput = new b2DistanceOutput();
+   });
+   b2TOIInput.b2TOIInput = function () {
+      this.proxyA = new b2DistanceProxy();
+      this.proxyB = new b2DistanceProxy();
+      this.sweepA = new b2Sweep();
+      this.sweepB = new b2Sweep();
+   };
+   b2WorldManifold.b2WorldManifold = function () {
+      this.m_normal = new b2Vec2();
+   };
+   b2WorldManifold.prototype.b2WorldManifold = function () {
+      this.m_points = new Vector(b2Settings.b2_maxManifoldPoints);
+      for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) {
+         this.m_points[i] = new b2Vec2();
+      }
+   }
+   b2WorldManifold.prototype.Initialize = function (manifold, xfA, radiusA, xfB, radiusB) {
+      if (radiusA === undefined) radiusA = 0;
+      if (radiusB === undefined) radiusB = 0;
+      if (manifold.m_pointCount == 0) {
+         return;
+      }
+      var i = 0;
+      var tVec;
+      var tMat;
+      var normalX = 0;
+      var normalY = 0;
+      var planePointX = 0;
+      var planePointY = 0;
+      var clipPointX = 0;
+      var clipPointY = 0;
+      switch (manifold.m_type) {
+      case b2Manifold.e_circles:
+         {
+            tMat = xfA.R;
+            tVec = manifold.m_localPoint;
+            var pointAX = xfA.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+            var pointAY = xfA.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+            tMat = xfB.R;
+            tVec = manifold.m_points[0].m_localPoint;
+            var pointBX = xfB.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+            var pointBY = xfB.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+            var dX = pointBX - pointAX;
+            var dY = pointBY - pointAY;
+            var d2 = dX * dX + dY * dY;
+            if (d2 > Number.MIN_VALUE * Number.MIN_VALUE) {
+               var d = Math.sqrt(d2);
+               this.m_normal.x = dX / d;
+               this.m_normal.y = dY / d;
+            }
+            else {
+               this.m_normal.x = 1;
+               this.m_normal.y = 0;
+            }
+            var cAX = pointAX + radiusA * this.m_normal.x;
+            var cAY = pointAY + radiusA * this.m_normal.y;
+            var cBX = pointBX - radiusB * this.m_normal.x;
+            var cBY = pointBY - radiusB * this.m_normal.y;
+            this.m_points[0].x = 0.5 * (cAX + cBX);
+            this.m_points[0].y = 0.5 * (cAY + cBY);
+         }
+         break;
+      case b2Manifold.e_faceA:
+         {
+            tMat = xfA.R;
+            tVec = manifold.m_localPlaneNormal;
+            normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+            normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+            tMat = xfA.R;
+            tVec = manifold.m_localPoint;
+            planePointX = xfA.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+            planePointY = xfA.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+            this.m_normal.x = normalX;
+            this.m_normal.y = normalY;
+            for (i = 0;
+            i < manifold.m_pointCount; i++) {
+               tMat = xfB.R;
+               tVec = manifold.m_points[i].m_localPoint;
+               clipPointX = xfB.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+               clipPointY = xfB.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+               this.m_points[i].x = clipPointX + 0.5 * (radiusA - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusB) * normalX;
+               this.m_points[i].y = clipPointY + 0.5 * (radiusA - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusB) * normalY;
+            }
+         }
+         break;
+      case b2Manifold.e_faceB:
+         {
+            tMat = xfB.R;
+            tVec = manifold.m_localPlaneNormal;
+            normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+            normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+            tMat = xfB.R;
+            tVec = manifold.m_localPoint;
+            planePointX = xfB.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+            planePointY = xfB.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+            this.m_normal.x = (-normalX);
+            this.m_normal.y = (-normalY);
+            for (i = 0;
+            i < manifold.m_pointCount; i++) {
+               tMat = xfA.R;
+               tVec = manifold.m_points[i].m_localPoint;
+               clipPointX = xfA.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+               clipPointY = xfA.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+               this.m_points[i].x = clipPointX + 0.5 * (radiusB - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusA) * normalX;
+               this.m_points[i].y = clipPointY + 0.5 * (radiusB - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusA) * normalY;
+            }
+         }
+         break;
+      }
+   }
+   ClipVertex.ClipVertex = function () {
+      this.v = new b2Vec2();
+      this.id = new b2ContactID();
+   };
+   ClipVertex.prototype.Set = function (other) {
+      this.v.SetV(other.v);
+      this.id.Set(other.id);
+   }
+   Features.Features = function () {};
+   Object.defineProperty(Features.prototype, 'referenceEdge', {
+      enumerable: false,
+      configurable: true,
+      get: function () {
+         return this._referenceEdge;
+      }
+   });
+   Object.defineProperty(Features.prototype, 'referenceEdge', {
+      enumerable: false,
+      configurable: true,
+      set: function (value) {
+         if (value === undefined) value = 0;
+         this._referenceEdge = value;
+         this._m_id._key = (this._m_id._key & 0xffffff00) | (this._referenceEdge & 0x000000ff);
+      }
+   });
+   Object.defineProperty(Features.prototype, 'incidentEdge', {
+      enumerable: false,
+      configurable: true,
+      get: function () {
+         return this._incidentEdge;
+      }
+   });
+   Object.defineProperty(Features.prototype, 'incidentEdge', {
+      enumerable: false,
+      configurable: true,
+      set: function (value) {
+         if (value === undefined) value = 0;
+         this._incidentEdge = value;
+         this._m_id._key = (this._m_id._key & 0xffff00ff) | ((this._incidentEdge << 8) & 0x0000ff00);
+      }
+   });
+   Object.defineProperty(Features.prototype, 'incidentVertex', {
+      enumerable: false,
+      configurable: true,
+      get: function () {
+         return this._incidentVertex;
+      }
+   });
+   Object.defineProperty(Features.prototype, 'incidentVertex', {
+      enumerable: false,
+      configurable: true,
+      set: function (value) {
+         if (value === undefined) value = 0;
+         this._incidentVertex = value;
+         this._m_id._key = (this._m_id._key & 0xff00ffff) | ((this._incidentVertex << 16) & 0x00ff0000);
+      }
+   });
+   Object.defineProperty(Features.prototype, 'flip', {
+      enumerable: false,
+      configurable: true,
+      get: function () {
+         return this._flip;
+      }
+   });
+   Object.defineProperty(Features.prototype, 'flip', {
+      enumerable: false,
+      configurable: true,
+      set: function (value) {
+         if (value === undefined) value = 0;
+         this._flip = value;
+         this._m_id._key = (this._m_id._key & 0x00ffffff) | ((this._flip << 24) & 0xff000000);
+      }
+   });
+})();
+(function () {
+   var b2Color = Box2D.Common.b2Color,
+      b2internal = Box2D.Common.b2internal,
+      b2Settings = Box2D.Common.b2Settings,
+      b2CircleShape = Box2D.Collision.Shapes.b2CircleShape,
+      b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef,
+      b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape,
+      b2MassData = Box2D.Collision.Shapes.b2MassData,
+      b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape,
+      b2Shape = Box2D.Collision.Shapes.b2Shape,
+      b2Mat22 = Box2D.Common.Math.b2Mat22,
+      b2Mat33 = Box2D.Common.Math.b2Mat33,
+      b2Math = Box2D.Common.Math.b2Math,
+      b2Sweep = Box2D.Common.Math.b2Sweep,
+      b2Transform = Box2D.Common.Math.b2Transform,
+      b2Vec2 = Box2D.Common.Math.b2Vec2,
+      b2Vec3 = Box2D.Common.Math.b2Vec3,
+      b2Body = Box2D.Dynamics.b2Body,
+      b2BodyDef = Box2D.Dynamics.b2BodyDef,
+      b2ContactFilter = Box2D.Dynamics.b2ContactFilter,
+      b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse,
+      b2ContactListener = Box2D.Dynamics.b2ContactListener,
+      b2ContactManager = Box2D.Dynamics.b2ContactManager,
+      b2DebugDraw = Box2D.Dynamics.b2DebugDraw,
+      b2DestructionListener = Box2D.Dynamics.b2DestructionListener,
+      b2FilterData = Box2D.Dynamics.b2FilterData,
+      b2Fixture = Box2D.Dynamics.b2Fixture,
+      b2FixtureDef = Box2D.Dynamics.b2FixtureDef,
+      b2Island = Box2D.Dynamics.b2Island,
+      b2TimeStep = Box2D.Dynamics.b2TimeStep,
+      b2World = Box2D.Dynamics.b2World,
+      b2AABB = Box2D.Collision.b2AABB,
+      b2Bound = Box2D.Collision.b2Bound,
+      b2BoundValues = Box2D.Collision.b2BoundValues,
+      b2Collision = Box2D.Collision.b2Collision,
+      b2ContactID = Box2D.Collision.b2ContactID,
+      b2ContactPoint = Box2D.Collision.b2ContactPoint,
+      b2Distance = Box2D.Collision.b2Distance,
+      b2DistanceInput = Box2D.Collision.b2DistanceInput,
+      b2DistanceOutput = Box2D.Collision.b2DistanceOutput,
+      b2DistanceProxy = Box2D.Collision.b2DistanceProxy,
+      b2DynamicTree = Box2D.Collision.b2DynamicTree,
+      b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase,
+      b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode,
+      b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair,
+      b2Manifold = Box2D.Collision.b2Manifold,
+      b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint,
+      b2Point = Box2D.Collision.b2Point,
+      b2RayCastInput = Box2D.Collision.b2RayCastInput,
+      b2RayCastOutput = Box2D.Collision.b2RayCastOutput,
+      b2Segment = Box2D.Collision.b2Segment,
+      b2SeparationFunction = Box2D.Collision.b2SeparationFunction,
+      b2Simplex = Box2D.Collision.b2Simplex,
+      b2SimplexCache = Box2D.Collision.b2SimplexCache,
+      b2SimplexVertex = Box2D.Collision.b2SimplexVertex,
+      b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact,
+      b2TOIInput = Box2D.Collision.b2TOIInput,
+      b2WorldManifold = Box2D.Collision.b2WorldManifold,
+      ClipVertex = Box2D.Collision.ClipVertex,
+      Features = Box2D.Collision.Features,
+      IBroadPhase = Box2D.Collision.IBroadPhase;
+
+   Box2D.inherit(b2CircleShape, Box2D.Collision.Shapes.b2Shape);
+   b2CircleShape.prototype.__super = Box2D.Collision.Shapes.b2Shape.prototype;
+   b2CircleShape.b2CircleShape = function () {
+      Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this, arguments);
+      this.m_p = new b2Vec2();
+   };
+   b2CircleShape.prototype.Copy = function () {
+      var s = new b2CircleShape();
+      s.Set(this);
+      return s;
+   }
+   b2CircleShape.prototype.Set = function (other) {
+      this.__super.Set.call(this, other);
+      if (Box2D.is(other, b2CircleShape)) {
+         var other2 = (other instanceof b2CircleShape ? other : null);
+         this.m_p.SetV(other2.m_p);
+      }
+   }
+   b2CircleShape.prototype.TestPoint = function (transform, p) {
+      var tMat = transform.R;
+      var dX = transform.position.x + (tMat.col1.x * this.m_p.x + tMat.col2.x * this.m_p.y);
+      var dY = transform.position.y + (tMat.col1.y * this.m_p.x + tMat.col2.y * this.m_p.y);
+      dX = p.x - dX;
+      dY = p.y - dY;
+      return (dX * dX + dY * dY) <= this.m_radius * this.m_radius;
+   }
+   b2CircleShape.prototype.RayCast = function (output, input, transform) {
+      var tMat = transform.R;
+      var positionX = transform.position.x + (tMat.col1.x * this.m_p.x + tMat.col2.x * this.m_p.y);
+      var positionY = transform.position.y + (tMat.col1.y * this.m_p.x + tMat.col2.y * this.m_p.y);
+      var sX = input.p1.x - positionX;
+      var sY = input.p1.y - positionY;
+      var b = (sX * sX + sY * sY) - this.m_radius * this.m_radius;
+      var rX = input.p2.x - input.p1.x;
+      var rY = input.p2.y - input.p1.y;
+      var c = (sX * rX + sY * rY);
+      var rr = (rX * rX + rY * rY);
+      var sigma = c * c - rr * b;
+      if (sigma < 0.0 || rr < Number.MIN_VALUE) {
+         return false;
+      }
+      var a = (-(c + Math.sqrt(sigma)));
+      if (0.0 <= a && a <= input.maxFraction * rr) {
+         a /= rr;
+         output.fraction = a;
+         output.normal.x = sX + a * rX;
+         output.normal.y = sY + a * rY;
+         output.normal.Normalize();
+         return true;
+      }
+      return false;
+   }
+   b2CircleShape.prototype.ComputeAABB = function (aabb, transform) {
+      var tMat = transform.R;
+      var pX = transform.position.x + (tMat.col1.x * this.m_p.x + tMat.col2.x * this.m_p.y);
+      var pY = transform.position.y + (tMat.col1.y * this.m_p.x + tMat.col2.y * this.m_p.y);
+      aabb.lowerBound.Set(pX - this.m_radius, pY - this.m_radius);
+      aabb.upperBound.Set(pX + this.m_radius, pY + this.m_radius);
+   }
+   b2CircleShape.prototype.ComputeMass = function (massData, density) {
+      if (density === undefined) density = 0;
+      massData.mass = density * b2Settings.b2_pi * this.m_radius * this.m_radius;
+      massData.center.SetV(this.m_p);
+      massData.I = massData.mass * (0.5 * this.m_radius * this.m_radius + (this.m_p.x * this.m_p.x + this.m_p.y * this.m_p.y));
+   }
+   b2CircleShape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) {
+      if (offset === undefined) offset = 0;
+      var p = b2Math.MulX(xf, this.m_p);
+      var l = (-(b2Math.Dot(normal, p) - offset));
+      if (l < (-this.m_radius) + Number.MIN_VALUE) {
+         return 0;
+      }
+      if (l > this.m_radius) {
+         c.SetV(p);
+         return Math.PI * this.m_radius * this.m_radius;
+      }
+      var r2 = this.m_radius * this.m_radius;
+      var l2 = l * l;
+      var area = r2 * (Math.asin(l / this.m_radius) + Math.PI / 2) + l * Math.sqrt(r2 - l2);
+      var com = (-2 / 3 * Math.pow(r2 - l2, 1.5) / area);
+      c.x = p.x + normal.x * com;
+      c.y = p.y + normal.y * com;
+      return area;
+   }
+   b2CircleShape.prototype.GetLocalPosition = function () {
+      return this.m_p;
+   }
+   b2CircleShape.prototype.SetLocalPosition = function (position) {
+      this.m_p.SetV(position);
+   }
+   b2CircleShape.prototype.GetRadius = function () {
+      return this.m_radius;
+   }
+   b2CircleShape.prototype.SetRadius = function (radius) {
+      if (radius === undefined) radius = 0;
+      this.m_radius = radius;
+   }
+   b2CircleShape.prototype.b2CircleShape = function (radius) {
+      if (radius === undefined) radius = 0;
+      this.__super.b2Shape.call(this);
+      this.m_type = b2Shape.e_circleShape;
+      this.m_radius = radius;
+   }
+   b2EdgeChainDef.b2EdgeChainDef = function () {};
+   b2EdgeChainDef.prototype.b2EdgeChainDef = function () {
+      this.vertexCount = 0;
+      this.isALoop = true;
+      this.vertices = [];
+   }
+   Box2D.inherit(b2EdgeShape, Box2D.Collision.Shapes.b2Shape);
+   b2EdgeShape.prototype.__super = Box2D.Collision.Shapes.b2Shape.prototype;
+   b2EdgeShape.b2EdgeShape = function () {
+      Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this, arguments);
+      this.s_supportVec = new b2Vec2();
+      this.m_v1 = new b2Vec2();
+      this.m_v2 = new b2Vec2();
+      this.m_coreV1 = new b2Vec2();
+      this.m_coreV2 = new b2Vec2();
+      this.m_normal = new b2Vec2();
+      this.m_direction = new b2Vec2();
+      this.m_cornerDir1 = new b2Vec2();
+      this.m_cornerDir2 = new b2Vec2();
+   };
+   b2EdgeShape.prototype.TestPoint = function (transform, p) {
+      return false;
+   }
+   b2EdgeShape.prototype.RayCast = function (output, input, transform) {
+      var tMat;
+      var rX = input.p2.x - input.p1.x;
+      var rY = input.p2.y - input.p1.y;
+      tMat = transform.R;
+      var v1X = transform.position.x + (tMat.col1.x * this.m_v1.x + tMat.col2.x * this.m_v1.y);
+      var v1Y = transform.position.y + (tMat.col1.y * this.m_v1.x + tMat.col2.y * this.m_v1.y);
+      var nX = transform.position.y + (tMat.col1.y * this.m_v2.x + tMat.col2.y * this.m_v2.y) - v1Y;
+      var nY = (-(transform.position.x + (tMat.col1.x * this.m_v2.x + tMat.col2.x * this.m_v2.y) - v1X));
+      var k_slop = 100.0 * Number.MIN_VALUE;
+      var denom = (-(rX * nX + rY * nY));
+      if (denom > k_slop) {
+         var bX = input.p1.x - v1X;
+         var bY = input.p1.y - v1Y;
+         var a = (bX * nX + bY * nY);
+         if (0.0 <= a && a <= input.maxFraction * denom) {
+            var mu2 = (-rX * bY) + rY * bX;
+            if ((-k_slop * denom) <= mu2 && mu2 <= denom * (1.0 + k_slop)) {
+               a /= denom;
+               output.fraction = a;
+               var nLen = Math.sqrt(nX * nX + nY * nY);
+               output.normal.x = nX / nLen;
+               output.normal.y = nY / nLen;
+               return true;
+            }
+         }
+      }
+      return false;
+   }
+   b2EdgeShape.prototype.ComputeAABB = function (aabb, transform) {
+      var tMat = transform.R;
+      var v1X = transform.position.x + (tMat.col1.x * this.m_v1.x + tMat.col2.x * this.m_v1.y);
+      var v1Y = transform.position.y + (tMat.col1.y * this.m_v1.x + tMat.col2.y * this.m_v1.y);
+      var v2X = transform.position.x + (tMat.col1.x * this.m_v2.x + tMat.col2.x * this.m_v2.y);
+      var v2Y = transform.position.y + (tMat.col1.y * this.m_v2.x + tMat.col2.y * this.m_v2.y);
+      if (v1X < v2X) {
+         aabb.lowerBound.x = v1X;
+         aabb.upperBound.x = v2X;
+      }
+      else {
+         aabb.lowerBound.x = v2X;
+         aabb.upperBound.x = v1X;
+      }
+      if (v1Y < v2Y) {
+         aabb.lowerBound.y = v1Y;
+         aabb.upperBound.y = v2Y;
+      }
+      else {
+         aabb.lowerBound.y = v2Y;
+         aabb.upperBound.y = v1Y;
+      }
+   }
+   b2EdgeShape.prototype.ComputeMass = function (massData, density) {
+      if (density === undefined) density = 0;
+      massData.mass = 0;
+      massData.center.SetV(this.m_v1);
+      massData.I = 0;
+   }
+   b2EdgeShape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) {
+      if (offset === undefined) offset = 0;
+      var v0 = new b2Vec2(normal.x * offset, normal.y * offset);
+      var v1 = b2Math.MulX(xf, this.m_v1);
+      var v2 = b2Math.MulX(xf, this.m_v2);
+      var d1 = b2Math.Dot(normal, v1) - offset;
+      var d2 = b2Math.Dot(normal, v2) - offset;
+      if (d1 > 0) {
+         if (d2 > 0) {
+            return 0;
+         }
+         else {
+            v1.x = (-d2 / (d1 - d2) * v1.x) + d1 / (d1 - d2) * v2.x;
+            v1.y = (-d2 / (d1 - d2) * v1.y) + d1 / (d1 - d2) * v2.y;
+         }
+      }
+      else {
+         if (d2 > 0) {
+            v2.x = (-d2 / (d1 - d2) * v1.x) + d1 / (d1 - d2) * v2.x;
+            v2.y = (-d2 / (d1 - d2) * v1.y) + d1 / (d1 - d2) * v2.y;
+         }
+         else {}
+      }
+      c.x = (v0.x + v1.x + v2.x) / 3;
+      c.y = (v0.y + v1.y + v2.y) / 3;
+      return 0.5 * ((v1.x - v0.x) * (v2.y - v0.y) - (v1.y - v0.y) * (v2.x - v0.x));
+   }
+   b2EdgeShape.prototype.GetLength = function () {
+      return this.m_length;
+   }
+   b2EdgeShape.prototype.GetVertex1 = function () {
+      return this.m_v1;
+   }
+   b2EdgeShape.prototype.GetVertex2 = function () {
+      return this.m_v2;
+   }
+   b2EdgeShape.prototype.GetCoreVertex1 = function () {
+      return this.m_coreV1;
+   }
+   b2EdgeShape.prototype.GetCoreVertex2 = function () {
+      return this.m_coreV2;
+   }
+   b2EdgeShape.prototype.GetNormalVector = function () {
+      return this.m_normal;
+   }
+   b2EdgeShape.prototype.GetDirectionVector = function () {
+      return this.m_direction;
+   }
+   b2EdgeShape.prototype.GetCorner1Vector = function () {
+      return this.m_cornerDir1;
+   }
+   b2EdgeShape.prototype.GetCorner2Vector = function () {
+      return this.m_cornerDir2;
+   }
+   b2EdgeShape.prototype.Corner1IsConvex = function () {
+      return this.m_cornerConvex1;
+   }
+   b2EdgeShape.prototype.Corner2IsConvex = function () {
+      return this.m_cornerConvex2;
+   }
+   b2EdgeShape.prototype.GetFirstVertex = function (xf) {
+      var tMat = xf.R;
+      return new b2Vec2(xf.position.x + (tMat.col1.x * this.m_coreV1.x + tMat.col2.x * this.m_coreV1.y), xf.position.y + (tMat.col1.y * this.m_coreV1.x + tMat.col2.y * this.m_coreV1.y));
+   }
+   b2EdgeShape.prototype.GetNextEdge = function () {
+      return this.m_nextEdge;
+   }
+   b2EdgeShape.prototype.GetPrevEdge = function () {
+      return this.m_prevEdge;
+   }
+   b2EdgeShape.prototype.Support = function (xf, dX, dY) {
+      if (dX === undefined) dX = 0;
+      if (dY === undefined) dY = 0;
+      var tMat = xf.R;
+      var v1X = xf.position.x + (tMat.col1.x * this.m_coreV1.x + tMat.col2.x * this.m_coreV1.y);
+      var v1Y = xf.position.y + (tMat.col1.y * this.m_coreV1.x + tMat.col2.y * this.m_coreV1.y);
+      var v2X = xf.position.x + (tMat.col1.x * this.m_coreV2.x + tMat.col2.x * this.m_coreV2.y);
+      var v2Y = xf.position.y + (tMat.col1.y * this.m_coreV2.x + tMat.col2.y * this.m_coreV2.y);
+      if ((v1X * dX + v1Y * dY) > (v2X * dX + v2Y * dY)) {
+         this.s_supportVec.x = v1X;
+         this.s_supportVec.y = v1Y;
+      }
+      else {
+         this.s_supportVec.x = v2X;
+         this.s_supportVec.y = v2Y;
+      }
+      return this.s_supportVec;
+   }
+   b2EdgeShape.prototype.b2EdgeShape = function (v1, v2) {
+      this.__super.b2Shape.call(this);
+      this.m_type = b2Shape.e_edgeShape;
+      this.m_prevEdge = null;
+      this.m_nextEdge = null;
+      this.m_v1 = v1;
+      this.m_v2 = v2;
+      this.m_direction.Set(this.m_v2.x - this.m_v1.x, this.m_v2.y - this.m_v1.y);
+      this.m_length = this.m_direction.Normalize();
+      this.m_normal.Set(this.m_direction.y, (-this.m_direction.x));
+      this.m_coreV1.Set((-b2Settings.b2_toiSlop * (this.m_normal.x - this.m_direction.x)) + this.m_v1.x, (-b2Settings.b2_toiSlop * (this.m_normal.y - this.m_direction.y)) + this.m_v1.y);
+      this.m_coreV2.Set((-b2Settings.b2_toiSlop * (this.m_normal.x + this.m_direction.x)) + this.m_v2.x, (-b2Settings.b2_toiSlop * (this.m_normal.y + this.m_direction.y)) + this.m_v2.y);
+      this.m_cornerDir1 = this.m_normal;
+      this.m_cornerDir2.Set((-this.m_normal.x), (-this.m_normal.y));
+   }
+   b2EdgeShape.prototype.SetPrevEdge = function (edge, core, cornerDir, convex) {
+      this.m_prevEdge = edge;
+      this.m_coreV1 = core;
+      this.m_cornerDir1 = cornerDir;
+      this.m_cornerConvex1 = convex;
+   }
+   b2EdgeShape.prototype.SetNextEdge = function (edge, core, cornerDir, convex) {
+      this.m_nextEdge = edge;
+      this.m_coreV2 = core;
+      this.m_cornerDir2 = cornerDir;
+      this.m_cornerConvex2 = convex;
+   }
+   b2MassData.b2MassData = function () {
+      this.mass = 0.0;
+      this.center = new b2Vec2(0, 0);
+      this.I = 0.0;
+   };
+   Box2D.inherit(b2PolygonShape, Box2D.Collision.Shapes.b2Shape);
+   b2PolygonShape.prototype.__super = Box2D.Collision.Shapes.b2Shape.prototype;
+   b2PolygonShape.b2PolygonShape = function () {
+      Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this, arguments);
+   };
+   b2PolygonShape.prototype.Copy = function () {
+      var s = new b2PolygonShape();
+      s.Set(this);
+      return s;
+   }
+   b2PolygonShape.prototype.Set = function (other) {
+      this.__super.Set.call(this, other);
+      if (Box2D.is(other, b2PolygonShape)) {
+         var other2 = (other instanceof b2PolygonShape ? other : null);
+         this.m_centroid.SetV(other2.m_centroid);
+         this.m_vertexCount = other2.m_vertexCount;
+         this.Reserve(this.m_vertexCount);
+         for (var i = 0; i < this.m_vertexCount; i++) {
+            this.m_vertices[i].SetV(other2.m_vertices[i]);
+            this.m_normals[i].SetV(other2.m_normals[i]);
+         }
+      }
+   }
+   b2PolygonShape.prototype.SetAsArray = function (vertices, vertexCount) {
+      if (vertexCount === undefined) vertexCount = 0;
+      var v = new Vector();
+      var i = 0,
+         tVec;
+      for (i = 0;
+      i < vertices.length; ++i) {
+         tVec = vertices[i];
+         v.push(tVec);
+      }
+      this.SetAsVector(v, vertexCount);
+   }
+   b2PolygonShape.AsArray = function (vertices, vertexCount) {
+      if (vertexCount === undefined) vertexCount = 0;
+      var polygonShape = new b2PolygonShape();
+      polygonShape.SetAsArray(vertices, vertexCount);
+      return polygonShape;
+   }
+   b2PolygonShape.prototype.SetAsVector = function (vertices, vertexCount) {
+      if (vertexCount === undefined) vertexCount = 0;
+      if (vertexCount == 0) vertexCount = vertices.length;
+      b2Settings.b2Assert(2 <= vertexCount);
+      this.m_vertexCount = vertexCount;
+      this.Reserve(vertexCount);
+      var i = 0;
+      for (i = 0;
+      i < this.m_vertexCount; i++) {
+         this.m_vertices[i].SetV(vertices[i]);
+      }
+      for (i = 0;
+      i < this.m_vertexCount; ++i) {
+         var i1 = parseInt(i);
+         var i2 = parseInt(i + 1 < this.m_vertexCount ? i + 1 : 0);
+         var edge = b2Math.SubtractVV(this.m_vertices[i2], this.m_vertices[i1]);
+         b2Settings.b2Assert(edge.LengthSquared() > Number.MIN_VALUE);
+         this.m_normals[i].SetV(b2Math.CrossVF(edge, 1.0));
+         this.m_normals[i].Normalize();
+      }
+      this.m_centroid = b2PolygonShape.ComputeCentroid(this.m_vertices, this.m_vertexCount);
+   }
+   b2PolygonShape.AsVector = function (vertices, vertexCount) {
+      if (vertexCount === undefined) vertexCount = 0;
+      var polygonShape = new b2PolygonShape();
+      polygonShape.SetAsVector(vertices, vertexCount);
+      return polygonShape;
+   }
+   b2PolygonShape.prototype.SetAsBox = function (hx, hy) {
+      if (hx === undefined) hx = 0;
+      if (hy === undefined) hy = 0;
+      this.m_vertexCount = 4;
+      this.Reserve(4);
+      this.m_vertices[0].Set((-hx), (-hy));
+      this.m_vertices[1].Set(hx, (-hy));
+      this.m_vertices[2].Set(hx, hy);
+      this.m_vertices[3].Set((-hx), hy);
+      this.m_normals[0].Set(0.0, (-1.0));
+      this.m_normals[1].Set(1.0, 0.0);
+      this.m_normals[2].Set(0.0, 1.0);
+      this.m_normals[3].Set((-1.0), 0.0);
+      this.m_centroid.SetZero();
+   }
+   b2PolygonShape.AsBox = function (hx, hy) {
+      if (hx === undefined) hx = 0;
+      if (hy === undefined) hy = 0;
+      var polygonShape = new b2PolygonShape();
+      polygonShape.SetAsBox(hx, hy);
+      return polygonShape;
+   }
+   b2PolygonShape.prototype.SetAsOrientedBox = function (hx, hy, center, angle) {
+      if (hx === undefined) hx = 0;
+      if (hy === undefined) hy = 0;
+      if (center === undefined) center = null;
+      if (angle === undefined) angle = 0.0;
+      this.m_vertexCount = 4;
+      this.Reserve(4);
+      this.m_vertices[0].Set((-hx), (-hy));
+      this.m_vertices[1].Set(hx, (-hy));
+      this.m_vertices[2].Set(hx, hy);
+      this.m_vertices[3].Set((-hx), hy);
+      this.m_normals[0].Set(0.0, (-1.0));
+      this.m_normals[1].Set(1.0, 0.0);
+      this.m_normals[2].Set(0.0, 1.0);
+      this.m_normals[3].Set((-1.0), 0.0);
+      this.m_centroid = center;
+      var xf = new b2Transform();
+      xf.position = center;
+      xf.R.Set(angle);
+      for (var i = 0; i < this.m_vertexCount; ++i) {
+         this.m_vertices[i] = b2Math.MulX(xf, this.m_vertices[i]);
+         this.m_normals[i] = b2Math.MulMV(xf.R, this.m_normals[i]);
+      }
+   }
+   b2PolygonShape.AsOrientedBox = function (hx, hy, center, angle) {
+      if (hx === undefined) hx = 0;
+      if (hy === undefined) hy = 0;
+      if (center === undefined) center = null;
+      if (angle === undefined) angle = 0.0;
+      var polygonShape = new b2PolygonShape();
+      polygonShape.SetAsOrientedBox(hx, hy, center, angle);
+      return polygonShape;
+   }
+   b2PolygonShape.prototype.SetAsEdge = function (v1, v2) {
+      this.m_vertexCount = 2;
+      this.Reserve(2);
+      this.m_vertices[0].SetV(v1);
+      this.m_vertices[1].SetV(v2);
+      this.m_centroid.x = 0.5 * (v1.x + v2.x);
+      this.m_centroid.y = 0.5 * (v1.y + v2.y);
+      this.m_normals[0] = b2Math.CrossVF(b2Math.SubtractVV(v2, v1), 1.0);
+      this.m_normals[0].Normalize();
+      this.m_normals[1].x = (-this.m_normals[0].x);
+      this.m_normals[1].y = (-this.m_normals[0].y);
+   }
+   b2PolygonShape.AsEdge = function (v1, v2) {
+      var polygonShape = new b2PolygonShape();
+      polygonShape.SetAsEdge(v1, v2);
+      return polygonShape;
+   }
+   b2PolygonShape.prototype.TestPoint = function (xf, p) {
+      var tVec;
+      var tMat = xf.R;
+      var tX = p.x - xf.position.x;
+      var tY = p.y - xf.position.y;
+      var pLocalX = (tX * tMat.col1.x + tY * tMat.col1.y);
+      var pLocalY = (tX * tMat.col2.x + tY * tMat.col2.y);
+      for (var i = 0; i < this.m_vertexCount; ++i) {
+         tVec = this.m_vertices[i];
+         tX = pLocalX - tVec.x;
+         tY = pLocalY - tVec.y;
+         tVec = this.m_normals[i];
+         var dot = (tVec.x * tX + tVec.y * tY);
+         if (dot > 0.0) {
+            return false;
+         }
+      }
+      return true;
+   }
+   b2PolygonShape.prototype.RayCast = function (output, input, transform) {
+      var lower = 0.0;
+      var upper = input.maxFraction;
+      var tX = 0;
+      var tY = 0;
+      var tMat;
+      var tVec;
+      tX = input.p1.x - transform.position.x;
+      tY = input.p1.y - transform.position.y;
+      tMat = transform.R;
+      var p1X = (tX * tMat.col1.x + tY * tMat.col1.y);
+      var p1Y = (tX * tMat.col2.x + tY * tMat.col2.y);
+      tX = input.p2.x - transform.position.x;
+      tY = input.p2.y - transform.position.y;
+      tMat = transform.R;
+      var p2X = (tX * tMat.col1.x + tY * tMat.col1.y);
+      var p2Y = (tX * tMat.col2.x + tY * tMat.col2.y);
+      var dX = p2X - p1X;
+      var dY = p2Y - p1Y;
+      var index = parseInt((-1));
+      for (var i = 0; i < this.m_vertexCount; ++i) {
+         tVec = this.m_vertices[i];
+         tX = tVec.x - p1X;
+         tY = tVec.y - p1Y;
+         tVec = this.m_normals[i];
+         var numerator = (tVec.x * tX + tVec.y * tY);
+         var denominator = (tVec.x * dX + tVec.y * dY);
+         if (denominator == 0.0) {
+            if (numerator < 0.0) {
+               return false;
+            }
+         }
+         else {
+            if (denominator < 0.0 && numerator < lower * denominator) {
+               lower = numerator / denominator;
+               index = i;
+            }
+            else if (denominator > 0.0 && numerator < upper * denominator) {
+               upper = numerator / denominator;
+            }
+         }
+         if (upper < lower - Number.MIN_VALUE) {
+            return false;
+         }
+      }
+      if (index >= 0) {
+         output.fraction = lower;
+         tMat = transform.R;
+         tVec = this.m_normals[index];
+         output.normal.x = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+         output.normal.y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+         return true;
+      }
+      return false;
+   }
+   b2PolygonShape.prototype.ComputeAABB = function (aabb, xf) {
+      var tMat = xf.R;
+      var tVec = this.m_vertices[0];
+      var lowerX = xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      var lowerY = xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      var upperX = lowerX;
+      var upperY = lowerY;
+      for (var i = 1; i < this.m_vertexCount; ++i) {
+         tVec = this.m_vertices[i];
+         var vX = xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+         var vY = xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+         lowerX = lowerX < vX ? lowerX : vX;
+         lowerY = lowerY < vY ? lowerY : vY;
+         upperX = upperX > vX ? upperX : vX;
+         upperY = upperY > vY ? upperY : vY;
+      }
+      aabb.lowerBound.x = lowerX - this.m_radius;
+      aabb.lowerBound.y = lowerY - this.m_radius;
+      aabb.upperBound.x = upperX + this.m_radius;
+      aabb.upperBound.y = upperY + this.m_radius;
+   }
+   b2PolygonShape.prototype.ComputeMass = function (massData, density) {
+      if (density === undefined) density = 0;
+      if (this.m_vertexCount == 2) {
+         massData.center.x = 0.5 * (this.m_vertices[0].x + this.m_vertices[1].x);
+         massData.center.y = 0.5 * (this.m_vertices[0].y + this.m_vertices[1].y);
+         massData.mass = 0.0;
+         massData.I = 0.0;
+         return;
+      }
+      var centerX = 0.0;
+      var centerY = 0.0;
+      var area = 0.0;
+      var I = 0.0;
+      var p1X = 0.0;
+      var p1Y = 0.0;
+      var k_inv3 = 1.0 / 3.0;
+      for (var i = 0; i < this.m_vertexCount; ++i) {
+         var p2 = this.m_vertices[i];
+         var p3 = i + 1 < this.m_vertexCount ? this.m_vertices[parseInt(i + 1)] : this.m_vertices[0];
+         var e1X = p2.x - p1X;
+         var e1Y = p2.y - p1Y;
+         var e2X = p3.x - p1X;
+         var e2Y = p3.y - p1Y;
+         var D = e1X * e2Y - e1Y * e2X;
+         var triangleArea = 0.5 * D;area += triangleArea;
+         centerX += triangleArea * k_inv3 * (p1X + p2.x + p3.x);
+         centerY += triangleArea * k_inv3 * (p1Y + p2.y + p3.y);
+         var px = p1X;
+         var py = p1Y;
+         var ex1 = e1X;
+         var ey1 = e1Y;
+         var ex2 = e2X;
+         var ey2 = e2Y;
+         var intx2 = k_inv3 * (0.25 * (ex1 * ex1 + ex2 * ex1 + ex2 * ex2) + (px * ex1 + px * ex2)) + 0.5 * px * px;
+         var inty2 = k_inv3 * (0.25 * (ey1 * ey1 + ey2 * ey1 + ey2 * ey2) + (py * ey1 + py * ey2)) + 0.5 * py * py;I += D * (intx2 + inty2);
+      }
+      massData.mass = density * area;
+      centerX *= 1.0 / area;
+      centerY *= 1.0 / area;
+      massData.center.Set(centerX, centerY);
+      massData.I = density * I;
+   }
+   b2PolygonShape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) {
+      if (offset === undefined) offset = 0;
+      var normalL = b2Math.MulTMV(xf.R, normal);
+      var offsetL = offset - b2Math.Dot(normal, xf.position);
+      var depths = new Vector_a2j_Number();
+      var diveCount = 0;
+      var intoIndex = parseInt((-1));
+      var outoIndex = parseInt((-1));
+      var lastSubmerged = false;
+      var i = 0;
+      for (i = 0;
+      i < this.m_vertexCount; ++i) {
+         depths[i] = b2Math.Dot(normalL, this.m_vertices[i]) - offsetL;
+         var isSubmerged = depths[i] < (-Number.MIN_VALUE);
+         if (i > 0) {
+            if (isSubmerged) {
+               if (!lastSubmerged) {
+                  intoIndex = i - 1;
+                  diveCount++;
+               }
+            }
+            else {
+               if (lastSubmerged) {
+                  outoIndex = i - 1;
+                  diveCount++;
+               }
+            }
+         }
+         lastSubmerged = isSubmerged;
+      }
+      switch (diveCount) {
+      case 0:
+         if (lastSubmerged) {
+            var md = new b2MassData();
+            this.ComputeMass(md, 1);
+            c.SetV(b2Math.MulX(xf, md.center));
+            return md.mass;
+         }
+         else {
+            return 0;
+         }
+         break;
+      case 1:
+         if (intoIndex == (-1)) {
+            intoIndex = this.m_vertexCount - 1;
+         }
+         else {
+            outoIndex = this.m_vertexCount - 1;
+         }
+         break;
+      }
+      var intoIndex2 = parseInt((intoIndex + 1) % this.m_vertexCount);
+      var outoIndex2 = parseInt((outoIndex + 1) % this.m_vertexCount);
+      var intoLamdda = (0 - depths[intoIndex]) / (depths[intoIndex2] - depths[intoIndex]);
+      var outoLamdda = (0 - depths[outoIndex]) / (depths[outoIndex2] - depths[outoIndex]);
+      var intoVec = new b2Vec2(this.m_vertices[intoIndex].x * (1 - intoLamdda) + this.m_vertices[intoIndex2].x * intoLamdda, this.m_vertices[intoIndex].y * (1 - intoLamdda) + this.m_vertices[intoIndex2].y * intoLamdda);
+      var outoVec = new b2Vec2(this.m_vertices[outoIndex].x * (1 - outoLamdda) + this.m_vertices[outoIndex2].x * outoLamdda, this.m_vertices[outoIndex].y * (1 - outoLamdda) + this.m_vertices[outoIndex2].y * outoLamdda);
+      var area = 0;
+      var center = new b2Vec2();
+      var p2 = this.m_vertices[intoIndex2];
+      var p3;
+      i = intoIndex2;
+      while (i != outoIndex2) {
+         i = (i + 1) % this.m_vertexCount;
+         if (i == outoIndex2) p3 = outoVec;
+         else p3 = this.m_vertices[i];
+         var triangleArea = 0.5 * ((p2.x - intoVec.x) * (p3.y - intoVec.y) - (p2.y - intoVec.y) * (p3.x - intoVec.x));
+         area += triangleArea;
+         center.x += triangleArea * (intoVec.x + p2.x + p3.x) / 3;
+         center.y += triangleArea * (intoVec.y + p2.y + p3.y) / 3;
+         p2 = p3;
+      }
+      center.Multiply(1 / area);
+      c.SetV(b2Math.MulX(xf, center));
+      return area;
+   }
+   b2PolygonShape.prototype.GetVertexCount = function () {
+      return this.m_vertexCount;
+   }
+   b2PolygonShape.prototype.GetVertices = function () {
+      return this.m_vertices;
+   }
+   b2PolygonShape.prototype.GetNormals = function () {
+      return this.m_normals;
+   }
+   b2PolygonShape.prototype.GetSupport = function (d) {
+      var bestIndex = 0;
+      var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y;
+      for (var i = 1; i < this.m_vertexCount; ++i) {
+         var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y;
+         if (value > bestValue) {
+            bestIndex = i;
+            bestValue = value;
+         }
+      }
+      return bestIndex;
+   }
+   b2PolygonShape.prototype.GetSupportVertex = function (d) {
+      var bestIndex = 0;
+      var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y;
+      for (var i = 1; i < this.m_vertexCount; ++i) {
+         var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y;
+         if (value > bestValue) {
+            bestIndex = i;
+            bestValue = value;
+         }
+      }
+      return this.m_vertices[bestIndex];
+   }
+   b2PolygonShape.prototype.Validate = function () {
+      return false;
+   }
+   b2PolygonShape.prototype.b2PolygonShape = function () {
+      this.__super.b2Shape.call(this);
+      this.m_type = b2Shape.e_polygonShape;
+      this.m_centroid = new b2Vec2();
+      this.m_vertices = new Vector();
+      this.m_normals = new Vector();
+   }
+   b2PolygonShape.prototype.Reserve = function (count) {
+      if (count === undefined) count = 0;
+      for (var i = parseInt(this.m_vertices.length); i < count; i++) {
+         this.m_vertices[i] = new b2Vec2();
+         this.m_normals[i] = new b2Vec2();
+      }
+   }
+   b2PolygonShape.ComputeCentroid = function (vs, count) {
+      if (count === undefined) count = 0;
+      var c = new b2Vec2();
+      var area = 0.0;
+      var p1X = 0.0;
+      var p1Y = 0.0;
+      var inv3 = 1.0 / 3.0;
+      for (var i = 0; i < count; ++i) {
+         var p2 = vs[i];
+         var p3 = i + 1 < count ? vs[parseInt(i + 1)] : vs[0];
+         var e1X = p2.x - p1X;
+         var e1Y = p2.y - p1Y;
+         var e2X = p3.x - p1X;
+         var e2Y = p3.y - p1Y;
+         var D = (e1X * e2Y - e1Y * e2X);
+         var triangleArea = 0.5 * D;area += triangleArea;
+         c.x += triangleArea * inv3 * (p1X + p2.x + p3.x);
+         c.y += triangleArea * inv3 * (p1Y + p2.y + p3.y);
+      }
+      c.x *= 1.0 / area;
+      c.y *= 1.0 / area;
+      return c;
+   }
+   b2PolygonShape.ComputeOBB = function (obb, vs, count) {
+      if (count === undefined) count = 0;
+      var i = 0;
+      var p = new Vector(count + 1);
+      for (i = 0;
+      i < count; ++i) {
+         p[i] = vs[i];
+      }
+      p[count] = p[0];
+      var minArea = Number.MAX_VALUE;
+      for (i = 1;
+      i <= count; ++i) {
+         var root = p[parseInt(i - 1)];
+         var uxX = p[i].x - root.x;
+         var uxY = p[i].y - root.y;
+         var length = Math.sqrt(uxX * uxX + uxY * uxY);
+         uxX /= length;
+         uxY /= length;
+         var uyX = (-uxY);
+         var uyY = uxX;
+         var lowerX = Number.MAX_VALUE;
+         var lowerY = Number.MAX_VALUE;
+         var upperX = (-Number.MAX_VALUE);
+         var upperY = (-Number.MAX_VALUE);
+         for (var j = 0; j < count; ++j) {
+            var dX = p[j].x - root.x;
+            var dY = p[j].y - root.y;
+            var rX = (uxX * dX + uxY * dY);
+            var rY = (uyX * dX + uyY * dY);
+            if (rX < lowerX) lowerX = rX;
+            if (rY < lowerY) lowerY = rY;
+            if (rX > upperX) upperX = rX;
+            if (rY > upperY) upperY = rY;
+         }
+         var area = (upperX - lowerX) * (upperY - lowerY);
+         if (area < 0.95 * minArea) {
+            minArea = area;
+            obb.R.col1.x = uxX;
+            obb.R.col1.y = uxY;
+            obb.R.col2.x = uyX;
+            obb.R.col2.y = uyY;
+            var centerX = 0.5 * (lowerX + upperX);
+            var centerY = 0.5 * (lowerY + upperY);
+            var tMat = obb.R;
+            obb.center.x = root.x + (tMat.col1.x * centerX + tMat.col2.x * centerY);
+            obb.center.y = root.y + (tMat.col1.y * centerX + tMat.col2.y * centerY);
+            obb.extents.x = 0.5 * (upperX - lowerX);
+            obb.extents.y = 0.5 * (upperY - lowerY);
+         }
+      }
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Collision.Shapes.b2PolygonShape.s_mat = new b2Mat22();
+   });
+   b2Shape.b2Shape = function () {};
+   b2Shape.prototype.Copy = function () {
+      return null;
+   }
+   b2Shape.prototype.Set = function (other) {
+      this.m_radius = other.m_radius;
+   }
+   b2Shape.prototype.GetType = function () {
+      return this.m_type;
+   }
+   b2Shape.prototype.TestPoint = function (xf, p) {
+      return false;
+   }
+   b2Shape.prototype.RayCast = function (output, input, transform) {
+      return false;
+   }
+   b2Shape.prototype.ComputeAABB = function (aabb, xf) {}
+   b2Shape.prototype.ComputeMass = function (massData, density) {
+      if (density === undefined) density = 0;
+   }
+   b2Shape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) {
+      if (offset === undefined) offset = 0;
+      return 0;
+   }
+   b2Shape.TestOverlap = function (shape1, transform1, shape2, transform2) {
+      var input = new b2DistanceInput();
+      input.proxyA = new b2DistanceProxy();
+      input.proxyA.Set(shape1);
+      input.proxyB = new b2DistanceProxy();
+      input.proxyB.Set(shape2);
+      input.transformA = transform1;
+      input.transformB = transform2;
+      input.useRadii = true;
+      var simplexCache = new b2SimplexCache();
+      simplexCache.count = 0;
+      var output = new b2DistanceOutput();
+      b2Distance.Distance(output, simplexCache, input);
+      return output.distance < 10.0 * Number.MIN_VALUE;
+   }
+   b2Shape.prototype.b2Shape = function () {
+      this.m_type = b2Shape.e_unknownShape;
+      this.m_radius = b2Settings.b2_linearSlop;
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Collision.Shapes.b2Shape.e_unknownShape = parseInt((-1));
+      Box2D.Collision.Shapes.b2Shape.e_circleShape = 0;
+      Box2D.Collision.Shapes.b2Shape.e_polygonShape = 1;
+      Box2D.Collision.Shapes.b2Shape.e_edgeShape = 2;
+      Box2D.Collision.Shapes.b2Shape.e_shapeTypeCount = 3;
+      Box2D.Collision.Shapes.b2Shape.e_hitCollide = 1;
+      Box2D.Collision.Shapes.b2Shape.e_missCollide = 0;
+      Box2D.Collision.Shapes.b2Shape.e_startsInsideCollide = parseInt((-1));
+   });
+})();
+(function () {
+   var b2Color = Box2D.Common.b2Color,
+      b2internal = Box2D.Common.b2internal,
+      b2Settings = Box2D.Common.b2Settings,
+      b2Mat22 = Box2D.Common.Math.b2Mat22,
+      b2Mat33 = Box2D.Common.Math.b2Mat33,
+      b2Math = Box2D.Common.Math.b2Math,
+      b2Sweep = Box2D.Common.Math.b2Sweep,
+      b2Transform = Box2D.Common.Math.b2Transform,
+      b2Vec2 = Box2D.Common.Math.b2Vec2,
+      b2Vec3 = Box2D.Common.Math.b2Vec3;
+
+   b2Color.b2Color = function () {
+      this._r = 0;
+      this._g = 0;
+      this._b = 0;
+   };
+   b2Color.prototype.b2Color = function (rr, gg, bb) {
+      if (rr === undefined) rr = 0;
+      if (gg === undefined) gg = 0;
+      if (bb === undefined) bb = 0;
+      this._r = Box2D.parseUInt(255 * b2Math.Clamp(rr, 0.0, 1.0));
+      this._g = Box2D.parseUInt(255 * b2Math.Clamp(gg, 0.0, 1.0));
+      this._b = Box2D.parseUInt(255 * b2Math.Clamp(bb, 0.0, 1.0));
+   }
+   b2Color.prototype.Set = function (rr, gg, bb) {
+      if (rr === undefined) rr = 0;
+      if (gg === undefined) gg = 0;
+      if (bb === undefined) bb = 0;
+      this._r = Box2D.parseUInt(255 * b2Math.Clamp(rr, 0.0, 1.0));
+      this._g = Box2D.parseUInt(255 * b2Math.Clamp(gg, 0.0, 1.0));
+      this._b = Box2D.parseUInt(255 * b2Math.Clamp(bb, 0.0, 1.0));
+   }
+   Object.defineProperty(b2Color.prototype, 'r', {
+      enumerable: false,
+      configurable: true,
+      set: function (rr) {
+         if (rr === undefined) rr = 0;
+         this._r = Box2D.parseUInt(255 * b2Math.Clamp(rr, 0.0, 1.0));
+      }
+   });
+   Object.defineProperty(b2Color.prototype, 'g', {
+      enumerable: false,
+      configurable: true,
+      set: function (gg) {
+         if (gg === undefined) gg = 0;
+         this._g = Box2D.parseUInt(255 * b2Math.Clamp(gg, 0.0, 1.0));
+      }
+   });
+   Object.defineProperty(b2Color.prototype, 'b', {
+      enumerable: false,
+      configurable: true,
+      set: function (bb) {
+         if (bb === undefined) bb = 0;
+         this._b = Box2D.parseUInt(255 * b2Math.Clamp(bb, 0.0, 1.0));
+      }
+   });
+   Object.defineProperty(b2Color.prototype, 'color', {
+      enumerable: false,
+      configurable: true,
+      get: function () {
+         return (this._r << 16) | (this._g << 8) | (this._b);
+      }
+   });
+   b2Settings.b2Settings = function () {};
+   b2Settings.b2MixFriction = function (friction1, friction2) {
+      if (friction1 === undefined) friction1 = 0;
+      if (friction2 === undefined) friction2 = 0;
+      return Math.sqrt(friction1 * friction2);
+   }
+   b2Settings.b2MixRestitution = function (restitution1, restitution2) {
+      if (restitution1 === undefined) restitution1 = 0;
+      if (restitution2 === undefined) restitution2 = 0;
+      return restitution1 > restitution2 ? restitution1 : restitution2;
+   }
+   b2Settings.b2Assert = function (a) {
+      if (!a) {
+         throw "Assertion Failed";
+      }
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Common.b2Settings.VERSION = "2.1alpha";
+      Box2D.Common.b2Settings.USHRT_MAX = 0x0000ffff;
+      Box2D.Common.b2Settings.b2_pi = Math.PI;
+      Box2D.Common.b2Settings.b2_maxManifoldPoints = 2;
+      Box2D.Common.b2Settings.b2_aabbExtension = 0.1;
+      Box2D.Common.b2Settings.b2_aabbMultiplier = 2.0;
+      Box2D.Common.b2Settings.b2_polygonRadius = 2.0 * b2Settings.b2_linearSlop;
+      Box2D.Common.b2Settings.b2_linearSlop = 0.005;
+      Box2D.Common.b2Settings.b2_angularSlop = 2.0 / 180.0 * b2Settings.b2_pi;
+      Box2D.Common.b2Settings.b2_toiSlop = 8.0 * b2Settings.b2_linearSlop;
+      Box2D.Common.b2Settings.b2_maxTOIContactsPerIsland = 32;
+      Box2D.Common.b2Settings.b2_maxTOIJointsPerIsland = 32;
+      Box2D.Common.b2Settings.b2_velocityThreshold = 1.0;
+      Box2D.Common.b2Settings.b2_maxLinearCorrection = 0.2;
+      Box2D.Common.b2Settings.b2_maxAngularCorrection = 8.0 / 180.0 * b2Settings.b2_pi;
+      Box2D.Common.b2Settings.b2_maxTranslation = 2.0;
+      Box2D.Common.b2Settings.b2_maxTranslationSquared = b2Settings.b2_maxTranslation * b2Settings.b2_maxTranslation;
+      Box2D.Common.b2Settings.b2_maxRotation = 0.5 * b2Settings.b2_pi;
+      Box2D.Common.b2Settings.b2_maxRotationSquared = b2Settings.b2_maxRotation * b2Settings.b2_maxRotation;
+      Box2D.Common.b2Settings.b2_contactBaumgarte = 0.2;
+      Box2D.Common.b2Settings.b2_timeToSleep = 0.5;
+      Box2D.Common.b2Settings.b2_linearSleepTolerance = 0.01;
+      Box2D.Common.b2Settings.b2_angularSleepTolerance = 2.0 / 180.0 * b2Settings.b2_pi;
+   });
+})();
+(function () {
+   var b2AABB = Box2D.Collision.b2AABB,
+      b2Color = Box2D.Common.b2Color,
+      b2internal = Box2D.Common.b2internal,
+      b2Settings = Box2D.Common.b2Settings,
+      b2Mat22 = Box2D.Common.Math.b2Mat22,
+      b2Mat33 = Box2D.Common.Math.b2Mat33,
+      b2Math = Box2D.Common.Math.b2Math,
+      b2Sweep = Box2D.Common.Math.b2Sweep,
+      b2Transform = Box2D.Common.Math.b2Transform,
+      b2Vec2 = Box2D.Common.Math.b2Vec2,
+      b2Vec3 = Box2D.Common.Math.b2Vec3;
+
+   b2Mat22.b2Mat22 = function () {
+      this.col1 = new b2Vec2();
+      this.col2 = new b2Vec2();
+   };
+   b2Mat22.prototype.b2Mat22 = function () {
+      this.SetIdentity();
+   }
+   b2Mat22.FromAngle = function (angle) {
+      if (angle === undefined) angle = 0;
+      var mat = new b2Mat22();
+      mat.Set(angle);
+      return mat;
+   }
+   b2Mat22.FromVV = function (c1, c2) {
+      var mat = new b2Mat22();
+      mat.SetVV(c1, c2);
+      return mat;
+   }
+   b2Mat22.prototype.Set = function (angle) {
+      if (angle === undefined) angle = 0;
+      var c = Math.cos(angle);
+      var s = Math.sin(angle);
+      this.col1.x = c;
+      this.col2.x = (-s);
+      this.col1.y = s;
+      this.col2.y = c;
+   }
+   b2Mat22.prototype.SetVV = function (c1, c2) {
+      this.col1.SetV(c1);
+      this.col2.SetV(c2);
+   }
+   b2Mat22.prototype.Copy = function () {
+      var mat = new b2Mat22();
+      mat.SetM(this);
+      return mat;
+   }
+   b2Mat22.prototype.SetM = function (m) {
+      this.col1.SetV(m.col1);
+      this.col2.SetV(m.col2);
+   }
+   b2Mat22.prototype.AddM = function (m) {
+      this.col1.x += m.col1.x;
+      this.col1.y += m.col1.y;
+      this.col2.x += m.col2.x;
+      this.col2.y += m.col2.y;
+   }
+   b2Mat22.prototype.SetIdentity = function () {
+      this.col1.x = 1.0;
+      this.col2.x = 0.0;
+      this.col1.y = 0.0;
+      this.col2.y = 1.0;
+   }
+   b2Mat22.prototype.SetZero = function () {
+      this.col1.x = 0.0;
+      this.col2.x = 0.0;
+      this.col1.y = 0.0;
+      this.col2.y = 0.0;
+   }
+   b2Mat22.prototype.GetAngle = function () {
+      return Math.atan2(this.col1.y, this.col1.x);
+   }
+   b2Mat22.prototype.GetInverse = function (out) {
+      var a = this.col1.x;
+      var b = this.col2.x;
+      var c = this.col1.y;
+      var d = this.col2.y;
+      var det = a * d - b * c;
+      if (det != 0.0) {
+         det = 1.0 / det;
+      }
+      out.col1.x = det * d;
+      out.col2.x = (-det * b);
+      out.col1.y = (-det * c);
+      out.col2.y = det * a;
+      return out;
+   }
+   b2Mat22.prototype.Solve = function (out, bX, bY) {
+      if (bX === undefined) bX = 0;
+      if (bY === undefined) bY = 0;
+      var a11 = this.col1.x;
+      var a12 = this.col2.x;
+      var a21 = this.col1.y;
+      var a22 = this.col2.y;
+      var det = a11 * a22 - a12 * a21;
+      if (det != 0.0) {
+         det = 1.0 / det;
+      }
+      out.x = det * (a22 * bX - a12 * bY);
+      out.y = det * (a11 * bY - a21 * bX);
+      return out;
+   }
+   b2Mat22.prototype.Abs = function () {
+      this.col1.Abs();
+      this.col2.Abs();
+   }
+   b2Mat33.b2Mat33 = function () {
+      this.col1 = new b2Vec3();
+      this.col2 = new b2Vec3();
+      this.col3 = new b2Vec3();
+   };
+   b2Mat33.prototype.b2Mat33 = function (c1, c2, c3) {
+      if (c1 === undefined) c1 = null;
+      if (c2 === undefined) c2 = null;
+      if (c3 === undefined) c3 = null;
+      if (!c1 && !c2 && !c3) {
+         this.col1.SetZero();
+         this.col2.SetZero();
+         this.col3.SetZero();
+      }
+      else {
+         this.col1.SetV(c1);
+         this.col2.SetV(c2);
+         this.col3.SetV(c3);
+      }
+   }
+   b2Mat33.prototype.SetVVV = function (c1, c2, c3) {
+      this.col1.SetV(c1);
+      this.col2.SetV(c2);
+      this.col3.SetV(c3);
+   }
+   b2Mat33.prototype.Copy = function () {
+      return new b2Mat33(this.col1, this.col2, this.col3);
+   }
+   b2Mat33.prototype.SetM = function (m) {
+      this.col1.SetV(m.col1);
+      this.col2.SetV(m.col2);
+      this.col3.SetV(m.col3);
+   }
+   b2Mat33.prototype.AddM = function (m) {
+      this.col1.x += m.col1.x;
+      this.col1.y += m.col1.y;
+      this.col1.z += m.col1.z;
+      this.col2.x += m.col2.x;
+      this.col2.y += m.col2.y;
+      this.col2.z += m.col2.z;
+      this.col3.x += m.col3.x;
+      this.col3.y += m.col3.y;
+      this.col3.z += m.col3.z;
+   }
+   b2Mat33.prototype.SetIdentity = function () {
+      this.col1.x = 1.0;
+      this.col2.x = 0.0;
+      this.col3.x = 0.0;
+      this.col1.y = 0.0;
+      this.col2.y = 1.0;
+      this.col3.y = 0.0;
+      this.col1.z = 0.0;
+      this.col2.z = 0.0;
+      this.col3.z = 1.0;
+   }
+   b2Mat33.prototype.SetZero = function () {
+      this.col1.x = 0.0;
+      this.col2.x = 0.0;
+      this.col3.x = 0.0;
+      this.col1.y = 0.0;
+      this.col2.y = 0.0;
+      this.col3.y = 0.0;
+      this.col1.z = 0.0;
+      this.col2.z = 0.0;
+      this.col3.z = 0.0;
+   }
+   b2Mat33.prototype.Solve22 = function (out, bX, bY) {
+      if (bX === undefined) bX = 0;
+      if (bY === undefined) bY = 0;
+      var a11 = this.col1.x;
+      var a12 = this.col2.x;
+      var a21 = this.col1.y;
+      var a22 = this.col2.y;
+      var det = a11 * a22 - a12 * a21;
+      if (det != 0.0) {
+         det = 1.0 / det;
+      }
+      out.x = det * (a22 * bX - a12 * bY);
+      out.y = det * (a11 * bY - a21 * bX);
+      return out;
+   }
+   b2Mat33.prototype.Solve33 = function (out, bX, bY, bZ) {
+      if (bX === undefined) bX = 0;
+      if (bY === undefined) bY = 0;
+      if (bZ === undefined) bZ = 0;
+      var a11 = this.col1.x;
+      var a21 = this.col1.y;
+      var a31 = this.col1.z;
+      var a12 = this.col2.x;
+      var a22 = this.col2.y;
+      var a32 = this.col2.z;
+      var a13 = this.col3.x;
+      var a23 = this.col3.y;
+      var a33 = this.col3.z;
+      var det = a11 * (a22 * a33 - a32 * a23) + a21 * (a32 * a13 - a12 * a33) + a31 * (a12 * a23 - a22 * a13);
+      if (det != 0.0) {
+         det = 1.0 / det;
+      }
+      out.x = det * (bX * (a22 * a33 - a32 * a23) + bY * (a32 * a13 - a12 * a33) + bZ * (a12 * a23 - a22 * a13));
+      out.y = det * (a11 * (bY * a33 - bZ * a23) + a21 * (bZ * a13 - bX * a33) + a31 * (bX * a23 - bY * a13));
+      out.z = det * (a11 * (a22 * bZ - a32 * bY) + a21 * (a32 * bX - a12 * bZ) + a31 * (a12 * bY - a22 * bX));
+      return out;
+   }
+   b2Math.b2Math = function () {};
+   b2Math.IsValid = function (x) {
+      if (x === undefined) x = 0;
+      return isFinite(x);
+   }
+   b2Math.Dot = function (a, b) {
+      return a.x * b.x + a.y * b.y;
+   }
+   b2Math.CrossVV = function (a, b) {
+      return a.x * b.y - a.y * b.x;
+   }
+   b2Math.CrossVF = function (a, s) {
+      if (s === undefined) s = 0;
+      var v = new b2Vec2(s * a.y, (-s * a.x));
+      return v;
+   }
+   b2Math.CrossFV = function (s, a) {
+      if (s === undefined) s = 0;
+      var v = new b2Vec2((-s * a.y), s * a.x);
+      return v;
+   }
+   b2Math.MulMV = function (A, v) {
+      var u = new b2Vec2(A.col1.x * v.x + A.col2.x * v.y, A.col1.y * v.x + A.col2.y * v.y);
+      return u;
+   }
+   b2Math.MulTMV = function (A, v) {
+      var u = new b2Vec2(b2Math.Dot(v, A.col1), b2Math.Dot(v, A.col2));
+      return u;
+   }
+   b2Math.MulX = function (T, v) {
+      var a = b2Math.MulMV(T.R, v);
+      a.x += T.position.x;
+      a.y += T.position.y;
+      return a;
+   }
+   b2Math.MulXT = function (T, v) {
+      var a = b2Math.SubtractVV(v, T.position);
+      var tX = (a.x * T.R.col1.x + a.y * T.R.col1.y);
+      a.y = (a.x * T.R.col2.x + a.y * T.R.col2.y);
+      a.x = tX;
+      return a;
+   }
+   b2Math.AddVV = function (a, b) {
+      var v = new b2Vec2(a.x + b.x, a.y + b.y);
+      return v;
+   }
+   b2Math.SubtractVV = function (a, b) {
+      var v = new b2Vec2(a.x - b.x, a.y - b.y);
+      return v;
+   }
+   b2Math.Distance = function (a, b) {
+      var cX = a.x - b.x;
+      var cY = a.y - b.y;
+      return Math.sqrt(cX * cX + cY * cY);
+   }
+   b2Math.DistanceSquared = function (a, b) {
+      var cX = a.x - b.x;
+      var cY = a.y - b.y;
+      return (cX * cX + cY * cY);
+   }
+   b2Math.MulFV = function (s, a) {
+      if (s === undefined) s = 0;
+      var v = new b2Vec2(s * a.x, s * a.y);
+      return v;
+   }
+   b2Math.AddMM = function (A, B) {
+      var C = b2Mat22.FromVV(b2Math.AddVV(A.col1, B.col1), b2Math.AddVV(A.col2, B.col2));
+      return C;
+   }
+   b2Math.MulMM = function (A, B) {
+      var C = b2Mat22.FromVV(b2Math.MulMV(A, B.col1), b2Math.MulMV(A, B.col2));
+      return C;
+   }
+   b2Math.MulTMM = function (A, B) {
+      var c1 = new b2Vec2(b2Math.Dot(A.col1, B.col1), b2Math.Dot(A.col2, B.col1));
+      var c2 = new b2Vec2(b2Math.Dot(A.col1, B.col2), b2Math.Dot(A.col2, B.col2));
+      var C = b2Mat22.FromVV(c1, c2);
+      return C;
+   }
+   b2Math.Abs = function (a) {
+      if (a === undefined) a = 0;
+      return a > 0.0 ? a : (-a);
+   }
+   b2Math.AbsV = function (a) {
+      var b = new b2Vec2(b2Math.Abs(a.x), b2Math.Abs(a.y));
+      return b;
+   }
+   b2Math.AbsM = function (A) {
+      var B = b2Mat22.FromVV(b2Math.AbsV(A.col1), b2Math.AbsV(A.col2));
+      return B;
+   }
+   b2Math.Min = function (a, b) {
+      if (a === undefined) a = 0;
+      if (b === undefined) b = 0;
+      return a < b ? a : b;
+   }
+   b2Math.MinV = function (a, b) {
+      var c = new b2Vec2(b2Math.Min(a.x, b.x), b2Math.Min(a.y, b.y));
+      return c;
+   }
+   b2Math.Max = function (a, b) {
+      if (a === undefined) a = 0;
+      if (b === undefined) b = 0;
+      return a > b ? a : b;
+   }
+   b2Math.MaxV = function (a, b) {
+      var c = new b2Vec2(b2Math.Max(a.x, b.x), b2Math.Max(a.y, b.y));
+      return c;
+   }
+   b2Math.Clamp = function (a, low, high) {
+      if (a === undefined) a = 0;
+      if (low === undefined) low = 0;
+      if (high === undefined) high = 0;
+      return a < low ? low : a > high ? high : a;
+   }
+   b2Math.ClampV = function (a, low, high) {
+      return b2Math.MaxV(low, b2Math.MinV(a, high));
+   }
+   b2Math.Swap = function (a, b) {
+      var tmp = a[0];
+      a[0] = b[0];
+      b[0] = tmp;
+   }
+   b2Math.Random = function () {
+      return Math.random() * 2 - 1;
+   }
+   b2Math.RandomRange = function (lo, hi) {
+      if (lo === undefined) lo = 0;
+      if (hi === undefined) hi = 0;
+      var r = Math.random();
+      r = (hi - lo) * r + lo;
+      return r;
+   }
+   b2Math.NextPowerOfTwo = function (x) {
+      if (x === undefined) x = 0;
+      x |= (x >> 1) & 0x7FFFFFFF;
+      x |= (x >> 2) & 0x3FFFFFFF;
+      x |= (x >> 4) & 0x0FFFFFFF;
+      x |= (x >> 8) & 0x00FFFFFF;
+      x |= (x >> 16) & 0x0000FFFF;
+      return x + 1;
+   }
+   b2Math.IsPowerOfTwo = function (x) {
+      if (x === undefined) x = 0;
+      var result = x > 0 && (x & (x - 1)) == 0;
+      return result;
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Common.Math.b2Math.b2Vec2_zero = new b2Vec2(0.0, 0.0);
+      Box2D.Common.Math.b2Math.b2Mat22_identity = b2Mat22.FromVV(new b2Vec2(1.0, 0.0), new b2Vec2(0.0, 1.0));
+      Box2D.Common.Math.b2Math.b2Transform_identity = new b2Transform(b2Math.b2Vec2_zero, b2Math.b2Mat22_identity);
+   });
+   b2Sweep.b2Sweep = function () {
+      this.localCenter = new b2Vec2();
+      this.c0 = new b2Vec2;
+      this.c = new b2Vec2();
+   };
+   b2Sweep.prototype.Set = function (other) {
+      this.localCenter.SetV(other.localCenter);
+      this.c0.SetV(other.c0);
+      this.c.SetV(other.c);
+      this.a0 = other.a0;
+      this.a = other.a;
+      this.t0 = other.t0;
+   }
+   b2Sweep.prototype.Copy = function () {
+      var copy = new b2Sweep();
+      copy.localCenter.SetV(this.localCenter);
+      copy.c0.SetV(this.c0);
+      copy.c.SetV(this.c);
+      copy.a0 = this.a0;
+      copy.a = this.a;
+      copy.t0 = this.t0;
+      return copy;
+   }
+   b2Sweep.prototype.GetTransform = function (xf, alpha) {
+      if (alpha === undefined) alpha = 0;
+      xf.position.x = (1.0 - alpha) * this.c0.x + alpha * this.c.x;
+      xf.position.y = (1.0 - alpha) * this.c0.y + alpha * this.c.y;
+      var angle = (1.0 - alpha) * this.a0 + alpha * this.a;
+      xf.R.Set(angle);
+      var tMat = xf.R;
+      xf.position.x -= (tMat.col1.x * this.localCenter.x + tMat.col2.x * this.localCenter.y);
+      xf.position.y -= (tMat.col1.y * this.localCenter.x + tMat.col2.y * this.localCenter.y);
+   }
+   b2Sweep.prototype.Advance = function (t) {
+      if (t === undefined) t = 0;
+      if (this.t0 < t && 1.0 - this.t0 > Number.MIN_VALUE) {
+         var alpha = (t - this.t0) / (1.0 - this.t0);
+         this.c0.x = (1.0 - alpha) * this.c0.x + alpha * this.c.x;
+         this.c0.y = (1.0 - alpha) * this.c0.y + alpha * this.c.y;
+         this.a0 = (1.0 - alpha) * this.a0 + alpha * this.a;
+         this.t0 = t;
+      }
+   }
+   b2Transform.b2Transform = function () {
+      this.position = new b2Vec2;
+      this.R = new b2Mat22();
+   };
+   b2Transform.prototype.b2Transform = function (pos, r) {
+      if (pos === undefined) pos = null;
+      if (r === undefined) r = null;
+      if (pos) {
+         this.position.SetV(pos);
+         this.R.SetM(r);
+      }
+   }
+   b2Transform.prototype.Initialize = function (pos, r) {
+      this.position.SetV(pos);
+      this.R.SetM(r);
+   }
+   b2Transform.prototype.SetIdentity = function () {
+      this.position.SetZero();
+      this.R.SetIdentity();
+   }
+   b2Transform.prototype.Set = function (x) {
+      this.position.SetV(x.position);
+      this.R.SetM(x.R);
+   }
+   b2Transform.prototype.GetAngle = function () {
+      return Math.atan2(this.R.col1.y, this.R.col1.x);
+   }
+   b2Vec2.b2Vec2 = function () {};
+   b2Vec2.prototype.b2Vec2 = function (x_, y_) {
+      if (x_ === undefined) x_ = 0;
+      if (y_ === undefined) y_ = 0;
+      this.x = x_;
+      this.y = y_;
+   }
+   b2Vec2.prototype.SetZero = function () {
+      this.x = 0.0;
+      this.y = 0.0;
+   }
+   b2Vec2.prototype.Set = function (x_, y_) {
+      if (x_ === undefined) x_ = 0;
+      if (y_ === undefined) y_ = 0;
+      this.x = x_;
+      this.y = y_;
+   }
+   b2Vec2.prototype.SetV = function (v) {
+      this.x = v.x;
+      this.y = v.y;
+   }
+   b2Vec2.prototype.GetNegative = function () {
+      return new b2Vec2((-this.x), (-this.y));
+   }
+   b2Vec2.prototype.NegativeSelf = function () {
+      this.x = (-this.x);
+      this.y = (-this.y);
+   }
+   b2Vec2.Make = function (x_, y_) {
+      if (x_ === undefined) x_ = 0;
+      if (y_ === undefined) y_ = 0;
+      return new b2Vec2(x_, y_);
+   }
+   b2Vec2.prototype.Copy = function () {
+      return new b2Vec2(this.x, this.y);
+   }
+   b2Vec2.prototype.Add = function (v) {
+      this.x += v.x;
+      this.y += v.y;
+   }
+   b2Vec2.prototype.Subtract = function (v) {
+      this.x -= v.x;
+      this.y -= v.y;
+   }
+   b2Vec2.prototype.Multiply = function (a) {
+      if (a === undefined) a = 0;
+      this.x *= a;
+      this.y *= a;
+   }
+   b2Vec2.prototype.MulM = function (A) {
+      var tX = this.x;
+      this.x = A.col1.x * tX + A.col2.x * this.y;
+      this.y = A.col1.y * tX + A.col2.y * this.y;
+   }
+   b2Vec2.prototype.MulTM = function (A) {
+      var tX = b2Math.Dot(this, A.col1);
+      this.y = b2Math.Dot(this, A.col2);
+      this.x = tX;
+   }
+   b2Vec2.prototype.CrossVF = function (s) {
+      if (s === undefined) s = 0;
+      var tX = this.x;
+      this.x = s * this.y;
+      this.y = (-s * tX);
+   }
+   b2Vec2.prototype.CrossFV = function (s) {
+      if (s === undefined) s = 0;
+      var tX = this.x;
+      this.x = (-s * this.y);
+      this.y = s * tX;
+   }
+   b2Vec2.prototype.MinV = function (b) {
+      this.x = this.x < b.x ? this.x : b.x;
+      this.y = this.y < b.y ? this.y : b.y;
+   }
+   b2Vec2.prototype.MaxV = function (b) {
+      this.x = this.x > b.x ? this.x : b.x;
+      this.y = this.y > b.y ? this.y : b.y;
+   }
+   b2Vec2.prototype.Abs = function () {
+      if (this.x < 0) this.x = (-this.x);
+      if (this.y < 0) this.y = (-this.y);
+   }
+   b2Vec2.prototype.Length = function () {
+      return Math.sqrt(this.x * this.x + this.y * this.y);
+   }
+   b2Vec2.prototype.LengthSquared = function () {
+      return (this.x * this.x + this.y * this.y);
+   }
+   b2Vec2.prototype.Normalize = function () {
+      var length = Math.sqrt(this.x * this.x + this.y * this.y);
+      if (length < Number.MIN_VALUE) {
+         return 0.0;
+      }
+      var invLength = 1.0 / length;
+      this.x *= invLength;
+      this.y *= invLength;
+      return length;
+   }
+   b2Vec2.prototype.IsValid = function () {
+      return b2Math.IsValid(this.x) && b2Math.IsValid(this.y);
+   }
+   b2Vec3.b2Vec3 = function () {};
+   b2Vec3.prototype.b2Vec3 = function (x, y, z) {
+      if (x === undefined) x = 0;
+      if (y === undefined) y = 0;
+      if (z === undefined) z = 0;
+      this.x = x;
+      this.y = y;
+      this.z = z;
+   }
+   b2Vec3.prototype.SetZero = function () {
+      this.x = this.y = this.z = 0.0;
+   }
+   b2Vec3.prototype.Set = function (x, y, z) {
+      if (x === undefined) x = 0;
+      if (y === undefined) y = 0;
+      if (z === undefined) z = 0;
+      this.x = x;
+      this.y = y;
+      this.z = z;
+   }
+   b2Vec3.prototype.SetV = function (v) {
+      this.x = v.x;
+      this.y = v.y;
+      this.z = v.z;
+   }
+   b2Vec3.prototype.GetNegative = function () {
+      return new b2Vec3((-this.x), (-this.y), (-this.z));
+   }
+   b2Vec3.prototype.NegativeSelf = function () {
+      this.x = (-this.x);
+      this.y = (-this.y);
+      this.z = (-this.z);
+   }
+   b2Vec3.prototype.Copy = function () {
+      return new b2Vec3(this.x, this.y, this.z);
+   }
+   b2Vec3.prototype.Add = function (v) {
+      this.x += v.x;
+      this.y += v.y;
+      this.z += v.z;
+   }
+   b2Vec3.prototype.Subtract = function (v) {
+      this.x -= v.x;
+      this.y -= v.y;
+      this.z -= v.z;
+   }
+   b2Vec3.prototype.Multiply = function (a) {
+      if (a === undefined) a = 0;
+      this.x *= a;
+      this.y *= a;
+      this.z *= a;
+   }
+})();
+(function () {
+   var b2ControllerEdge = Box2D.Dynamics.Controllers.b2ControllerEdge,
+      b2Mat22 = Box2D.Common.Math.b2Mat22,
+      b2Mat33 = Box2D.Common.Math.b2Mat33,
+      b2Math = Box2D.Common.Math.b2Math,
+      b2Sweep = Box2D.Common.Math.b2Sweep,
+      b2Transform = Box2D.Common.Math.b2Transform,
+      b2Vec2 = Box2D.Common.Math.b2Vec2,
+      b2Vec3 = Box2D.Common.Math.b2Vec3,
+      b2Color = Box2D.Common.b2Color,
+      b2internal = Box2D.Common.b2internal,
+      b2Settings = Box2D.Common.b2Settings,
+      b2AABB = Box2D.Collision.b2AABB,
+      b2Bound = Box2D.Collision.b2Bound,
+      b2BoundValues = Box2D.Collision.b2BoundValues,
+      b2Collision = Box2D.Collision.b2Collision,
+      b2ContactID = Box2D.Collision.b2ContactID,
+      b2ContactPoint = Box2D.Collision.b2ContactPoint,
+      b2Distance = Box2D.Collision.b2Distance,
+      b2DistanceInput = Box2D.Collision.b2DistanceInput,
+      b2DistanceOutput = Box2D.Collision.b2DistanceOutput,
+      b2DistanceProxy = Box2D.Collision.b2DistanceProxy,
+      b2DynamicTree = Box2D.Collision.b2DynamicTree,
+      b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase,
+      b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode,
+      b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair,
+      b2Manifold = Box2D.Collision.b2Manifold,
+      b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint,
+      b2Point = Box2D.Collision.b2Point,
+      b2RayCastInput = Box2D.Collision.b2RayCastInput,
+      b2RayCastOutput = Box2D.Collision.b2RayCastOutput,
+      b2Segment = Box2D.Collision.b2Segment,
+      b2SeparationFunction = Box2D.Collision.b2SeparationFunction,
+      b2Simplex = Box2D.Collision.b2Simplex,
+      b2SimplexCache = Box2D.Collision.b2SimplexCache,
+      b2SimplexVertex = Box2D.Collision.b2SimplexVertex,
+      b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact,
+      b2TOIInput = Box2D.Collision.b2TOIInput,
+      b2WorldManifold = Box2D.Collision.b2WorldManifold,
+      ClipVertex = Box2D.Collision.ClipVertex,
+      Features = Box2D.Collision.Features,
+      IBroadPhase = Box2D.Collision.IBroadPhase,
+      b2CircleShape = Box2D.Collision.Shapes.b2CircleShape,
+      b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef,
+      b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape,
+      b2MassData = Box2D.Collision.Shapes.b2MassData,
+      b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape,
+      b2Shape = Box2D.Collision.Shapes.b2Shape,
+      b2Body = Box2D.Dynamics.b2Body,
+      b2BodyDef = Box2D.Dynamics.b2BodyDef,
+      b2ContactFilter = Box2D.Dynamics.b2ContactFilter,
+      b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse,
+      b2ContactListener = Box2D.Dynamics.b2ContactListener,
+      b2ContactManager = Box2D.Dynamics.b2ContactManager,
+      b2DebugDraw = Box2D.Dynamics.b2DebugDraw,
+      b2DestructionListener = Box2D.Dynamics.b2DestructionListener,
+      b2FilterData = Box2D.Dynamics.b2FilterData,
+      b2Fixture = Box2D.Dynamics.b2Fixture,
+      b2FixtureDef = Box2D.Dynamics.b2FixtureDef,
+      b2Island = Box2D.Dynamics.b2Island,
+      b2TimeStep = Box2D.Dynamics.b2TimeStep,
+      b2World = Box2D.Dynamics.b2World,
+      b2CircleContact = Box2D.Dynamics.Contacts.b2CircleContact,
+      b2Contact = Box2D.Dynamics.Contacts.b2Contact,
+      b2ContactConstraint = Box2D.Dynamics.Contacts.b2ContactConstraint,
+      b2ContactConstraintPoint = Box2D.Dynamics.Contacts.b2ContactConstraintPoint,
+      b2ContactEdge = Box2D.Dynamics.Contacts.b2ContactEdge,
+      b2ContactFactory = Box2D.Dynamics.Contacts.b2ContactFactory,
+      b2ContactRegister = Box2D.Dynamics.Contacts.b2ContactRegister,
+      b2ContactResult = Box2D.Dynamics.Contacts.b2ContactResult,
+      b2ContactSolver = Box2D.Dynamics.Contacts.b2ContactSolver,
+      b2EdgeAndCircleContact = Box2D.Dynamics.Contacts.b2EdgeAndCircleContact,
+      b2NullContact = Box2D.Dynamics.Contacts.b2NullContact,
+      b2PolyAndCircleContact = Box2D.Dynamics.Contacts.b2PolyAndCircleContact,
+      b2PolyAndEdgeContact = Box2D.Dynamics.Contacts.b2PolyAndEdgeContact,
+      b2PolygonContact = Box2D.Dynamics.Contacts.b2PolygonContact,
+      b2PositionSolverManifold = Box2D.Dynamics.Contacts.b2PositionSolverManifold,
+      b2Controller = Box2D.Dynamics.Controllers.b2Controller,
+      b2DistanceJoint = Box2D.Dynamics.Joints.b2DistanceJoint,
+      b2DistanceJointDef = Box2D.Dynamics.Joints.b2DistanceJointDef,
+      b2FrictionJoint = Box2D.Dynamics.Joints.b2FrictionJoint,
+      b2FrictionJointDef = Box2D.Dynamics.Joints.b2FrictionJointDef,
+      b2GearJoint = Box2D.Dynamics.Joints.b2GearJoint,
+      b2GearJointDef = Box2D.Dynamics.Joints.b2GearJointDef,
+      b2Jacobian = Box2D.Dynamics.Joints.b2Jacobian,
+      b2Joint = Box2D.Dynamics.Joints.b2Joint,
+      b2JointDef = Box2D.Dynamics.Joints.b2JointDef,
+      b2JointEdge = Box2D.Dynamics.Joints.b2JointEdge,
+      b2LineJoint = Box2D.Dynamics.Joints.b2LineJoint,
+      b2LineJointDef = Box2D.Dynamics.Joints.b2LineJointDef,
+      b2MouseJoint = Box2D.Dynamics.Joints.b2MouseJoint,
+      b2MouseJointDef = Box2D.Dynamics.Joints.b2MouseJointDef,
+      b2PrismaticJoint = Box2D.Dynamics.Joints.b2PrismaticJoint,
+      b2PrismaticJointDef = Box2D.Dynamics.Joints.b2PrismaticJointDef,
+      b2PulleyJoint = Box2D.Dynamics.Joints.b2PulleyJoint,
+      b2PulleyJointDef = Box2D.Dynamics.Joints.b2PulleyJointDef,
+      b2RevoluteJoint = Box2D.Dynamics.Joints.b2RevoluteJoint,
+      b2RevoluteJointDef = Box2D.Dynamics.Joints.b2RevoluteJointDef,
+      b2WeldJoint = Box2D.Dynamics.Joints.b2WeldJoint,
+      b2WeldJointDef = Box2D.Dynamics.Joints.b2WeldJointDef;
+
+   b2Body.b2Body = function () {
+      this.m_xf = new b2Transform();
+      this.m_sweep = new b2Sweep();
+      this.m_linearVelocity = new b2Vec2();
+      this.m_force = new b2Vec2();
+   };
+   b2Body.prototype.connectEdges = function (s1, s2, angle1) {
+      if (angle1 === undefined) angle1 = 0;
+      var angle2 = Math.atan2(s2.GetDirectionVector().y, s2.GetDirectionVector().x);
+      var coreOffset = Math.tan((angle2 - angle1) * 0.5);
+      var core = b2Math.MulFV(coreOffset, s2.GetDirectionVector());
+      core = b2Math.SubtractVV(core, s2.GetNormalVector());
+      core = b2Math.MulFV(b2Settings.b2_toiSlop, core);
+      core = b2Math.AddVV(core, s2.GetVertex1());
+      var cornerDir = b2Math.AddVV(s1.GetDirectionVector(), s2.GetDirectionVector());
+      cornerDir.Normalize();
+      var convex = b2Math.Dot(s1.GetDirectionVector(), s2.GetNormalVector()) > 0.0;
+      s1.SetNextEdge(s2, core, cornerDir, convex);
+      s2.SetPrevEdge(s1, core, cornerDir, convex);
+      return angle2;
+   }
+   b2Body.prototype.CreateFixture = function (def) {
+      if (this.m_world.IsLocked() == true) {
+         return null;
+      }
+      var fixture = new b2Fixture();
+      fixture.Create(this, this.m_xf, def);
+      if (this.m_flags & b2Body.e_activeFlag) {
+         var broadPhase = this.m_world.m_contactManager.m_broadPhase;
+         fixture.CreateProxy(broadPhase, this.m_xf);
+      }
+      fixture.m_next = this.m_fixtureList;
+      this.m_fixtureList = fixture;
+      ++this.m_fixtureCount;
+      fixture.m_body = this;
+      if (fixture.m_density > 0.0) {
+         this.ResetMassData();
+      }
+      this.m_world.m_flags |= b2World.e_newFixture;
+      return fixture;
+   }
+   b2Body.prototype.CreateFixture2 = function (shape, density) {
+      if (density === undefined) density = 0.0;
+      var def = new b2FixtureDef();
+      def.shape = shape;
+      def.density = density;
+      return this.CreateFixture(def);
+   }
+   b2Body.prototype.DestroyFixture = function (fixture) {
+      if (this.m_world.IsLocked() == true) {
+         return;
+      }
+      var node = this.m_fixtureList;
+      var ppF = null;
+      var found = false;
+      while (node != null) {
+         if (node == fixture) {
+            if (ppF) ppF.m_next = fixture.m_next;
+            else this.m_fixtureList = fixture.m_next;
+            found = true;
+            break;
+         }
+         ppF = node;
+         node = node.m_next;
+      }
+      var edge = this.m_contactList;
+      while (edge) {
+         var c = edge.contact;
+         edge = edge.next;
+         var fixtureA = c.GetFixtureA();
+         var fixtureB = c.GetFixtureB();
+         if (fixture == fixtureA || fixture == fixtureB) {
+            this.m_world.m_contactManager.Destroy(c);
+         }
+      }
+      if (this.m_flags & b2Body.e_activeFlag) {
+         var broadPhase = this.m_world.m_contactManager.m_broadPhase;
+         fixture.DestroyProxy(broadPhase);
+      }
+      else {}
+      fixture.Destroy();
+      fixture.m_body = null;
+      fixture.m_next = null;
+      --this.m_fixtureCount;
+      this.ResetMassData();
+   }
+   b2Body.prototype.SetPositionAndAngle = function (position, angle) {
+      if (angle === undefined) angle = 0;
+      var f;
+      if (this.m_world.IsLocked() == true) {
+         return;
+      }
+      this.m_xf.R.Set(angle);
+      this.m_xf.position.SetV(position);
+      var tMat = this.m_xf.R;
+      var tVec = this.m_sweep.localCenter;
+      this.m_sweep.c.x = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      this.m_sweep.c.y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      this.m_sweep.c.x += this.m_xf.position.x;
+      this.m_sweep.c.y += this.m_xf.position.y;
+      this.m_sweep.c0.SetV(this.m_sweep.c);
+      this.m_sweep.a0 = this.m_sweep.a = angle;
+      var broadPhase = this.m_world.m_contactManager.m_broadPhase;
+      for (f = this.m_fixtureList;
+      f; f = f.m_next) {
+         f.Synchronize(broadPhase, this.m_xf, this.m_xf);
+      }
+      this.m_world.m_contactManager.FindNewContacts();
+   }
+   b2Body.prototype.SetTransform = function (xf) {
+      this.SetPositionAndAngle(xf.position, xf.GetAngle());
+   }
+   b2Body.prototype.GetTransform = function () {
+      return this.m_xf;
+   }
+   b2Body.prototype.GetPosition = function () {
+      return this.m_xf.position;
+   }
+   b2Body.prototype.SetPosition = function (position) {
+      this.SetPositionAndAngle(position, this.GetAngle());
+   }
+   b2Body.prototype.GetAngle = function () {
+      return this.m_sweep.a;
+   }
+   b2Body.prototype.SetAngle = function (angle) {
+      if (angle === undefined) angle = 0;
+      this.SetPositionAndAngle(this.GetPosition(), angle);
+   }
+   b2Body.prototype.GetWorldCenter = function () {
+      return this.m_sweep.c;
+   }
+   b2Body.prototype.GetLocalCenter = function () {
+      return this.m_sweep.localCenter;
+   }
+   b2Body.prototype.SetLinearVelocity = function (v) {
+      if (this.m_type == b2Body.b2_staticBody) {
+         return;
+      }
+      this.m_linearVelocity.SetV(v);
+   }
+   b2Body.prototype.GetLinearVelocity = function () {
+      return this.m_linearVelocity;
+   }
+   b2Body.prototype.SetAngularVelocity = function (omega) {
+      if (omega === undefined) omega = 0;
+      if (this.m_type == b2Body.b2_staticBody) {
+         return;
+      }
+      this.m_angularVelocity = omega;
+   }
+   b2Body.prototype.GetAngularVelocity = function () {
+      return this.m_angularVelocity;
+   }
+   b2Body.prototype.GetDefinition = function () {
+      var bd = new b2BodyDef();
+      bd.type = this.GetType();
+      bd.allowSleep = (this.m_flags & b2Body.e_allowSleepFlag) == b2Body.e_allowSleepFlag;
+      bd.angle = this.GetAngle();
+      bd.angularDamping = this.m_angularDamping;
+      bd.angularVelocity = this.m_angularVelocity;
+      bd.fixedRotation = (this.m_flags & b2Body.e_fixedRotationFlag) == b2Body.e_fixedRotationFlag;
+      bd.bullet = (this.m_flags & b2Body.e_bulletFlag) == b2Body.e_bulletFlag;
+      bd.awake = (this.m_flags & b2Body.e_awakeFlag) == b2Body.e_awakeFlag;
+      bd.linearDamping = this.m_linearDamping;
+      bd.linearVelocity.SetV(this.GetLinearVelocity());
+      bd.position = this.GetPosition();
+      bd.userData = this.GetUserData();
+      return bd;
+   }
+   b2Body.prototype.ApplyForce = function (force, point) {
+      if (this.m_type != b2Body.b2_dynamicBody) {
+         return;
+      }
+      if (this.IsAwake() == false) {
+         this.SetAwake(true);
+      }
+      this.m_force.x += force.x;
+      this.m_force.y += force.y;
+      this.m_torque += ((point.x - this.m_sweep.c.x) * force.y - (point.y - this.m_sweep.c.y) * force.x);
+   }
+   b2Body.prototype.ApplyTorque = function (torque) {
+      if (torque === undefined) torque = 0;
+      if (this.m_type != b2Body.b2_dynamicBody) {
+         return;
+      }
+      if (this.IsAwake() == false) {
+         this.SetAwake(true);
+      }
+      this.m_torque += torque;
+   }
+   b2Body.prototype.ApplyImpulse = function (impulse, point) {
+      if (this.m_type != b2Body.b2_dynamicBody) {
+         return;
+      }
+      if (this.IsAwake() == false) {
+         this.SetAwake(true);
+      }
+      this.m_linearVelocity.x += this.m_invMass * impulse.x;
+      this.m_linearVelocity.y += this.m_invMass * impulse.y;
+      this.m_angularVelocity += this.m_invI * ((point.x - this.m_sweep.c.x) * impulse.y - (point.y - this.m_sweep.c.y) * impulse.x);
+   }
+   b2Body.prototype.Split = function (callback) {
+      var linearVelocity = this.GetLinearVelocity().Copy();
+      var angularVelocity = this.GetAngularVelocity();
+      var center = this.GetWorldCenter();
+      var body1 = this;
+      var body2 = this.m_world.CreateBody(this.GetDefinition());
+      var prev;
+      for (var f = body1.m_fixtureList; f;) {
+         if (callback(f)) {
+            var next = f.m_next;
+            if (prev) {
+               prev.m_next = next;
+            }
+            else {
+               body1.m_fixtureList = next;
+            }
+            body1.m_fixtureCount--;
+            f.m_next = body2.m_fixtureList;
+            body2.m_fixtureList = f;
+            body2.m_fixtureCount++;
+            f.m_body = body2;
+            f = next;
+         }
+         else {
+            prev = f;
+            f = f.m_next;
+         }
+      }
+      body1.ResetMassData();
+      body2.ResetMassData();
+      var center1 = body1.GetWorldCenter();
+      var center2 = body2.GetWorldCenter();
+      var velocity1 = b2Math.AddVV(linearVelocity, b2Math.CrossFV(angularVelocity, b2Math.SubtractVV(center1, center)));
+      var velocity2 = b2Math.AddVV(linearVelocity, b2Math.CrossFV(angularVelocity, b2Math.SubtractVV(center2, center)));
+      body1.SetLinearVelocity(velocity1);
+      body2.SetLinearVelocity(velocity2);
+      body1.SetAngularVelocity(angularVelocity);
+      body2.SetAngularVelocity(angularVelocity);
+      body1.SynchronizeFixtures();
+      body2.SynchronizeFixtures();
+      return body2;
+   }
+   b2Body.prototype.Merge = function (other) {
+      var f;
+      for (f = other.m_fixtureList;
+      f;) {
+         var next = f.m_next;
+         other.m_fixtureCount--;
+         f.m_next = this.m_fixtureList;
+         this.m_fixtureList = f;
+         this.m_fixtureCount++;
+         f.m_body = body2;
+         f = next;
+      }
+      body1.m_fixtureCount = 0;
+      var body1 = this;
+      var body2 = other;
+      var center1 = body1.GetWorldCenter();
+      var center2 = body2.GetWorldCenter();
+      var velocity1 = body1.GetLinearVelocity().Copy();
+      var velocity2 = body2.GetLinearVelocity().Copy();
+      var angular1 = body1.GetAngularVelocity();
+      var angular = body2.GetAngularVelocity();
+      body1.ResetMassData();
+      this.SynchronizeFixtures();
+   }
+   b2Body.prototype.GetMass = function () {
+      return this.m_mass;
+   }
+   b2Body.prototype.GetInertia = function () {
+      return this.m_I;
+   }
+   b2Body.prototype.GetMassData = function (data) {
+      data.mass = this.m_mass;
+      data.I = this.m_I;
+      data.center.SetV(this.m_sweep.localCenter);
+   }
+   b2Body.prototype.SetMassData = function (massData) {
+      b2Settings.b2Assert(this.m_world.IsLocked() == false);
+      if (this.m_world.IsLocked() == true) {
+         return;
+      }
+      if (this.m_type != b2Body.b2_dynamicBody) {
+         return;
+      }
+      this.m_invMass = 0.0;
+      this.m_I = 0.0;
+      this.m_invI = 0.0;
+      this.m_mass = massData.mass;
+      if (this.m_mass <= 0.0) {
+         this.m_mass = 1.0;
+      }
+      this.m_invMass = 1.0 / this.m_mass;
+      if (massData.I > 0.0 && (this.m_flags & b2Body.e_fixedRotationFlag) == 0) {
+         this.m_I = massData.I - this.m_mass * (massData.center.x * massData.center.x + massData.center.y * massData.center.y);
+         this.m_invI = 1.0 / this.m_I;
+      }
+      var oldCenter = this.m_sweep.c.Copy();
+      this.m_sweep.localCenter.SetV(massData.center);
+      this.m_sweep.c0.SetV(b2Math.MulX(this.m_xf, this.m_sweep.localCenter));
+      this.m_sweep.c.SetV(this.m_sweep.c0);
+      this.m_linearVelocity.x += this.m_angularVelocity * (-(this.m_sweep.c.y - oldCenter.y));
+      this.m_linearVelocity.y += this.m_angularVelocity * (+(this.m_sweep.c.x - oldCenter.x));
+   }
+   b2Body.prototype.ResetMassData = function () {
+      this.m_mass = 0.0;
+      this.m_invMass = 0.0;
+      this.m_I = 0.0;
+      this.m_invI = 0.0;
+      this.m_sweep.localCenter.SetZero();
+      if (this.m_type == b2Body.b2_staticBody || this.m_type == b2Body.b2_kinematicBody) {
+         return;
+      }
+      var center = b2Vec2.Make(0, 0);
+      for (var f = this.m_fixtureList; f; f = f.m_next) {
+         if (f.m_density == 0.0) {
+            continue;
+         }
+         var massData = f.GetMassData();
+         this.m_mass += massData.mass;
+         center.x += massData.center.x * massData.mass;
+         center.y += massData.center.y * massData.mass;
+         this.m_I += massData.I;
+      }
+      if (this.m_mass > 0.0) {
+         this.m_invMass = 1.0 / this.m_mass;
+         center.x *= this.m_invMass;
+         center.y *= this.m_invMass;
+      }
+      else {
+         this.m_mass = 1.0;
+         this.m_invMass = 1.0;
+      }
+      if (this.m_I > 0.0 && (this.m_flags & b2Body.e_fixedRotationFlag) == 0) {
+         this.m_I -= this.m_mass * (center.x * center.x + center.y * center.y);
+         this.m_I *= this.m_inertiaScale;
+         b2Settings.b2Assert(this.m_I > 0);
+         this.m_invI = 1.0 / this.m_I;
+      }
+      else {
+         this.m_I = 0.0;
+         this.m_invI = 0.0;
+      }
+      var oldCenter = this.m_sweep.c.Copy();
+      this.m_sweep.localCenter.SetV(center);
+      this.m_sweep.c0.SetV(b2Math.MulX(this.m_xf, this.m_sweep.localCenter));
+      this.m_sweep.c.SetV(this.m_sweep.c0);
+      this.m_linearVelocity.x += this.m_angularVelocity * (-(this.m_sweep.c.y - oldCenter.y));
+      this.m_linearVelocity.y += this.m_angularVelocity * (+(this.m_sweep.c.x - oldCenter.x));
+   }
+   b2Body.prototype.GetWorldPoint = function (localPoint) {
+      var A = this.m_xf.R;
+      var u = new b2Vec2(A.col1.x * localPoint.x + A.col2.x * localPoint.y, A.col1.y * localPoint.x + A.col2.y * localPoint.y);
+      u.x += this.m_xf.position.x;
+      u.y += this.m_xf.position.y;
+      return u;
+   }
+   b2Body.prototype.GetWorldVector = function (localVector) {
+      return b2Math.MulMV(this.m_xf.R, localVector);
+   }
+   b2Body.prototype.GetLocalPoint = function (worldPoint) {
+      return b2Math.MulXT(this.m_xf, worldPoint);
+   }
+   b2Body.prototype.GetLocalVector = function (worldVector) {
+      return b2Math.MulTMV(this.m_xf.R, worldVector);
+   }
+   b2Body.prototype.GetLinearVelocityFromWorldPoint = function (worldPoint) {
+      return new b2Vec2(this.m_linearVelocity.x - this.m_angularVelocity * (worldPoint.y - this.m_sweep.c.y), this.m_linearVelocity.y + this.m_angularVelocity * (worldPoint.x - this.m_sweep.c.x));
+   }
+   b2Body.prototype.GetLinearVelocityFromLocalPoint = function (localPoint) {
+      var A = this.m_xf.R;
+      var worldPoint = new b2Vec2(A.col1.x * localPoint.x + A.col2.x * localPoint.y, A.col1.y * localPoint.x + A.col2.y * localPoint.y);
+      worldPoint.x += this.m_xf.position.x;
+      worldPoint.y += this.m_xf.position.y;
+      return new b2Vec2(this.m_linearVelocity.x - this.m_angularVelocity * (worldPoint.y - this.m_sweep.c.y), this.m_linearVelocity.y + this.m_angularVelocity * (worldPoint.x - this.m_sweep.c.x));
+   }
+   b2Body.prototype.GetLinearDamping = function () {
+      return this.m_linearDamping;
+   }
+   b2Body.prototype.SetLinearDamping = function (linearDamping) {
+      if (linearDamping === undefined) linearDamping = 0;
+      this.m_linearDamping = linearDamping;
+   }
+   b2Body.prototype.GetAngularDamping = function () {
+      return this.m_angularDamping;
+   }
+   b2Body.prototype.SetAngularDamping = function (angularDamping) {
+      if (angularDamping === undefined) angularDamping = 0;
+      this.m_angularDamping = angularDamping;
+   }
+   b2Body.prototype.SetType = function (type) {
+      if (type === undefined) type = 0;
+      if (this.m_type == type) {
+         return;
+      }
+      this.m_type = type;
+      this.ResetMassData();
+      if (this.m_type == b2Body.b2_staticBody) {
+         this.m_linearVelocity.SetZero();
+         this.m_angularVelocity = 0.0;
+      }
+      this.SetAwake(true);
+      this.m_force.SetZero();
+      this.m_torque = 0.0;
+      for (var ce = this.m_contactList; ce; ce = ce.next) {
+         ce.contact.FlagForFiltering();
+      }
+   }
+   b2Body.prototype.GetType = function () {
+      return this.m_type;
+   }
+   b2Body.prototype.SetBullet = function (flag) {
+      if (flag) {
+         this.m_flags |= b2Body.e_bulletFlag;
+      }
+      else {
+         this.m_flags &= ~b2Body.e_bulletFlag;
+      }
+   }
+   b2Body.prototype.IsBullet = function () {
+      return (this.m_flags & b2Body.e_bulletFlag) == b2Body.e_bulletFlag;
+   }
+   b2Body.prototype.SetSleepingAllowed = function (flag) {
+      if (flag) {
+         this.m_flags |= b2Body.e_allowSleepFlag;
+      }
+      else {
+         this.m_flags &= ~b2Body.e_allowSleepFlag;
+         this.SetAwake(true);
+      }
+   }
+   b2Body.prototype.SetAwake = function (flag) {
+      if (flag) {
+         this.m_flags |= b2Body.e_awakeFlag;
+         this.m_sleepTime = 0.0;
+      }
+      else {
+         this.m_flags &= ~b2Body.e_awakeFlag;
+         this.m_sleepTime = 0.0;
+         this.m_linearVelocity.SetZero();
+         this.m_angularVelocity = 0.0;
+         this.m_force.SetZero();
+         this.m_torque = 0.0;
+      }
+   }
+   b2Body.prototype.IsAwake = function () {
+      return (this.m_flags & b2Body.e_awakeFlag) == b2Body.e_awakeFlag;
+   }
+   b2Body.prototype.SetFixedRotation = function (fixed) {
+      if (fixed) {
+         this.m_flags |= b2Body.e_fixedRotationFlag;
+      }
+      else {
+         this.m_flags &= ~b2Body.e_fixedRotationFlag;
+      }
+      this.ResetMassData();
+   }
+   b2Body.prototype.IsFixedRotation = function () {
+      return (this.m_flags & b2Body.e_fixedRotationFlag) == b2Body.e_fixedRotationFlag;
+   }
+   b2Body.prototype.SetActive = function (flag) {
+      if (flag == this.IsActive()) {
+         return;
+      }
+      var broadPhase;
+      var f;
+      if (flag) {
+         this.m_flags |= b2Body.e_activeFlag;
+         broadPhase = this.m_world.m_contactManager.m_broadPhase;
+         for (f = this.m_fixtureList;
+         f; f = f.m_next) {
+            f.CreateProxy(broadPhase, this.m_xf);
+         }
+      }
+      else {
+         this.m_flags &= ~b2Body.e_activeFlag;
+         broadPhase = this.m_world.m_contactManager.m_broadPhase;
+         for (f = this.m_fixtureList;
+         f; f = f.m_next) {
+            f.DestroyProxy(broadPhase);
+         }
+         var ce = this.m_contactList;
+         while (ce) {
+            var ce0 = ce;
+            ce = ce.next;
+            this.m_world.m_contactManager.Destroy(ce0.contact);
+         }
+         this.m_contactList = null;
+      }
+   }
+   b2Body.prototype.IsActive = function () {
+      return (this.m_flags & b2Body.e_activeFlag) == b2Body.e_activeFlag;
+   }
+   b2Body.prototype.IsSleepingAllowed = function () {
+      return (this.m_flags & b2Body.e_allowSleepFlag) == b2Body.e_allowSleepFlag;
+   }
+   b2Body.prototype.GetFixtureList = function () {
+      return this.m_fixtureList;
+   }
+   b2Body.prototype.GetJointList = function () {
+      return this.m_jointList;
+   }
+   b2Body.prototype.GetControllerList = function () {
+      return this.m_controllerList;
+   }
+   b2Body.prototype.GetContactList = function () {
+      return this.m_contactList;
+   }
+   b2Body.prototype.GetNext = function () {
+      return this.m_next;
+   }
+   b2Body.prototype.GetUserData = function () {
+      return this.m_userData;
+   }
+   b2Body.prototype.SetUserData = function (data) {
+      this.m_userData = data;
+   }
+   b2Body.prototype.GetWorld = function () {
+      return this.m_world;
+   }
+   b2Body.prototype.b2Body = function (bd, world) {
+      this.m_flags = 0;
+      if (bd.bullet) {
+         this.m_flags |= b2Body.e_bulletFlag;
+      }
+      if (bd.fixedRotation) {
+         this.m_flags |= b2Body.e_fixedRotationFlag;
+      }
+      if (bd.allowSleep) {
+         this.m_flags |= b2Body.e_allowSleepFlag;
+      }
+      if (bd.awake) {
+         this.m_flags |= b2Body.e_awakeFlag;
+      }
+      if (bd.active) {
+         this.m_flags |= b2Body.e_activeFlag;
+      }
+      this.m_world = world;
+      this.m_xf.position.SetV(bd.position);
+      this.m_xf.R.Set(bd.angle);
+      this.m_sweep.localCenter.SetZero();
+      this.m_sweep.t0 = 1.0;
+      this.m_sweep.a0 = this.m_sweep.a = bd.angle;
+      var tMat = this.m_xf.R;
+      var tVec = this.m_sweep.localCenter;
+      this.m_sweep.c.x = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      this.m_sweep.c.y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      this.m_sweep.c.x += this.m_xf.position.x;
+      this.m_sweep.c.y += this.m_xf.position.y;
+      this.m_sweep.c0.SetV(this.m_sweep.c);
+      this.m_jointList = null;
+      this.m_controllerList = null;
+      this.m_contactList = null;
+      this.m_controllerCount = 0;
+      this.m_prev = null;
+      this.m_next = null;
+      this.m_linearVelocity.SetV(bd.linearVelocity);
+      this.m_angularVelocity = bd.angularVelocity;
+      this.m_linearDamping = bd.linearDamping;
+      this.m_angularDamping = bd.angularDamping;
+      this.m_force.Set(0.0, 0.0);
+      this.m_torque = 0.0;
+      this.m_sleepTime = 0.0;
+      this.m_type = bd.type;
+      if (this.m_type == b2Body.b2_dynamicBody) {
+         this.m_mass = 1.0;
+         this.m_invMass = 1.0;
+      }
+      else {
+         this.m_mass = 0.0;
+         this.m_invMass = 0.0;
+      }
+      this.m_I = 0.0;
+      this.m_invI = 0.0;
+      this.m_inertiaScale = bd.inertiaScale;
+      this.m_userData = bd.userData;
+      this.m_fixtureList = null;
+      this.m_fixtureCount = 0;
+   }
+   b2Body.prototype.SynchronizeFixtures = function () {
+      var xf1 = b2Body.s_xf1;
+      xf1.R.Set(this.m_sweep.a0);
+      var tMat = xf1.R;
+      var tVec = this.m_sweep.localCenter;
+      xf1.position.x = this.m_sweep.c0.x - (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      xf1.position.y = this.m_sweep.c0.y - (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+      var f;
+      var broadPhase = this.m_world.m_contactManager.m_broadPhase;
+      for (f = this.m_fixtureList;
+      f; f = f.m_next) {
+         f.Synchronize(broadPhase, xf1, this.m_xf);
+      }
+   }
+   b2Body.prototype.SynchronizeTransform = function () {
+      this.m_xf.R.Set(this.m_sweep.a);
+      var tMat = this.m_xf.R;
+      var tVec = this.m_sweep.localCenter;
+      this.m_xf.position.x = this.m_sweep.c.x - (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+      this.m_xf.position.y = this.m_sweep.c.y - (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+   }
+   b2Body.prototype.ShouldCollide = function (other) {
+      if (this.m_type != b2Body.b2_dynamicBody && other.m_type != b2Body.b2_dynamicBody) {
+         return false;
+      }
+      for (var jn = this.m_jointList; jn; jn = jn.next) {
+         if (jn.other == other) if (jn.joint.m_collideConnected == false) {
+            return false;
+         }
+      }
+      return true;
+   }
+   b2Body.prototype.Advance = function (t) {
+      if (t === undefined) t = 0;
+      this.m_sweep.Advance(t);
+      this.m_sweep.c.SetV(this.m_sweep.c0);
+      this.m_sweep.a = this.m_sweep.a0;
+      this.SynchronizeTransform();
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Dynamics.b2Body.s_xf1 = new b2Transform();
+      Box2D.Dynamics.b2Body.e_islandFlag = 0x0001;
+      Box2D.Dynamics.b2Body.e_awakeFlag = 0x0002;
+      Box2D.Dynamics.b2Body.e_allowSleepFlag = 0x0004;
+      Box2D.Dynamics.b2Body.e_bulletFlag = 0x0008;
+      Box2D.Dynamics.b2Body.e_fixedRotationFlag = 0x0010;
+      Box2D.Dynamics.b2Body.e_activeFlag = 0x0020;
+      Box2D.Dynamics.b2Body.b2_staticBody = 0;
+      Box2D.Dynamics.b2Body.b2_kinematicBody = 1;
+      Box2D.Dynamics.b2Body.b2_dynamicBody = 2;
+   });
+   b2BodyDef.b2BodyDef = function () {
+      this.position = new b2Vec2();
+      this.linearVelocity = new b2Vec2();
+   };
+   b2BodyDef.prototype.b2BodyDef = function () {
+      this.userData = null;
+      this.position.Set(0.0, 0.0);
+      this.angle = 0.0;
+      this.linearVelocity.Set(0, 0);
+      this.angularVelocity = 0.0;
+      this.linearDamping = 0.0;
+      this.angularDamping = 0.0;
+      this.allowSleep = true;
+      this.awake = true;
+      this.fixedRotation = false;
+      this.bullet = false;
+      this.type = b2Body.b2_staticBody;
+      this.active = true;
+      this.inertiaScale = 1.0;
+   }
+   b2ContactFilter.b2ContactFilter = function () {};
+   b2ContactFilter.prototype.ShouldCollide = function (fixtureA, fixtureB) {
+      var filter1 = fixtureA.GetFilterData();
+      var filter2 = fixtureB.GetFilterData();
+      if (filter1.groupIndex == filter2.groupIndex && filter1.groupIndex != 0) {
+         return filter1.groupIndex > 0;
+      }
+      var collide = (filter1.maskBits & filter2.categoryBits) != 0 && (filter1.categoryBits & filter2.maskBits) != 0;
+      return collide;
+   }
+   b2ContactFilter.prototype.RayCollide = function (userData, fixture) {
+      if (!userData) return true;
+      return this.ShouldCollide((userData instanceof b2Fixture ? userData : null), fixture);
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Dynamics.b2ContactFilter.b2_defaultFilter = new b2ContactFilter();
+   });
+   b2ContactImpulse.b2ContactImpulse = function () {
+      this.normalImpulses = new Vector_a2j_Number(b2Settings.b2_maxManifoldPoints);
+      this.tangentImpulses = new Vector_a2j_Number(b2Settings.b2_maxManifoldPoints);
+   };
+   b2ContactListener.b2ContactListener = function () {};
+   b2ContactListener.prototype.BeginContact = function (contact) {}
+   b2ContactListener.prototype.EndContact = function (contact) {}
+   b2ContactListener.prototype.PreSolve = function (contact, oldManifold) {}
+   b2ContactListener.prototype.PostSolve = function (contact, impulse) {}
+   Box2D.postDefs.push(function () {
+      Box2D.Dynamics.b2ContactListener.b2_defaultListener = new b2ContactListener();
+   });
+   b2ContactManager.b2ContactManager = function () {};
+   b2ContactManager.prototype.b2ContactManager = function () {
+      this.m_world = null;
+      this.m_contactCount = 0;
+      this.m_contactFilter = b2ContactFilter.b2_defaultFilter;
+      this.m_contactListener = b2ContactListener.b2_defaultListener;
+      this.m_contactFactory = new b2ContactFactory(this.m_allocator);
+      this.m_broadPhase = new b2DynamicTreeBroadPhase();
+   }
+   b2ContactManager.prototype.AddPair = function (proxyUserDataA, proxyUserDataB) {
+      var fixtureA = (proxyUserDataA instanceof b2Fixture ? proxyUserDataA : null);
+      var fixtureB = (proxyUserDataB instanceof b2Fixture ? proxyUserDataB : null);
+      var bodyA = fixtureA.GetBody();
+      var bodyB = fixtureB.GetBody();
+      if (bodyA == bodyB) return;
+      var edge = bodyB.GetContactList();
+      while (edge) {
+         if (edge.other == bodyA) {
+            var fA = edge.contact.GetFixtureA();
+            var fB = edge.contact.GetFixtureB();
+            if (fA == fixtureA && fB == fixtureB) return;
+            if (fA == fixtureB && fB == fixtureA) return;
+         }
+         edge = edge.next;
+      }
+      if (bodyB.ShouldCollide(bodyA) == false) {
+         return;
+      }
+      if (this.m_contactFilter.ShouldCollide(fixtureA, fixtureB) == false) {
+         return;
+      }
+      var c = this.m_contactFactory.Create(fixtureA, fixtureB);
+      fixtureA = c.GetFixtureA();
+      fixtureB = c.GetFixtureB();
+      bodyA = fixtureA.m_body;
+      bodyB = fixtureB.m_body;
+      c.m_prev = null;
+      c.m_next = this.m_world.m_contactList;
+      if (this.m_world.m_contactList != null) {
+         this.m_world.m_contactList.m_prev = c;
+      }
+      this.m_world.m_contactList = c;
+      c.m_nodeA.contact = c;
+      c.m_nodeA.other = bodyB;
+      c.m_nodeA.prev = null;
+      c.m_nodeA.next = bodyA.m_contactList;
+      if (bodyA.m_contactList != null) {
+         bodyA.m_contactList.prev = c.m_nodeA;
+      }
+      bodyA.m_contactList = c.m_nodeA;
+      c.m_nodeB.contact = c;
+      c.m_nodeB.other = bodyA;
+      c.m_nodeB.prev = null;
+      c.m_nodeB.next = bodyB.m_contactList;
+      if (bodyB.m_contactList != null) {
+         bodyB.m_contactList.prev = c.m_nodeB;
+      }
+      bodyB.m_contactList = c.m_nodeB;
+      ++this.m_world.m_contactCount;
+      return;
+   }
+   b2ContactManager.prototype.FindNewContacts = function () {
+      this.m_broadPhase.UpdatePairs(Box2D.generateCallback(this, this.AddPair));
+   }
+   b2ContactManager.prototype.Destroy = function (c) {
+      var fixtureA = c.GetFixtureA();
+      var fixtureB = c.GetFixtureB();
+      var bodyA = fixtureA.GetBody();
+      var bodyB = fixtureB.GetBody();
+      if (c.IsTouching()) {
+         this.m_contactListener.EndContact(c);
+      }
+      if (c.m_prev) {
+         c.m_prev.m_next = c.m_next;
+      }
+      if (c.m_next) {
+         c.m_next.m_prev = c.m_prev;
+      }
+      if (c == this.m_world.m_contactList) {
+         this.m_world.m_contactList = c.m_next;
+      }
+      if (c.m_nodeA.prev) {
+         c.m_nodeA.prev.next = c.m_nodeA.next;
+      }
+      if (c.m_nodeA.next) {
+         c.m_nodeA.next.prev = c.m_nodeA.prev;
+      }
+      if (c.m_nodeA == bodyA.m_contactList) {
+         bodyA.m_contactList = c.m_nodeA.next;
+      }
+      if (c.m_nodeB.prev) {
+         c.m_nodeB.prev.next = c.m_nodeB.next;
+      }
+      if (c.m_nodeB.next) {
+         c.m_nodeB.next.prev = c.m_nodeB.prev;
+      }
+      if (c.m_nodeB == bodyB.m_contactList) {
+         bodyB.m_contactList = c.m_nodeB.next;
+      }
+      this.m_contactFactory.Destroy(c);
+      --this.m_contactCount;
+   }
+   b2ContactManager.prototype.Collide = function () {
+      var c = this.m_world.m_contactList;
+      while (c) {
+         var fixtureA = c.GetFixtureA();
+         var fixtureB = c.GetFixtureB();
+         var bodyA = fixtureA.GetBody();
+         var bodyB = fixtureB.GetBody();
+         if (bodyA.IsAwake() == false && bodyB.IsAwake() == false) {
+            c = c.GetNext();
+            continue;
+         }
+         if (c.m_flags & b2Contact.e_filterFlag) {
+            if (bodyB.ShouldCollide(bodyA) == false) {
+               var cNuke = c;
+               c = cNuke.GetNext();
+               this.Destroy(cNuke);
+               continue;
+            }
+            if (this.m_contactFilter.ShouldCollide(fixtureA, fixtureB) == false) {
+               cNuke = c;
+               c = cNuke.GetNext();
+               this.Destroy(cNuke);
+               continue;
+            }
+            c.m_flags &= ~b2Contact.e_filterFlag;
+         }
+         var proxyA = fixtureA.m_proxy;
+         var proxyB = fixtureB.m_proxy;
+         var overlap = this.m_broadPhase.TestOverlap(proxyA, proxyB);
+         if (overlap == false) {
+            cNuke = c;
+            c = cNuke.GetNext();
+            this.Destroy(cNuke);
+            continue;
+         }
+         c.Update(this.m_contactListener);
+         c = c.GetNext();
+      }
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Dynamics.b2ContactManager.s_evalCP = new b2ContactPoint();
+   });
+   b2DebugDraw.b2DebugDraw = function () {};
+   b2DebugDraw.prototype.b2DebugDraw = function () {}
+   b2DebugDraw.prototype.SetFlags = function (flags) {
+      if (flags === undefined) flags = 0;
+   }
+   b2DebugDraw.prototype.GetFlags = function () {}
+   b2DebugDraw.prototype.AppendFlags = function (flags) {
+      if (flags === undefined) flags = 0;
+   }
+   b2DebugDraw.prototype.ClearFlags = function (flags) {
+      if (flags === undefined) flags = 0;
+   }
+   b2DebugDraw.prototype.SetSprite = function (sprite) {}
+   b2DebugDraw.prototype.GetSprite = function () {}
+   b2DebugDraw.prototype.SetDrawScale = function (drawScale) {
+      if (drawScale === undefined) drawScale = 0;
+   }
+   b2DebugDraw.prototype.GetDrawScale = function () {}
+   b2DebugDraw.prototype.SetLineThickness = function (lineThickness) {
+      if (lineThickness === undefined) lineThickness = 0;
+   }
+   b2DebugDraw.prototype.GetLineThickness = function () {}
+   b2DebugDraw.prototype.SetAlpha = function (alpha) {
+      if (alpha === undefined) alpha = 0;
+   }
+   b2DebugDraw.prototype.GetAlpha = function () {}
+   b2DebugDraw.prototype.SetFillAlpha = function (alpha) {
+      if (alpha === undefined) alpha = 0;
+   }
+   b2DebugDraw.prototype.GetFillAlpha = function () {}
+   b2DebugDraw.prototype.SetXFormScale = function (xformScale) {
+      if (xformScale === undefined) xformScale = 0;
+   }
+   b2DebugDraw.prototype.GetXFormScale = function () {}
+   b2DebugDraw.prototype.DrawPolygon = function (vertices, vertexCount, color) {
+      if (vertexCount === undefined) vertexCount = 0;
+   }
+   b2DebugDraw.prototype.DrawSolidPolygon = function (vertices, vertexCount, color) {
+      if (vertexCount === undefined) vertexCount = 0;
+   }
+   b2DebugDraw.prototype.DrawCircle = function (center, radius, color) {
+      if (radius === undefined) radius = 0;
+   }
+   b2DebugDraw.prototype.DrawSolidCircle = function (center, radius, axis, color) {
+      if (radius === undefined) radius = 0;
+   }
+   b2DebugDraw.prototype.DrawSegment = function (p1, p2, color) {}
+   b2DebugDraw.prototype.DrawTransform = function (xf) {}
+   Box2D.postDefs.push(function () {
+      Box2D.Dynamics.b2DebugDraw.e_shapeBit = 0x0001;
+      Box2D.Dynamics.b2DebugDraw.e_jointBit = 0x0002;
+      Box2D.Dynamics.b2DebugDraw.e_aabbBit = 0x0004;
+      Box2D.Dynamics.b2DebugDraw.e_pairBit = 0x0008;
+      Box2D.Dynamics.b2DebugDraw.e_centerOfMassBit = 0x0010;
+      Box2D.Dynamics.b2DebugDraw.e_controllerBit = 0x0020;
+   });
+   b2DestructionListener.b2DestructionListener = function () {};
+   b2DestructionListener.prototype.SayGoodbyeJoint = function (joint) {}
+   b2DestructionListener.prototype.SayGoodbyeFixture = function (fixture) {}
+   b2FilterData.b2FilterData = function () {
+      this.categoryBits = 0x0001;
+      this.maskBits = 0xFFFF;
+      this.groupIndex = 0;
+   };
+   b2FilterData.prototype.Copy = function () {
+      var copy = new b2FilterData();
+      copy.categoryBits = this.categoryBits;
+      copy.maskBits = this.maskBits;
+      copy.groupIndex = this.groupIndex;
+      return copy;
+   }
+   b2Fixture.b2Fixture = function () {
+      this.m_filter = new b2FilterData();
+   };
+   b2Fixture.prototype.GetType = function () {
+      return this.m_shape.GetType();
+   }
+   b2Fixture.prototype.GetShape = function () {
+      return this.m_shape;
+   }
+   b2Fixture.prototype.SetSensor = function (sensor) {
+      if (this.m_isSensor == sensor) return;
+      this.m_isSensor = sensor;
+      if (this.m_body == null) return;
+      var edge = this.m_body.GetContactList();
+      while (edge) {
+         var contact = edge.contact;
+         var fixtureA = contact.GetFixtureA();
+         var fixtureB = contact.GetFixtureB();
+         if (fixtureA == this || fixtureB == this) contact.SetSensor(fixtureA.IsSensor() || fixtureB.IsSensor());
+         edge = edge.next;
+      }
+   }
+   b2Fixture.prototype.IsSensor = function () {
+      return this.m_isSensor;
+   }
+   b2Fixture.prototype.SetFilterData = function (filter) {
+      this.m_filter = filter.Copy();
+      if (this.m_body) return;
+      var edge = this.m_body.GetContactList();
+      while (edge) {
+         var contact = edge.contact;
+         var fixtureA = contact.GetFixtureA();
+         var fixtureB = contact.GetFixtureB();
+         if (fixtureA == this || fixtureB == this) contact.FlagForFiltering();
+         edge = edge.next;
+      }
+   }
+   b2Fixture.prototype.GetFilterData = function () {
+      return this.m_filter.Copy();
+   }
+   b2Fixture.prototype.GetBody = function () {
+      return this.m_body;
+   }
+   b2Fixture.prototype.GetNext = function () {
+      return this.m_next;
+   }
+   b2Fixture.prototype.GetUserData = function () {
+      return this.m_userData;
+   }
+   b2Fixture.prototype.SetUserData = function (data) {
+      this.m_userData = data;
+   }
+   b2Fixture.prototype.TestPoint = function (p) {
+      return this.m_shape.TestPoint(this.m_body.GetTransform(), p);
+   }
+   b2Fixture.prototype.RayCast = function (output, input) {
+      return this.m_shape.RayCast(output, input, this.m_body.GetTransform());
+   }
+   b2Fixture.prototype.GetMassData = function (massData) {
+      if (massData === undefined) massData = null;
+      if (massData == null) {
+         massData = new b2MassData();
+      }
+      this.m_shape.ComputeMass(massData, this.m_density);
+      return massData;
+   }
+   b2Fixture.prototype.SetDensity = function (density) {
+      if (density === undefined) density = 0;
+      this.m_density = density;
+   }
+   b2Fixture.prototype.GetDensity = function () {
+      return this.m_density;
+   }
+   b2Fixture.prototype.GetFriction = function () {
+      return this.m_friction;
+   }
+   b2Fixture.prototype.SetFriction = function (friction) {
+      if (friction === undefined) friction = 0;
+      this.m_friction = friction;
+   }
+   b2Fixture.prototype.GetRestitution = function () {
+      return this.m_restitution;
+   }
+   b2Fixture.prototype.SetRestitution = function (restitution) {
+      if (restitution === undefined) restitution = 0;
+      this.m_restitution = restitution;
+   }
+   b2Fixture.prototype.GetAABB = function () {
+      return this.m_aabb;
+   }
+   b2Fixture.prototype.b2Fixture = function () {
+      this.m_aabb = new b2AABB();
+      this.m_userData = null;
+      this.m_body = null;
+      this.m_next = null;
+      this.m_shape = null;
+      this.m_density = 0.0;
+      this.m_friction = 0.0;
+      this.m_restitution = 0.0;
+   }
+   b2Fixture.prototype.Create = function (body, xf, def) {
+      this.m_userData = def.userData;
+      this.m_friction = def.friction;
+      this.m_restitution = def.restitution;
+      this.m_body = body;
+      this.m_next = null;
+      this.m_filter = def.filter.Copy();
+      this.m_isSensor = def.isSensor;
+      this.m_shape = def.shape.Copy();
+      this.m_density = def.density;
+   }
+   b2Fixture.prototype.Destroy = function () {
+      this.m_shape = null;
+   }
+   b2Fixture.prototype.CreateProxy = function (broadPhase, xf) {
+      this.m_shape.ComputeAABB(this.m_aabb, xf);
+      this.m_proxy = broadPhase.CreateProxy(this.m_aabb, this);
+   }
+   b2Fixture.prototype.DestroyProxy = function (broadPhase) {
+      if (this.m_proxy == null) {
+         return;
+      }
+      broadPhase.DestroyProxy(this.m_proxy);
+      this.m_proxy = null;
+   }
+   b2Fixture.prototype.Synchronize = function (broadPhase, transform1, transform2) {
+      if (!this.m_proxy) return;
+      var aabb1 = new b2AABB();
+      var aabb2 = new b2AABB();
+      this.m_shape.ComputeAABB(aabb1, transform1);
+      this.m_shape.ComputeAABB(aabb2, transform2);
+      this.m_aabb.Combine(aabb1, aabb2);
+      var displacement = b2Math.SubtractVV(transform2.position, transform1.position);
+      broadPhase.MoveProxy(this.m_proxy, this.m_aabb, displacement);
+   }
+   b2FixtureDef.b2FixtureDef = function () {
+      this.filter = new b2FilterData();
+   };
+   b2FixtureDef.prototype.b2FixtureDef = function () {
+      this.shape = null;
+      this.userData = null;
+      this.friction = 0.2;
+      this.restitution = 0.0;
+      this.density = 0.0;
+      this.filter.categoryBits = 0x0001;
+      this.filter.maskBits = 0xFFFF;
+      this.filter.groupIndex = 0;
+      this.isSensor = false;
+   }
+   b2Island.b2Island = function () {};
+   b2Island.prototype.b2Island = function () {
+      this.m_bodies = new Vector();
+      this.m_contacts = new Vector();
+      this.m_joints = new Vector();
+   }
+   b2Island.prototype.Initialize = function (bodyCapacity, contactCapacity, jointCapacity, allocator, listener, contactSolver) {
+      if (bodyCapacity === undefined) bodyCapacity = 0;
+      if (contactCapacity === undefined) contactCapacity = 0;
+      if (jointCapacity === undefined) jointCapacity = 0;
+      var i = 0;
+      this.m_bodyCapacity = bodyCapacity;
+      this.m_contactCapacity = contactCapacity;
+      this.m_jointCapacity = jointCapacity;
+      this.m_bodyCount = 0;
+      this.m_contactCount = 0;
+      this.m_jointCount = 0;
+      this.m_allocator = allocator;
+      this.m_listener = listener;
+      this.m_contactSolver = contactSolver;
+      for (i = this.m_bodies.length;
+      i < bodyCapacity; i++)
+      this.m_bodies[i] = null;
+      for (i = this.m_contacts.length;
+      i < contactCapacity; i++)
+      this.m_contacts[i] = null;
+      for (i = this.m_joints.length;
+      i < jointCapacity; i++)
+      this.m_joints[i] = null;
+   }
+   b2Island.prototype.Clear = function () {
+      this.m_bodyCount = 0;
+      this.m_contactCount = 0;
+      this.m_jointCount = 0;
+   }
+   b2Island.prototype.Solve = function (step, gravity, allowSleep) {
+      var i = 0;
+      var j = 0;
+      var b;
+      var joint;
+      for (i = 0;
+      i < this.m_bodyCount; ++i) {
+         b = this.m_bodies[i];
+         if (b.GetType() != b2Body.b2_dynamicBody) continue;
+         b.m_linearVelocity.x += step.dt * (gravity.x + b.m_invMass * b.m_force.x);
+         b.m_linearVelocity.y += step.dt * (gravity.y + b.m_invMass * b.m_force.y);
+         b.m_angularVelocity += step.dt * b.m_invI * b.m_torque;
+         b.m_linearVelocity.Multiply(b2Math.Clamp(1.0 - step.dt * b.m_linearDamping, 0.0, 1.0));
+         b.m_angularVelocity *= b2Math.Clamp(1.0 - step.dt * b.m_angularDamping, 0.0, 1.0);
+      }
+      this.m_contactSolver.Initialize(step, this.m_contacts, this.m_contactCount, this.m_allocator);
+      var contactSolver = this.m_contactSolver;
+      contactSolver.InitVelocityConstraints(step);
+      for (i = 0;
+      i < this.m_jointCount; ++i) {
+         joint = this.m_joints[i];
+         joint.InitVelocityConstraints(step);
+      }
+      for (i = 0;
+      i < step.velocityIterations; ++i) {
+         for (j = 0;
+         j < this.m_jointCount; ++j) {
+            joint = this.m_joints[j];
+            joint.SolveVelocityConstraints(step);
+         }
+         contactSolver.SolveVelocityConstraints();
+      }
+      for (i = 0;
+      i < this.m_jointCount; ++i) {
+         joint = this.m_joints[i];
+         joint.FinalizeVelocityConstraints();
+      }
+      contactSolver.FinalizeVelocityConstraints();
+      for (i = 0;
+      i < this.m_bodyCount; ++i) {
+         b = this.m_bodies[i];
+         if (b.GetType() == b2Body.b2_staticBody) continue;
+         var translationX = step.dt * b.m_linearVelocity.x;
+         var translationY = step.dt * b.m_linearVelocity.y;
+         if ((translationX * translationX + translationY * translationY) > b2Settings.b2_maxTranslationSquared) {
+            b.m_linearVelocity.Normalize();
+            b.m_linearVelocity.x *= b2Settings.b2_maxTranslation * step.inv_dt;
+            b.m_linearVelocity.y *= b2Settings.b2_maxTranslation * step.inv_dt;
+         }
+         var rotation = step.dt * b.m_angularVelocity;
+         if (rotation * rotation > b2Settings.b2_maxRotationSquared) {
+            if (b.m_angularVelocity < 0.0) {
+               b.m_angularVelocity = (-b2Settings.b2_maxRotation * step.inv_dt);
+            }
+            else {
+               b.m_angularVelocity = b2Settings.b2_maxRotation * step.inv_dt;
+            }
+         }
+         b.m_sweep.c0.SetV(b.m_sweep.c);
+         b.m_sweep.a0 = b.m_sweep.a;
+         b.m_sweep.c.x += step.dt * b.m_linearVelocity.x;
+         b.m_sweep.c.y += step.dt * b.m_linearVelocity.y;
+         b.m_sweep.a += step.dt * b.m_angularVelocity;
+         b.SynchronizeTransform();
+      }
+      for (i = 0;
+      i < step.positionIterations; ++i) {
+         var contactsOkay = contactSolver.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
+         var jointsOkay = true;
+         for (j = 0;
+         j < this.m_jointCount; ++j) {
+            joint = this.m_joints[j];
+            var jointOkay = joint.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
+            jointsOkay = jointsOkay && jointOkay;
+         }
+         if (contactsOkay && jointsOkay) {
+            break;
+         }
+      }
+      this.Report(contactSolver.m_constraints);
+      if (allowSleep) {
+         var minSleepTime = Number.MAX_VALUE;
+         var linTolSqr = b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance;
+         var angTolSqr = b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance;
+         for (i = 0;
+         i < this.m_bodyCount; ++i) {
+            b = this.m_bodies[i];
+            if (b.GetType() == b2Body.b2_staticBody) {
+               continue;
+            }
+            if ((b.m_flags & b2Body.e_allowSleepFlag) == 0) {
+               b.m_sleepTime = 0.0;
+               minSleepTime = 0.0;
+            }
+            if ((b.m_flags & b2Body.e_allowSleepFlag) == 0 || b.m_angularVelocity * b.m_angularVelocity > angTolSqr || b2Math.Dot(b.m_linearVelocity, b.m_linearVelocity) > linTolSqr) {
+               b.m_sleepTime = 0.0;
+               minSleepTime = 0.0;
+            }
+            else {
+               b.m_sleepTime += step.dt;
+               minSleepTime = b2Math.Min(minSleepTime, b.m_sleepTime);
+            }
+         }
+         if (minSleepTime >= b2Settings.b2_timeToSleep) {
+            for (i = 0;
+            i < this.m_bodyCount; ++i) {
+               b = this.m_bodies[i];
+               b.SetAwake(false);
+            }
+         }
+      }
+   }
+   b2Island.prototype.SolveTOI = function (subStep) {
+      var i = 0;
+      var j = 0;
+      this.m_contactSolver.Initialize(subStep, this.m_contacts, this.m_contactCount, this.m_allocator);
+      var contactSolver = this.m_contactSolver;
+      for (i = 0;
+      i < this.m_jointCount; ++i) {
+         this.m_joints[i].InitVelocityConstraints(subStep);
+      }
+      for (i = 0;
+      i < subStep.velocityIterations; ++i) {
+         contactSolver.SolveVelocityConstraints();
+         for (j = 0;
+         j < this.m_jointCount; ++j) {
+            this.m_joints[j].SolveVelocityConstraints(subStep);
+         }
+      }
+      for (i = 0;
+      i < this.m_bodyCount; ++i) {
+         var b = this.m_bodies[i];
+         if (b.GetType() == b2Body.b2_staticBody) continue;
+         var translationX = subStep.dt * b.m_linearVelocity.x;
+         var translationY = subStep.dt * b.m_linearVelocity.y;
+         if ((translationX * translationX + translationY * translationY) > b2Settings.b2_maxTranslationSquared) {
+            b.m_linearVelocity.Normalize();
+            b.m_linearVelocity.x *= b2Settings.b2_maxTranslation * subStep.inv_dt;
+            b.m_linearVelocity.y *= b2Settings.b2_maxTranslation * subStep.inv_dt;
+         }
+         var rotation = subStep.dt * b.m_angularVelocity;
+         if (rotation * rotation > b2Settings.b2_maxRotationSquared) {
+            if (b.m_angularVelocity < 0.0) {
+               b.m_angularVelocity = (-b2Settings.b2_maxRotation * subStep.inv_dt);
+            }
+            else {
+               b.m_angularVelocity = b2Settings.b2_maxRotation * subStep.inv_dt;
+            }
+         }
+         b.m_sweep.c0.SetV(b.m_sweep.c);
+         b.m_sweep.a0 = b.m_sweep.a;
+         b.m_sweep.c.x += subStep.dt * b.m_linearVelocity.x;
+         b.m_sweep.c.y += subStep.dt * b.m_linearVelocity.y;
+         b.m_sweep.a += subStep.dt * b.m_angularVelocity;
+         b.SynchronizeTransform();
+      }
+      var k_toiBaumgarte = 0.75;
+      for (i = 0;
+      i < subStep.positionIterations; ++i) {
+         var contactsOkay = contactSolver.SolvePositionConstraints(k_toiBaumgarte);
+         var jointsOkay = true;
+         for (j = 0;
+         j < this.m_jointCount; ++j) {
+            var jointOkay = this.m_joints[j].SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
+            jointsOkay = jointsOkay && jointOkay;
+         }
+         if (contactsOkay && jointsOkay) {
+            break;
+         }
+      }
+      this.Report(contactSolver.m_constraints);
+   }
+   b2Island.prototype.Report = function (constraints) {
+      if (this.m_listener == null) {
+         return;
+      }
+      for (var i = 0; i < this.m_contactCount; ++i) {
+         var c = this.m_contacts[i];
+         var cc = constraints[i];
+         for (var j = 0; j < cc.pointCount; ++j) {
+            b2Island.s_impulse.normalImpulses[j] = cc.points[j].normalImpulse;
+            b2Island.s_impulse.tangentImpulses[j] = cc.points[j].tangentImpulse;
+         }
+         this.m_listener.PostSolve(c, b2Island.s_impulse);
+      }
+   }
+   b2Island.prototype.AddBody = function (body) {
+      body.m_islandIndex = this.m_bodyCount;
+      this.m_bodies[this.m_bodyCount++] = body;
+   }
+   b2Island.prototype.AddContact = function (contact) {
+      this.m_contacts[this.m_contactCount++] = contact;
+   }
+   b2Island.prototype.AddJoint = function (joint) {
+      this.m_joints[this.m_jointCount++] = joint;
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Dynamics.b2Island.s_impulse = new b2ContactImpulse();
+   });
+   b2TimeStep.b2TimeStep = function () {};
+   b2TimeStep.prototype.Set = function (step) {
+      this.dt = step.dt;
+      this.inv_dt = step.inv_dt;
+      this.positionIterations = step.positionIterations;
+      this.velocityIterations = step.velocityIterations;
+      this.warmStarting = step.warmStarting;
+   }
+   b2World.b2World = function () {
+      this.s_stack = new Vector();
+      this.m_contactManager = new b2ContactManager();
+      this.m_contactSolver = new b2ContactSolver();
+      this.m_island = new b2Island();
+   };
+   b2World.prototype.b2World = function (gravity, doSleep) {
+      this.m_destructionListener = null;
+      this.m_debugDraw = null;
+      this.m_bodyList = null;
+      this.m_contactList = null;
+      this.m_jointList = null;
+      this.m_controllerList = null;
+      this.m_bodyCount = 0;
+      this.m_contactCount = 0;
+      this.m_jointCount = 0;
+      this.m_controllerCount = 0;
+      b2World.m_warmStarting = true;
+      b2World.m_continuousPhysics = true;
+      this.m_allowSleep = doSleep;
+      this.m_gravity = gravity;
+      this.m_inv_dt0 = 0.0;
+      this.m_contactManager.m_world = this;
+      var bd = new b2BodyDef();
+      this.m_groundBody = this.CreateBody(bd);
+   }
+   b2World.prototype.SetDestructionListener = function (listener) {
+      this.m_destructionListener = listener;
+   }
+   b2World.prototype.SetContactFilter = function (filter) {
+      this.m_contactManager.m_contactFilter = filter;
+   }
+   b2World.prototype.SetContactListener = function (listener) {
+      this.m_contactManager.m_contactListener = listener;
+   }
+   b2World.prototype.SetDebugDraw = function (debugDraw) {
+      this.m_debugDraw = debugDraw;
+   }
+   b2World.prototype.SetBroadPhase = function (broadPhase) {
+      var oldBroadPhase = this.m_contactManager.m_broadPhase;
+      this.m_contactManager.m_broadPhase = broadPhase;
+      for (var b = this.m_bodyList; b; b = b.m_next) {
+         for (var f = b.m_fixtureList; f; f = f.m_next) {
+            f.m_proxy = broadPhase.CreateProxy(oldBroadPhase.GetFatAABB(f.m_proxy), f);
+         }
+      }
+   }
+   b2World.prototype.Validate = function () {
+      this.m_contactManager.m_broadPhase.Validate();
+   }
+   b2World.prototype.GetProxyCount = function () {
+      return this.m_contactManager.m_broadPhase.GetProxyCount();
+   }
+   b2World.prototype.CreateBody = function (def) {
+      if (this.IsLocked() == true) {
+         return null;
+      }
+      var b = new b2Body(def, this);
+      b.m_prev = null;
+      b.m_next = this.m_bodyList;
+      if (this.m_bodyList) {
+         this.m_bodyList.m_prev = b;
+      }
+      this.m_bodyList = b;
+      ++this.m_bodyCount;
+      return b;
+   }
+   b2World.prototype.DestroyBody = function (b) {
+      if (this.IsLocked() == true) {
+         return;
+      }
+      var jn = b.m_jointList;
+      while (jn) {
+         var jn0 = jn;
+         jn = jn.next;
+         if (this.m_destructionListener) {
+            this.m_destructionListener.SayGoodbyeJoint(jn0.joint);
+         }
+         this.DestroyJoint(jn0.joint);
+      }
+      var coe = b.m_controllerList;
+      while (coe) {
+         var coe0 = coe;
+         coe = coe.nextController;
+         coe0.controller.RemoveBody(b);
+      }
+      var ce = b.m_contactList;
+      while (ce) {
+         var ce0 = ce;
+         ce = ce.next;
+         this.m_contactManager.Destroy(ce0.contact);
+      }
+      b.m_contactList = null;
+      var f = b.m_fixtureList;
+      while (f) {
+         var f0 = f;
+         f = f.m_next;
+         if (this.m_destructionListener) {
+            this.m_destructionListener.SayGoodbyeFixture(f0);
+         }
+         f0.DestroyProxy(this.m_contactManager.m_broadPhase);
+         f0.Destroy();
+      }
+      b.m_fixtureList = null;
+      b.m_fixtureCount = 0;
+      if (b.m_prev) {
+         b.m_prev.m_next = b.m_next;
+      }
+      if (b.m_next) {
+         b.m_next.m_prev = b.m_prev;
+      }
+      if (b == this.m_bodyList) {
+         this.m_bodyList = b.m_next;
+      }--this.m_bodyCount;
+   }
+   b2World.prototype.CreateJoint = function (def) {
+      var j = b2Joint.Create(def, null);
+      j.m_prev = null;
+      j.m_next = this.m_jointList;
+      if (this.m_jointList) {
+         this.m_jointList.m_prev = j;
+      }
+      this.m_jointList = j;
+      ++this.m_jointCount;
+      j.m_edgeA.joint = j;
+      j.m_edgeA.other = j.m_bodyB;
+      j.m_edgeA.prev = null;
+      j.m_edgeA.next = j.m_bodyA.m_jointList;
+      if (j.m_bodyA.m_jointList) j.m_bodyA.m_jointList.prev = j.m_edgeA;
+      j.m_bodyA.m_jointList = j.m_edgeA;
+      j.m_edgeB.joint = j;
+      j.m_edgeB.other = j.m_bodyA;
+      j.m_edgeB.prev = null;
+      j.m_edgeB.next = j.m_bodyB.m_jointList;
+      if (j.m_bodyB.m_jointList) j.m_bodyB.m_jointList.prev = j.m_edgeB;
+      j.m_bodyB.m_jointList = j.m_edgeB;
+      var bodyA = def.bodyA;
+      var bodyB = def.bodyB;
+      if (def.collideConnected == false) {
+         var edge = bodyB.GetContactList();
+         while (edge) {
+            if (edge.other == bodyA) {
+               edge.contact.FlagForFiltering();
+            }
+            edge = edge.next;
+         }
+      }
+      return j;
+   }
+   b2World.prototype.DestroyJoint = function (j) {
+      var collideConnected = j.m_collideConnected;
+      if (j.m_prev) {
+         j.m_prev.m_next = j.m_next;
+      }
+      if (j.m_next) {
+         j.m_next.m_prev = j.m_prev;
+      }
+      if (j == this.m_jointList) {
+         this.m_jointList = j.m_next;
+      }
+      var bodyA = j.m_bodyA;
+      var bodyB = j.m_bodyB;
+      bodyA.SetAwake(true);
+      bodyB.SetAwake(true);
+      if (j.m_edgeA.prev) {
+         j.m_edgeA.prev.next = j.m_edgeA.next;
+      }
+      if (j.m_edgeA.next) {
+         j.m_edgeA.next.prev = j.m_edgeA.prev;
+      }
+      if (j.m_edgeA == bodyA.m_jointList) {
+         bodyA.m_jointList = j.m_edgeA.next;
+      }
+      j.m_edgeA.prev = null;
+      j.m_edgeA.next = null;
+      if (j.m_edgeB.prev) {
+         j.m_edgeB.prev.next = j.m_edgeB.next;
+      }
+      if (j.m_edgeB.next) {
+         j.m_edgeB.next.prev = j.m_edgeB.prev;
+      }
+      if (j.m_edgeB == bodyB.m_jointList) {
+         bodyB.m_jointList = j.m_edgeB.next;
+      }
+      j.m_edgeB.prev = null;
+      j.m_edgeB.next = null;
+      b2Joint.Destroy(j, null);
+      --this.m_jointCount;
+      if (collideConnected == false) {
+         var edge = bodyB.GetContactList();
+         while (edge) {
+            if (edge.other == bodyA) {
+               edge.contact.FlagForFiltering();
+            }
+            edge = edge.next;
+         }
+      }
+   }
+   b2World.prototype.AddController = function (c) {
+      c.m_next = this.m_controllerList;
+      c.m_prev = null;
+      this.m_controllerList = c;
+      c.m_world = this;
+      this.m_controllerCount++;
+      return c;
+   }
+   b2World.prototype.RemoveController = function (c) {
+      if (c.m_prev) c.m_prev.m_next = c.m_next;
+      if (c.m_next) c.m_next.m_prev = c.m_prev;
+      if (this.m_controllerList == c) this.m_controllerList = c.m_next;
+      this.m_controllerCount--;
+   }
+   b2World.prototype.CreateController = function (controller) {
+      if (controller.m_world != this) throw new Error("Controller can only be a member of one world");
+      controller.m_next = this.m_controllerList;
+      controller.m_prev = null;
+      if (this.m_controllerList) this.m_controllerList.m_prev = controller;
+      this.m_controllerList = controller;
+      ++this.m_controllerCount;
+      controller.m_world = this;
+      return controller;
+   }
+   b2World.prototype.DestroyController = function (controller) {
+      controller.Clear();
+      if (controller.m_next) controller.m_next.m_prev = controller.m_prev;
+      if (controller.m_prev) controller.m_prev.m_next = controller.m_next;
+      if (controller == this.m_controllerList) this.m_controllerList = controller.m_next;
+      --this.m_controllerCount;
+   }
+   b2World.prototype.SetWarmStarting = function (flag) {
+      b2World.m_warmStarting = flag;
+   }
+   b2World.prototype.SetContinuousPhysics = function (flag) {
+      b2World.m_continuousPhysics = flag;
+   }
+   b2World.prototype.GetBodyCount = function () {
+      return this.m_bodyCount;
+   }
+   b2World.prototype.GetJointCount = function () {
+      return this.m_jointCount;
+   }
+   b2World.prototype.GetContactCount = function () {
+      return this.m_contactCount;
+   }
+   b2World.prototype.SetGravity = function (gravity) {
+      this.m_gravity = gravity;
+   }
+   b2World.prototype.GetGravity = function () {
+      return this.m_gravity;
+   }
+   b2World.prototype.GetGroundBody = function () {
+      return this.m_groundBody;
+   }
+   b2World.prototype.Step = function (dt, velocityIterations, positionIterations) {
+      if (dt === undefined) dt = 0;
+      if (velocityIterations === undefined) velocityIterations = 0;
+      if (positionIterations === undefined) positionIterations = 0;
+      if (this.m_flags & b2World.e_newFixture) {
+         this.m_contactManager.FindNewContacts();
+         this.m_flags &= ~b2World.e_newFixture;
+      }
+      this.m_flags |= b2World.e_locked;
+      var step = b2World.s_timestep2;
+      step.dt = dt;
+      step.velocityIterations = velocityIterations;
+      step.positionIterations = positionIterations;
+      if (dt > 0.0) {
+         step.inv_dt = 1.0 / dt;
+      }
+      else {
+         step.inv_dt = 0.0;
+      }
+      step.dtRatio = this.m_inv_dt0 * dt;
+      step.warmStarting = b2World.m_warmStarting;
+      this.m_contactManager.Collide();
+      if (step.dt > 0.0) {
+         this.Solve(step);
+      }
+      if (b2World.m_continuousPhysics && step.dt > 0.0) {
+         this.SolveTOI(step);
+      }
+      if (step.dt > 0.0) {
+         this.m_inv_dt0 = step.inv_dt;
+      }
+      this.m_flags &= ~b2World.e_locked;
+   }
+   b2World.prototype.ClearForces = function () {
+      for (var body = this.m_bodyList; body; body = body.m_next) {
+         body.m_force.SetZero();
+         body.m_torque = 0.0;
+      }
+   }
+   b2World.prototype.DrawDebugData = function () {
+      if (this.m_debugDraw == null) {
+         return;
+      }
+      this.m_debugDraw.m_sprite.graphics.clear();
+      var flags = this.m_debugDraw.GetFlags();
+      var i = 0;
+      var b;
+      var f;
+      var s;
+      var j;
+      var bp;
+      var invQ = new b2Vec2;
+      var x1 = new b2Vec2;
+      var x2 = new b2Vec2;
+      var xf;
+      var b1 = new b2AABB();
+      var b2 = new b2AABB();
+      var vs = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()];
+      var color = new b2Color(0, 0, 0);
+      if (flags & b2DebugDraw.e_shapeBit) {
+         for (b = this.m_bodyList;
+         b; b = b.m_next) {
+            xf = b.m_xf;
+            for (f = b.GetFixtureList();
+            f; f = f.m_next) {
+               s = f.GetShape();
+               if (b.IsActive() == false) {
+                  color.Set(0.5, 0.5, 0.3);
+                  this.DrawShape(s, xf, color);
+               }
+               else if (b.GetType() == b2Body.b2_staticBody) {
+                  color.Set(0.5, 0.9, 0.5);
+                  this.DrawShape(s, xf, color);
+               }
+               else if (b.GetType() == b2Body.b2_kinematicBody) {
+                  color.Set(0.5, 0.5, 0.9);
+                  this.DrawShape(s, xf, color);
+               }
+               else if (b.IsAwake() == false) {
+                  color.Set(0.6, 0.6, 0.6);
+                  this.DrawShape(s, xf, color);
+               }
+               else {
+                  color.Set(0.9, 0.7, 0.7);
+                  this.DrawShape(s, xf, color);
+               }
+            }
+         }
+      }
+      if (flags & b2DebugDraw.e_jointBit) {
+         for (j = this.m_jointList;
+         j; j = j.m_next) {
+            this.DrawJoint(j);
+         }
+      }
+      if (flags & b2DebugDraw.e_controllerBit) {
+         for (var c = this.m_controllerList; c; c = c.m_next) {
+            c.Draw(this.m_debugDraw);
+         }
+      }
+      if (flags & b2DebugDraw.e_pairBit) {
+         color.Set(0.3, 0.9, 0.9);
+         for (var contact = this.m_contactManager.m_contactList; contact; contact = contact.GetNext()) {
+            var fixtureA = contact.GetFixtureA();
+            var fixtureB = contact.GetFixtureB();
+            var cA = fixtureA.GetAABB().GetCenter();
+            var cB = fixtureB.GetAABB().GetCenter();
+            this.m_debugDraw.DrawSegment(cA, cB, color);
+         }
+      }
+      if (flags & b2DebugDraw.e_aabbBit) {
+         bp = this.m_contactManager.m_broadPhase;
+         vs = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()];
+         for (b = this.m_bodyList;
+         b; b = b.GetNext()) {
+            if (b.IsActive() == false) {
+               continue;
+            }
+            for (f = b.GetFixtureList();
+            f; f = f.GetNext()) {
+               var aabb = bp.GetFatAABB(f.m_proxy);
+               vs[0].Set(aabb.lowerBound.x, aabb.lowerBound.y);
+               vs[1].Set(aabb.upperBound.x, aabb.lowerBound.y);
+               vs[2].Set(aabb.upperBound.x, aabb.upperBound.y);
+               vs[3].Set(aabb.lowerBound.x, aabb.upperBound.y);
+               this.m_debugDraw.DrawPolygon(vs, 4, color);
+            }
+         }
+      }
+      if (flags & b2DebugDraw.e_centerOfMassBit) {
+         for (b = this.m_bodyList;
+         b; b = b.m_next) {
+            xf = b2World.s_xf;
+            xf.R = b.m_xf.R;
+            xf.position = b.GetWorldCenter();
+            this.m_debugDraw.DrawTransform(xf);
+         }
+      }
+   }
+   b2World.prototype.QueryAABB = function (callback, aabb) {
+      var __this = this;
+      var broadPhase = __this.m_contactManager.m_broadPhase;
+
+      function WorldQueryWrapper(proxy) {
+         return callback(broadPhase.GetUserData(proxy));
+      };
+      broadPhase.Query(WorldQueryWrapper, aabb);
+   }
+   b2World.prototype.QueryShape = function (callback, shape, transform) {
+      var __this = this;
+      if (transform === undefined) transform = null;
+      if (transform == null) {
+         transform = new b2Transform();
+         transform.SetIdentity();
+      }
+      var broadPhase = __this.m_contactManager.m_broadPhase;
+
+      function WorldQueryWrapper(proxy) {
+         var fixture = (broadPhase.GetUserData(proxy) instanceof b2Fixture ? broadPhase.GetUserData(proxy) : null);
+         if (b2Shape.TestOverlap(shape, transform, fixture.GetShape(), fixture.GetBody().GetTransform())) return callback(fixture);
+         return true;
+      };
+      var aabb = new b2AABB();
+      shape.ComputeAABB(aabb, transform);
+      broadPhase.Query(WorldQueryWrapper, aabb);
+   }
+   b2World.prototype.QueryPoint = function (callback, p) {
+      var __this = this;
+      var broadPhase = __this.m_contactManager.m_broadPhase;
+
+      function WorldQueryWrapper(proxy) {
+         var fixture = (broadPhase.GetUserData(proxy) instanceof b2Fixture ? broadPhase.GetUserData(proxy) : null);
+         if (fixture.TestPoint(p)) return callback(fixture);
+         return true;
+      };
+      var aabb = new b2AABB();
+      aabb.lowerBound.Set(p.x - b2Settings.b2_linearSlop, p.y - b2Settings.b2_linearSlop);
+      aabb.upperBound.Set(p.x + b2Settings.b2_linearSlop, p.y + b2Settings.b2_linearSlop);
+      broadPhase.Query(WorldQueryWrapper, aabb);
+   }
+   b2World.prototype.RayCast = function (callback, point1, point2) {
+      var __this = this;
+      var broadPhase = __this.m_contactManager.m_broadPhase;
+      var output = new b2RayCastOutput;
+
+      function RayCastWrapper(input, proxy) {
+         var userData = broadPhase.GetUserData(proxy);
+         var fixture = (userData instanceof b2Fixture ? userData : null);
+         var hit = fixture.RayCast(output, input);
+         if (hit) {
+            var fraction = output.fraction;
+            var point = new b2Vec2((1.0 - fraction) * point1.x + fraction * point2.x, (1.0 - fraction) * point1.y + fraction * point2.y);
+            return callback(fixture, point, output.normal, fraction);
+         }
+         return input.maxFraction;
+      };
+      var input = new b2RayCastInput(point1, point2);
+      broadPhase.RayCast(RayCastWrapper, input);
+   }
+   b2World.prototype.RayCastOne = function (point1, point2) {
+      var __this = this;
+      var result;
+
+      function RayCastOneWrapper(fixture, point, normal, fraction) {
+         if (fraction === undefined) fraction = 0;
+         result = fixture;
+         return fraction;
+      };
+      __this.RayCast(RayCastOneWrapper, point1, point2);
+      return result;
+   }
+   b2World.prototype.RayCastAll = function (point1, point2) {
+      var __this = this;
+      var result = new Vector();
+
+      function RayCastAllWrapper(fixture, point, normal, fraction) {
+         if (fraction === undefined) fraction = 0;
+         result[result.length] = fixture;
+         return 1;
+      };
+      __this.RayCast(RayCastAllWrapper, point1, point2);
+      return result;
+   }
+   b2World.prototype.GetBodyList = function () {
+      return this.m_bodyList;
+   }
+   b2World.prototype.GetJointList = function () {
+      return this.m_jointList;
+   }
+   b2World.prototype.GetContactList = function () {
+      return this.m_contactList;
+   }
+   b2World.prototype.IsLocked = function () {
+      return (this.m_flags & b2World.e_locked) > 0;
+   }
+   b2World.prototype.Solve = function (step) {
+      var b;
+      for (var controller = this.m_controllerList; controller; controller = controller.m_next) {
+         controller.Step(step);
+      }
+      var island = this.m_island;
+      island.Initialize(this.m_bodyCount, this.m_contactCount, this.m_jointCount, null, this.m_contactManager.m_contactListener, this.m_contactSolver);
+      for (b = this.m_bodyList;
+      b; b = b.m_next) {
+         b.m_flags &= ~b2Body.e_islandFlag;
+      }
+      for (var c = this.m_contactList; c; c = c.m_next) {
+         c.m_flags &= ~b2Contact.e_islandFlag;
+      }
+      for (var j = this.m_jointList; j; j = j.m_next) {
+         j.m_islandFlag = false;
+      }
+      var stackSize = parseInt(this.m_bodyCount);
+      var stack = this.s_stack;
+      for (var seed = this.m_bodyList; seed; seed = seed.m_next) {
+         if (seed.m_flags & b2Body.e_islandFlag) {
+            continue;
+         }
+         if (seed.IsAwake() == false || seed.IsActive() == false) {
+            continue;
+         }
+         if (seed.GetType() == b2Body.b2_staticBody) {
+            continue;
+         }
+         island.Clear();
+         var stackCount = 0;
+         stack[stackCount++] = seed;
+         seed.m_flags |= b2Body.e_islandFlag;
+         while (stackCount > 0) {
+            b = stack[--stackCount];
+            island.AddBody(b);
+            if (b.IsAwake() == false) {
+               b.SetAwake(true);
+            }
+            if (b.GetType() == b2Body.b2_staticBody) {
+               continue;
+            }
+            var other;
+            for (var ce = b.m_contactList; ce; ce = ce.next) {
+               if (ce.contact.m_flags & b2Contact.e_islandFlag) {
+                  continue;
+               }
+               if (ce.contact.IsSensor() == true || ce.contact.IsEnabled() == false || ce.contact.IsTouching() == false) {
+                  continue;
+               }
+               island.AddContact(ce.contact);
+               ce.contact.m_flags |= b2Contact.e_islandFlag;
+               other = ce.other;
+               if (other.m_flags & b2Body.e_islandFlag) {
+                  continue;
+               }
+               stack[stackCount++] = other;
+               other.m_flags |= b2Body.e_islandFlag;
+            }
+            for (var jn = b.m_jointList; jn; jn = jn.next) {
+               if (jn.joint.m_islandFlag == true) {
+                  continue;
+               }
+               other = jn.other;
+               if (other.IsActive() == false) {
+                  continue;
+               }
+               island.AddJoint(jn.joint);
+               jn.joint.m_islandFlag = true;
+               if (other.m_flags & b2Body.e_islandFlag) {
+                  continue;
+               }
+               stack[stackCount++] = other;
+               other.m_flags |= b2Body.e_islandFlag;
+            }
+         }
+         island.Solve(step, this.m_gravity, this.m_allowSleep);
+         for (var i = 0; i < island.m_bodyCount; ++i) {
+            b = island.m_bodies[i];
+            if (b.GetType() == b2Body.b2_staticBody) {
+               b.m_flags &= ~b2Body.e_islandFlag;
+            }
+         }
+      }
+      for (i = 0;
+      i < stack.length; ++i) {
+         if (!stack[i]) break;
+         stack[i] = null;
+      }
+      for (b = this.m_bodyList;
+      b; b = b.m_next) {
+         if (b.IsAwake() == false || b.IsActive() == false) {
+            continue;
+         }
+         if (b.GetType() == b2Body.b2_staticBody) {
+            continue;
+         }
+         b.SynchronizeFixtures();
+      }
+      this.m_contactManager.FindNewContacts();
+   }
+   b2World.prototype.SolveTOI = function (step) {
+      var b;
+      var fA;
+      var fB;
+      var bA;
+      var bB;
+      var cEdge;
+      var j;
+      var island = this.m_island;
+      island.Initialize(this.m_bodyCount, b2Settings.b2_maxTOIContactsPerIsland, b2Settings.b2_maxTOIJointsPerIsland, null, this.m_contactManager.m_contactListener, this.m_contactSolver);
+      var queue = b2World.s_queue;
+      for (b = this.m_bodyList;
+      b; b = b.m_next) {
+         b.m_flags &= ~b2Body.e_islandFlag;
+         b.m_sweep.t0 = 0.0;
+      }
+      var c;
+      for (c = this.m_contactList;
+      c; c = c.m_next) {
+         c.m_flags &= ~ (b2Contact.e_toiFlag | b2Contact.e_islandFlag);
+      }
+      for (j = this.m_jointList;
+      j; j = j.m_next) {
+         j.m_islandFlag = false;
+      }
+      for (;;) {
+         var minContact = null;
+         var minTOI = 1.0;
+         for (c = this.m_contactList;
+         c; c = c.m_next) {
+            if (c.IsSensor() == true || c.IsEnabled() == false || c.IsContinuous() == false) {
+               continue;
+            }
+            var toi = 1.0;
+            if (c.m_flags & b2Contact.e_toiFlag) {
+               toi = c.m_toi;
+            }
+            else {
+               fA = c.m_fixtureA;
+               fB = c.m_fixtureB;
+               bA = fA.m_body;
+               bB = fB.m_body;
+               if ((bA.GetType() != b2Body.b2_dynamicBody || bA.IsAwake() == false) && (bB.GetType() != b2Body.b2_dynamicBody || bB.IsAwake() == false)) {
+                  continue;
+               }
+               var t0 = bA.m_sweep.t0;
+               if (bA.m_sweep.t0 < bB.m_sweep.t0) {
+                  t0 = bB.m_sweep.t0;
+                  bA.m_sweep.Advance(t0);
+               }
+               else if (bB.m_sweep.t0 < bA.m_sweep.t0) {
+                  t0 = bA.m_sweep.t0;
+                  bB.m_sweep.Advance(t0);
+               }
+               toi = c.ComputeTOI(bA.m_sweep, bB.m_sweep);
+               b2Settings.b2Assert(0.0 <= toi && toi <= 1.0);
+               if (toi > 0.0 && toi < 1.0) {
+                  toi = (1.0 - toi) * t0 + toi;
+                  if (toi > 1) toi = 1;
+               }
+               c.m_toi = toi;
+               c.m_flags |= b2Contact.e_toiFlag;
+            }
+            if (Number.MIN_VALUE < toi && toi < minTOI) {
+               minContact = c;
+               minTOI = toi;
+            }
+         }
+         if (minContact == null || 1.0 - 100.0 * Number.MIN_VALUE < minTOI) {
+            break;
+         }
+         fA = minContact.m_fixtureA;
+         fB = minContact.m_fixtureB;
+         bA = fA.m_body;
+         bB = fB.m_body;
+         b2World.s_backupA.Set(bA.m_sweep);
+         b2World.s_backupB.Set(bB.m_sweep);
+         bA.Advance(minTOI);
+         bB.Advance(minTOI);
+         minContact.Update(this.m_contactManager.m_contactListener);
+         minContact.m_flags &= ~b2Contact.e_toiFlag;
+         if (minContact.IsSensor() == true || minContact.IsEnabled() == false) {
+            bA.m_sweep.Set(b2World.s_backupA);
+            bB.m_sweep.Set(b2World.s_backupB);
+            bA.SynchronizeTransform();
+            bB.SynchronizeTransform();
+            continue;
+         }
+         if (minContact.IsTouching() == false) {
+            continue;
+         }
+         var seed = bA;
+         if (seed.GetType() != b2Body.b2_dynamicBody) {
+            seed = bB;
+         }
+         island.Clear();
+         var queueStart = 0;
+         var queueSize = 0;
+         queue[queueStart + queueSize++] = seed;
+         seed.m_flags |= b2Body.e_islandFlag;
+         while (queueSize > 0) {
+            b = queue[queueStart++];
+            --queueSize;
+            island.AddBody(b);
+            if (b.IsAwake() == false) {
+               b.SetAwake(true);
+            }
+            if (b.GetType() != b2Body.b2_dynamicBody) {
+               continue;
+            }
+            for (cEdge = b.m_contactList;
+            cEdge; cEdge = cEdge.next) {
+               if (island.m_contactCount == island.m_contactCapacity) {
+                  break;
+               }
+               if (cEdge.contact.m_flags & b2Contact.e_islandFlag) {
+                  continue;
+               }
+               if (cEdge.contact.IsSensor() == true || cEdge.contact.IsEnabled() == false || cEdge.contact.IsTouching() == false) {
+                  continue;
+               }
+               island.AddContact(cEdge.contact);
+               cEdge.contact.m_flags |= b2Contact.e_islandFlag;
+               var other = cEdge.other;
+               if (other.m_flags & b2Body.e_islandFlag) {
+                  continue;
+               }
+               if (other.GetType() != b2Body.b2_staticBody) {
+                  other.Advance(minTOI);
+                  other.SetAwake(true);
+               }
+               queue[queueStart + queueSize] = other;
+               ++queueSize;
+               other.m_flags |= b2Body.e_islandFlag;
+            }
+            for (var jEdge = b.m_jointList; jEdge; jEdge = jEdge.next) {
+               if (island.m_jointCount == island.m_jointCapacity) continue;
+               if (jEdge.joint.m_islandFlag == true) continue;
+               other = jEdge.other;
+               if (other.IsActive() == false) {
+                  continue;
+               }
+               island.AddJoint(jEdge.joint);
+               jEdge.joint.m_islandFlag = true;
+               if (other.m_flags & b2Body.e_islandFlag) continue;
+               if (other.GetType() != b2Body.b2_staticBody) {
+                  other.Advance(minTOI);
+                  other.SetAwake(true);
+               }
+               queue[queueStart + queueSize] = other;
+               ++queueSize;
+               other.m_flags |= b2Body.e_islandFlag;
+            }
+         }
+         var subStep = b2World.s_timestep;
+         subStep.warmStarting = false;
+         subStep.dt = (1.0 - minTOI) * step.dt;
+         subStep.inv_dt = 1.0 / subStep.dt;
+         subStep.dtRatio = 0.0;
+         subStep.velocityIterations = step.velocityIterations;
+         subStep.positionIterations = step.positionIterations;
+         island.SolveTOI(subStep);
+         var i = 0;
+         for (i = 0;
+         i < island.m_bodyCount; ++i) {
+            b = island.m_bodies[i];
+            b.m_flags &= ~b2Body.e_islandFlag;
+            if (b.IsAwake() == false) {
+               continue;
+            }
+            if (b.GetType() != b2Body.b2_dynamicBody) {
+               continue;
+            }
+            b.SynchronizeFixtures();
+            for (cEdge = b.m_contactList;
+            cEdge; cEdge = cEdge.next) {
+               cEdge.contact.m_flags &= ~b2Contact.e_toiFlag;
+            }
+         }
+         for (i = 0;
+         i < island.m_contactCount; ++i) {
+            c = island.m_contacts[i];
+            c.m_flags &= ~ (b2Contact.e_toiFlag | b2Contact.e_islandFlag);
+         }
+         for (i = 0;
+         i < island.m_jointCount; ++i) {
+            j = island.m_joints[i];
+            j.m_islandFlag = false;
+         }
+         this.m_contactManager.FindNewContacts();
+      }
+   }
+   b2World.prototype.DrawJoint = function (joint) {
+      var b1 = joint.GetBodyA();
+      var b2 = joint.GetBodyB();
+      var xf1 = b1.m_xf;
+      var xf2 = b2.m_xf;
+      var x1 = xf1.position;
+      var x2 = xf2.position;
+      var p1 = joint.GetAnchorA();
+      var p2 = joint.GetAnchorB();
+      var color = b2World.s_jointColor;
+      switch (joint.m_type) {
+      case b2Joint.e_distanceJoint:
+         this.m_debugDraw.DrawSegment(p1, p2, color);
+         break;
+      case b2Joint.e_pulleyJoint:
+         {
+            var pulley = ((joint instanceof b2PulleyJoint ? joint : null));
+            var s1 = pulley.GetGroundAnchorA();
+            var s2 = pulley.GetGroundAnchorB();
+            this.m_debugDraw.DrawSegment(s1, p1, color);
+            this.m_debugDraw.DrawSegment(s2, p2, color);
+            this.m_debugDraw.DrawSegment(s1, s2, color);
+         }
+         break;
+      case b2Joint.e_mouseJoint:
+         this.m_debugDraw.DrawSegment(p1, p2, color);
+         break;
+      default:
+         if (b1 != this.m_groundBody) this.m_debugDraw.DrawSegment(x1, p1, color);
+         this.m_debugDraw.DrawSegment(p1, p2, color);
+         if (b2 != this.m_groundBody) this.m_debugDraw.DrawSegment(x2, p2, color);
+      }
+   }
+   b2World.prototype.DrawShape = function (shape, xf, color) {
+      switch (shape.m_type) {
+      case b2Shape.e_circleShape:
+         {
+            var circle = ((shape instanceof b2CircleShape ? shape : null));
+            var center = b2Math.MulX(xf, circle.m_p);
+            var radius = circle.m_radius;
+            var axis = xf.R.col1;
+            this.m_debugDraw.DrawSolidCircle(center, radius, axis, color);
+         }
+         break;
+      case b2Shape.e_polygonShape:
+         {
+            var i = 0;
+            var poly = ((shape instanceof b2PolygonShape ? shape : null));
+            var vertexCount = parseInt(poly.GetVertexCount());
+            var localVertices = poly.GetVertices();
+            var vertices = new Vector(vertexCount);
+            for (i = 0;
+            i < vertexCount; ++i) {
+               vertices[i] = b2Math.MulX(xf, localVertices[i]);
+            }
+            this.m_debugDraw.DrawSolidPolygon(vertices, vertexCount, color);
+         }
+         break;
+      case b2Shape.e_edgeShape:
+         {
+            var edge = (shape instanceof b2EdgeShape ? shape : null);
+            this.m_debugDraw.DrawSegment(b2Math.MulX(xf, edge.GetVertex1()), b2Math.MulX(xf, edge.GetVertex2()), color);
+         }
+         break;
+      }
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Dynamics.b2World.s_timestep2 = new b2TimeStep();
+      Box2D.Dynamics.b2World.s_xf = new b2Transform();
+      Box2D.Dynamics.b2World.s_backupA = new b2Sweep();
+      Box2D.Dynamics.b2World.s_backupB = new b2Sweep();
+      Box2D.Dynamics.b2World.s_timestep = new b2TimeStep();
+      Box2D.Dynamics.b2World.s_queue = new Vector();
+      Box2D.Dynamics.b2World.s_jointColor = new b2Color(0.5, 0.8, 0.8);
+      Box2D.Dynamics.b2World.e_newFixture = 0x0001;
+      Box2D.Dynamics.b2World.e_locked = 0x0002;
+   });
+})();
+(function () {
+   var b2CircleShape = Box2D.Collision.Shapes.b2CircleShape,
+      b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef,
+      b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape,
+      b2MassData = Box2D.Collision.Shapes.b2MassData,
+      b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape,
+      b2Shape = Box2D.Collision.Shapes.b2Shape,
+      b2CircleContact = Box2D.Dynamics.Contacts.b2CircleContact,
+      b2Contact = Box2D.Dynamics.Contacts.b2Contact,
+      b2ContactConstraint = Box2D.Dynamics.Contacts.b2ContactConstraint,
+      b2ContactConstraintPoint = Box2D.Dynamics.Contacts.b2ContactConstraintPoint,
+      b2ContactEdge = Box2D.Dynamics.Contacts.b2ContactEdge,
+      b2ContactFactory = Box2D.Dynamics.Contacts.b2ContactFactory,
+      b2ContactRegister = Box2D.Dynamics.Contacts.b2ContactRegister,
+      b2ContactResult = Box2D.Dynamics.Contacts.b2ContactResult,
+      b2ContactSolver = Box2D.Dynamics.Contacts.b2ContactSolver,
+      b2EdgeAndCircleContact = Box2D.Dynamics.Contacts.b2EdgeAndCircleContact,
+      b2NullContact = Box2D.Dynamics.Contacts.b2NullContact,
+      b2PolyAndCircleContact = Box2D.Dynamics.Contacts.b2PolyAndCircleContact,
+      b2PolyAndEdgeContact = Box2D.Dynamics.Contacts.b2PolyAndEdgeContact,
+      b2PolygonContact = Box2D.Dynamics.Contacts.b2PolygonContact,
+      b2PositionSolverManifold = Box2D.Dynamics.Contacts.b2PositionSolverManifold,
+      b2Body = Box2D.Dynamics.b2Body,
+      b2BodyDef = Box2D.Dynamics.b2BodyDef,
+      b2ContactFilter = Box2D.Dynamics.b2ContactFilter,
+      b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse,
+      b2ContactListener = Box2D.Dynamics.b2ContactListener,
+      b2ContactManager = Box2D.Dynamics.b2ContactManager,
+      b2DebugDraw = Box2D.Dynamics.b2DebugDraw,
+      b2DestructionListener = Box2D.Dynamics.b2DestructionListener,
+      b2FilterData = Box2D.Dynamics.b2FilterData,
+      b2Fixture = Box2D.Dynamics.b2Fixture,
+      b2FixtureDef = Box2D.Dynamics.b2FixtureDef,
+      b2Island = Box2D.Dynamics.b2Island,
+      b2TimeStep = Box2D.Dynamics.b2TimeStep,
+      b2World = Box2D.Dynamics.b2World,
+      b2Color = Box2D.Common.b2Color,
+      b2internal = Box2D.Common.b2internal,
+      b2Settings = Box2D.Common.b2Settings,
+      b2Mat22 = Box2D.Common.Math.b2Mat22,
+      b2Mat33 = Box2D.Common.Math.b2Mat33,
+      b2Math = Box2D.Common.Math.b2Math,
+      b2Sweep = Box2D.Common.Math.b2Sweep,
+      b2Transform = Box2D.Common.Math.b2Transform,
+      b2Vec2 = Box2D.Common.Math.b2Vec2,
+      b2Vec3 = Box2D.Common.Math.b2Vec3,
+      b2AABB = Box2D.Collision.b2AABB,
+      b2Bound = Box2D.Collision.b2Bound,
+      b2BoundValues = Box2D.Collision.b2BoundValues,
+      b2Collision = Box2D.Collision.b2Collision,
+      b2ContactID = Box2D.Collision.b2ContactID,
+      b2ContactPoint = Box2D.Collision.b2ContactPoint,
+      b2Distance = Box2D.Collision.b2Distance,
+      b2DistanceInput = Box2D.Collision.b2DistanceInput,
+      b2DistanceOutput = Box2D.Collision.b2DistanceOutput,
+      b2DistanceProxy = Box2D.Collision.b2DistanceProxy,
+      b2DynamicTree = Box2D.Collision.b2DynamicTree,
+      b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase,
+      b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode,
+      b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair,
+      b2Manifold = Box2D.Collision.b2Manifold,
+      b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint,
+      b2Point = Box2D.Collision.b2Point,
+      b2RayCastInput = Box2D.Collision.b2RayCastInput,
+      b2RayCastOutput = Box2D.Collision.b2RayCastOutput,
+      b2Segment = Box2D.Collision.b2Segment,
+      b2SeparationFunction = Box2D.Collision.b2SeparationFunction,
+      b2Simplex = Box2D.Collision.b2Simplex,
+      b2SimplexCache = Box2D.Collision.b2SimplexCache,
+      b2SimplexVertex = Box2D.Collision.b2SimplexVertex,
+      b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact,
+      b2TOIInput = Box2D.Collision.b2TOIInput,
+      b2WorldManifold = Box2D.Collision.b2WorldManifold,
+      ClipVertex = Box2D.Collision.ClipVertex,
+      Features = Box2D.Collision.Features,
+      IBroadPhase = Box2D.Collision.IBroadPhase;
+
+   Box2D.inherit(b2CircleContact, Box2D.Dynamics.Contacts.b2Contact);
+   b2CircleContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype;
+   b2CircleContact.b2CircleContact = function () {
+      Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments);
+   };
+   b2CircleContact.Create = function (allocator) {
+      return new b2CircleContact();
+   }
+   b2CircleContact.Destroy = function (contact, allocator) {}
+   b2CircleContact.prototype.Reset = function (fixtureA, fixtureB) {
+      this.__super.Reset.call(this, fixtureA, fixtureB);
+   }
+   b2CircleContact.prototype.Evaluate = function () {
+      var bA = this.m_fixtureA.GetBody();
+      var bB = this.m_fixtureB.GetBody();
+      b2Collision.CollideCircles(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2CircleShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2CircleShape ? this.m_fixtureB.GetShape() : null), bB.m_xf);
+   }
+   b2Contact.b2Contact = function () {
+      this.m_nodeA = new b2ContactEdge();
+      this.m_nodeB = new b2ContactEdge();
+      this.m_manifold = new b2Manifold();
+      this.m_oldManifold = new b2Manifold();
+   };
+   b2Contact.prototype.GetManifold = function () {
+      return this.m_manifold;
+   }
+   b2Contact.prototype.GetWorldManifold = function (worldManifold) {
+      var bodyA = this.m_fixtureA.GetBody();
+      var bodyB = this.m_fixtureB.GetBody();
+      var shapeA = this.m_fixtureA.GetShape();
+      var shapeB = this.m_fixtureB.GetShape();
+      worldManifold.Initialize(this.m_manifold, bodyA.GetTransform(), shapeA.m_radius, bodyB.GetTransform(), shapeB.m_radius);
+   }
+   b2Contact.prototype.IsTouching = function () {
+      return (this.m_flags & b2Contact.e_touchingFlag) == b2Contact.e_touchingFlag;
+   }
+   b2Contact.prototype.IsContinuous = function () {
+      return (this.m_flags & b2Contact.e_continuousFlag) == b2Contact.e_continuousFlag;
+   }
+   b2Contact.prototype.SetSensor = function (sensor) {
+      if (sensor) {
+         this.m_flags |= b2Contact.e_sensorFlag;
+      }
+      else {
+         this.m_flags &= ~b2Contact.e_sensorFlag;
+      }
+   }
+   b2Contact.prototype.IsSensor = function () {
+      return (this.m_flags & b2Contact.e_sensorFlag) == b2Contact.e_sensorFlag;
+   }
+   b2Contact.prototype.SetEnabled = function (flag) {
+      if (flag) {
+         this.m_flags |= b2Contact.e_enabledFlag;
+      }
+      else {
+         this.m_flags &= ~b2Contact.e_enabledFlag;
+      }
+   }
+   b2Contact.prototype.IsEnabled = function () {
+      return (this.m_flags & b2Contact.e_enabledFlag) == b2Contact.e_enabledFlag;
+   }
+   b2Contact.prototype.GetNext = function () {
+      return this.m_next;
+   }
+   b2Contact.prototype.GetFixtureA = function () {
+      return this.m_fixtureA;
+   }
+   b2Contact.prototype.GetFixtureB = function () {
+      return this.m_fixtureB;
+   }
+   b2Contact.prototype.FlagForFiltering = function () {
+      this.m_flags |= b2Contact.e_filterFlag;
+   }
+   b2Contact.prototype.b2Contact = function () {}
+   b2Contact.prototype.Reset = function (fixtureA, fixtureB) {
+      if (fixtureA === undefined) fixtureA = null;
+      if (fixtureB === undefined) fixtureB = null;
+      this.m_flags = b2Contact.e_enabledFlag;
+      if (!fixtureA || !fixtureB) {
+         this.m_fixtureA = null;
+         this.m_fixtureB = null;
+         return;
+      }
+      if (fixtureA.IsSensor() || fixtureB.IsSensor()) {
+         this.m_flags |= b2Contact.e_sensorFlag;
+      }
+      var bodyA = fixtureA.GetBody();
+      var bodyB = fixtureB.GetBody();
+      if (bodyA.GetType() != b2Body.b2_dynamicBody || bodyA.IsBullet() || bodyB.GetType() != b2Body.b2_dynamicBody || bodyB.IsBullet()) {
+         this.m_flags |= b2Contact.e_continuousFlag;
+      }
+      this.m_fixtureA = fixtureA;
+      this.m_fixtureB = fixtureB;
+      this.m_manifold.m_pointCount = 0;
+      this.m_prev = null;
+      this.m_next = null;
+      this.m_nodeA.contact = null;
+      this.m_nodeA.prev = null;
+      this.m_nodeA.next = null;
+      this.m_nodeA.other = null;
+      this.m_nodeB.contact = null;
+      this.m_nodeB.prev = null;
+      this.m_nodeB.next = null;
+      this.m_nodeB.other = null;
+   }
+   b2Contact.prototype.Update = function (listener) {
+      var tManifold = this.m_oldManifold;
+      this.m_oldManifold = this.m_manifold;
+      this.m_manifold = tManifold;
+      this.m_flags |= b2Contact.e_enabledFlag;
+      var touching = false;
+      var wasTouching = (this.m_flags & b2Contact.e_touchingFlag) == b2Contact.e_touchingFlag;
+      var bodyA = this.m_fixtureA.m_body;
+      var bodyB = this.m_fixtureB.m_body;
+      var aabbOverlap = this.m_fixtureA.m_aabb.TestOverlap(this.m_fixtureB.m_aabb);
+      if (this.m_flags & b2Contact.e_sensorFlag) {
+         if (aabbOverlap) {
+            var shapeA = this.m_fixtureA.GetShape();
+            var shapeB = this.m_fixtureB.GetShape();
+            var xfA = bodyA.GetTransform();
+            var xfB = bodyB.GetTransform();
+            touching = b2Shape.TestOverlap(shapeA, xfA, shapeB, xfB);
+         }
+         this.m_manifold.m_pointCount = 0;
+      }
+      else {
+         if (bodyA.GetType() != b2Body.b2_dynamicBody || bodyA.IsBullet() || bodyB.GetType() != b2Body.b2_dynamicBody || bodyB.IsBullet()) {
+            this.m_flags |= b2Contact.e_continuousFlag;
+         }
+         else {
+            this.m_flags &= ~b2Contact.e_continuousFlag;
+         }
+         if (aabbOverlap) {
+            this.Evaluate();
+            touching = this.m_manifold.m_pointCount > 0;
+            for (var i = 0; i < this.m_manifold.m_pointCount; ++i) {
+               var mp2 = this.m_manifold.m_points[i];
+               mp2.m_normalImpulse = 0.0;
+               mp2.m_tangentImpulse = 0.0;
+               var id2 = mp2.m_id;
+               for (var j = 0; j < this.m_oldManifold.m_pointCount; ++j) {
+                  var mp1 = this.m_oldManifold.m_points[j];
+                  if (mp1.m_id.key == id2.key) {
+                     mp2.m_normalImpulse = mp1.m_normalImpulse;
+                     mp2.m_tangentImpulse = mp1.m_tangentImpulse;
+                     break;
+                  }
+               }
+            }
+         }
+         else {
+            this.m_manifold.m_pointCount = 0;
+         }
+         if (touching != wasTouching) {
+            bodyA.SetAwake(true);
+            bodyB.SetAwake(true);
+         }
+      }
+      if (touching) {
+         this.m_flags |= b2Contact.e_touchingFlag;
+      }
+      else {
+         this.m_flags &= ~b2Contact.e_touchingFlag;
+      }
+      if (wasTouching == false && touching == true) {
+         listener.BeginContact(this);
+      }
+      if (wasTouching == true && touching == false) {
+         listener.EndContact(this);
+      }
+      if ((this.m_flags & b2Contact.e_sensorFlag) == 0) {
+         listener.PreSolve(this, this.m_oldManifold);
+      }
+   }
+   b2Contact.prototype.Evaluate = function () {}
+   b2Contact.prototype.ComputeTOI = function (sweepA, sweepB) {
+      b2Contact.s_input.proxyA.Set(this.m_fixtureA.GetShape());
+      b2Contact.s_input.proxyB.Set(this.m_fixtureB.GetShape());
+      b2Contact.s_input.sweepA = sweepA;
+      b2Contact.s_input.sweepB = sweepB;
+      b2Contact.s_input.tolerance = b2Settings.b2_linearSlop;
+      return b2TimeOfImpact.TimeOfImpact(b2Contact.s_input);
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Dynamics.Contacts.b2Contact.e_sensorFlag = 0x0001;
+      Box2D.Dynamics.Contacts.b2Contact.e_continuousFlag = 0x0002;
+      Box2D.Dynamics.Contacts.b2Contact.e_islandFlag = 0x0004;
+      Box2D.Dynamics.Contacts.b2Contact.e_toiFlag = 0x0008;
+      Box2D.Dynamics.Contacts.b2Contact.e_touchingFlag = 0x0010;
+      Box2D.Dynamics.Contacts.b2Contact.e_enabledFlag = 0x0020;
+      Box2D.Dynamics.Contacts.b2Contact.e_filterFlag = 0x0040;
+      Box2D.Dynamics.Contacts.b2Contact.s_input = new b2TOIInput();
+   });
+   b2ContactConstraint.b2ContactConstraint = function () {
+      this.localPlaneNormal = new b2Vec2();
+      this.localPoint = new b2Vec2();
+      this.normal = new b2Vec2();
+      this.normalMass = new b2Mat22();
+      this.K = new b2Mat22();
+   };
+   b2ContactConstraint.prototype.b2ContactConstraint = function () {
+      this.points = new Vector(b2Settings.b2_maxManifoldPoints);
+      for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) {
+         this.points[i] = new b2ContactConstraintPoint();
+      }
+   }
+   b2ContactConstraintPoint.b2ContactConstraintPoint = function () {
+      this.localPoint = new b2Vec2();
+      this.rA = new b2Vec2();
+      this.rB = new b2Vec2();
+   };
+   b2ContactEdge.b2ContactEdge = function () {};
+   b2ContactFactory.b2ContactFactory = function () {};
+   b2ContactFactory.prototype.b2ContactFactory = function (allocator) {
+      this.m_allocator = allocator;
+      this.InitializeRegisters();
+   }
+   b2ContactFactory.prototype.AddType = function (createFcn, destroyFcn, type1, type2) {
+      if (type1 === undefined) type1 = 0;
+      if (type2 === undefined) type2 = 0;
+      this.m_registers[type1][type2].createFcn = createFcn;
+      this.m_registers[type1][type2].destroyFcn = destroyFcn;
+      this.m_registers[type1][type2].primary = true;
+      if (type1 != type2) {
+         this.m_registers[type2][type1].createFcn = createFcn;
+         this.m_registers[type2][type1].destroyFcn = destroyFcn;
+         this.m_registers[type2][type1].primary = false;
+      }
+   }
+   b2ContactFactory.prototype.InitializeRegisters = function () {
+      this.m_registers = new Vector(b2Shape.e_shapeTypeCount);
+      for (var i = 0; i < b2Shape.e_shapeTypeCount; i++) {
+         this.m_registers[i] = new Vector(b2Shape.e_shapeTypeCount);
+         for (var j = 0; j < b2Shape.e_shapeTypeCount; j++) {
+            this.m_registers[i][j] = new b2ContactRegister();
+         }
+      }
+      this.AddType(b2CircleContact.Create, b2CircleContact.Destroy, b2Shape.e_circleShape, b2Shape.e_circleShape);
+      this.AddType(b2PolyAndCircleContact.Create, b2PolyAndCircleContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_circleShape);
+      this.AddType(b2PolygonContact.Create, b2PolygonContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_polygonShape);
+      this.AddType(b2EdgeAndCircleContact.Create, b2EdgeAndCircleContact.Destroy, b2Shape.e_edgeShape, b2Shape.e_circleShape);
+      this.AddType(b2PolyAndEdgeContact.Create, b2PolyAndEdgeContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_edgeShape);
+   }
+   b2ContactFactory.prototype.Create = function (fixtureA, fixtureB) {
+      var type1 = parseInt(fixtureA.GetType());
+      var type2 = parseInt(fixtureB.GetType());
+      var reg = this.m_registers[type1][type2];
+      var c;
+      if (reg.pool) {
+         c = reg.pool;
+         reg.pool = c.m_next;
+         reg.poolCount--;
+         c.Reset(fixtureA, fixtureB);
+         return c;
+      }
+      var createFcn = reg.createFcn;
+      if (createFcn != null) {
+         if (reg.primary) {
+            c = createFcn(this.m_allocator);
+            c.Reset(fixtureA, fixtureB);
+            return c;
+         }
+         else {
+            c = createFcn(this.m_allocator);
+            c.Reset(fixtureB, fixtureA);
+            return c;
+         }
+      }
+      else {
+         return null;
+      }
+   }
+   b2ContactFactory.prototype.Destroy = function (contact) {
+      if (contact.m_manifold.m_pointCount > 0) {
+         contact.m_fixtureA.m_body.SetAwake(true);
+         contact.m_fixtureB.m_body.SetAwake(true);
+      }
+      var type1 = parseInt(contact.m_fixtureA.GetType());
+      var type2 = parseInt(contact.m_fixtureB.GetType());
+      var reg = this.m_registers[type1][type2];
+      if (true) {
+         reg.poolCount++;
+         contact.m_next = reg.pool;
+         reg.pool = contact;
+      }
+      var destroyFcn = reg.destroyFcn;
+      destroyFcn(contact, this.m_allocator);
+   }
+   b2ContactRegister.b2ContactRegister = function () {};
+   b2ContactResult.b2ContactResult = function () {
+      this.position = new b2Vec2();
+      this.normal = new b2Vec2();
+      this.id = new b2ContactID();
+   };
+   b2ContactSolver.b2ContactSolver = function () {
+      this.m_step = new b2TimeStep();
+      this.m_constraints = new Vector();
+   };
+   b2ContactSolver.prototype.b2ContactSolver = function () {}
+   b2ContactSolver.prototype.Initialize = function (step, contacts, contactCount, allocator) {
+      if (contactCount === undefined) contactCount = 0;
+      var contact;
+      this.m_step.Set(step);
+      this.m_allocator = allocator;
+      var i = 0;
+      var tVec;
+      var tMat;
+      this.m_constraintCount = contactCount;
+      while (this.m_constraints.length < this.m_constraintCount) {
+         this.m_constraints[this.m_constraints.length] = new b2ContactConstraint();
+      }
+      for (i = 0;
+      i < contactCount; ++i) {
+         contact = contacts[i];
+         var fixtureA = contact.m_fixtureA;
+         var fixtureB = contact.m_fixtureB;
+         var shapeA = fixtureA.m_shape;
+         var shapeB = fixtureB.m_shape;
+         var radiusA = shapeA.m_radius;
+         var radiusB = shapeB.m_radius;
+         var bodyA = fixtureA.m_body;
+         var bodyB = fixtureB.m_body;
+         var manifold = contact.GetManifold();
+         var friction = b2Settings.b2MixFriction(fixtureA.GetFriction(), fixtureB.GetFriction());
+         var restitution = b2Settings.b2MixRestitution(fixtureA.GetRestitution(), fixtureB.GetRestitution());
+         var vAX = bodyA.m_linearVelocity.x;
+         var vAY = bodyA.m_linearVelocity.y;
+         var vBX = bodyB.m_linearVelocity.x;
+         var vBY = bodyB.m_linearVelocity.y;
+         var wA = bodyA.m_angularVelocity;
+         var wB = bodyB.m_angularVelocity;
+         b2Settings.b2Assert(manifold.m_pointCount > 0);
+         b2ContactSolver.s_worldManifold.Initialize(manifold, bodyA.m_xf, radiusA, bodyB.m_xf, radiusB);
+         var normalX = b2ContactSolver.s_worldManifold.m_normal.x;
+         var normalY = b2ContactSolver.s_worldManifold.m_normal.y;
+         var cc = this.m_constraints[i];
+         cc.bodyA = bodyA;
+         cc.bodyB = bodyB;
+         cc.manifold = manifold;
+         cc.normal.x = normalX;
+         cc.normal.y = normalY;
+         cc.pointCount = manifold.m_pointCount;
+         cc.friction = friction;
+         cc.restitution = restitution;
+         cc.localPlaneNormal.x = manifold.m_localPlaneNormal.x;
+         cc.localPlaneNormal.y = manifold.m_localPlaneNormal.y;
+         cc.localPoint.x = manifold.m_localPoint.x;
+         cc.localPoint.y = manifold.m_localPoint.y;
+         cc.radius = radiusA + radiusB;
+         cc.type = manifold.m_type;
+         for (var k = 0; k < cc.pointCount; ++k) {
+            var cp = manifold.m_points[k];
+            var ccp = cc.points[k];
+            ccp.normalImpulse = cp.m_normalImpulse;
+            ccp.tangentImpulse = cp.m_tangentImpulse;
+            ccp.localPoint.SetV(cp.m_localPoint);
+            var rAX = ccp.rA.x = b2ContactSolver.s_worldManifold.m_points[k].x - bodyA.m_sweep.c.x;
+            var rAY = ccp.rA.y = b2ContactSolver.s_worldManifold.m_points[k].y - bodyA.m_sweep.c.y;
+            var rBX = ccp.rB.x = b2ContactSolver.s_worldManifold.m_points[k].x - bodyB.m_sweep.c.x;
+            var rBY = ccp.rB.y = b2ContactSolver.s_worldManifold.m_points[k].y - bodyB.m_sweep.c.y;
+            var rnA = rAX * normalY - rAY * normalX;
+            var rnB = rBX * normalY - rBY * normalX;
+            rnA *= rnA;
+            rnB *= rnB;
+            var kNormal = bodyA.m_invMass + bodyB.m_invMass + bodyA.m_invI * rnA + bodyB.m_invI * rnB;
+            ccp.normalMass = 1.0 / kNormal;
+            var kEqualized = bodyA.m_mass * bodyA.m_invMass + bodyB.m_mass * bodyB.m_invMass;
+            kEqualized += bodyA.m_mass * bodyA.m_invI * rnA + bodyB.m_mass * bodyB.m_invI * rnB;
+            ccp.equalizedMass = 1.0 / kEqualized;
+            var tangentX = normalY;
+            var tangentY = (-normalX);
+            var rtA = rAX * tangentY - rAY * tangentX;
+            var rtB = rBX * tangentY - rBY * tangentX;
+            rtA *= rtA;
+            rtB *= rtB;
+            var kTangent = bodyA.m_invMass + bodyB.m_invMass + bodyA.m_invI * rtA + bodyB.m_invI * rtB;
+            ccp.tangentMass = 1.0 / kTangent;
+            ccp.velocityBias = 0.0;
+            var tX = vBX + ((-wB * rBY)) - vAX - ((-wA * rAY));
+            var tY = vBY + (wB * rBX) - vAY - (wA * rAX);
+            var vRel = cc.normal.x * tX + cc.normal.y * tY;
+            if (vRel < (-b2Settings.b2_velocityThreshold)) {
+               ccp.velocityBias += (-cc.restitution * vRel);
+            }
+         }
+         if (cc.pointCount == 2) {
+            var ccp1 = cc.points[0];
+            var ccp2 = cc.points[1];
+            var invMassA = bodyA.m_invMass;
+            var invIA = bodyA.m_invI;
+            var invMassB = bodyB.m_invMass;
+            var invIB = bodyB.m_invI;
+            var rn1A = ccp1.rA.x * normalY - ccp1.rA.y * normalX;
+            var rn1B = ccp1.rB.x * normalY - ccp1.rB.y * normalX;
+            var rn2A = ccp2.rA.x * normalY - ccp2.rA.y * normalX;
+            var rn2B = ccp2.rB.x * normalY - ccp2.rB.y * normalX;
+            var k11 = invMassA + invMassB + invIA * rn1A * rn1A + invIB * rn1B * rn1B;
+            var k22 = invMassA + invMassB + invIA * rn2A * rn2A + invIB * rn2B * rn2B;
+            var k12 = invMassA + invMassB + invIA * rn1A * rn2A + invIB * rn1B * rn2B;
+            var k_maxConditionNumber = 100.0;
+            if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) {
+               cc.K.col1.Set(k11, k12);
+               cc.K.col2.Set(k12, k22);
+               cc.K.GetInverse(cc.normalMass);
+            }
+            else {
+               cc.pointCount = 1;
+            }
+         }
+      }
+   }
+   b2ContactSolver.prototype.InitVelocityConstraints = function (step) {
+      var tVec;
+      var tVec2;
+      var tMat;
+      for (var i = 0; i < this.m_constraintCount; ++i) {
+         var c = this.m_constraints[i];
+         var bodyA = c.bodyA;
+         var bodyB = c.bodyB;
+         var invMassA = bodyA.m_invMass;
+         var invIA = bodyA.m_invI;
+         var invMassB = bodyB.m_invMass;
+         var invIB = bodyB.m_invI;
+         var normalX = c.normal.x;
+         var normalY = c.normal.y;
+         var tangentX = normalY;
+         var tangentY = (-normalX);
+         var tX = 0;
+         var j = 0;
+         var tCount = 0;
+         if (step.warmStarting) {
+            tCount = c.pointCount;
+            for (j = 0;
+            j < tCount; ++j) {
+               var ccp = c.points[j];
+               ccp.normalImpulse *= step.dtRatio;
+               ccp.tangentImpulse *= step.dtRatio;
+               var PX = ccp.normalImpulse * normalX + ccp.tangentImpulse * tangentX;
+               var PY = ccp.normalImpulse * normalY + ccp.tangentImpulse * tangentY;
+               bodyA.m_angularVelocity -= invIA * (ccp.rA.x * PY - ccp.rA.y * PX);
+               bodyA.m_linearVelocity.x -= invMassA * PX;
+               bodyA.m_linearVelocity.y -= invMassA * PY;
+               bodyB.m_angularVelocity += invIB * (ccp.rB.x * PY - ccp.rB.y * PX);
+               bodyB.m_linearVelocity.x += invMassB * PX;
+               bodyB.m_linearVelocity.y += invMassB * PY;
+            }
+         }
+         else {
+            tCount = c.pointCount;
+            for (j = 0;
+            j < tCount; ++j) {
+               var ccp2 = c.points[j];
+               ccp2.normalImpulse = 0.0;
+               ccp2.tangentImpulse = 0.0;
+            }
+         }
+      }
+   }
+   b2ContactSolver.prototype.SolveVelocityConstraints = function () {
+      var j = 0;
+      var ccp;
+      var rAX = 0;
+      var rAY = 0;
+      var rBX = 0;
+      var rBY = 0;
+      var dvX = 0;
+      var dvY = 0;
+      var vn = 0;
+      var vt = 0;
+      var lambda = 0;
+      var maxFriction = 0;
+      var newImpulse = 0;
+      var PX = 0;
+      var PY = 0;
+      var dX = 0;
+      var dY = 0;
+      var P1X = 0;
+      var P1Y = 0;
+      var P2X = 0;
+      var P2Y = 0;
+      var tMat;
+      var tVec;
+      for (var i = 0; i < this.m_constraintCount; ++i) {
+         var c = this.m_constraints[i];
+         var bodyA = c.bodyA;
+         var bodyB = c.bodyB;
+         var wA = bodyA.m_angularVelocity;
+         var wB = bodyB.m_angularVelocity;
+         var vA = bodyA.m_linearVelocity;
+         var vB = bodyB.m_linearVelocity;
+         var invMassA = bodyA.m_invMass;
+         var invIA = bodyA.m_invI;
+         var invMassB = bodyB.m_invMass;
+         var invIB = bodyB.m_invI;
+         var normalX = c.normal.x;
+         var normalY = c.normal.y;
+         var tangentX = normalY;
+         var tangentY = (-normalX);
+         var friction = c.friction;
+         var tX = 0;
+         for (j = 0;
+         j < c.pointCount; j++) {
+            ccp = c.points[j];
+            dvX = vB.x - wB * ccp.rB.y - vA.x + wA * ccp.rA.y;
+            dvY = vB.y + wB * ccp.rB.x - vA.y - wA * ccp.rA.x;
+            vt = dvX * tangentX + dvY * tangentY;
+            lambda = ccp.tangentMass * (-vt);
+            maxFriction = friction * ccp.normalImpulse;
+            newImpulse = b2Math.Clamp(ccp.tangentImpulse + lambda, (-maxFriction), maxFriction);
+            lambda = newImpulse - ccp.tangentImpulse;
+            PX = lambda * tangentX;
+            PY = lambda * tangentY;
+            vA.x -= invMassA * PX;
+            vA.y -= invMassA * PY;
+            wA -= invIA * (ccp.rA.x * PY - ccp.rA.y * PX);
+            vB.x += invMassB * PX;
+            vB.y += invMassB * PY;
+            wB += invIB * (ccp.rB.x * PY - ccp.rB.y * PX);
+            ccp.tangentImpulse = newImpulse;
+         }
+         var tCount = parseInt(c.pointCount);
+         if (c.pointCount == 1) {
+            ccp = c.points[0];
+            dvX = vB.x + ((-wB * ccp.rB.y)) - vA.x - ((-wA * ccp.rA.y));
+            dvY = vB.y + (wB * ccp.rB.x) - vA.y - (wA * ccp.rA.x);
+            vn = dvX * normalX + dvY * normalY;
+            lambda = (-ccp.normalMass * (vn - ccp.velocityBias));
+            newImpulse = ccp.normalImpulse + lambda;
+            newImpulse = newImpulse > 0 ? newImpulse : 0.0;
+            lambda = newImpulse - ccp.normalImpulse;
+            PX = lambda * normalX;
+            PY = lambda * normalY;
+            vA.x -= invMassA * PX;
+            vA.y -= invMassA * PY;
+            wA -= invIA * (ccp.rA.x * PY - ccp.rA.y * PX);
+            vB.x += invMassB * PX;
+            vB.y += invMassB * PY;
+            wB += invIB * (ccp.rB.x * PY - ccp.rB.y * PX);
+            ccp.normalImpulse = newImpulse;
+         }
+         else {
+            var cp1 = c.points[0];
+            var cp2 = c.points[1];
+            var aX = cp1.normalImpulse;
+            var aY = cp2.normalImpulse;
+            var dv1X = vB.x - wB * cp1.rB.y - vA.x + wA * cp1.rA.y;
+            var dv1Y = vB.y + wB * cp1.rB.x - vA.y - wA * cp1.rA.x;
+            var dv2X = vB.x - wB * cp2.rB.y - vA.x + wA * cp2.rA.y;
+            var dv2Y = vB.y + wB * cp2.rB.x - vA.y - wA * cp2.rA.x;
+            var vn1 = dv1X * normalX + dv1Y * normalY;
+            var vn2 = dv2X * normalX + dv2Y * normalY;
+            var bX = vn1 - cp1.velocityBias;
+            var bY = vn2 - cp2.velocityBias;
+            tMat = c.K;
+            bX -= tMat.col1.x * aX + tMat.col2.x * aY;
+            bY -= tMat.col1.y * aX + tMat.col2.y * aY;
+            var k_errorTol = 0.001;
+            for (;;) {
+               tMat = c.normalMass;
+               var xX = (-(tMat.col1.x * bX + tMat.col2.x * bY));
+               var xY = (-(tMat.col1.y * bX + tMat.col2.y * bY));
+               if (xX >= 0.0 && xY >= 0.0) {
+                  dX = xX - aX;
+                  dY = xY - aY;
+                  P1X = dX * normalX;
+                  P1Y = dX * normalY;
+                  P2X = dY * normalX;
+                  P2Y = dY * normalY;
+                  vA.x -= invMassA * (P1X + P2X);
+                  vA.y -= invMassA * (P1Y + P2Y);
+                  wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X);
+                  vB.x += invMassB * (P1X + P2X);
+                  vB.y += invMassB * (P1Y + P2Y);
+                  wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X);
+                  cp1.normalImpulse = xX;
+                  cp2.normalImpulse = xY;
+                  break;
+               }
+               xX = (-cp1.normalMass * bX);
+               xY = 0.0;
+               vn1 = 0.0;
+               vn2 = c.K.col1.y * xX + bY;
+               if (xX >= 0.0 && vn2 >= 0.0) {
+                  dX = xX - aX;
+                  dY = xY - aY;
+                  P1X = dX * normalX;
+                  P1Y = dX * normalY;
+                  P2X = dY * normalX;
+                  P2Y = dY * normalY;
+                  vA.x -= invMassA * (P1X + P2X);
+                  vA.y -= invMassA * (P1Y + P2Y);
+                  wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X);
+                  vB.x += invMassB * (P1X + P2X);
+                  vB.y += invMassB * (P1Y + P2Y);
+                  wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X);
+                  cp1.normalImpulse = xX;
+                  cp2.normalImpulse = xY;
+                  break;
+               }
+               xX = 0.0;
+               xY = (-cp2.normalMass * bY);
+               vn1 = c.K.col2.x * xY + bX;
+               vn2 = 0.0;
+               if (xY >= 0.0 && vn1 >= 0.0) {
+                  dX = xX - aX;
+                  dY = xY - aY;
+                  P1X = dX * normalX;
+                  P1Y = dX * normalY;
+                  P2X = dY * normalX;
+                  P2Y = dY * normalY;
+                  vA.x -= invMassA * (P1X + P2X);
+                  vA.y -= invMassA * (P1Y + P2Y);
+                  wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X);
+                  vB.x += invMassB * (P1X + P2X);
+                  vB.y += invMassB * (P1Y + P2Y);
+                  wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X);
+                  cp1.normalImpulse = xX;
+                  cp2.normalImpulse = xY;
+                  break;
+               }
+               xX = 0.0;
+               xY = 0.0;
+               vn1 = bX;
+               vn2 = bY;
+               if (vn1 >= 0.0 && vn2 >= 0.0) {
+                  dX = xX - aX;
+                  dY = xY - aY;
+                  P1X = dX * normalX;
+                  P1Y = dX * normalY;
+                  P2X = dY * normalX;
+                  P2Y = dY * normalY;
+                  vA.x -= invMassA * (P1X + P2X);
+                  vA.y -= invMassA * (P1Y + P2Y);
+                  wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X);
+                  vB.x += invMassB * (P1X + P2X);
+                  vB.y += invMassB * (P1Y + P2Y);
+                  wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X);
+                  cp1.normalImpulse = xX;
+                  cp2.normalImpulse = xY;
+                  break;
+               }
+               break;
+            }
+         }
+         bodyA.m_angularVelocity = wA;
+         bodyB.m_angularVelocity = wB;
+      }
+   }
+   b2ContactSolver.prototype.FinalizeVelocityConstraints = function () {
+      for (var i = 0; i < this.m_constraintCount; ++i) {
+         var c = this.m_constraints[i];
+         var m = c.manifold;
+         for (var j = 0; j < c.pointCount; ++j) {
+            var point1 = m.m_points[j];
+            var point2 = c.points[j];
+            point1.m_normalImpulse = point2.normalImpulse;
+            point1.m_tangentImpulse = point2.tangentImpulse;
+         }
+      }
+   }
+   b2ContactSolver.prototype.SolvePositionConstraints = function (baumgarte) {
+      if (baumgarte === undefined) baumgarte = 0;
+      var minSeparation = 0.0;
+      for (var i = 0; i < this.m_constraintCount; i++) {
+         var c = this.m_constraints[i];
+         var bodyA = c.bodyA;
+         var bodyB = c.bodyB;
+         var invMassA = bodyA.m_mass * bodyA.m_invMass;
+         var invIA = bodyA.m_mass * bodyA.m_invI;
+         var invMassB = bodyB.m_mass * bodyB.m_invMass;
+         var invIB = bodyB.m_mass * bodyB.m_invI;
+         b2ContactSolver.s_psm.Initialize(c);
+         var normal = b2ContactSolver.s_psm.m_normal;
+         for (var j = 0; j < c.pointCount; j++) {
+            var ccp = c.points[j];
+            var point = b2ContactSolver.s_psm.m_points[j];
+            var separation = b2ContactSolver.s_psm.m_separations[j];
+            var rAX = point.x - bodyA.m_sweep.c.x;
+            var rAY = point.y - bodyA.m_sweep.c.y;
+            var rBX = point.x - bodyB.m_sweep.c.x;
+            var rBY = point.y - bodyB.m_sweep.c.y;
+            minSeparation = minSeparation < separation ? minSeparation : separation;
+            var C = b2Math.Clamp(baumgarte * (separation + b2Settings.b2_linearSlop), (-b2Settings.b2_maxLinearCorrection), 0.0);
+            var impulse = (-ccp.equalizedMass * C);
+            var PX = impulse * normal.x;
+            var PY = impulse * normal.y;bodyA.m_sweep.c.x -= invMassA * PX;
+            bodyA.m_sweep.c.y -= invMassA * PY;
+            bodyA.m_sweep.a -= invIA * (rAX * PY - rAY * PX);
+            bodyA.SynchronizeTransform();
+            bodyB.m_sweep.c.x += invMassB * PX;
+            bodyB.m_sweep.c.y += invMassB * PY;
+            bodyB.m_sweep.a += invIB * (rBX * PY - rBY * PX);
+            bodyB.SynchronizeTransform();
+         }
+      }
+      return minSeparation > (-1.5 * b2Settings.b2_linearSlop);
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold = new b2WorldManifold();
+      Box2D.Dynamics.Contacts.b2ContactSolver.s_psm = new b2PositionSolverManifold();
+   });
+   Box2D.inherit(b2EdgeAndCircleContact, Box2D.Dynamics.Contacts.b2Contact);
+   b2EdgeAndCircleContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype;
+   b2EdgeAndCircleContact.b2EdgeAndCircleContact = function () {
+      Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments);
+   };
+   b2EdgeAndCircleContact.Create = function (allocator) {
+      return new b2EdgeAndCircleContact();
+   }
+   b2EdgeAndCircleContact.Destroy = function (contact, allocator) {}
+   b2EdgeAndCircleContact.prototype.Reset = function (fixtureA, fixtureB) {
+      this.__super.Reset.call(this, fixtureA, fixtureB);
+   }
+   b2EdgeAndCircleContact.prototype.Evaluate = function () {
+      var bA = this.m_fixtureA.GetBody();
+      var bB = this.m_fixtureB.GetBody();
+      this.b2CollideEdgeAndCircle(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2EdgeShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2CircleShape ? this.m_fixtureB.GetShape() : null), bB.m_xf);
+   }
+   b2EdgeAndCircleContact.prototype.b2CollideEdgeAndCircle = function (manifold, edge, xf1, circle, xf2) {}
+   Box2D.inherit(b2NullContact, Box2D.Dynamics.Contacts.b2Contact);
+   b2NullContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype;
+   b2NullContact.b2NullContact = function () {
+      Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments);
+   };
+   b2NullContact.prototype.b2NullContact = function () {
+      this.__super.b2Contact.call(this);
+   }
+   b2NullContact.prototype.Evaluate = function () {}
+   Box2D.inherit(b2PolyAndCircleContact, Box2D.Dynamics.Contacts.b2Contact);
+   b2PolyAndCircleContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype;
+   b2PolyAndCircleContact.b2PolyAndCircleContact = function () {
+      Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments);
+   };
+   b2PolyAndCircleContact.Create = function (allocator) {
+      return new b2PolyAndCircleContact();
+   }
+   b2PolyAndCircleContact.Destroy = function (contact, allocator) {}
+   b2PolyAndCircleContact.prototype.Reset = function (fixtureA, fixtureB) {
+      this.__super.Reset.call(this, fixtureA, fixtureB);
+      b2Settings.b2Assert(fixtureA.GetType() == b2Shape.e_polygonShape);
+      b2Settings.b2Assert(fixtureB.GetType() == b2Shape.e_circleShape);
+   }
+   b2PolyAndCircleContact.prototype.Evaluate = function () {
+      var bA = this.m_fixtureA.m_body;
+      var bB = this.m_fixtureB.m_body;
+      b2Collision.CollidePolygonAndCircle(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2PolygonShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2CircleShape ? this.m_fixtureB.GetShape() : null), bB.m_xf);
+   }
+   Box2D.inherit(b2PolyAndEdgeContact, Box2D.Dynamics.Contacts.b2Contact);
+   b2PolyAndEdgeContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype;
+   b2PolyAndEdgeContact.b2PolyAndEdgeContact = function () {
+      Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments);
+   };
+   b2PolyAndEdgeContact.Create = function (allocator) {
+      return new b2PolyAndEdgeContact();
+   }
+   b2PolyAndEdgeContact.Destroy = function (contact, allocator) {}
+   b2PolyAndEdgeContact.prototype.Reset = function (fixtureA, fixtureB) {
+      this.__super.Reset.call(this, fixtureA, fixtureB);
+      b2Settings.b2Assert(fixtureA.GetType() == b2Shape.e_polygonShape);
+      b2Settings.b2Assert(fixtureB.GetType() == b2Shape.e_edgeShape);
+   }
+   b2PolyAndEdgeContact.prototype.Evaluate = function () {
+      var bA = this.m_fixtureA.GetBody();
+      var bB = this.m_fixtureB.GetBody();
+      this.b2CollidePolyAndEdge(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2PolygonShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2EdgeShape ? this.m_fixtureB.GetShape() : null), bB.m_xf);
+   }
+   b2PolyAndEdgeContact.prototype.b2CollidePolyAndEdge = function (manifold, polygon, xf1, edge, xf2) {}
+   Box2D.inherit(b2PolygonContact, Box2D.Dynamics.Contacts.b2Contact);
+   b2PolygonContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype;
+   b2PolygonContact.b2PolygonContact = function () {
+      Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments);
+   };
+   b2PolygonContact.Create = function (allocator) {
+      return new b2PolygonContact();
+   }
+   b2PolygonContact.Destroy = function (contact, allocator) {}
+   b2PolygonContact.prototype.Reset = function (fixtureA, fixtureB) {
+      this.__super.Reset.call(this, fixtureA, fixtureB);
+   }
+   b2PolygonContact.prototype.Evaluate = function () {
+      var bA = this.m_fixtureA.GetBody();
+      var bB = this.m_fixtureB.GetBody();
+      b2Collision.CollidePolygons(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2PolygonShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2PolygonShape ? this.m_fixtureB.GetShape() : null), bB.m_xf);
+   }
+   b2PositionSolverManifold.b2PositionSolverManifold = function () {};
+   b2PositionSolverManifold.prototype.b2PositionSolverManifold = function () {
+      this.m_normal = new b2Vec2();
+      this.m_separations = new Vector_a2j_Number(b2Settings.b2_maxManifoldPoints);
+      this.m_points = new Vector(b2Settings.b2_maxManifoldPoints);
+      for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) {
+         this.m_points[i] = new b2Vec2();
+      }
+   }
+   b2PositionSolverManifold.prototype.Initialize = function (cc) {
+      b2Settings.b2Assert(cc.pointCount > 0);
+      var i = 0;
+      var clipPointX = 0;
+      var clipPointY = 0;
+      var tMat;
+      var tVec;
+      var planePointX = 0;
+      var planePointY = 0;
+      switch (cc.type) {
+      case b2Manifold.e_circles:
+         {
+            tMat = cc.bodyA.m_xf.R;
+            tVec = cc.localPoint;
+            var pointAX = cc.bodyA.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+            var pointAY = cc.bodyA.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+            tMat = cc.bodyB.m_xf.R;
+            tVec = cc.points[0].localPoint;
+            var pointBX = cc.bodyB.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+            var pointBY = cc.bodyB.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+            var dX = pointBX - pointAX;
+            var dY = pointBY - pointAY;
+            var d2 = dX * dX + dY * dY;
+            if (d2 > Number.MIN_VALUE * Number.MIN_VALUE) {
+               var d = Math.sqrt(d2);
+               this.m_normal.x = dX / d;
+               this.m_normal.y = dY / d;
+            }
+            else {
+               this.m_normal.x = 1.0;
+               this.m_normal.y = 0.0;
+            }
+            this.m_points[0].x = 0.5 * (pointAX + pointBX);
+            this.m_points[0].y = 0.5 * (pointAY + pointBY);
+            this.m_separations[0] = dX * this.m_normal.x + dY * this.m_normal.y - cc.radius;
+         }
+         break;
+      case b2Manifold.e_faceA:
+         {
+            tMat = cc.bodyA.m_xf.R;
+            tVec = cc.localPlaneNormal;
+            this.m_normal.x = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+            this.m_normal.y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+            tMat = cc.bodyA.m_xf.R;
+            tVec = cc.localPoint;
+            planePointX = cc.bodyA.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+            planePointY = cc.bodyA.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+            tMat = cc.bodyB.m_xf.R;
+            for (i = 0;
+            i < cc.pointCount; ++i) {
+               tVec = cc.points[i].localPoint;
+               clipPointX = cc.bodyB.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+               clipPointY = cc.bodyB.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+               this.m_separations[i] = (clipPointX - planePointX) * this.m_normal.x + (clipPointY - planePointY) * this.m_normal.y - cc.radius;
+               this.m_points[i].x = clipPointX;
+               this.m_points[i].y = clipPointY;
+            }
+         }
+         break;
+      case b2Manifold.e_faceB:
+         {
+            tMat = cc.bodyB.m_xf.R;
+            tVec = cc.localPlaneNormal;
+            this.m_normal.x = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+            this.m_normal.y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+            tMat = cc.bodyB.m_xf.R;
+            tVec = cc.localPoint;
+            planePointX = cc.bodyB.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+            planePointY = cc.bodyB.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+            tMat = cc.bodyA.m_xf.R;
+            for (i = 0;
+            i < cc.pointCount; ++i) {
+               tVec = cc.points[i].localPoint;
+               clipPointX = cc.bodyA.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y);
+               clipPointY = cc.bodyA.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y);
+               this.m_separations[i] = (clipPointX - planePointX) * this.m_normal.x + (clipPointY - planePointY) * this.m_normal.y - cc.radius;
+               this.m_points[i].Set(clipPointX, clipPointY);
+            }
+            this.m_normal.x *= (-1);
+            this.m_normal.y *= (-1);
+         }
+         break;
+      }
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Dynamics.Contacts.b2PositionSolverManifold.circlePointA = new b2Vec2();
+      Box2D.Dynamics.Contacts.b2PositionSolverManifold.circlePointB = new b2Vec2();
+   });
+})();
+(function () {
+   var b2Body = Box2D.Dynamics.b2Body,
+      b2BodyDef = Box2D.Dynamics.b2BodyDef,
+      b2ContactFilter = Box2D.Dynamics.b2ContactFilter,
+      b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse,
+      b2ContactListener = Box2D.Dynamics.b2ContactListener,
+      b2ContactManager = Box2D.Dynamics.b2ContactManager,
+      b2DebugDraw = Box2D.Dynamics.b2DebugDraw,
+      b2DestructionListener = Box2D.Dynamics.b2DestructionListener,
+      b2FilterData = Box2D.Dynamics.b2FilterData,
+      b2Fixture = Box2D.Dynamics.b2Fixture,
+      b2FixtureDef = Box2D.Dynamics.b2FixtureDef,
+      b2Island = Box2D.Dynamics.b2Island,
+      b2TimeStep = Box2D.Dynamics.b2TimeStep,
+      b2World = Box2D.Dynamics.b2World,
+      b2Mat22 = Box2D.Common.Math.b2Mat22,
+      b2Mat33 = Box2D.Common.Math.b2Mat33,
+      b2Math = Box2D.Common.Math.b2Math,
+      b2Sweep = Box2D.Common.Math.b2Sweep,
+      b2Transform = Box2D.Common.Math.b2Transform,
+      b2Vec2 = Box2D.Common.Math.b2Vec2,
+      b2Vec3 = Box2D.Common.Math.b2Vec3,
+      b2Color = Box2D.Common.b2Color,
+      b2internal = Box2D.Common.b2internal,
+      b2Settings = Box2D.Common.b2Settings,
+      b2CircleShape = Box2D.Collision.Shapes.b2CircleShape,
+      b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef,
+      b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape,
+      b2MassData = Box2D.Collision.Shapes.b2MassData,
+      b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape,
+      b2Shape = Box2D.Collision.Shapes.b2Shape,
+      b2BuoyancyController = Box2D.Dynamics.Controllers.b2BuoyancyController,
+      b2ConstantAccelController = Box2D.Dynamics.Controllers.b2ConstantAccelController,
+      b2ConstantForceController = Box2D.Dynamics.Controllers.b2ConstantForceController,
+      b2Controller = Box2D.Dynamics.Controllers.b2Controller,
+      b2ControllerEdge = Box2D.Dynamics.Controllers.b2ControllerEdge,
+      b2GravityController = Box2D.Dynamics.Controllers.b2GravityController,
+      b2TensorDampingController = Box2D.Dynamics.Controllers.b2TensorDampingController;
+
+   Box2D.inherit(b2BuoyancyController, Box2D.Dynamics.Controllers.b2Controller);
+   b2BuoyancyController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype;
+   b2BuoyancyController.b2BuoyancyController = function () {
+      Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments);
+      this.normal = new b2Vec2(0, (-1));
+      this.offset = 0;
+      this.density = 0;
+      this.velocity = new b2Vec2(0, 0);
+      this.linearDrag = 2;
+      this.angularDrag = 1;
+      this.useDensity = false;
+      this.useWorldGravity = true;
+      this.gravity = null;
+   };
+   b2BuoyancyController.prototype.Step = function (step) {
+      if (!this.m_bodyList) return;
+      if (this.useWorldGravity) {
+         this.gravity = this.GetWorld().GetGravity().Copy();
+      }
+      for (var i = this.m_bodyList; i; i = i.nextBody) {
+         var body = i.body;
+         if (body.IsAwake() == false) {
+            continue;
+         }
+         var areac = new b2Vec2();
+         var massc = new b2Vec2();
+         var area = 0.0;
+         var mass = 0.0;
+         for (var fixture = body.GetFixtureList(); fixture; fixture = fixture.GetNext()) {
+            var sc = new b2Vec2();
+            var sarea = fixture.GetShape().ComputeSubmergedArea(this.normal, this.offset, body.GetTransform(), sc);
+            area += sarea;
+            areac.x += sarea * sc.x;
+            areac.y += sarea * sc.y;
+            var shapeDensity = 0;
+            if (this.useDensity) {
+               shapeDensity = 1;
+            }
+            else {
+               shapeDensity = 1;
+            }
+            mass += sarea * shapeDensity;
+            massc.x += sarea * sc.x * shapeDensity;
+            massc.y += sarea * sc.y * shapeDensity;
+         }
+         areac.x /= area;
+         areac.y /= area;
+         massc.x /= mass;
+         massc.y /= mass;
+         if (area < Number.MIN_VALUE) continue;
+         var buoyancyForce = this.gravity.GetNegative();
+         buoyancyForce.Multiply(this.density * area);
+         body.ApplyForce(buoyancyForce, massc);
+         var dragForce = body.GetLinearVelocityFromWorldPoint(areac);
+         dragForce.Subtract(this.velocity);
+         dragForce.Multiply((-this.linearDrag * area));
+         body.ApplyForce(dragForce, areac);
+         body.ApplyTorque((-body.GetInertia() / body.GetMass() * area * body.GetAngularVelocity() * this.angularDrag));
+      }
+   }
+   b2BuoyancyController.prototype.Draw = function (debugDraw) {
+      var r = 1000;
+      var p1 = new b2Vec2();
+      var p2 = new b2Vec2();
+      p1.x = this.normal.x * this.offset + this.normal.y * r;
+      p1.y = this.normal.y * this.offset - this.normal.x * r;
+      p2.x = this.normal.x * this.offset - this.normal.y * r;
+      p2.y = this.normal.y * this.offset + this.normal.x * r;
+      var color = new b2Color(0, 0, 1);
+      debugDraw.DrawSegment(p1, p2, color);
+   }
+   Box2D.inherit(b2ConstantAccelController, Box2D.Dynamics.Controllers.b2Controller);
+   b2ConstantAccelController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype;
+   b2ConstantAccelController.b2ConstantAccelController = function () {
+      Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments);
+      this.A = new b2Vec2(0, 0);
+   };
+   b2ConstantAccelController.prototype.Step = function (step) {
+      var smallA = new b2Vec2(this.A.x * step.dt, this.A.y * step.dt);
+      for (var i = this.m_bodyList; i; i = i.nextBody) {
+         var body = i.body;
+         if (!body.IsAwake()) continue;
+         body.SetLinearVelocity(new b2Vec2(body.GetLinearVelocity().x + smallA.x, body.GetLinearVelocity().y + smallA.y));
+      }
+   }
+   Box2D.inherit(b2ConstantForceController, Box2D.Dynamics.Controllers.b2Controller);
+   b2ConstantForceController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype;
+   b2ConstantForceController.b2ConstantForceController = function () {
+      Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments);
+      this.F = new b2Vec2(0, 0);
+   };
+   b2ConstantForceController.prototype.Step = function (step) {
+      for (var i = this.m_bodyList; i; i = i.nextBody) {
+         var body = i.body;
+         if (!body.IsAwake()) continue;
+         body.ApplyForce(this.F, body.GetWorldCenter());
+      }
+   }
+   b2Controller.b2Controller = function () {};
+   b2Controller.prototype.Step = function (step) {}
+   b2Controller.prototype.Draw = function (debugDraw) {}
+   b2Controller.prototype.AddBody = function (body) {
+      var edge = new b2ControllerEdge();
+      edge.controller = this;
+      edge.body = body;
+      edge.nextBody = this.m_bodyList;
+      edge.prevBody = null;
+      this.m_bodyList = edge;
+      if (edge.nextBody) edge.nextBody.prevBody = edge;
+      this.m_bodyCount++;
+      edge.nextController = body.m_controllerList;
+      edge.prevController = null;
+      body.m_controllerList = edge;
+      if (edge.nextController) edge.nextController.prevController = edge;
+      body.m_controllerCount++;
+   }
+   b2Controller.prototype.RemoveBody = function (body) {
+      var edge = body.m_controllerList;
+      while (edge && edge.controller != this)
+      edge = edge.nextController;
+      if (edge.prevBody) edge.prevBody.nextBody = edge.nextBody;
+      if (edge.nextBody) edge.nextBody.prevBody = edge.prevBody;
+      if (edge.nextController) edge.nextController.prevController = edge.prevController;
+      if (edge.prevController) edge.prevController.nextController = edge.nextController;
+      if (this.m_bodyList == edge) this.m_bodyList = edge.nextBody;
+      if (body.m_controllerList == edge) body.m_controllerList = edge.nextController;
+      body.m_controllerCount--;
+      this.m_bodyCount--;
+   }
+   b2Controller.prototype.Clear = function () {
+      while (this.m_bodyList)
+      this.RemoveBody(this.m_bodyList.body);
+   }
+   b2Controller.prototype.GetNext = function () {
+      return this.m_next;
+   }
+   b2Controller.prototype.GetWorld = function () {
+      return this.m_world;
+   }
+   b2Controller.prototype.GetBodyList = function () {
+      return this.m_bodyList;
+   }
+   b2ControllerEdge.b2ControllerEdge = function () {};
+   Box2D.inherit(b2GravityController, Box2D.Dynamics.Controllers.b2Controller);
+   b2GravityController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype;
+   b2GravityController.b2GravityController = function () {
+      Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments);
+      this.G = 1;
+      this.invSqr = true;
+   };
+   b2GravityController.prototype.Step = function (step) {
+      var i = null;
+      var body1 = null;
+      var p1 = null;
+      var mass1 = 0;
+      var j = null;
+      var body2 = null;
+      var p2 = null;
+      var dx = 0;
+      var dy = 0;
+      var r2 = 0;
+      var f = null;
+      if (this.invSqr) {
+         for (i = this.m_bodyList;
+         i; i = i.nextBody) {
+            body1 = i.body;
+            p1 = body1.GetWorldCenter();
+            mass1 = body1.GetMass();
+            for (j = this.m_bodyList;
+            j != i; j = j.nextBody) {
+               body2 = j.body;
+               p2 = body2.GetWorldCenter();
+               dx = p2.x - p1.x;
+               dy = p2.y - p1.y;
+               r2 = dx * dx + dy * dy;
+               if (r2 < Number.MIN_VALUE) continue;
+               f = new b2Vec2(dx, dy);
+               f.Multiply(this.G / r2 / Math.sqrt(r2) * mass1 * body2.GetMass());
+               if (body1.IsAwake()) body1.ApplyForce(f, p1);
+               f.Multiply((-1));
+               if (body2.IsAwake()) body2.ApplyForce(f, p2);
+            }
+         }
+      }
+      else {
+         for (i = this.m_bodyList;
+         i; i = i.nextBody) {
+            body1 = i.body;
+            p1 = body1.GetWorldCenter();
+            mass1 = body1.GetMass();
+            for (j = this.m_bodyList;
+            j != i; j = j.nextBody) {
+               body2 = j.body;
+               p2 = body2.GetWorldCenter();
+               dx = p2.x - p1.x;
+               dy = p2.y - p1.y;
+               r2 = dx * dx + dy * dy;
+               if (r2 < Number.MIN_VALUE) continue;
+               f = new b2Vec2(dx, dy);
+               f.Multiply(this.G / r2 * mass1 * body2.GetMass());
+               if (body1.IsAwake()) body1.ApplyForce(f, p1);
+               f.Multiply((-1));
+               if (body2.IsAwake()) body2.ApplyForce(f, p2);
+            }
+         }
+      }
+   }
+   Box2D.inherit(b2TensorDampingController, Box2D.Dynamics.Controllers.b2Controller);
+   b2TensorDampingController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype;
+   b2TensorDampingController.b2TensorDampingController = function () {
+      Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments);
+      this.T = new b2Mat22();
+      this.maxTimestep = 0;
+   };
+   b2TensorDampingController.prototype.SetAxisAligned = function (xDamping, yDamping) {
+      if (xDamping === undefined) xDamping = 0;
+      if (yDamping === undefined) yDamping = 0;
+      this.T.col1.x = (-xDamping);
+      this.T.col1.y = 0;
+      this.T.col2.x = 0;
+      this.T.col2.y = (-yDamping);
+      if (xDamping > 0 || yDamping > 0) {
+         this.maxTimestep = 1 / Math.max(xDamping, yDamping);
+      }
+      else {
+         this.maxTimestep = 0;
+      }
+   }
+   b2TensorDampingController.prototype.Step = function (step) {
+      var timestep = step.dt;
+      if (timestep <= Number.MIN_VALUE) return;
+      if (timestep > this.maxTimestep && this.maxTimestep > 0) timestep = this.maxTimestep;
+      for (var i = this.m_bodyList; i; i = i.nextBody) {
+         var body = i.body;
+         if (!body.IsAwake()) {
+            continue;
+         }
+         var damping = body.GetWorldVector(b2Math.MulMV(this.T, body.GetLocalVector(body.GetLinearVelocity())));
+         body.SetLinearVelocity(new b2Vec2(body.GetLinearVelocity().x + damping.x * timestep, body.GetLinearVelocity().y + damping.y * timestep));
+      }
+   }
+})();
+(function () {
+   var b2Color = Box2D.Common.b2Color,
+      b2internal = Box2D.Common.b2internal,
+      b2Settings = Box2D.Common.b2Settings,
+      b2Mat22 = Box2D.Common.Math.b2Mat22,
+      b2Mat33 = Box2D.Common.Math.b2Mat33,
+      b2Math = Box2D.Common.Math.b2Math,
+      b2Sweep = Box2D.Common.Math.b2Sweep,
+      b2Transform = Box2D.Common.Math.b2Transform,
+      b2Vec2 = Box2D.Common.Math.b2Vec2,
+      b2Vec3 = Box2D.Common.Math.b2Vec3,
+      b2DistanceJoint = Box2D.Dynamics.Joints.b2DistanceJoint,
+      b2DistanceJointDef = Box2D.Dynamics.Joints.b2DistanceJointDef,
+      b2FrictionJoint = Box2D.Dynamics.Joints.b2FrictionJoint,
+      b2FrictionJointDef = Box2D.Dynamics.Joints.b2FrictionJointDef,
+      b2GearJoint = Box2D.Dynamics.Joints.b2GearJoint,
+      b2GearJointDef = Box2D.Dynamics.Joints.b2GearJointDef,
+      b2Jacobian = Box2D.Dynamics.Joints.b2Jacobian,
+      b2Joint = Box2D.Dynamics.Joints.b2Joint,
+      b2JointDef = Box2D.Dynamics.Joints.b2JointDef,
+      b2JointEdge = Box2D.Dynamics.Joints.b2JointEdge,
+      b2LineJoint = Box2D.Dynamics.Joints.b2LineJoint,
+      b2LineJointDef = Box2D.Dynamics.Joints.b2LineJointDef,
+      b2MouseJoint = Box2D.Dynamics.Joints.b2MouseJoint,
+      b2MouseJointDef = Box2D.Dynamics.Joints.b2MouseJointDef,
+      b2PrismaticJoint = Box2D.Dynamics.Joints.b2PrismaticJoint,
+      b2PrismaticJointDef = Box2D.Dynamics.Joints.b2PrismaticJointDef,
+      b2PulleyJoint = Box2D.Dynamics.Joints.b2PulleyJoint,
+      b2PulleyJointDef = Box2D.Dynamics.Joints.b2PulleyJointDef,
+      b2RevoluteJoint = Box2D.Dynamics.Joints.b2RevoluteJoint,
+      b2RevoluteJointDef = Box2D.Dynamics.Joints.b2RevoluteJointDef,
+      b2WeldJoint = Box2D.Dynamics.Joints.b2WeldJoint,
+      b2WeldJointDef = Box2D.Dynamics.Joints.b2WeldJointDef,
+      b2Body = Box2D.Dynamics.b2Body,
+      b2BodyDef = Box2D.Dynamics.b2BodyDef,
+      b2ContactFilter = Box2D.Dynamics.b2ContactFilter,
+      b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse,
+      b2ContactListener = Box2D.Dynamics.b2ContactListener,
+      b2ContactManager = Box2D.Dynamics.b2ContactManager,
+      b2DebugDraw = Box2D.Dynamics.b2DebugDraw,
+      b2DestructionListener = Box2D.Dynamics.b2DestructionListener,
+      b2FilterData = Box2D.Dynamics.b2FilterData,
+      b2Fixture = Box2D.Dynamics.b2Fixture,
+      b2FixtureDef = Box2D.Dynamics.b2FixtureDef,
+      b2Island = Box2D.Dynamics.b2Island,
+      b2TimeStep = Box2D.Dynamics.b2TimeStep,
+      b2World = Box2D.Dynamics.b2World;
+
+   Box2D.inherit(b2DistanceJoint, Box2D.Dynamics.Joints.b2Joint);
+   b2DistanceJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype;
+   b2DistanceJoint.b2DistanceJoint = function () {
+      Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments);
+      this.m_localAnchor1 = new b2Vec2();
+      this.m_localAnchor2 = new b2Vec2();
+      this.m_u = new b2Vec2();
+   };
+   b2DistanceJoint.prototype.GetAnchorA = function () {
+      return this.m_bodyA.GetWorldPoint(this.m_localAnchor1);
+   }
+   b2DistanceJoint.prototype.GetAnchorB = function () {
+      return this.m_bodyB.GetWorldPoint(this.m_localAnchor2);
+   }
+   b2DistanceJoint.prototype.GetReactionForce = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return new b2Vec2(inv_dt * this.m_impulse * this.m_u.x, inv_dt * this.m_impulse * this.m_u.y);
+   }
+   b2DistanceJoint.prototype.GetReactionTorque = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return 0.0;
+   }
+   b2DistanceJoint.prototype.GetLength = function () {
+      return this.m_length;
+   }
+   b2DistanceJoint.prototype.SetLength = function (length) {
+      if (length === undefined) length = 0;
+      this.m_length = length;
+   }
+   b2DistanceJoint.prototype.GetFrequency = function () {
+      return this.m_frequencyHz;
+   }
+   b2DistanceJoint.prototype.SetFrequency = function (hz) {
+      if (hz === undefined) hz = 0;
+      this.m_frequencyHz = hz;
+   }
+   b2DistanceJoint.prototype.GetDampingRatio = function () {
+      return this.m_dampingRatio;
+   }
+   b2DistanceJoint.prototype.SetDampingRatio = function (ratio) {
+      if (ratio === undefined) ratio = 0;
+      this.m_dampingRatio = ratio;
+   }
+   b2DistanceJoint.prototype.b2DistanceJoint = function (def) {
+      this.__super.b2Joint.call(this, def);
+      var tMat;
+      var tX = 0;
+      var tY = 0;
+      this.m_localAnchor1.SetV(def.localAnchorA);
+      this.m_localAnchor2.SetV(def.localAnchorB);
+      this.m_length = def.length;
+      this.m_frequencyHz = def.frequencyHz;
+      this.m_dampingRatio = def.dampingRatio;
+      this.m_impulse = 0.0;
+      this.m_gamma = 0.0;
+      this.m_bias = 0.0;
+   }
+   b2DistanceJoint.prototype.InitVelocityConstraints = function (step) {
+      var tMat;
+      var tX = 0;
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      tMat = bA.m_xf.R;
+      var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x;
+      var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+      r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+      r1X = tX;
+      tMat = bB.m_xf.R;
+      var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x;
+      var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+      r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+      r2X = tX;
+      this.m_u.x = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X;
+      this.m_u.y = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y;
+      var length = Math.sqrt(this.m_u.x * this.m_u.x + this.m_u.y * this.m_u.y);
+      if (length > b2Settings.b2_linearSlop) {
+         this.m_u.Multiply(1.0 / length);
+      }
+      else {
+         this.m_u.SetZero();
+      }
+      var cr1u = (r1X * this.m_u.y - r1Y * this.m_u.x);
+      var cr2u = (r2X * this.m_u.y - r2Y * this.m_u.x);
+      var invMass = bA.m_invMass + bA.m_invI * cr1u * cr1u + bB.m_invMass + bB.m_invI * cr2u * cr2u;
+      this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0;
+      if (this.m_frequencyHz > 0.0) {
+         var C = length - this.m_length;
+         var omega = 2.0 * Math.PI * this.m_frequencyHz;
+         var d = 2.0 * this.m_mass * this.m_dampingRatio * omega;
+         var k = this.m_mass * omega * omega;
+         this.m_gamma = step.dt * (d + step.dt * k);
+         this.m_gamma = this.m_gamma != 0.0 ? 1 / this.m_gamma : 0.0;
+         this.m_bias = C * step.dt * k * this.m_gamma;
+         this.m_mass = invMass + this.m_gamma;
+         this.m_mass = this.m_mass != 0.0 ? 1.0 / this.m_mass : 0.0;
+      }
+      if (step.warmStarting) {
+         this.m_impulse *= step.dtRatio;
+         var PX = this.m_impulse * this.m_u.x;
+         var PY = this.m_impulse * this.m_u.y;
+         bA.m_linearVelocity.x -= bA.m_invMass * PX;
+         bA.m_linearVelocity.y -= bA.m_invMass * PY;
+         bA.m_angularVelocity -= bA.m_invI * (r1X * PY - r1Y * PX);
+         bB.m_linearVelocity.x += bB.m_invMass * PX;
+         bB.m_linearVelocity.y += bB.m_invMass * PY;
+         bB.m_angularVelocity += bB.m_invI * (r2X * PY - r2Y * PX);
+      }
+      else {
+         this.m_impulse = 0.0;
+      }
+   }
+   b2DistanceJoint.prototype.SolveVelocityConstraints = function (step) {
+      var tMat;
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      tMat = bA.m_xf.R;
+      var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x;
+      var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y;
+      var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+      r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+      r1X = tX;
+      tMat = bB.m_xf.R;
+      var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x;
+      var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+      r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+      r2X = tX;
+      var v1X = bA.m_linearVelocity.x + ((-bA.m_angularVelocity * r1Y));
+      var v1Y = bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X);
+      var v2X = bB.m_linearVelocity.x + ((-bB.m_angularVelocity * r2Y));
+      var v2Y = bB.m_linearVelocity.y + (bB.m_angularVelocity * r2X);
+      var Cdot = (this.m_u.x * (v2X - v1X) + this.m_u.y * (v2Y - v1Y));
+      var impulse = (-this.m_mass * (Cdot + this.m_bias + this.m_gamma * this.m_impulse));
+      this.m_impulse += impulse;
+      var PX = impulse * this.m_u.x;
+      var PY = impulse * this.m_u.y;
+      bA.m_linearVelocity.x -= bA.m_invMass * PX;
+      bA.m_linearVelocity.y -= bA.m_invMass * PY;
+      bA.m_angularVelocity -= bA.m_invI * (r1X * PY - r1Y * PX);
+      bB.m_linearVelocity.x += bB.m_invMass * PX;
+      bB.m_linearVelocity.y += bB.m_invMass * PY;
+      bB.m_angularVelocity += bB.m_invI * (r2X * PY - r2Y * PX);
+   }
+   b2DistanceJoint.prototype.SolvePositionConstraints = function (baumgarte) {
+      if (baumgarte === undefined) baumgarte = 0;
+      var tMat;
+      if (this.m_frequencyHz > 0.0) {
+         return true;
+      }
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      tMat = bA.m_xf.R;
+      var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x;
+      var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y;
+      var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+      r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+      r1X = tX;
+      tMat = bB.m_xf.R;
+      var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x;
+      var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+      r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+      r2X = tX;
+      var dX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X;
+      var dY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y;
+      var length = Math.sqrt(dX * dX + dY * dY);
+      dX /= length;
+      dY /= length;
+      var C = length - this.m_length;
+      C = b2Math.Clamp(C, (-b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
+      var impulse = (-this.m_mass * C);
+      this.m_u.Set(dX, dY);
+      var PX = impulse * this.m_u.x;
+      var PY = impulse * this.m_u.y;
+      bA.m_sweep.c.x -= bA.m_invMass * PX;
+      bA.m_sweep.c.y -= bA.m_invMass * PY;
+      bA.m_sweep.a -= bA.m_invI * (r1X * PY - r1Y * PX);
+      bB.m_sweep.c.x += bB.m_invMass * PX;
+      bB.m_sweep.c.y += bB.m_invMass * PY;
+      bB.m_sweep.a += bB.m_invI * (r2X * PY - r2Y * PX);
+      bA.SynchronizeTransform();
+      bB.SynchronizeTransform();
+      return b2Math.Abs(C) < b2Settings.b2_linearSlop;
+   }
+   Box2D.inherit(b2DistanceJointDef, Box2D.Dynamics.Joints.b2JointDef);
+   b2DistanceJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype;
+   b2DistanceJointDef.b2DistanceJointDef = function () {
+      Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments);
+      this.localAnchorA = new b2Vec2();
+      this.localAnchorB = new b2Vec2();
+   };
+   b2DistanceJointDef.prototype.b2DistanceJointDef = function () {
+      this.__super.b2JointDef.call(this);
+      this.type = b2Joint.e_distanceJoint;
+      this.length = 1.0;
+      this.frequencyHz = 0.0;
+      this.dampingRatio = 0.0;
+   }
+   b2DistanceJointDef.prototype.Initialize = function (bA, bB, anchorA, anchorB) {
+      this.bodyA = bA;
+      this.bodyB = bB;
+      this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchorA));
+      this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchorB));
+      var dX = anchorB.x - anchorA.x;
+      var dY = anchorB.y - anchorA.y;
+      this.length = Math.sqrt(dX * dX + dY * dY);
+      this.frequencyHz = 0.0;
+      this.dampingRatio = 0.0;
+   }
+   Box2D.inherit(b2FrictionJoint, Box2D.Dynamics.Joints.b2Joint);
+   b2FrictionJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype;
+   b2FrictionJoint.b2FrictionJoint = function () {
+      Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments);
+      this.m_localAnchorA = new b2Vec2();
+      this.m_localAnchorB = new b2Vec2();
+      this.m_linearMass = new b2Mat22();
+      this.m_linearImpulse = new b2Vec2();
+   };
+   b2FrictionJoint.prototype.GetAnchorA = function () {
+      return this.m_bodyA.GetWorldPoint(this.m_localAnchorA);
+   }
+   b2FrictionJoint.prototype.GetAnchorB = function () {
+      return this.m_bodyB.GetWorldPoint(this.m_localAnchorB);
+   }
+   b2FrictionJoint.prototype.GetReactionForce = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return new b2Vec2(inv_dt * this.m_linearImpulse.x, inv_dt * this.m_linearImpulse.y);
+   }
+   b2FrictionJoint.prototype.GetReactionTorque = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return inv_dt * this.m_angularImpulse;
+   }
+   b2FrictionJoint.prototype.SetMaxForce = function (force) {
+      if (force === undefined) force = 0;
+      this.m_maxForce = force;
+   }
+   b2FrictionJoint.prototype.GetMaxForce = function () {
+      return this.m_maxForce;
+   }
+   b2FrictionJoint.prototype.SetMaxTorque = function (torque) {
+      if (torque === undefined) torque = 0;
+      this.m_maxTorque = torque;
+   }
+   b2FrictionJoint.prototype.GetMaxTorque = function () {
+      return this.m_maxTorque;
+   }
+   b2FrictionJoint.prototype.b2FrictionJoint = function (def) {
+      this.__super.b2Joint.call(this, def);
+      this.m_localAnchorA.SetV(def.localAnchorA);
+      this.m_localAnchorB.SetV(def.localAnchorB);
+      this.m_linearMass.SetZero();
+      this.m_angularMass = 0.0;
+      this.m_linearImpulse.SetZero();
+      this.m_angularImpulse = 0.0;
+      this.m_maxForce = def.maxForce;
+      this.m_maxTorque = def.maxTorque;
+   }
+   b2FrictionJoint.prototype.InitVelocityConstraints = function (step) {
+      var tMat;
+      var tX = 0;
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      tMat = bA.m_xf.R;
+      var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x;
+      var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * rAX + tMat.col2.x * rAY);
+      rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY);
+      rAX = tX;
+      tMat = bB.m_xf.R;
+      var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x;
+      var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * rBX + tMat.col2.x * rBY);
+      rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY);
+      rBX = tX;
+      var mA = bA.m_invMass;
+      var mB = bB.m_invMass;
+      var iA = bA.m_invI;
+      var iB = bB.m_invI;
+      var K = new b2Mat22();
+      K.col1.x = mA + mB;
+      K.col2.x = 0.0;
+      K.col1.y = 0.0;
+      K.col2.y = mA + mB;
+      K.col1.x += iA * rAY * rAY;
+      K.col2.x += (-iA * rAX * rAY);
+      K.col1.y += (-iA * rAX * rAY);
+      K.col2.y += iA * rAX * rAX;
+      K.col1.x += iB * rBY * rBY;
+      K.col2.x += (-iB * rBX * rBY);
+      K.col1.y += (-iB * rBX * rBY);
+      K.col2.y += iB * rBX * rBX;
+      K.GetInverse(this.m_linearMass);
+      this.m_angularMass = iA + iB;
+      if (this.m_angularMass > 0.0) {
+         this.m_angularMass = 1.0 / this.m_angularMass;
+      }
+      if (step.warmStarting) {
+         this.m_linearImpulse.x *= step.dtRatio;
+         this.m_linearImpulse.y *= step.dtRatio;
+         this.m_angularImpulse *= step.dtRatio;
+         var P = this.m_linearImpulse;
+         bA.m_linearVelocity.x -= mA * P.x;
+         bA.m_linearVelocity.y -= mA * P.y;
+         bA.m_angularVelocity -= iA * (rAX * P.y - rAY * P.x + this.m_angularImpulse);
+         bB.m_linearVelocity.x += mB * P.x;
+         bB.m_linearVelocity.y += mB * P.y;
+         bB.m_angularVelocity += iB * (rBX * P.y - rBY * P.x + this.m_angularImpulse);
+      }
+      else {
+         this.m_linearImpulse.SetZero();
+         this.m_angularImpulse = 0.0;
+      }
+   }
+   b2FrictionJoint.prototype.SolveVelocityConstraints = function (step) {
+      var tMat;
+      var tX = 0;
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var vA = bA.m_linearVelocity;
+      var wA = bA.m_angularVelocity;
+      var vB = bB.m_linearVelocity;
+      var wB = bB.m_angularVelocity;
+      var mA = bA.m_invMass;
+      var mB = bB.m_invMass;
+      var iA = bA.m_invI;
+      var iB = bB.m_invI;
+      tMat = bA.m_xf.R;
+      var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x;
+      var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * rAX + tMat.col2.x * rAY);
+      rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY);
+      rAX = tX;
+      tMat = bB.m_xf.R;
+      var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x;
+      var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * rBX + tMat.col2.x * rBY);
+      rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY);
+      rBX = tX;
+      var maxImpulse = 0; {
+         var Cdot = wB - wA;
+         var impulse = (-this.m_angularMass * Cdot);
+         var oldImpulse = this.m_angularImpulse;
+         maxImpulse = step.dt * this.m_maxTorque;
+         this.m_angularImpulse = b2Math.Clamp(this.m_angularImpulse + impulse, (-maxImpulse), maxImpulse);
+         impulse = this.m_angularImpulse - oldImpulse;
+         wA -= iA * impulse;
+         wB += iB * impulse;
+      } {
+         var CdotX = vB.x - wB * rBY - vA.x + wA * rAY;
+         var CdotY = vB.y + wB * rBX - vA.y - wA * rAX;
+         var impulseV = b2Math.MulMV(this.m_linearMass, new b2Vec2((-CdotX), (-CdotY)));
+         var oldImpulseV = this.m_linearImpulse.Copy();
+         this.m_linearImpulse.Add(impulseV);
+         maxImpulse = step.dt * this.m_maxForce;
+         if (this.m_linearImpulse.LengthSquared() > maxImpulse * maxImpulse) {
+            this.m_linearImpulse.Normalize();
+            this.m_linearImpulse.Multiply(maxImpulse);
+         }
+         impulseV = b2Math.SubtractVV(this.m_linearImpulse, oldImpulseV);
+         vA.x -= mA * impulseV.x;
+         vA.y -= mA * impulseV.y;
+         wA -= iA * (rAX * impulseV.y - rAY * impulseV.x);
+         vB.x += mB * impulseV.x;
+         vB.y += mB * impulseV.y;
+         wB += iB * (rBX * impulseV.y - rBY * impulseV.x);
+      }
+      bA.m_angularVelocity = wA;
+      bB.m_angularVelocity = wB;
+   }
+   b2FrictionJoint.prototype.SolvePositionConstraints = function (baumgarte) {
+      if (baumgarte === undefined) baumgarte = 0;
+      return true;
+   }
+   Box2D.inherit(b2FrictionJointDef, Box2D.Dynamics.Joints.b2JointDef);
+   b2FrictionJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype;
+   b2FrictionJointDef.b2FrictionJointDef = function () {
+      Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments);
+      this.localAnchorA = new b2Vec2();
+      this.localAnchorB = new b2Vec2();
+   };
+   b2FrictionJointDef.prototype.b2FrictionJointDef = function () {
+      this.__super.b2JointDef.call(this);
+      this.type = b2Joint.e_frictionJoint;
+      this.maxForce = 0.0;
+      this.maxTorque = 0.0;
+   }
+   b2FrictionJointDef.prototype.Initialize = function (bA, bB, anchor) {
+      this.bodyA = bA;
+      this.bodyB = bB;
+      this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchor));
+      this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchor));
+   }
+   Box2D.inherit(b2GearJoint, Box2D.Dynamics.Joints.b2Joint);
+   b2GearJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype;
+   b2GearJoint.b2GearJoint = function () {
+      Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments);
+      this.m_groundAnchor1 = new b2Vec2();
+      this.m_groundAnchor2 = new b2Vec2();
+      this.m_localAnchor1 = new b2Vec2();
+      this.m_localAnchor2 = new b2Vec2();
+      this.m_J = new b2Jacobian();
+   };
+   b2GearJoint.prototype.GetAnchorA = function () {
+      return this.m_bodyA.GetWorldPoint(this.m_localAnchor1);
+   }
+   b2GearJoint.prototype.GetAnchorB = function () {
+      return this.m_bodyB.GetWorldPoint(this.m_localAnchor2);
+   }
+   b2GearJoint.prototype.GetReactionForce = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return new b2Vec2(inv_dt * this.m_impulse * this.m_J.linearB.x, inv_dt * this.m_impulse * this.m_J.linearB.y);
+   }
+   b2GearJoint.prototype.GetReactionTorque = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      var tMat = this.m_bodyB.m_xf.R;
+      var rX = this.m_localAnchor1.x - this.m_bodyB.m_sweep.localCenter.x;
+      var rY = this.m_localAnchor1.y - this.m_bodyB.m_sweep.localCenter.y;
+      var tX = tMat.col1.x * rX + tMat.col2.x * rY;
+      rY = tMat.col1.y * rX + tMat.col2.y * rY;
+      rX = tX;
+      var PX = this.m_impulse * this.m_J.linearB.x;
+      var PY = this.m_impulse * this.m_J.linearB.y;
+      return inv_dt * (this.m_impulse * this.m_J.angularB - rX * PY + rY * PX);
+   }
+   b2GearJoint.prototype.GetRatio = function () {
+      return this.m_ratio;
+   }
+   b2GearJoint.prototype.SetRatio = function (ratio) {
+      if (ratio === undefined) ratio = 0;
+      this.m_ratio = ratio;
+   }
+   b2GearJoint.prototype.b2GearJoint = function (def) {
+      this.__super.b2Joint.call(this, def);
+      var type1 = parseInt(def.joint1.m_type);
+      var type2 = parseInt(def.joint2.m_type);
+      this.m_revolute1 = null;
+      this.m_prismatic1 = null;
+      this.m_revolute2 = null;
+      this.m_prismatic2 = null;
+      var coordinate1 = 0;
+      var coordinate2 = 0;
+      this.m_ground1 = def.joint1.GetBodyA();
+      this.m_bodyA = def.joint1.GetBodyB();
+      if (type1 == b2Joint.e_revoluteJoint) {
+         this.m_revolute1 = (def.joint1 instanceof b2RevoluteJoint ? def.joint1 : null);
+         this.m_groundAnchor1.SetV(this.m_revolute1.m_localAnchor1);
+         this.m_localAnchor1.SetV(this.m_revolute1.m_localAnchor2);
+         coordinate1 = this.m_revolute1.GetJointAngle();
+      }
+      else {
+         this.m_prismatic1 = (def.joint1 instanceof b2PrismaticJoint ? def.joint1 : null);
+         this.m_groundAnchor1.SetV(this.m_prismatic1.m_localAnchor1);
+         this.m_localAnchor1.SetV(this.m_prismatic1.m_localAnchor2);
+         coordinate1 = this.m_prismatic1.GetJointTranslation();
+      }
+      this.m_ground2 = def.joint2.GetBodyA();
+      this.m_bodyB = def.joint2.GetBodyB();
+      if (type2 == b2Joint.e_revoluteJoint) {
+         this.m_revolute2 = (def.joint2 instanceof b2RevoluteJoint ? def.joint2 : null);
+         this.m_groundAnchor2.SetV(this.m_revolute2.m_localAnchor1);
+         this.m_localAnchor2.SetV(this.m_revolute2.m_localAnchor2);
+         coordinate2 = this.m_revolute2.GetJointAngle();
+      }
+      else {
+         this.m_prismatic2 = (def.joint2 instanceof b2PrismaticJoint ? def.joint2 : null);
+         this.m_groundAnchor2.SetV(this.m_prismatic2.m_localAnchor1);
+         this.m_localAnchor2.SetV(this.m_prismatic2.m_localAnchor2);
+         coordinate2 = this.m_prismatic2.GetJointTranslation();
+      }
+      this.m_ratio = def.ratio;
+      this.m_constant = coordinate1 + this.m_ratio * coordinate2;
+      this.m_impulse = 0.0;
+   }
+   b2GearJoint.prototype.InitVelocityConstraints = function (step) {
+      var g1 = this.m_ground1;
+      var g2 = this.m_ground2;
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var ugX = 0;
+      var ugY = 0;
+      var rX = 0;
+      var rY = 0;
+      var tMat;
+      var tVec;
+      var crug = 0;
+      var tX = 0;
+      var K = 0.0;
+      this.m_J.SetZero();
+      if (this.m_revolute1) {
+         this.m_J.angularA = (-1.0);
+         K += bA.m_invI;
+      }
+      else {
+         tMat = g1.m_xf.R;
+         tVec = this.m_prismatic1.m_localXAxis1;
+         ugX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+         ugY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+         tMat = bA.m_xf.R;
+         rX = this.m_localAnchor1.x - bA.m_sweep.localCenter.x;
+         rY = this.m_localAnchor1.y - bA.m_sweep.localCenter.y;
+         tX = tMat.col1.x * rX + tMat.col2.x * rY;
+         rY = tMat.col1.y * rX + tMat.col2.y * rY;
+         rX = tX;
+         crug = rX * ugY - rY * ugX;
+         this.m_J.linearA.Set((-ugX), (-ugY));
+         this.m_J.angularA = (-crug);
+         K += bA.m_invMass + bA.m_invI * crug * crug;
+      }
+      if (this.m_revolute2) {
+         this.m_J.angularB = (-this.m_ratio);
+         K += this.m_ratio * this.m_ratio * bB.m_invI;
+      }
+      else {
+         tMat = g2.m_xf.R;
+         tVec = this.m_prismatic2.m_localXAxis1;
+         ugX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y;
+         ugY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y;
+         tMat = bB.m_xf.R;
+         rX = this.m_localAnchor2.x - bB.m_sweep.localCenter.x;
+         rY = this.m_localAnchor2.y - bB.m_sweep.localCenter.y;
+         tX = tMat.col1.x * rX + tMat.col2.x * rY;
+         rY = tMat.col1.y * rX + tMat.col2.y * rY;
+         rX = tX;
+         crug = rX * ugY - rY * ugX;
+         this.m_J.linearB.Set((-this.m_ratio * ugX), (-this.m_ratio * ugY));
+         this.m_J.angularB = (-this.m_ratio * crug);
+         K += this.m_ratio * this.m_ratio * (bB.m_invMass + bB.m_invI * crug * crug);
+      }
+      this.m_mass = K > 0.0 ? 1.0 / K : 0.0;
+      if (step.warmStarting) {
+         bA.m_linearVelocity.x += bA.m_invMass * this.m_impulse * this.m_J.linearA.x;
+         bA.m_linearVelocity.y += bA.m_invMass * this.m_impulse * this.m_J.linearA.y;
+         bA.m_angularVelocity += bA.m_invI * this.m_impulse * this.m_J.angularA;
+         bB.m_linearVelocity.x += bB.m_invMass * this.m_impulse * this.m_J.linearB.x;
+         bB.m_linearVelocity.y += bB.m_invMass * this.m_impulse * this.m_J.linearB.y;
+         bB.m_angularVelocity += bB.m_invI * this.m_impulse * this.m_J.angularB;
+      }
+      else {
+         this.m_impulse = 0.0;
+      }
+   }
+   b2GearJoint.prototype.SolveVelocityConstraints = function (step) {
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var Cdot = this.m_J.Compute(bA.m_linearVelocity, bA.m_angularVelocity, bB.m_linearVelocity, bB.m_angularVelocity);
+      var impulse = (-this.m_mass * Cdot);
+      this.m_impulse += impulse;
+      bA.m_linearVelocity.x += bA.m_invMass * impulse * this.m_J.linearA.x;
+      bA.m_linearVelocity.y += bA.m_invMass * impulse * this.m_J.linearA.y;
+      bA.m_angularVelocity += bA.m_invI * impulse * this.m_J.angularA;
+      bB.m_linearVelocity.x += bB.m_invMass * impulse * this.m_J.linearB.x;
+      bB.m_linearVelocity.y += bB.m_invMass * impulse * this.m_J.linearB.y;
+      bB.m_angularVelocity += bB.m_invI * impulse * this.m_J.angularB;
+   }
+   b2GearJoint.prototype.SolvePositionConstraints = function (baumgarte) {
+      if (baumgarte === undefined) baumgarte = 0;
+      var linearError = 0.0;
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var coordinate1 = 0;
+      var coordinate2 = 0;
+      if (this.m_revolute1) {
+         coordinate1 = this.m_revolute1.GetJointAngle();
+      }
+      else {
+         coordinate1 = this.m_prismatic1.GetJointTranslation();
+      }
+      if (this.m_revolute2) {
+         coordinate2 = this.m_revolute2.GetJointAngle();
+      }
+      else {
+         coordinate2 = this.m_prismatic2.GetJointTranslation();
+      }
+      var C = this.m_constant - (coordinate1 + this.m_ratio * coordinate2);
+      var impulse = (-this.m_mass * C);
+      bA.m_sweep.c.x += bA.m_invMass * impulse * this.m_J.linearA.x;
+      bA.m_sweep.c.y += bA.m_invMass * impulse * this.m_J.linearA.y;
+      bA.m_sweep.a += bA.m_invI * impulse * this.m_J.angularA;
+      bB.m_sweep.c.x += bB.m_invMass * impulse * this.m_J.linearB.x;
+      bB.m_sweep.c.y += bB.m_invMass * impulse * this.m_J.linearB.y;
+      bB.m_sweep.a += bB.m_invI * impulse * this.m_J.angularB;
+      bA.SynchronizeTransform();
+      bB.SynchronizeTransform();
+      return linearError < b2Settings.b2_linearSlop;
+   }
+   Box2D.inherit(b2GearJointDef, Box2D.Dynamics.Joints.b2JointDef);
+   b2GearJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype;
+   b2GearJointDef.b2GearJointDef = function () {
+      Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments);
+   };
+   b2GearJointDef.prototype.b2GearJointDef = function () {
+      this.__super.b2JointDef.call(this);
+      this.type = b2Joint.e_gearJoint;
+      this.joint1 = null;
+      this.joint2 = null;
+      this.ratio = 1.0;
+   }
+   b2Jacobian.b2Jacobian = function () {
+      this.linearA = new b2Vec2();
+      this.linearB = new b2Vec2();
+   };
+   b2Jacobian.prototype.SetZero = function () {
+      this.linearA.SetZero();
+      this.angularA = 0.0;
+      this.linearB.SetZero();
+      this.angularB = 0.0;
+   }
+   b2Jacobian.prototype.Set = function (x1, a1, x2, a2) {
+      if (a1 === undefined) a1 = 0;
+      if (a2 === undefined) a2 = 0;
+      this.linearA.SetV(x1);
+      this.angularA = a1;
+      this.linearB.SetV(x2);
+      this.angularB = a2;
+   }
+   b2Jacobian.prototype.Compute = function (x1, a1, x2, a2) {
+      if (a1 === undefined) a1 = 0;
+      if (a2 === undefined) a2 = 0;
+      return (this.linearA.x * x1.x + this.linearA.y * x1.y) + this.angularA * a1 + (this.linearB.x * x2.x + this.linearB.y * x2.y) + this.angularB * a2;
+   }
+   b2Joint.b2Joint = function () {
+      this.m_edgeA = new b2JointEdge();
+      this.m_edgeB = new b2JointEdge();
+      this.m_localCenterA = new b2Vec2();
+      this.m_localCenterB = new b2Vec2();
+   };
+   b2Joint.prototype.GetType = function () {
+      return this.m_type;
+   }
+   b2Joint.prototype.GetAnchorA = function () {
+      return null;
+   }
+   b2Joint.prototype.GetAnchorB = function () {
+      return null;
+   }
+   b2Joint.prototype.GetReactionForce = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return null;
+   }
+   b2Joint.prototype.GetReactionTorque = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return 0.0;
+   }
+   b2Joint.prototype.GetBodyA = function () {
+      return this.m_bodyA;
+   }
+   b2Joint.prototype.GetBodyB = function () {
+      return this.m_bodyB;
+   }
+   b2Joint.prototype.GetNext = function () {
+      return this.m_next;
+   }
+   b2Joint.prototype.GetUserData = function () {
+      return this.m_userData;
+   }
+   b2Joint.prototype.SetUserData = function (data) {
+      this.m_userData = data;
+   }
+   b2Joint.prototype.IsActive = function () {
+      return this.m_bodyA.IsActive() && this.m_bodyB.IsActive();
+   }
+   b2Joint.Create = function (def, allocator) {
+      var joint = null;
+      switch (def.type) {
+      case b2Joint.e_distanceJoint:
+         {
+            joint = new b2DistanceJoint((def instanceof b2DistanceJointDef ? def : null));
+         }
+         break;
+      case b2Joint.e_mouseJoint:
+         {
+            joint = new b2MouseJoint((def instanceof b2MouseJointDef ? def : null));
+         }
+         break;
+      case b2Joint.e_prismaticJoint:
+         {
+            joint = new b2PrismaticJoint((def instanceof b2PrismaticJointDef ? def : null));
+         }
+         break;
+      case b2Joint.e_revoluteJoint:
+         {
+            joint = new b2RevoluteJoint((def instanceof b2RevoluteJointDef ? def : null));
+         }
+         break;
+      case b2Joint.e_pulleyJoint:
+         {
+            joint = new b2PulleyJoint((def instanceof b2PulleyJointDef ? def : null));
+         }
+         break;
+      case b2Joint.e_gearJoint:
+         {
+            joint = new b2GearJoint((def instanceof b2GearJointDef ? def : null));
+         }
+         break;
+      case b2Joint.e_lineJoint:
+         {
+            joint = new b2LineJoint((def instanceof b2LineJointDef ? def : null));
+         }
+         break;
+      case b2Joint.e_weldJoint:
+         {
+            joint = new b2WeldJoint((def instanceof b2WeldJointDef ? def : null));
+         }
+         break;
+      case b2Joint.e_frictionJoint:
+         {
+            joint = new b2FrictionJoint((def instanceof b2FrictionJointDef ? def : null));
+         }
+         break;
+      default:
+         break;
+      }
+      return joint;
+   }
+   b2Joint.Destroy = function (joint, allocator) {}
+   b2Joint.prototype.b2Joint = function (def) {
+      b2Settings.b2Assert(def.bodyA != def.bodyB);
+      this.m_type = def.type;
+      this.m_prev = null;
+      this.m_next = null;
+      this.m_bodyA = def.bodyA;
+      this.m_bodyB = def.bodyB;
+      this.m_collideConnected = def.collideConnected;
+      this.m_islandFlag = false;
+      this.m_userData = def.userData;
+   }
+   b2Joint.prototype.InitVelocityConstraints = function (step) {}
+   b2Joint.prototype.SolveVelocityConstraints = function (step) {}
+   b2Joint.prototype.FinalizeVelocityConstraints = function () {}
+   b2Joint.prototype.SolvePositionConstraints = function (baumgarte) {
+      if (baumgarte === undefined) baumgarte = 0;
+      return false;
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Dynamics.Joints.b2Joint.e_unknownJoint = 0;
+      Box2D.Dynamics.Joints.b2Joint.e_revoluteJoint = 1;
+      Box2D.Dynamics.Joints.b2Joint.e_prismaticJoint = 2;
+      Box2D.Dynamics.Joints.b2Joint.e_distanceJoint = 3;
+      Box2D.Dynamics.Joints.b2Joint.e_pulleyJoint = 4;
+      Box2D.Dynamics.Joints.b2Joint.e_mouseJoint = 5;
+      Box2D.Dynamics.Joints.b2Joint.e_gearJoint = 6;
+      Box2D.Dynamics.Joints.b2Joint.e_lineJoint = 7;
+      Box2D.Dynamics.Joints.b2Joint.e_weldJoint = 8;
+      Box2D.Dynamics.Joints.b2Joint.e_frictionJoint = 9;
+      Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit = 0;
+      Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit = 1;
+      Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit = 2;
+      Box2D.Dynamics.Joints.b2Joint.e_equalLimits = 3;
+   });
+   b2JointDef.b2JointDef = function () {};
+   b2JointDef.prototype.b2JointDef = function () {
+      this.type = b2Joint.e_unknownJoint;
+      this.userData = null;
+      this.bodyA = null;
+      this.bodyB = null;
+      this.collideConnected = false;
+   }
+   b2JointEdge.b2JointEdge = function () {};
+   Box2D.inherit(b2LineJoint, Box2D.Dynamics.Joints.b2Joint);
+   b2LineJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype;
+   b2LineJoint.b2LineJoint = function () {
+      Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments);
+      this.m_localAnchor1 = new b2Vec2();
+      this.m_localAnchor2 = new b2Vec2();
+      this.m_localXAxis1 = new b2Vec2();
+      this.m_localYAxis1 = new b2Vec2();
+      this.m_axis = new b2Vec2();
+      this.m_perp = new b2Vec2();
+      this.m_K = new b2Mat22();
+      this.m_impulse = new b2Vec2();
+   };
+   b2LineJoint.prototype.GetAnchorA = function () {
+      return this.m_bodyA.GetWorldPoint(this.m_localAnchor1);
+   }
+   b2LineJoint.prototype.GetAnchorB = function () {
+      return this.m_bodyB.GetWorldPoint(this.m_localAnchor2);
+   }
+   b2LineJoint.prototype.GetReactionForce = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return new b2Vec2(inv_dt * (this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.x), inv_dt * (this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.y));
+   }
+   b2LineJoint.prototype.GetReactionTorque = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return inv_dt * this.m_impulse.y;
+   }
+   b2LineJoint.prototype.GetJointTranslation = function () {
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var tMat;
+      var p1 = bA.GetWorldPoint(this.m_localAnchor1);
+      var p2 = bB.GetWorldPoint(this.m_localAnchor2);
+      var dX = p2.x - p1.x;
+      var dY = p2.y - p1.y;
+      var axis = bA.GetWorldVector(this.m_localXAxis1);
+      var translation = axis.x * dX + axis.y * dY;
+      return translation;
+   }
+   b2LineJoint.prototype.GetJointSpeed = function () {
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var tMat;
+      tMat = bA.m_xf.R;
+      var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x;
+      var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y;
+      var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+      r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+      r1X = tX;
+      tMat = bB.m_xf.R;
+      var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x;
+      var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+      r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+      r2X = tX;
+      var p1X = bA.m_sweep.c.x + r1X;
+      var p1Y = bA.m_sweep.c.y + r1Y;
+      var p2X = bB.m_sweep.c.x + r2X;
+      var p2Y = bB.m_sweep.c.y + r2Y;
+      var dX = p2X - p1X;
+      var dY = p2Y - p1Y;
+      var axis = bA.GetWorldVector(this.m_localXAxis1);
+      var v1 = bA.m_linearVelocity;
+      var v2 = bB.m_linearVelocity;
+      var w1 = bA.m_angularVelocity;
+      var w2 = bB.m_angularVelocity;
+      var speed = (dX * ((-w1 * axis.y)) + dY * (w1 * axis.x)) + (axis.x * (((v2.x + ((-w2 * r2Y))) - v1.x) - ((-w1 * r1Y))) + axis.y * (((v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X)));
+      return speed;
+   }
+   b2LineJoint.prototype.IsLimitEnabled = function () {
+      return this.m_enableLimit;
+   }
+   b2LineJoint.prototype.EnableLimit = function (flag) {
+      this.m_bodyA.SetAwake(true);
+      this.m_bodyB.SetAwake(true);
+      this.m_enableLimit = flag;
+   }
+   b2LineJoint.prototype.GetLowerLimit = function () {
+      return this.m_lowerTranslation;
+   }
+   b2LineJoint.prototype.GetUpperLimit = function () {
+      return this.m_upperTranslation;
+   }
+   b2LineJoint.prototype.SetLimits = function (lower, upper) {
+      if (lower === undefined) lower = 0;
+      if (upper === undefined) upper = 0;
+      this.m_bodyA.SetAwake(true);
+      this.m_bodyB.SetAwake(true);
+      this.m_lowerTranslation = lower;
+      this.m_upperTranslation = upper;
+   }
+   b2LineJoint.prototype.IsMotorEnabled = function () {
+      return this.m_enableMotor;
+   }
+   b2LineJoint.prototype.EnableMotor = function (flag) {
+      this.m_bodyA.SetAwake(true);
+      this.m_bodyB.SetAwake(true);
+      this.m_enableMotor = flag;
+   }
+   b2LineJoint.prototype.SetMotorSpeed = function (speed) {
+      if (speed === undefined) speed = 0;
+      this.m_bodyA.SetAwake(true);
+      this.m_bodyB.SetAwake(true);
+      this.m_motorSpeed = speed;
+   }
+   b2LineJoint.prototype.GetMotorSpeed = function () {
+      return this.m_motorSpeed;
+   }
+   b2LineJoint.prototype.SetMaxMotorForce = function (force) {
+      if (force === undefined) force = 0;
+      this.m_bodyA.SetAwake(true);
+      this.m_bodyB.SetAwake(true);
+      this.m_maxMotorForce = force;
+   }
+   b2LineJoint.prototype.GetMaxMotorForce = function () {
+      return this.m_maxMotorForce;
+   }
+   b2LineJoint.prototype.GetMotorForce = function () {
+      return this.m_motorImpulse;
+   }
+   b2LineJoint.prototype.b2LineJoint = function (def) {
+      this.__super.b2Joint.call(this, def);
+      var tMat;
+      var tX = 0;
+      var tY = 0;
+      this.m_localAnchor1.SetV(def.localAnchorA);
+      this.m_localAnchor2.SetV(def.localAnchorB);
+      this.m_localXAxis1.SetV(def.localAxisA);
+      this.m_localYAxis1.x = (-this.m_localXAxis1.y);
+      this.m_localYAxis1.y = this.m_localXAxis1.x;
+      this.m_impulse.SetZero();
+      this.m_motorMass = 0.0;
+      this.m_motorImpulse = 0.0;
+      this.m_lowerTranslation = def.lowerTranslation;
+      this.m_upperTranslation = def.upperTranslation;
+      this.m_maxMotorForce = def.maxMotorForce;
+      this.m_motorSpeed = def.motorSpeed;
+      this.m_enableLimit = def.enableLimit;
+      this.m_enableMotor = def.enableMotor;
+      this.m_limitState = b2Joint.e_inactiveLimit;
+      this.m_axis.SetZero();
+      this.m_perp.SetZero();
+   }
+   b2LineJoint.prototype.InitVelocityConstraints = function (step) {
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var tMat;
+      var tX = 0;
+      this.m_localCenterA.SetV(bA.GetLocalCenter());
+      this.m_localCenterB.SetV(bB.GetLocalCenter());
+      var xf1 = bA.GetTransform();
+      var xf2 = bB.GetTransform();
+      tMat = bA.m_xf.R;
+      var r1X = this.m_localAnchor1.x - this.m_localCenterA.x;
+      var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y;
+      tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+      r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+      r1X = tX;
+      tMat = bB.m_xf.R;
+      var r2X = this.m_localAnchor2.x - this.m_localCenterB.x;
+      var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y;
+      tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+      r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+      r2X = tX;
+      var dX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X;
+      var dY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y;
+      this.m_invMassA = bA.m_invMass;
+      this.m_invMassB = bB.m_invMass;
+      this.m_invIA = bA.m_invI;
+      this.m_invIB = bB.m_invI; {
+         this.m_axis.SetV(b2Math.MulMV(xf1.R, this.m_localXAxis1));
+         this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x;
+         this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x;
+         this.m_motorMass = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_a1 * this.m_a1 + this.m_invIB * this.m_a2 * this.m_a2;
+         this.m_motorMass = this.m_motorMass > Number.MIN_VALUE ? 1.0 / this.m_motorMass : 0.0;
+      } {
+         this.m_perp.SetV(b2Math.MulMV(xf1.R, this.m_localYAxis1));
+         this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x;
+         this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x;
+         var m1 = this.m_invMassA;
+         var m2 = this.m_invMassB;
+         var i1 = this.m_invIA;
+         var i2 = this.m_invIB;
+         this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2;
+         this.m_K.col1.y = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2;
+         this.m_K.col2.x = this.m_K.col1.y;
+         this.m_K.col2.y = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2;
+      }
+      if (this.m_enableLimit) {
+         var jointTransition = this.m_axis.x * dX + this.m_axis.y * dY;
+         if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) {
+            this.m_limitState = b2Joint.e_equalLimits;
+         }
+         else if (jointTransition <= this.m_lowerTranslation) {
+            if (this.m_limitState != b2Joint.e_atLowerLimit) {
+               this.m_limitState = b2Joint.e_atLowerLimit;
+               this.m_impulse.y = 0.0;
+            }
+         }
+         else if (jointTransition >= this.m_upperTranslation) {
+            if (this.m_limitState != b2Joint.e_atUpperLimit) {
+               this.m_limitState = b2Joint.e_atUpperLimit;
+               this.m_impulse.y = 0.0;
+            }
+         }
+         else {
+            this.m_limitState = b2Joint.e_inactiveLimit;
+            this.m_impulse.y = 0.0;
+         }
+      }
+      else {
+         this.m_limitState = b2Joint.e_inactiveLimit;
+      }
+      if (this.m_enableMotor == false) {
+         this.m_motorImpulse = 0.0;
+      }
+      if (step.warmStarting) {
+         this.m_impulse.x *= step.dtRatio;
+         this.m_impulse.y *= step.dtRatio;
+         this.m_motorImpulse *= step.dtRatio;
+         var PX = this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.x;
+         var PY = this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.y;
+         var L1 = this.m_impulse.x * this.m_s1 + (this.m_motorImpulse + this.m_impulse.y) * this.m_a1;
+         var L2 = this.m_impulse.x * this.m_s2 + (this.m_motorImpulse + this.m_impulse.y) * this.m_a2;
+         bA.m_linearVelocity.x -= this.m_invMassA * PX;
+         bA.m_linearVelocity.y -= this.m_invMassA * PY;
+         bA.m_angularVelocity -= this.m_invIA * L1;
+         bB.m_linearVelocity.x += this.m_invMassB * PX;
+         bB.m_linearVelocity.y += this.m_invMassB * PY;
+         bB.m_angularVelocity += this.m_invIB * L2;
+      }
+      else {
+         this.m_impulse.SetZero();
+         this.m_motorImpulse = 0.0;
+      }
+   }
+   b2LineJoint.prototype.SolveVelocityConstraints = function (step) {
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var v1 = bA.m_linearVelocity;
+      var w1 = bA.m_angularVelocity;
+      var v2 = bB.m_linearVelocity;
+      var w2 = bB.m_angularVelocity;
+      var PX = 0;
+      var PY = 0;
+      var L1 = 0;
+      var L2 = 0;
+      if (this.m_enableMotor && this.m_limitState != b2Joint.e_equalLimits) {
+         var Cdot = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1;
+         var impulse = this.m_motorMass * (this.m_motorSpeed - Cdot);
+         var oldImpulse = this.m_motorImpulse;
+         var maxImpulse = step.dt * this.m_maxMotorForce;
+         this.m_motorImpulse = b2Math.Clamp(this.m_motorImpulse + impulse, (-maxImpulse), maxImpulse);
+         impulse = this.m_motorImpulse - oldImpulse;
+         PX = impulse * this.m_axis.x;
+         PY = impulse * this.m_axis.y;
+         L1 = impulse * this.m_a1;
+         L2 = impulse * this.m_a2;
+         v1.x -= this.m_invMassA * PX;
+         v1.y -= this.m_invMassA * PY;
+         w1 -= this.m_invIA * L1;
+         v2.x += this.m_invMassB * PX;
+         v2.y += this.m_invMassB * PY;
+         w2 += this.m_invIB * L2;
+      }
+      var Cdot1 = this.m_perp.x * (v2.x - v1.x) + this.m_perp.y * (v2.y - v1.y) + this.m_s2 * w2 - this.m_s1 * w1;
+      if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) {
+         var Cdot2 = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1;
+         var f1 = this.m_impulse.Copy();
+         var df = this.m_K.Solve(new b2Vec2(), (-Cdot1), (-Cdot2));
+         this.m_impulse.Add(df);
+         if (this.m_limitState == b2Joint.e_atLowerLimit) {
+            this.m_impulse.y = b2Math.Max(this.m_impulse.y, 0.0);
+         }
+         else if (this.m_limitState == b2Joint.e_atUpperLimit) {
+            this.m_impulse.y = b2Math.Min(this.m_impulse.y, 0.0);
+         }
+         var b = (-Cdot1) - (this.m_impulse.y - f1.y) * this.m_K.col2.x;
+         var f2r = 0;
+         if (this.m_K.col1.x != 0.0) {
+            f2r = b / this.m_K.col1.x + f1.x;
+         }
+         else {
+            f2r = f1.x;
+         }
+         this.m_impulse.x = f2r;
+         df.x = this.m_impulse.x - f1.x;
+         df.y = this.m_impulse.y - f1.y;
+         PX = df.x * this.m_perp.x + df.y * this.m_axis.x;
+         PY = df.x * this.m_perp.y + df.y * this.m_axis.y;
+         L1 = df.x * this.m_s1 + df.y * this.m_a1;
+         L2 = df.x * this.m_s2 + df.y * this.m_a2;
+         v1.x -= this.m_invMassA * PX;
+         v1.y -= this.m_invMassA * PY;
+         w1 -= this.m_invIA * L1;
+         v2.x += this.m_invMassB * PX;
+         v2.y += this.m_invMassB * PY;
+         w2 += this.m_invIB * L2;
+      }
+      else {
+         var df2 = 0;
+         if (this.m_K.col1.x != 0.0) {
+            df2 = ((-Cdot1)) / this.m_K.col1.x;
+         }
+         else {
+            df2 = 0.0;
+         }
+         this.m_impulse.x += df2;
+         PX = df2 * this.m_perp.x;
+         PY = df2 * this.m_perp.y;
+         L1 = df2 * this.m_s1;
+         L2 = df2 * this.m_s2;
+         v1.x -= this.m_invMassA * PX;
+         v1.y -= this.m_invMassA * PY;
+         w1 -= this.m_invIA * L1;
+         v2.x += this.m_invMassB * PX;
+         v2.y += this.m_invMassB * PY;
+         w2 += this.m_invIB * L2;
+      }
+      bA.m_linearVelocity.SetV(v1);
+      bA.m_angularVelocity = w1;
+      bB.m_linearVelocity.SetV(v2);
+      bB.m_angularVelocity = w2;
+   }
+   b2LineJoint.prototype.SolvePositionConstraints = function (baumgarte) {
+      if (baumgarte === undefined) baumgarte = 0;
+      var limitC = 0;
+      var oldLimitImpulse = 0;
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var c1 = bA.m_sweep.c;
+      var a1 = bA.m_sweep.a;
+      var c2 = bB.m_sweep.c;
+      var a2 = bB.m_sweep.a;
+      var tMat;
+      var tX = 0;
+      var m1 = 0;
+      var m2 = 0;
+      var i1 = 0;
+      var i2 = 0;
+      var linearError = 0.0;
+      var angularError = 0.0;
+      var active = false;
+      var C2 = 0.0;
+      var R1 = b2Mat22.FromAngle(a1);
+      var R2 = b2Mat22.FromAngle(a2);
+      tMat = R1;
+      var r1X = this.m_localAnchor1.x - this.m_localCenterA.x;
+      var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y;
+      tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+      r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+      r1X = tX;
+      tMat = R2;
+      var r2X = this.m_localAnchor2.x - this.m_localCenterB.x;
+      var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y;
+      tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+      r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+      r2X = tX;
+      var dX = c2.x + r2X - c1.x - r1X;
+      var dY = c2.y + r2Y - c1.y - r1Y;
+      if (this.m_enableLimit) {
+         this.m_axis = b2Math.MulMV(R1, this.m_localXAxis1);
+         this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x;
+         this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x;
+         var translation = this.m_axis.x * dX + this.m_axis.y * dY;
+         if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) {
+            C2 = b2Math.Clamp(translation, (-b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
+            linearError = b2Math.Abs(translation);
+            active = true;
+         }
+         else if (translation <= this.m_lowerTranslation) {
+            C2 = b2Math.Clamp(translation - this.m_lowerTranslation + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0);
+            linearError = this.m_lowerTranslation - translation;
+            active = true;
+         }
+         else if (translation >= this.m_upperTranslation) {
+            C2 = b2Math.Clamp(translation - this.m_upperTranslation + b2Settings.b2_linearSlop, 0.0, b2Settings.b2_maxLinearCorrection);
+            linearError = translation - this.m_upperTranslation;
+            active = true;
+         }
+      }
+      this.m_perp = b2Math.MulMV(R1, this.m_localYAxis1);
+      this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x;
+      this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x;
+      var impulse = new b2Vec2();
+      var C1 = this.m_perp.x * dX + this.m_perp.y * dY;
+      linearError = b2Math.Max(linearError, b2Math.Abs(C1));
+      angularError = 0.0;
+      if (active) {
+         m1 = this.m_invMassA;
+         m2 = this.m_invMassB;
+         i1 = this.m_invIA;
+         i2 = this.m_invIB;
+         this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2;
+         this.m_K.col1.y = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2;
+         this.m_K.col2.x = this.m_K.col1.y;
+         this.m_K.col2.y = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2;
+         this.m_K.Solve(impulse, (-C1), (-C2));
+      }
+      else {
+         m1 = this.m_invMassA;
+         m2 = this.m_invMassB;
+         i1 = this.m_invIA;
+         i2 = this.m_invIB;
+         var k11 = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2;
+         var impulse1 = 0;
+         if (k11 != 0.0) {
+            impulse1 = ((-C1)) / k11;
+         }
+         else {
+            impulse1 = 0.0;
+         }
+         impulse.x = impulse1;
+         impulse.y = 0.0;
+      }
+      var PX = impulse.x * this.m_perp.x + impulse.y * this.m_axis.x;
+      var PY = impulse.x * this.m_perp.y + impulse.y * this.m_axis.y;
+      var L1 = impulse.x * this.m_s1 + impulse.y * this.m_a1;
+      var L2 = impulse.x * this.m_s2 + impulse.y * this.m_a2;
+      c1.x -= this.m_invMassA * PX;
+      c1.y -= this.m_invMassA * PY;
+      a1 -= this.m_invIA * L1;
+      c2.x += this.m_invMassB * PX;
+      c2.y += this.m_invMassB * PY;
+      a2 += this.m_invIB * L2;
+      bA.m_sweep.a = a1;
+      bB.m_sweep.a = a2;
+      bA.SynchronizeTransform();
+      bB.SynchronizeTransform();
+      return linearError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop;
+   }
+   Box2D.inherit(b2LineJointDef, Box2D.Dynamics.Joints.b2JointDef);
+   b2LineJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype;
+   b2LineJointDef.b2LineJointDef = function () {
+      Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments);
+      this.localAnchorA = new b2Vec2();
+      this.localAnchorB = new b2Vec2();
+      this.localAxisA = new b2Vec2();
+   };
+   b2LineJointDef.prototype.b2LineJointDef = function () {
+      this.__super.b2JointDef.call(this);
+      this.type = b2Joint.e_lineJoint;
+      this.localAxisA.Set(1.0, 0.0);
+      this.enableLimit = false;
+      this.lowerTranslation = 0.0;
+      this.upperTranslation = 0.0;
+      this.enableMotor = false;
+      this.maxMotorForce = 0.0;
+      this.motorSpeed = 0.0;
+   }
+   b2LineJointDef.prototype.Initialize = function (bA, bB, anchor, axis) {
+      this.bodyA = bA;
+      this.bodyB = bB;
+      this.localAnchorA = this.bodyA.GetLocalPoint(anchor);
+      this.localAnchorB = this.bodyB.GetLocalPoint(anchor);
+      this.localAxisA = this.bodyA.GetLocalVector(axis);
+   }
+   Box2D.inherit(b2MouseJoint, Box2D.Dynamics.Joints.b2Joint);
+   b2MouseJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype;
+   b2MouseJoint.b2MouseJoint = function () {
+      Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments);
+      this.K = new b2Mat22();
+      this.K1 = new b2Mat22();
+      this.K2 = new b2Mat22();
+      this.m_localAnchor = new b2Vec2();
+      this.m_target = new b2Vec2();
+      this.m_impulse = new b2Vec2();
+      this.m_mass = new b2Mat22();
+      this.m_C = new b2Vec2();
+   };
+   b2MouseJoint.prototype.GetAnchorA = function () {
+      return this.m_target;
+   }
+   b2MouseJoint.prototype.GetAnchorB = function () {
+      return this.m_bodyB.GetWorldPoint(this.m_localAnchor);
+   }
+   b2MouseJoint.prototype.GetReactionForce = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return new b2Vec2(inv_dt * this.m_impulse.x, inv_dt * this.m_impulse.y);
+   }
+   b2MouseJoint.prototype.GetReactionTorque = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return 0.0;
+   }
+   b2MouseJoint.prototype.GetTarget = function () {
+      return this.m_target;
+   }
+   b2MouseJoint.prototype.SetTarget = function (target) {
+      if (this.m_bodyB.IsAwake() == false) {
+         this.m_bodyB.SetAwake(true);
+      }
+      this.m_target = target;
+   }
+   b2MouseJoint.prototype.GetMaxForce = function () {
+      return this.m_maxForce;
+   }
+   b2MouseJoint.prototype.SetMaxForce = function (maxForce) {
+      if (maxForce === undefined) maxForce = 0;
+      this.m_maxForce = maxForce;
+   }
+   b2MouseJoint.prototype.GetFrequency = function () {
+      return this.m_frequencyHz;
+   }
+   b2MouseJoint.prototype.SetFrequency = function (hz) {
+      if (hz === undefined) hz = 0;
+      this.m_frequencyHz = hz;
+   }
+   b2MouseJoint.prototype.GetDampingRatio = function () {
+      return this.m_dampingRatio;
+   }
+   b2MouseJoint.prototype.SetDampingRatio = function (ratio) {
+      if (ratio === undefined) ratio = 0;
+      this.m_dampingRatio = ratio;
+   }
+   b2MouseJoint.prototype.b2MouseJoint = function (def) {
+      this.__super.b2Joint.call(this, def);
+      this.m_target.SetV(def.target);
+      var tX = this.m_target.x - this.m_bodyB.m_xf.position.x;
+      var tY = this.m_target.y - this.m_bodyB.m_xf.position.y;
+      var tMat = this.m_bodyB.m_xf.R;
+      this.m_localAnchor.x = (tX * tMat.col1.x + tY * tMat.col1.y);
+      this.m_localAnchor.y = (tX * tMat.col2.x + tY * tMat.col2.y);
+      this.m_maxForce = def.maxForce;
+      this.m_impulse.SetZero();
+      this.m_frequencyHz = def.frequencyHz;
+      this.m_dampingRatio = def.dampingRatio;
+      this.m_beta = 0.0;
+      this.m_gamma = 0.0;
+   }
+   b2MouseJoint.prototype.InitVelocityConstraints = function (step) {
+      var b = this.m_bodyB;
+      var mass = b.GetMass();
+      var omega = 2.0 * Math.PI * this.m_frequencyHz;
+      var d = 2.0 * mass * this.m_dampingRatio * omega;
+      var k = mass * omega * omega;
+      this.m_gamma = step.dt * (d + step.dt * k);
+      this.m_gamma = this.m_gamma != 0 ? 1 / this.m_gamma : 0.0;
+      this.m_beta = step.dt * k * this.m_gamma;
+      var tMat;tMat = b.m_xf.R;
+      var rX = this.m_localAnchor.x - b.m_sweep.localCenter.x;
+      var rY = this.m_localAnchor.y - b.m_sweep.localCenter.y;
+      var tX = (tMat.col1.x * rX + tMat.col2.x * rY);rY = (tMat.col1.y * rX + tMat.col2.y * rY);
+      rX = tX;
+      var invMass = b.m_invMass;
+      var invI = b.m_invI;this.K1.col1.x = invMass;
+      this.K1.col2.x = 0.0;
+      this.K1.col1.y = 0.0;
+      this.K1.col2.y = invMass;
+      this.K2.col1.x = invI * rY * rY;
+      this.K2.col2.x = (-invI * rX * rY);
+      this.K2.col1.y = (-invI * rX * rY);
+      this.K2.col2.y = invI * rX * rX;
+      this.K.SetM(this.K1);
+      this.K.AddM(this.K2);
+      this.K.col1.x += this.m_gamma;
+      this.K.col2.y += this.m_gamma;
+      this.K.GetInverse(this.m_mass);
+      this.m_C.x = b.m_sweep.c.x + rX - this.m_target.x;
+      this.m_C.y = b.m_sweep.c.y + rY - this.m_target.y;
+      b.m_angularVelocity *= 0.98;
+      this.m_impulse.x *= step.dtRatio;
+      this.m_impulse.y *= step.dtRatio;
+      b.m_linearVelocity.x += invMass * this.m_impulse.x;
+      b.m_linearVelocity.y += invMass * this.m_impulse.y;
+      b.m_angularVelocity += invI * (rX * this.m_impulse.y - rY * this.m_impulse.x);
+   }
+   b2MouseJoint.prototype.SolveVelocityConstraints = function (step) {
+      var b = this.m_bodyB;
+      var tMat;
+      var tX = 0;
+      var tY = 0;
+      tMat = b.m_xf.R;
+      var rX = this.m_localAnchor.x - b.m_sweep.localCenter.x;
+      var rY = this.m_localAnchor.y - b.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * rX + tMat.col2.x * rY);
+      rY = (tMat.col1.y * rX + tMat.col2.y * rY);
+      rX = tX;
+      var CdotX = b.m_linearVelocity.x + ((-b.m_angularVelocity * rY));
+      var CdotY = b.m_linearVelocity.y + (b.m_angularVelocity * rX);
+      tMat = this.m_mass;
+      tX = CdotX + this.m_beta * this.m_C.x + this.m_gamma * this.m_impulse.x;
+      tY = CdotY + this.m_beta * this.m_C.y + this.m_gamma * this.m_impulse.y;
+      var impulseX = (-(tMat.col1.x * tX + tMat.col2.x * tY));
+      var impulseY = (-(tMat.col1.y * tX + tMat.col2.y * tY));
+      var oldImpulseX = this.m_impulse.x;
+      var oldImpulseY = this.m_impulse.y;
+      this.m_impulse.x += impulseX;
+      this.m_impulse.y += impulseY;
+      var maxImpulse = step.dt * this.m_maxForce;
+      if (this.m_impulse.LengthSquared() > maxImpulse * maxImpulse) {
+         this.m_impulse.Multiply(maxImpulse / this.m_impulse.Length());
+      }
+      impulseX = this.m_impulse.x - oldImpulseX;
+      impulseY = this.m_impulse.y - oldImpulseY;
+      b.m_linearVelocity.x += b.m_invMass * impulseX;
+      b.m_linearVelocity.y += b.m_invMass * impulseY;
+      b.m_angularVelocity += b.m_invI * (rX * impulseY - rY * impulseX);
+   }
+   b2MouseJoint.prototype.SolvePositionConstraints = function (baumgarte) {
+      if (baumgarte === undefined) baumgarte = 0;
+      return true;
+   }
+   Box2D.inherit(b2MouseJointDef, Box2D.Dynamics.Joints.b2JointDef);
+   b2MouseJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype;
+   b2MouseJointDef.b2MouseJointDef = function () {
+      Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments);
+      this.target = new b2Vec2();
+   };
+   b2MouseJointDef.prototype.b2MouseJointDef = function () {
+      this.__super.b2JointDef.call(this);
+      this.type = b2Joint.e_mouseJoint;
+      this.maxForce = 0.0;
+      this.frequencyHz = 5.0;
+      this.dampingRatio = 0.7;
+   }
+   Box2D.inherit(b2PrismaticJoint, Box2D.Dynamics.Joints.b2Joint);
+   b2PrismaticJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype;
+   b2PrismaticJoint.b2PrismaticJoint = function () {
+      Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments);
+      this.m_localAnchor1 = new b2Vec2();
+      this.m_localAnchor2 = new b2Vec2();
+      this.m_localXAxis1 = new b2Vec2();
+      this.m_localYAxis1 = new b2Vec2();
+      this.m_axis = new b2Vec2();
+      this.m_perp = new b2Vec2();
+      this.m_K = new b2Mat33();
+      this.m_impulse = new b2Vec3();
+   };
+   b2PrismaticJoint.prototype.GetAnchorA = function () {
+      return this.m_bodyA.GetWorldPoint(this.m_localAnchor1);
+   }
+   b2PrismaticJoint.prototype.GetAnchorB = function () {
+      return this.m_bodyB.GetWorldPoint(this.m_localAnchor2);
+   }
+   b2PrismaticJoint.prototype.GetReactionForce = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return new b2Vec2(inv_dt * (this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.x), inv_dt * (this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.y));
+   }
+   b2PrismaticJoint.prototype.GetReactionTorque = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return inv_dt * this.m_impulse.y;
+   }
+   b2PrismaticJoint.prototype.GetJointTranslation = function () {
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var tMat;
+      var p1 = bA.GetWorldPoint(this.m_localAnchor1);
+      var p2 = bB.GetWorldPoint(this.m_localAnchor2);
+      var dX = p2.x - p1.x;
+      var dY = p2.y - p1.y;
+      var axis = bA.GetWorldVector(this.m_localXAxis1);
+      var translation = axis.x * dX + axis.y * dY;
+      return translation;
+   }
+   b2PrismaticJoint.prototype.GetJointSpeed = function () {
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var tMat;
+      tMat = bA.m_xf.R;
+      var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x;
+      var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y;
+      var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+      r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+      r1X = tX;
+      tMat = bB.m_xf.R;
+      var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x;
+      var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+      r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+      r2X = tX;
+      var p1X = bA.m_sweep.c.x + r1X;
+      var p1Y = bA.m_sweep.c.y + r1Y;
+      var p2X = bB.m_sweep.c.x + r2X;
+      var p2Y = bB.m_sweep.c.y + r2Y;
+      var dX = p2X - p1X;
+      var dY = p2Y - p1Y;
+      var axis = bA.GetWorldVector(this.m_localXAxis1);
+      var v1 = bA.m_linearVelocity;
+      var v2 = bB.m_linearVelocity;
+      var w1 = bA.m_angularVelocity;
+      var w2 = bB.m_angularVelocity;
+      var speed = (dX * ((-w1 * axis.y)) + dY * (w1 * axis.x)) + (axis.x * (((v2.x + ((-w2 * r2Y))) - v1.x) - ((-w1 * r1Y))) + axis.y * (((v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X)));
+      return speed;
+   }
+   b2PrismaticJoint.prototype.IsLimitEnabled = function () {
+      return this.m_enableLimit;
+   }
+   b2PrismaticJoint.prototype.EnableLimit = function (flag) {
+      this.m_bodyA.SetAwake(true);
+      this.m_bodyB.SetAwake(true);
+      this.m_enableLimit = flag;
+   }
+   b2PrismaticJoint.prototype.GetLowerLimit = function () {
+      return this.m_lowerTranslation;
+   }
+   b2PrismaticJoint.prototype.GetUpperLimit = function () {
+      return this.m_upperTranslation;
+   }
+   b2PrismaticJoint.prototype.SetLimits = function (lower, upper) {
+      if (lower === undefined) lower = 0;
+      if (upper === undefined) upper = 0;
+      this.m_bodyA.SetAwake(true);
+      this.m_bodyB.SetAwake(true);
+      this.m_lowerTranslation = lower;
+      this.m_upperTranslation = upper;
+   }
+   b2PrismaticJoint.prototype.IsMotorEnabled = function () {
+      return this.m_enableMotor;
+   }
+   b2PrismaticJoint.prototype.EnableMotor = function (flag) {
+      this.m_bodyA.SetAwake(true);
+      this.m_bodyB.SetAwake(true);
+      this.m_enableMotor = flag;
+   }
+   b2PrismaticJoint.prototype.SetMotorSpeed = function (speed) {
+      if (speed === undefined) speed = 0;
+      this.m_bodyA.SetAwake(true);
+      this.m_bodyB.SetAwake(true);
+      this.m_motorSpeed = speed;
+   }
+   b2PrismaticJoint.prototype.GetMotorSpeed = function () {
+      return this.m_motorSpeed;
+   }
+   b2PrismaticJoint.prototype.SetMaxMotorForce = function (force) {
+      if (force === undefined) force = 0;
+      this.m_bodyA.SetAwake(true);
+      this.m_bodyB.SetAwake(true);
+      this.m_maxMotorForce = force;
+   }
+   b2PrismaticJoint.prototype.GetMotorForce = function () {
+      return this.m_motorImpulse;
+   }
+   b2PrismaticJoint.prototype.b2PrismaticJoint = function (def) {
+      this.__super.b2Joint.call(this, def);
+      var tMat;
+      var tX = 0;
+      var tY = 0;
+      this.m_localAnchor1.SetV(def.localAnchorA);
+      this.m_localAnchor2.SetV(def.localAnchorB);
+      this.m_localXAxis1.SetV(def.localAxisA);
+      this.m_localYAxis1.x = (-this.m_localXAxis1.y);
+      this.m_localYAxis1.y = this.m_localXAxis1.x;
+      this.m_refAngle = def.referenceAngle;
+      this.m_impulse.SetZero();
+      this.m_motorMass = 0.0;
+      this.m_motorImpulse = 0.0;
+      this.m_lowerTranslation = def.lowerTranslation;
+      this.m_upperTranslation = def.upperTranslation;
+      this.m_maxMotorForce = def.maxMotorForce;
+      this.m_motorSpeed = def.motorSpeed;
+      this.m_enableLimit = def.enableLimit;
+      this.m_enableMotor = def.enableMotor;
+      this.m_limitState = b2Joint.e_inactiveLimit;
+      this.m_axis.SetZero();
+      this.m_perp.SetZero();
+   }
+   b2PrismaticJoint.prototype.InitVelocityConstraints = function (step) {
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var tMat;
+      var tX = 0;
+      this.m_localCenterA.SetV(bA.GetLocalCenter());
+      this.m_localCenterB.SetV(bB.GetLocalCenter());
+      var xf1 = bA.GetTransform();
+      var xf2 = bB.GetTransform();
+      tMat = bA.m_xf.R;
+      var r1X = this.m_localAnchor1.x - this.m_localCenterA.x;
+      var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y;
+      tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+      r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+      r1X = tX;
+      tMat = bB.m_xf.R;
+      var r2X = this.m_localAnchor2.x - this.m_localCenterB.x;
+      var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y;
+      tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+      r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+      r2X = tX;
+      var dX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X;
+      var dY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y;
+      this.m_invMassA = bA.m_invMass;
+      this.m_invMassB = bB.m_invMass;
+      this.m_invIA = bA.m_invI;
+      this.m_invIB = bB.m_invI; {
+         this.m_axis.SetV(b2Math.MulMV(xf1.R, this.m_localXAxis1));
+         this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x;
+         this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x;
+         this.m_motorMass = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_a1 * this.m_a1 + this.m_invIB * this.m_a2 * this.m_a2;
+         if (this.m_motorMass > Number.MIN_VALUE) this.m_motorMass = 1.0 / this.m_motorMass;
+      } {
+         this.m_perp.SetV(b2Math.MulMV(xf1.R, this.m_localYAxis1));
+         this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x;
+         this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x;
+         var m1 = this.m_invMassA;
+         var m2 = this.m_invMassB;
+         var i1 = this.m_invIA;
+         var i2 = this.m_invIB;
+         this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2;
+         this.m_K.col1.y = i1 * this.m_s1 + i2 * this.m_s2;
+         this.m_K.col1.z = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2;
+         this.m_K.col2.x = this.m_K.col1.y;
+         this.m_K.col2.y = i1 + i2;
+         this.m_K.col2.z = i1 * this.m_a1 + i2 * this.m_a2;
+         this.m_K.col3.x = this.m_K.col1.z;
+         this.m_K.col3.y = this.m_K.col2.z;
+         this.m_K.col3.z = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2;
+      }
+      if (this.m_enableLimit) {
+         var jointTransition = this.m_axis.x * dX + this.m_axis.y * dY;
+         if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) {
+            this.m_limitState = b2Joint.e_equalLimits;
+         }
+         else if (jointTransition <= this.m_lowerTranslation) {
+            if (this.m_limitState != b2Joint.e_atLowerLimit) {
+               this.m_limitState = b2Joint.e_atLowerLimit;
+               this.m_impulse.z = 0.0;
+            }
+         }
+         else if (jointTransition >= this.m_upperTranslation) {
+            if (this.m_limitState != b2Joint.e_atUpperLimit) {
+               this.m_limitState = b2Joint.e_atUpperLimit;
+               this.m_impulse.z = 0.0;
+            }
+         }
+         else {
+            this.m_limitState = b2Joint.e_inactiveLimit;
+            this.m_impulse.z = 0.0;
+         }
+      }
+      else {
+         this.m_limitState = b2Joint.e_inactiveLimit;
+      }
+      if (this.m_enableMotor == false) {
+         this.m_motorImpulse = 0.0;
+      }
+      if (step.warmStarting) {
+         this.m_impulse.x *= step.dtRatio;
+         this.m_impulse.y *= step.dtRatio;
+         this.m_motorImpulse *= step.dtRatio;
+         var PX = this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.x;
+         var PY = this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.y;
+         var L1 = this.m_impulse.x * this.m_s1 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1;
+         var L2 = this.m_impulse.x * this.m_s2 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2;
+         bA.m_linearVelocity.x -= this.m_invMassA * PX;
+         bA.m_linearVelocity.y -= this.m_invMassA * PY;
+         bA.m_angularVelocity -= this.m_invIA * L1;
+         bB.m_linearVelocity.x += this.m_invMassB * PX;
+         bB.m_linearVelocity.y += this.m_invMassB * PY;
+         bB.m_angularVelocity += this.m_invIB * L2;
+      }
+      else {
+         this.m_impulse.SetZero();
+         this.m_motorImpulse = 0.0;
+      }
+   }
+   b2PrismaticJoint.prototype.SolveVelocityConstraints = function (step) {
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var v1 = bA.m_linearVelocity;
+      var w1 = bA.m_angularVelocity;
+      var v2 = bB.m_linearVelocity;
+      var w2 = bB.m_angularVelocity;
+      var PX = 0;
+      var PY = 0;
+      var L1 = 0;
+      var L2 = 0;
+      if (this.m_enableMotor && this.m_limitState != b2Joint.e_equalLimits) {
+         var Cdot = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1;
+         var impulse = this.m_motorMass * (this.m_motorSpeed - Cdot);
+         var oldImpulse = this.m_motorImpulse;
+         var maxImpulse = step.dt * this.m_maxMotorForce;
+         this.m_motorImpulse = b2Math.Clamp(this.m_motorImpulse + impulse, (-maxImpulse), maxImpulse);
+         impulse = this.m_motorImpulse - oldImpulse;
+         PX = impulse * this.m_axis.x;
+         PY = impulse * this.m_axis.y;
+         L1 = impulse * this.m_a1;
+         L2 = impulse * this.m_a2;
+         v1.x -= this.m_invMassA * PX;
+         v1.y -= this.m_invMassA * PY;
+         w1 -= this.m_invIA * L1;
+         v2.x += this.m_invMassB * PX;
+         v2.y += this.m_invMassB * PY;
+         w2 += this.m_invIB * L2;
+      }
+      var Cdot1X = this.m_perp.x * (v2.x - v1.x) + this.m_perp.y * (v2.y - v1.y) + this.m_s2 * w2 - this.m_s1 * w1;
+      var Cdot1Y = w2 - w1;
+      if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) {
+         var Cdot2 = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1;
+         var f1 = this.m_impulse.Copy();
+         var df = this.m_K.Solve33(new b2Vec3(), (-Cdot1X), (-Cdot1Y), (-Cdot2));
+         this.m_impulse.Add(df);
+         if (this.m_limitState == b2Joint.e_atLowerLimit) {
+            this.m_impulse.z = b2Math.Max(this.m_impulse.z, 0.0);
+         }
+         else if (this.m_limitState == b2Joint.e_atUpperLimit) {
+            this.m_impulse.z = b2Math.Min(this.m_impulse.z, 0.0);
+         }
+         var bX = (-Cdot1X) - (this.m_impulse.z - f1.z) * this.m_K.col3.x;
+         var bY = (-Cdot1Y) - (this.m_impulse.z - f1.z) * this.m_K.col3.y;
+         var f2r = this.m_K.Solve22(new b2Vec2(), bX, bY);
+         f2r.x += f1.x;
+         f2r.y += f1.y;
+         this.m_impulse.x = f2r.x;
+         this.m_impulse.y = f2r.y;
+         df.x = this.m_impulse.x - f1.x;
+         df.y = this.m_impulse.y - f1.y;
+         df.z = this.m_impulse.z - f1.z;
+         PX = df.x * this.m_perp.x + df.z * this.m_axis.x;
+         PY = df.x * this.m_perp.y + df.z * this.m_axis.y;
+         L1 = df.x * this.m_s1 + df.y + df.z * this.m_a1;
+         L2 = df.x * this.m_s2 + df.y + df.z * this.m_a2;
+         v1.x -= this.m_invMassA * PX;
+         v1.y -= this.m_invMassA * PY;
+         w1 -= this.m_invIA * L1;
+         v2.x += this.m_invMassB * PX;
+         v2.y += this.m_invMassB * PY;
+         w2 += this.m_invIB * L2;
+      }
+      else {
+         var df2 = this.m_K.Solve22(new b2Vec2(), (-Cdot1X), (-Cdot1Y));
+         this.m_impulse.x += df2.x;
+         this.m_impulse.y += df2.y;
+         PX = df2.x * this.m_perp.x;
+         PY = df2.x * this.m_perp.y;
+         L1 = df2.x * this.m_s1 + df2.y;
+         L2 = df2.x * this.m_s2 + df2.y;
+         v1.x -= this.m_invMassA * PX;
+         v1.y -= this.m_invMassA * PY;
+         w1 -= this.m_invIA * L1;
+         v2.x += this.m_invMassB * PX;
+         v2.y += this.m_invMassB * PY;
+         w2 += this.m_invIB * L2;
+      }
+      bA.m_linearVelocity.SetV(v1);
+      bA.m_angularVelocity = w1;
+      bB.m_linearVelocity.SetV(v2);
+      bB.m_angularVelocity = w2;
+   }
+   b2PrismaticJoint.prototype.SolvePositionConstraints = function (baumgarte) {
+      if (baumgarte === undefined) baumgarte = 0;
+      var limitC = 0;
+      var oldLimitImpulse = 0;
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var c1 = bA.m_sweep.c;
+      var a1 = bA.m_sweep.a;
+      var c2 = bB.m_sweep.c;
+      var a2 = bB.m_sweep.a;
+      var tMat;
+      var tX = 0;
+      var m1 = 0;
+      var m2 = 0;
+      var i1 = 0;
+      var i2 = 0;
+      var linearError = 0.0;
+      var angularError = 0.0;
+      var active = false;
+      var C2 = 0.0;
+      var R1 = b2Mat22.FromAngle(a1);
+      var R2 = b2Mat22.FromAngle(a2);
+      tMat = R1;
+      var r1X = this.m_localAnchor1.x - this.m_localCenterA.x;
+      var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y;
+      tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+      r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+      r1X = tX;
+      tMat = R2;
+      var r2X = this.m_localAnchor2.x - this.m_localCenterB.x;
+      var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y;
+      tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+      r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+      r2X = tX;
+      var dX = c2.x + r2X - c1.x - r1X;
+      var dY = c2.y + r2Y - c1.y - r1Y;
+      if (this.m_enableLimit) {
+         this.m_axis = b2Math.MulMV(R1, this.m_localXAxis1);
+         this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x;
+         this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x;
+         var translation = this.m_axis.x * dX + this.m_axis.y * dY;
+         if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) {
+            C2 = b2Math.Clamp(translation, (-b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
+            linearError = b2Math.Abs(translation);
+            active = true;
+         }
+         else if (translation <= this.m_lowerTranslation) {
+            C2 = b2Math.Clamp(translation - this.m_lowerTranslation + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0);
+            linearError = this.m_lowerTranslation - translation;
+            active = true;
+         }
+         else if (translation >= this.m_upperTranslation) {
+            C2 = b2Math.Clamp(translation - this.m_upperTranslation + b2Settings.b2_linearSlop, 0.0, b2Settings.b2_maxLinearCorrection);
+            linearError = translation - this.m_upperTranslation;
+            active = true;
+         }
+      }
+      this.m_perp = b2Math.MulMV(R1, this.m_localYAxis1);
+      this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x;
+      this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x;
+      var impulse = new b2Vec3();
+      var C1X = this.m_perp.x * dX + this.m_perp.y * dY;
+      var C1Y = a2 - a1 - this.m_refAngle;
+      linearError = b2Math.Max(linearError, b2Math.Abs(C1X));
+      angularError = b2Math.Abs(C1Y);
+      if (active) {
+         m1 = this.m_invMassA;
+         m2 = this.m_invMassB;
+         i1 = this.m_invIA;
+         i2 = this.m_invIB;
+         this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2;
+         this.m_K.col1.y = i1 * this.m_s1 + i2 * this.m_s2;
+         this.m_K.col1.z = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2;
+         this.m_K.col2.x = this.m_K.col1.y;
+         this.m_K.col2.y = i1 + i2;
+         this.m_K.col2.z = i1 * this.m_a1 + i2 * this.m_a2;
+         this.m_K.col3.x = this.m_K.col1.z;
+         this.m_K.col3.y = this.m_K.col2.z;
+         this.m_K.col3.z = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2;
+         this.m_K.Solve33(impulse, (-C1X), (-C1Y), (-C2));
+      }
+      else {
+         m1 = this.m_invMassA;
+         m2 = this.m_invMassB;
+         i1 = this.m_invIA;
+         i2 = this.m_invIB;
+         var k11 = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2;
+         var k12 = i1 * this.m_s1 + i2 * this.m_s2;
+         var k22 = i1 + i2;
+         this.m_K.col1.Set(k11, k12, 0.0);
+         this.m_K.col2.Set(k12, k22, 0.0);
+         var impulse1 = this.m_K.Solve22(new b2Vec2(), (-C1X), (-C1Y));
+         impulse.x = impulse1.x;
+         impulse.y = impulse1.y;
+         impulse.z = 0.0;
+      }
+      var PX = impulse.x * this.m_perp.x + impulse.z * this.m_axis.x;
+      var PY = impulse.x * this.m_perp.y + impulse.z * this.m_axis.y;
+      var L1 = impulse.x * this.m_s1 + impulse.y + impulse.z * this.m_a1;
+      var L2 = impulse.x * this.m_s2 + impulse.y + impulse.z * this.m_a2;
+      c1.x -= this.m_invMassA * PX;
+      c1.y -= this.m_invMassA * PY;
+      a1 -= this.m_invIA * L1;
+      c2.x += this.m_invMassB * PX;
+      c2.y += this.m_invMassB * PY;
+      a2 += this.m_invIB * L2;
+      bA.m_sweep.a = a1;
+      bB.m_sweep.a = a2;
+      bA.SynchronizeTransform();
+      bB.SynchronizeTransform();
+      return linearError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop;
+   }
+   Box2D.inherit(b2PrismaticJointDef, Box2D.Dynamics.Joints.b2JointDef);
+   b2PrismaticJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype;
+   b2PrismaticJointDef.b2PrismaticJointDef = function () {
+      Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments);
+      this.localAnchorA = new b2Vec2();
+      this.localAnchorB = new b2Vec2();
+      this.localAxisA = new b2Vec2();
+   };
+   b2PrismaticJointDef.prototype.b2PrismaticJointDef = function () {
+      this.__super.b2JointDef.call(this);
+      this.type = b2Joint.e_prismaticJoint;
+      this.localAxisA.Set(1.0, 0.0);
+      this.referenceAngle = 0.0;
+      this.enableLimit = false;
+      this.lowerTranslation = 0.0;
+      this.upperTranslation = 0.0;
+      this.enableMotor = false;
+      this.maxMotorForce = 0.0;
+      this.motorSpeed = 0.0;
+   }
+   b2PrismaticJointDef.prototype.Initialize = function (bA, bB, anchor, axis) {
+      this.bodyA = bA;
+      this.bodyB = bB;
+      this.localAnchorA = this.bodyA.GetLocalPoint(anchor);
+      this.localAnchorB = this.bodyB.GetLocalPoint(anchor);
+      this.localAxisA = this.bodyA.GetLocalVector(axis);
+      this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle();
+   }
+   Box2D.inherit(b2PulleyJoint, Box2D.Dynamics.Joints.b2Joint);
+   b2PulleyJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype;
+   b2PulleyJoint.b2PulleyJoint = function () {
+      Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments);
+      this.m_groundAnchor1 = new b2Vec2();
+      this.m_groundAnchor2 = new b2Vec2();
+      this.m_localAnchor1 = new b2Vec2();
+      this.m_localAnchor2 = new b2Vec2();
+      this.m_u1 = new b2Vec2();
+      this.m_u2 = new b2Vec2();
+   };
+   b2PulleyJoint.prototype.GetAnchorA = function () {
+      return this.m_bodyA.GetWorldPoint(this.m_localAnchor1);
+   }
+   b2PulleyJoint.prototype.GetAnchorB = function () {
+      return this.m_bodyB.GetWorldPoint(this.m_localAnchor2);
+   }
+   b2PulleyJoint.prototype.GetReactionForce = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return new b2Vec2(inv_dt * this.m_impulse * this.m_u2.x, inv_dt * this.m_impulse * this.m_u2.y);
+   }
+   b2PulleyJoint.prototype.GetReactionTorque = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return 0.0;
+   }
+   b2PulleyJoint.prototype.GetGroundAnchorA = function () {
+      var a = this.m_ground.m_xf.position.Copy();
+      a.Add(this.m_groundAnchor1);
+      return a;
+   }
+   b2PulleyJoint.prototype.GetGroundAnchorB = function () {
+      var a = this.m_ground.m_xf.position.Copy();
+      a.Add(this.m_groundAnchor2);
+      return a;
+   }
+   b2PulleyJoint.prototype.GetLength1 = function () {
+      var p = this.m_bodyA.GetWorldPoint(this.m_localAnchor1);
+      var sX = this.m_ground.m_xf.position.x + this.m_groundAnchor1.x;
+      var sY = this.m_ground.m_xf.position.y + this.m_groundAnchor1.y;
+      var dX = p.x - sX;
+      var dY = p.y - sY;
+      return Math.sqrt(dX * dX + dY * dY);
+   }
+   b2PulleyJoint.prototype.GetLength2 = function () {
+      var p = this.m_bodyB.GetWorldPoint(this.m_localAnchor2);
+      var sX = this.m_ground.m_xf.position.x + this.m_groundAnchor2.x;
+      var sY = this.m_ground.m_xf.position.y + this.m_groundAnchor2.y;
+      var dX = p.x - sX;
+      var dY = p.y - sY;
+      return Math.sqrt(dX * dX + dY * dY);
+   }
+   b2PulleyJoint.prototype.GetRatio = function () {
+      return this.m_ratio;
+   }
+   b2PulleyJoint.prototype.b2PulleyJoint = function (def) {
+      this.__super.b2Joint.call(this, def);
+      var tMat;
+      var tX = 0;
+      var tY = 0;
+      this.m_ground = this.m_bodyA.m_world.m_groundBody;
+      this.m_groundAnchor1.x = def.groundAnchorA.x - this.m_ground.m_xf.position.x;
+      this.m_groundAnchor1.y = def.groundAnchorA.y - this.m_ground.m_xf.position.y;
+      this.m_groundAnchor2.x = def.groundAnchorB.x - this.m_ground.m_xf.position.x;
+      this.m_groundAnchor2.y = def.groundAnchorB.y - this.m_ground.m_xf.position.y;
+      this.m_localAnchor1.SetV(def.localAnchorA);
+      this.m_localAnchor2.SetV(def.localAnchorB);
+      this.m_ratio = def.ratio;
+      this.m_constant = def.lengthA + this.m_ratio * def.lengthB;
+      this.m_maxLength1 = b2Math.Min(def.maxLengthA, this.m_constant - this.m_ratio * b2PulleyJoint.b2_minPulleyLength);
+      this.m_maxLength2 = b2Math.Min(def.maxLengthB, (this.m_constant - b2PulleyJoint.b2_minPulleyLength) / this.m_ratio);
+      this.m_impulse = 0.0;
+      this.m_limitImpulse1 = 0.0;
+      this.m_limitImpulse2 = 0.0;
+   }
+   b2PulleyJoint.prototype.InitVelocityConstraints = function (step) {
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var tMat;
+      tMat = bA.m_xf.R;
+      var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x;
+      var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y;
+      var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+      r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+      r1X = tX;
+      tMat = bB.m_xf.R;
+      var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x;
+      var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+      r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+      r2X = tX;
+      var p1X = bA.m_sweep.c.x + r1X;
+      var p1Y = bA.m_sweep.c.y + r1Y;
+      var p2X = bB.m_sweep.c.x + r2X;
+      var p2Y = bB.m_sweep.c.y + r2Y;
+      var s1X = this.m_ground.m_xf.position.x + this.m_groundAnchor1.x;
+      var s1Y = this.m_ground.m_xf.position.y + this.m_groundAnchor1.y;
+      var s2X = this.m_ground.m_xf.position.x + this.m_groundAnchor2.x;
+      var s2Y = this.m_ground.m_xf.position.y + this.m_groundAnchor2.y;
+      this.m_u1.Set(p1X - s1X, p1Y - s1Y);
+      this.m_u2.Set(p2X - s2X, p2Y - s2Y);
+      var length1 = this.m_u1.Length();
+      var length2 = this.m_u2.Length();
+      if (length1 > b2Settings.b2_linearSlop) {
+         this.m_u1.Multiply(1.0 / length1);
+      }
+      else {
+         this.m_u1.SetZero();
+      }
+      if (length2 > b2Settings.b2_linearSlop) {
+         this.m_u2.Multiply(1.0 / length2);
+      }
+      else {
+         this.m_u2.SetZero();
+      }
+      var C = this.m_constant - length1 - this.m_ratio * length2;
+      if (C > 0.0) {
+         this.m_state = b2Joint.e_inactiveLimit;
+         this.m_impulse = 0.0;
+      }
+      else {
+         this.m_state = b2Joint.e_atUpperLimit;
+      }
+      if (length1 < this.m_maxLength1) {
+         this.m_limitState1 = b2Joint.e_inactiveLimit;
+         this.m_limitImpulse1 = 0.0;
+      }
+      else {
+         this.m_limitState1 = b2Joint.e_atUpperLimit;
+      }
+      if (length2 < this.m_maxLength2) {
+         this.m_limitState2 = b2Joint.e_inactiveLimit;
+         this.m_limitImpulse2 = 0.0;
+      }
+      else {
+         this.m_limitState2 = b2Joint.e_atUpperLimit;
+      }
+      var cr1u1 = r1X * this.m_u1.y - r1Y * this.m_u1.x;
+      var cr2u2 = r2X * this.m_u2.y - r2Y * this.m_u2.x;
+      this.m_limitMass1 = bA.m_invMass + bA.m_invI * cr1u1 * cr1u1;
+      this.m_limitMass2 = bB.m_invMass + bB.m_invI * cr2u2 * cr2u2;
+      this.m_pulleyMass = this.m_limitMass1 + this.m_ratio * this.m_ratio * this.m_limitMass2;
+      this.m_limitMass1 = 1.0 / this.m_limitMass1;
+      this.m_limitMass2 = 1.0 / this.m_limitMass2;
+      this.m_pulleyMass = 1.0 / this.m_pulleyMass;
+      if (step.warmStarting) {
+         this.m_impulse *= step.dtRatio;
+         this.m_limitImpulse1 *= step.dtRatio;
+         this.m_limitImpulse2 *= step.dtRatio;
+         var P1X = ((-this.m_impulse) - this.m_limitImpulse1) * this.m_u1.x;
+         var P1Y = ((-this.m_impulse) - this.m_limitImpulse1) * this.m_u1.y;
+         var P2X = ((-this.m_ratio * this.m_impulse) - this.m_limitImpulse2) * this.m_u2.x;
+         var P2Y = ((-this.m_ratio * this.m_impulse) - this.m_limitImpulse2) * this.m_u2.y;
+         bA.m_linearVelocity.x += bA.m_invMass * P1X;
+         bA.m_linearVelocity.y += bA.m_invMass * P1Y;
+         bA.m_angularVelocity += bA.m_invI * (r1X * P1Y - r1Y * P1X);
+         bB.m_linearVelocity.x += bB.m_invMass * P2X;
+         bB.m_linearVelocity.y += bB.m_invMass * P2Y;
+         bB.m_angularVelocity += bB.m_invI * (r2X * P2Y - r2Y * P2X);
+      }
+      else {
+         this.m_impulse = 0.0;
+         this.m_limitImpulse1 = 0.0;
+         this.m_limitImpulse2 = 0.0;
+      }
+   }
+   b2PulleyJoint.prototype.SolveVelocityConstraints = function (step) {
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var tMat;
+      tMat = bA.m_xf.R;
+      var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x;
+      var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y;
+      var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+      r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+      r1X = tX;
+      tMat = bB.m_xf.R;
+      var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x;
+      var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+      r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+      r2X = tX;
+      var v1X = 0;
+      var v1Y = 0;
+      var v2X = 0;
+      var v2Y = 0;
+      var P1X = 0;
+      var P1Y = 0;
+      var P2X = 0;
+      var P2Y = 0;
+      var Cdot = 0;
+      var impulse = 0;
+      var oldImpulse = 0;
+      if (this.m_state == b2Joint.e_atUpperLimit) {
+         v1X = bA.m_linearVelocity.x + ((-bA.m_angularVelocity * r1Y));
+         v1Y = bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X);
+         v2X = bB.m_linearVelocity.x + ((-bB.m_angularVelocity * r2Y));
+         v2Y = bB.m_linearVelocity.y + (bB.m_angularVelocity * r2X);
+         Cdot = (-(this.m_u1.x * v1X + this.m_u1.y * v1Y)) - this.m_ratio * (this.m_u2.x * v2X + this.m_u2.y * v2Y);
+         impulse = this.m_pulleyMass * ((-Cdot));
+         oldImpulse = this.m_impulse;
+         this.m_impulse = b2Math.Max(0.0, this.m_impulse + impulse);
+         impulse = this.m_impulse - oldImpulse;
+         P1X = (-impulse * this.m_u1.x);
+         P1Y = (-impulse * this.m_u1.y);
+         P2X = (-this.m_ratio * impulse * this.m_u2.x);
+         P2Y = (-this.m_ratio * impulse * this.m_u2.y);
+         bA.m_linearVelocity.x += bA.m_invMass * P1X;
+         bA.m_linearVelocity.y += bA.m_invMass * P1Y;
+         bA.m_angularVelocity += bA.m_invI * (r1X * P1Y - r1Y * P1X);
+         bB.m_linearVelocity.x += bB.m_invMass * P2X;
+         bB.m_linearVelocity.y += bB.m_invMass * P2Y;
+         bB.m_angularVelocity += bB.m_invI * (r2X * P2Y - r2Y * P2X);
+      }
+      if (this.m_limitState1 == b2Joint.e_atUpperLimit) {
+         v1X = bA.m_linearVelocity.x + ((-bA.m_angularVelocity * r1Y));
+         v1Y = bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X);
+         Cdot = (-(this.m_u1.x * v1X + this.m_u1.y * v1Y));
+         impulse = (-this.m_limitMass1 * Cdot);
+         oldImpulse = this.m_limitImpulse1;
+         this.m_limitImpulse1 = b2Math.Max(0.0, this.m_limitImpulse1 + impulse);
+         impulse = this.m_limitImpulse1 - oldImpulse;
+         P1X = (-impulse * this.m_u1.x);
+         P1Y = (-impulse * this.m_u1.y);
+         bA.m_linearVelocity.x += bA.m_invMass * P1X;
+         bA.m_linearVelocity.y += bA.m_invMass * P1Y;
+         bA.m_angularVelocity += bA.m_invI * (r1X * P1Y - r1Y * P1X);
+      }
+      if (this.m_limitState2 == b2Joint.e_atUpperLimit) {
+         v2X = bB.m_linearVelocity.x + ((-bB.m_angularVelocity * r2Y));
+         v2Y = bB.m_linearVelocity.y + (bB.m_angularVelocity * r2X);
+         Cdot = (-(this.m_u2.x * v2X + this.m_u2.y * v2Y));
+         impulse = (-this.m_limitMass2 * Cdot);
+         oldImpulse = this.m_limitImpulse2;
+         this.m_limitImpulse2 = b2Math.Max(0.0, this.m_limitImpulse2 + impulse);
+         impulse = this.m_limitImpulse2 - oldImpulse;
+         P2X = (-impulse * this.m_u2.x);
+         P2Y = (-impulse * this.m_u2.y);
+         bB.m_linearVelocity.x += bB.m_invMass * P2X;
+         bB.m_linearVelocity.y += bB.m_invMass * P2Y;
+         bB.m_angularVelocity += bB.m_invI * (r2X * P2Y - r2Y * P2X);
+      }
+   }
+   b2PulleyJoint.prototype.SolvePositionConstraints = function (baumgarte) {
+      if (baumgarte === undefined) baumgarte = 0;
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var tMat;
+      var s1X = this.m_ground.m_xf.position.x + this.m_groundAnchor1.x;
+      var s1Y = this.m_ground.m_xf.position.y + this.m_groundAnchor1.y;
+      var s2X = this.m_ground.m_xf.position.x + this.m_groundAnchor2.x;
+      var s2Y = this.m_ground.m_xf.position.y + this.m_groundAnchor2.y;
+      var r1X = 0;
+      var r1Y = 0;
+      var r2X = 0;
+      var r2Y = 0;
+      var p1X = 0;
+      var p1Y = 0;
+      var p2X = 0;
+      var p2Y = 0;
+      var length1 = 0;
+      var length2 = 0;
+      var C = 0;
+      var impulse = 0;
+      var oldImpulse = 0;
+      var oldLimitPositionImpulse = 0;
+      var tX = 0;
+      var linearError = 0.0;
+      if (this.m_state == b2Joint.e_atUpperLimit) {
+         tMat = bA.m_xf.R;
+         r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x;
+         r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y;
+         tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+         r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+         r1X = tX;
+         tMat = bB.m_xf.R;
+         r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x;
+         r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y;
+         tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+         r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+         r2X = tX;
+         p1X = bA.m_sweep.c.x + r1X;
+         p1Y = bA.m_sweep.c.y + r1Y;
+         p2X = bB.m_sweep.c.x + r2X;
+         p2Y = bB.m_sweep.c.y + r2Y;
+         this.m_u1.Set(p1X - s1X, p1Y - s1Y);
+         this.m_u2.Set(p2X - s2X, p2Y - s2Y);
+         length1 = this.m_u1.Length();
+         length2 = this.m_u2.Length();
+         if (length1 > b2Settings.b2_linearSlop) {
+            this.m_u1.Multiply(1.0 / length1);
+         }
+         else {
+            this.m_u1.SetZero();
+         }
+         if (length2 > b2Settings.b2_linearSlop) {
+            this.m_u2.Multiply(1.0 / length2);
+         }
+         else {
+            this.m_u2.SetZero();
+         }
+         C = this.m_constant - length1 - this.m_ratio * length2;
+         linearError = b2Math.Max(linearError, (-C));
+         C = b2Math.Clamp(C + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0);
+         impulse = (-this.m_pulleyMass * C);
+         p1X = (-impulse * this.m_u1.x);
+         p1Y = (-impulse * this.m_u1.y);
+         p2X = (-this.m_ratio * impulse * this.m_u2.x);
+         p2Y = (-this.m_ratio * impulse * this.m_u2.y);
+         bA.m_sweep.c.x += bA.m_invMass * p1X;
+         bA.m_sweep.c.y += bA.m_invMass * p1Y;
+         bA.m_sweep.a += bA.m_invI * (r1X * p1Y - r1Y * p1X);
+         bB.m_sweep.c.x += bB.m_invMass * p2X;
+         bB.m_sweep.c.y += bB.m_invMass * p2Y;
+         bB.m_sweep.a += bB.m_invI * (r2X * p2Y - r2Y * p2X);
+         bA.SynchronizeTransform();
+         bB.SynchronizeTransform();
+      }
+      if (this.m_limitState1 == b2Joint.e_atUpperLimit) {
+         tMat = bA.m_xf.R;
+         r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x;
+         r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y;
+         tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+         r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+         r1X = tX;
+         p1X = bA.m_sweep.c.x + r1X;
+         p1Y = bA.m_sweep.c.y + r1Y;
+         this.m_u1.Set(p1X - s1X, p1Y - s1Y);
+         length1 = this.m_u1.Length();
+         if (length1 > b2Settings.b2_linearSlop) {
+            this.m_u1.x *= 1.0 / length1;
+            this.m_u1.y *= 1.0 / length1;
+         }
+         else {
+            this.m_u1.SetZero();
+         }
+         C = this.m_maxLength1 - length1;
+         linearError = b2Math.Max(linearError, (-C));
+         C = b2Math.Clamp(C + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0);
+         impulse = (-this.m_limitMass1 * C);
+         p1X = (-impulse * this.m_u1.x);
+         p1Y = (-impulse * this.m_u1.y);
+         bA.m_sweep.c.x += bA.m_invMass * p1X;
+         bA.m_sweep.c.y += bA.m_invMass * p1Y;
+         bA.m_sweep.a += bA.m_invI * (r1X * p1Y - r1Y * p1X);
+         bA.SynchronizeTransform();
+      }
+      if (this.m_limitState2 == b2Joint.e_atUpperLimit) {
+         tMat = bB.m_xf.R;
+         r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x;
+         r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y;
+         tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+         r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+         r2X = tX;
+         p2X = bB.m_sweep.c.x + r2X;
+         p2Y = bB.m_sweep.c.y + r2Y;
+         this.m_u2.Set(p2X - s2X, p2Y - s2Y);
+         length2 = this.m_u2.Length();
+         if (length2 > b2Settings.b2_linearSlop) {
+            this.m_u2.x *= 1.0 / length2;
+            this.m_u2.y *= 1.0 / length2;
+         }
+         else {
+            this.m_u2.SetZero();
+         }
+         C = this.m_maxLength2 - length2;
+         linearError = b2Math.Max(linearError, (-C));
+         C = b2Math.Clamp(C + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0);
+         impulse = (-this.m_limitMass2 * C);
+         p2X = (-impulse * this.m_u2.x);
+         p2Y = (-impulse * this.m_u2.y);
+         bB.m_sweep.c.x += bB.m_invMass * p2X;
+         bB.m_sweep.c.y += bB.m_invMass * p2Y;
+         bB.m_sweep.a += bB.m_invI * (r2X * p2Y - r2Y * p2X);
+         bB.SynchronizeTransform();
+      }
+      return linearError < b2Settings.b2_linearSlop;
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Dynamics.Joints.b2PulleyJoint.b2_minPulleyLength = 2.0;
+   });
+   Box2D.inherit(b2PulleyJointDef, Box2D.Dynamics.Joints.b2JointDef);
+   b2PulleyJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype;
+   b2PulleyJointDef.b2PulleyJointDef = function () {
+      Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments);
+      this.groundAnchorA = new b2Vec2();
+      this.groundAnchorB = new b2Vec2();
+      this.localAnchorA = new b2Vec2();
+      this.localAnchorB = new b2Vec2();
+   };
+   b2PulleyJointDef.prototype.b2PulleyJointDef = function () {
+      this.__super.b2JointDef.call(this);
+      this.type = b2Joint.e_pulleyJoint;
+      this.groundAnchorA.Set((-1.0), 1.0);
+      this.groundAnchorB.Set(1.0, 1.0);
+      this.localAnchorA.Set((-1.0), 0.0);
+      this.localAnchorB.Set(1.0, 0.0);
+      this.lengthA = 0.0;
+      this.maxLengthA = 0.0;
+      this.lengthB = 0.0;
+      this.maxLengthB = 0.0;
+      this.ratio = 1.0;
+      this.collideConnected = true;
+   }
+   b2PulleyJointDef.prototype.Initialize = function (bA, bB, gaA, gaB, anchorA, anchorB, r) {
+      if (r === undefined) r = 0;
+      this.bodyA = bA;
+      this.bodyB = bB;
+      this.groundAnchorA.SetV(gaA);
+      this.groundAnchorB.SetV(gaB);
+      this.localAnchorA = this.bodyA.GetLocalPoint(anchorA);
+      this.localAnchorB = this.bodyB.GetLocalPoint(anchorB);
+      var d1X = anchorA.x - gaA.x;
+      var d1Y = anchorA.y - gaA.y;
+      this.lengthA = Math.sqrt(d1X * d1X + d1Y * d1Y);
+      var d2X = anchorB.x - gaB.x;
+      var d2Y = anchorB.y - gaB.y;
+      this.lengthB = Math.sqrt(d2X * d2X + d2Y * d2Y);
+      this.ratio = r;
+      var C = this.lengthA + this.ratio * this.lengthB;
+      this.maxLengthA = C - this.ratio * b2PulleyJoint.b2_minPulleyLength;
+      this.maxLengthB = (C - b2PulleyJoint.b2_minPulleyLength) / this.ratio;
+   }
+   Box2D.inherit(b2RevoluteJoint, Box2D.Dynamics.Joints.b2Joint);
+   b2RevoluteJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype;
+   b2RevoluteJoint.b2RevoluteJoint = function () {
+      Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments);
+      this.K = new b2Mat22();
+      this.K1 = new b2Mat22();
+      this.K2 = new b2Mat22();
+      this.K3 = new b2Mat22();
+      this.impulse3 = new b2Vec3();
+      this.impulse2 = new b2Vec2();
+      this.reduced = new b2Vec2();
+      this.m_localAnchor1 = new b2Vec2();
+      this.m_localAnchor2 = new b2Vec2();
+      this.m_impulse = new b2Vec3();
+      this.m_mass = new b2Mat33();
+   };
+   b2RevoluteJoint.prototype.GetAnchorA = function () {
+      return this.m_bodyA.GetWorldPoint(this.m_localAnchor1);
+   }
+   b2RevoluteJoint.prototype.GetAnchorB = function () {
+      return this.m_bodyB.GetWorldPoint(this.m_localAnchor2);
+   }
+   b2RevoluteJoint.prototype.GetReactionForce = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return new b2Vec2(inv_dt * this.m_impulse.x, inv_dt * this.m_impulse.y);
+   }
+   b2RevoluteJoint.prototype.GetReactionTorque = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return inv_dt * this.m_impulse.z;
+   }
+   b2RevoluteJoint.prototype.GetJointAngle = function () {
+      return this.m_bodyB.m_sweep.a - this.m_bodyA.m_sweep.a - this.m_referenceAngle;
+   }
+   b2RevoluteJoint.prototype.GetJointSpeed = function () {
+      return this.m_bodyB.m_angularVelocity - this.m_bodyA.m_angularVelocity;
+   }
+   b2RevoluteJoint.prototype.IsLimitEnabled = function () {
+      return this.m_enableLimit;
+   }
+   b2RevoluteJoint.prototype.EnableLimit = function (flag) {
+      this.m_enableLimit = flag;
+   }
+   b2RevoluteJoint.prototype.GetLowerLimit = function () {
+      return this.m_lowerAngle;
+   }
+   b2RevoluteJoint.prototype.GetUpperLimit = function () {
+      return this.m_upperAngle;
+   }
+   b2RevoluteJoint.prototype.SetLimits = function (lower, upper) {
+      if (lower === undefined) lower = 0;
+      if (upper === undefined) upper = 0;
+      this.m_lowerAngle = lower;
+      this.m_upperAngle = upper;
+   }
+   b2RevoluteJoint.prototype.IsMotorEnabled = function () {
+      this.m_bodyA.SetAwake(true);
+      this.m_bodyB.SetAwake(true);
+      return this.m_enableMotor;
+   }
+   b2RevoluteJoint.prototype.EnableMotor = function (flag) {
+      this.m_enableMotor = flag;
+   }
+   b2RevoluteJoint.prototype.SetMotorSpeed = function (speed) {
+      if (speed === undefined) speed = 0;
+      this.m_bodyA.SetAwake(true);
+      this.m_bodyB.SetAwake(true);
+      this.m_motorSpeed = speed;
+   }
+   b2RevoluteJoint.prototype.GetMotorSpeed = function () {
+      return this.m_motorSpeed;
+   }
+   b2RevoluteJoint.prototype.SetMaxMotorTorque = function (torque) {
+      if (torque === undefined) torque = 0;
+      this.m_maxMotorTorque = torque;
+   }
+   b2RevoluteJoint.prototype.GetMotorTorque = function () {
+      return this.m_maxMotorTorque;
+   }
+   b2RevoluteJoint.prototype.b2RevoluteJoint = function (def) {
+      this.__super.b2Joint.call(this, def);
+      this.m_localAnchor1.SetV(def.localAnchorA);
+      this.m_localAnchor2.SetV(def.localAnchorB);
+      this.m_referenceAngle = def.referenceAngle;
+      this.m_impulse.SetZero();
+      this.m_motorImpulse = 0.0;
+      this.m_lowerAngle = def.lowerAngle;
+      this.m_upperAngle = def.upperAngle;
+      this.m_maxMotorTorque = def.maxMotorTorque;
+      this.m_motorSpeed = def.motorSpeed;
+      this.m_enableLimit = def.enableLimit;
+      this.m_enableMotor = def.enableMotor;
+      this.m_limitState = b2Joint.e_inactiveLimit;
+   }
+   b2RevoluteJoint.prototype.InitVelocityConstraints = function (step) {
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var tMat;
+      var tX = 0;
+      if (this.m_enableMotor || this.m_enableLimit) {}
+      tMat = bA.m_xf.R;
+      var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x;
+      var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+      r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+      r1X = tX;
+      tMat = bB.m_xf.R;
+      var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x;
+      var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+      r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+      r2X = tX;
+      var m1 = bA.m_invMass;
+      var m2 = bB.m_invMass;
+      var i1 = bA.m_invI;
+      var i2 = bB.m_invI;
+      this.m_mass.col1.x = m1 + m2 + r1Y * r1Y * i1 + r2Y * r2Y * i2;
+      this.m_mass.col2.x = (-r1Y * r1X * i1) - r2Y * r2X * i2;
+      this.m_mass.col3.x = (-r1Y * i1) - r2Y * i2;
+      this.m_mass.col1.y = this.m_mass.col2.x;
+      this.m_mass.col2.y = m1 + m2 + r1X * r1X * i1 + r2X * r2X * i2;
+      this.m_mass.col3.y = r1X * i1 + r2X * i2;
+      this.m_mass.col1.z = this.m_mass.col3.x;
+      this.m_mass.col2.z = this.m_mass.col3.y;
+      this.m_mass.col3.z = i1 + i2;
+      this.m_motorMass = 1.0 / (i1 + i2);
+      if (this.m_enableMotor == false) {
+         this.m_motorImpulse = 0.0;
+      }
+      if (this.m_enableLimit) {
+         var jointAngle = bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle;
+         if (b2Math.Abs(this.m_upperAngle - this.m_lowerAngle) < 2.0 * b2Settings.b2_angularSlop) {
+            this.m_limitState = b2Joint.e_equalLimits;
+         }
+         else if (jointAngle <= this.m_lowerAngle) {
+            if (this.m_limitState != b2Joint.e_atLowerLimit) {
+               this.m_impulse.z = 0.0;
+            }
+            this.m_limitState = b2Joint.e_atLowerLimit;
+         }
+         else if (jointAngle >= this.m_upperAngle) {
+            if (this.m_limitState != b2Joint.e_atUpperLimit) {
+               this.m_impulse.z = 0.0;
+            }
+            this.m_limitState = b2Joint.e_atUpperLimit;
+         }
+         else {
+            this.m_limitState = b2Joint.e_inactiveLimit;
+            this.m_impulse.z = 0.0;
+         }
+      }
+      else {
+         this.m_limitState = b2Joint.e_inactiveLimit;
+      }
+      if (step.warmStarting) {
+         this.m_impulse.x *= step.dtRatio;
+         this.m_impulse.y *= step.dtRatio;
+         this.m_motorImpulse *= step.dtRatio;
+         var PX = this.m_impulse.x;
+         var PY = this.m_impulse.y;
+         bA.m_linearVelocity.x -= m1 * PX;
+         bA.m_linearVelocity.y -= m1 * PY;
+         bA.m_angularVelocity -= i1 * ((r1X * PY - r1Y * PX) + this.m_motorImpulse + this.m_impulse.z);
+         bB.m_linearVelocity.x += m2 * PX;
+         bB.m_linearVelocity.y += m2 * PY;
+         bB.m_angularVelocity += i2 * ((r2X * PY - r2Y * PX) + this.m_motorImpulse + this.m_impulse.z);
+      }
+      else {
+         this.m_impulse.SetZero();
+         this.m_motorImpulse = 0.0;
+      }
+   }
+   b2RevoluteJoint.prototype.SolveVelocityConstraints = function (step) {
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var tMat;
+      var tX = 0;
+      var newImpulse = 0;
+      var r1X = 0;
+      var r1Y = 0;
+      var r2X = 0;
+      var r2Y = 0;
+      var v1 = bA.m_linearVelocity;
+      var w1 = bA.m_angularVelocity;
+      var v2 = bB.m_linearVelocity;
+      var w2 = bB.m_angularVelocity;
+      var m1 = bA.m_invMass;
+      var m2 = bB.m_invMass;
+      var i1 = bA.m_invI;
+      var i2 = bB.m_invI;
+      if (this.m_enableMotor && this.m_limitState != b2Joint.e_equalLimits) {
+         var Cdot = w2 - w1 - this.m_motorSpeed;
+         var impulse = this.m_motorMass * ((-Cdot));
+         var oldImpulse = this.m_motorImpulse;
+         var maxImpulse = step.dt * this.m_maxMotorTorque;
+         this.m_motorImpulse = b2Math.Clamp(this.m_motorImpulse + impulse, (-maxImpulse), maxImpulse);
+         impulse = this.m_motorImpulse - oldImpulse;
+         w1 -= i1 * impulse;
+         w2 += i2 * impulse;
+      }
+      if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) {
+         tMat = bA.m_xf.R;
+         r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x;
+         r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y;
+         tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+         r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+         r1X = tX;
+         tMat = bB.m_xf.R;
+         r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x;
+         r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y;
+         tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+         r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+         r2X = tX;
+         var Cdot1X = v2.x + ((-w2 * r2Y)) - v1.x - ((-w1 * r1Y));
+         var Cdot1Y = v2.y + (w2 * r2X) - v1.y - (w1 * r1X);
+         var Cdot2 = w2 - w1;
+         this.m_mass.Solve33(this.impulse3, (-Cdot1X), (-Cdot1Y), (-Cdot2));
+         if (this.m_limitState == b2Joint.e_equalLimits) {
+            this.m_impulse.Add(this.impulse3);
+         }
+         else if (this.m_limitState == b2Joint.e_atLowerLimit) {
+            newImpulse = this.m_impulse.z + this.impulse3.z;
+            if (newImpulse < 0.0) {
+               this.m_mass.Solve22(this.reduced, (-Cdot1X), (-Cdot1Y));
+               this.impulse3.x = this.reduced.x;
+               this.impulse3.y = this.reduced.y;
+               this.impulse3.z = (-this.m_impulse.z);
+               this.m_impulse.x += this.reduced.x;
+               this.m_impulse.y += this.reduced.y;
+               this.m_impulse.z = 0.0;
+            }
+         }
+         else if (this.m_limitState == b2Joint.e_atUpperLimit) {
+            newImpulse = this.m_impulse.z + this.impulse3.z;
+            if (newImpulse > 0.0) {
+               this.m_mass.Solve22(this.reduced, (-Cdot1X), (-Cdot1Y));
+               this.impulse3.x = this.reduced.x;
+               this.impulse3.y = this.reduced.y;
+               this.impulse3.z = (-this.m_impulse.z);
+               this.m_impulse.x += this.reduced.x;
+               this.m_impulse.y += this.reduced.y;
+               this.m_impulse.z = 0.0;
+            }
+         }
+         v1.x -= m1 * this.impulse3.x;
+         v1.y -= m1 * this.impulse3.y;
+         w1 -= i1 * (r1X * this.impulse3.y - r1Y * this.impulse3.x + this.impulse3.z);
+         v2.x += m2 * this.impulse3.x;
+         v2.y += m2 * this.impulse3.y;
+         w2 += i2 * (r2X * this.impulse3.y - r2Y * this.impulse3.x + this.impulse3.z);
+      }
+      else {
+         tMat = bA.m_xf.R;
+         r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x;
+         r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y;
+         tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+         r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+         r1X = tX;
+         tMat = bB.m_xf.R;
+         r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x;
+         r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y;
+         tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+         r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+         r2X = tX;
+         var CdotX = v2.x + ((-w2 * r2Y)) - v1.x - ((-w1 * r1Y));
+         var CdotY = v2.y + (w2 * r2X) - v1.y - (w1 * r1X);
+         this.m_mass.Solve22(this.impulse2, (-CdotX), (-CdotY));
+         this.m_impulse.x += this.impulse2.x;
+         this.m_impulse.y += this.impulse2.y;
+         v1.x -= m1 * this.impulse2.x;
+         v1.y -= m1 * this.impulse2.y;
+         w1 -= i1 * (r1X * this.impulse2.y - r1Y * this.impulse2.x);
+         v2.x += m2 * this.impulse2.x;
+         v2.y += m2 * this.impulse2.y;
+         w2 += i2 * (r2X * this.impulse2.y - r2Y * this.impulse2.x);
+      }
+      bA.m_linearVelocity.SetV(v1);
+      bA.m_angularVelocity = w1;
+      bB.m_linearVelocity.SetV(v2);
+      bB.m_angularVelocity = w2;
+   }
+   b2RevoluteJoint.prototype.SolvePositionConstraints = function (baumgarte) {
+      if (baumgarte === undefined) baumgarte = 0;
+      var oldLimitImpulse = 0;
+      var C = 0;
+      var tMat;
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var angularError = 0.0;
+      var positionError = 0.0;
+      var tX = 0;
+      var impulseX = 0;
+      var impulseY = 0;
+      if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) {
+         var angle = bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle;
+         var limitImpulse = 0.0;
+         if (this.m_limitState == b2Joint.e_equalLimits) {
+            C = b2Math.Clamp(angle - this.m_lowerAngle, (-b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
+            limitImpulse = (-this.m_motorMass * C);
+            angularError = b2Math.Abs(C);
+         }
+         else if (this.m_limitState == b2Joint.e_atLowerLimit) {
+            C = angle - this.m_lowerAngle;
+            angularError = (-C);
+            C = b2Math.Clamp(C + b2Settings.b2_angularSlop, (-b2Settings.b2_maxAngularCorrection), 0.0);
+            limitImpulse = (-this.m_motorMass * C);
+         }
+         else if (this.m_limitState == b2Joint.e_atUpperLimit) {
+            C = angle - this.m_upperAngle;
+            angularError = C;
+            C = b2Math.Clamp(C - b2Settings.b2_angularSlop, 0.0, b2Settings.b2_maxAngularCorrection);
+            limitImpulse = (-this.m_motorMass * C);
+         }
+         bA.m_sweep.a -= bA.m_invI * limitImpulse;
+         bB.m_sweep.a += bB.m_invI * limitImpulse;
+         bA.SynchronizeTransform();
+         bB.SynchronizeTransform();
+      } {
+         tMat = bA.m_xf.R;
+         var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x;
+         var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y;
+         tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y);
+         r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y);
+         r1X = tX;
+         tMat = bB.m_xf.R;
+         var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x;
+         var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y;
+         tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y);
+         r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y);
+         r2X = tX;
+         var CX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X;
+         var CY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y;
+         var CLengthSquared = CX * CX + CY * CY;
+         var CLength = Math.sqrt(CLengthSquared);
+         positionError = CLength;
+         var invMass1 = bA.m_invMass;
+         var invMass2 = bB.m_invMass;
+         var invI1 = bA.m_invI;
+         var invI2 = bB.m_invI;
+         var k_allowedStretch = 10.0 * b2Settings.b2_linearSlop;
+         if (CLengthSquared > k_allowedStretch * k_allowedStretch) {
+            var uX = CX / CLength;
+            var uY = CY / CLength;
+            var k = invMass1 + invMass2;
+            var m = 1.0 / k;
+            impulseX = m * ((-CX));
+            impulseY = m * ((-CY));
+            var k_beta = 0.5;
+            bA.m_sweep.c.x -= k_beta * invMass1 * impulseX;
+            bA.m_sweep.c.y -= k_beta * invMass1 * impulseY;
+            bB.m_sweep.c.x += k_beta * invMass2 * impulseX;
+            bB.m_sweep.c.y += k_beta * invMass2 * impulseY;
+            CX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X;
+            CY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y;
+         }
+         this.K1.col1.x = invMass1 + invMass2;
+         this.K1.col2.x = 0.0;
+         this.K1.col1.y = 0.0;
+         this.K1.col2.y = invMass1 + invMass2;
+         this.K2.col1.x = invI1 * r1Y * r1Y;
+         this.K2.col2.x = (-invI1 * r1X * r1Y);
+         this.K2.col1.y = (-invI1 * r1X * r1Y);
+         this.K2.col2.y = invI1 * r1X * r1X;
+         this.K3.col1.x = invI2 * r2Y * r2Y;
+         this.K3.col2.x = (-invI2 * r2X * r2Y);
+         this.K3.col1.y = (-invI2 * r2X * r2Y);
+         this.K3.col2.y = invI2 * r2X * r2X;
+         this.K.SetM(this.K1);
+         this.K.AddM(this.K2);
+         this.K.AddM(this.K3);
+         this.K.Solve(b2RevoluteJoint.tImpulse, (-CX), (-CY));
+         impulseX = b2RevoluteJoint.tImpulse.x;
+         impulseY = b2RevoluteJoint.tImpulse.y;
+         bA.m_sweep.c.x -= bA.m_invMass * impulseX;
+         bA.m_sweep.c.y -= bA.m_invMass * impulseY;
+         bA.m_sweep.a -= bA.m_invI * (r1X * impulseY - r1Y * impulseX);
+         bB.m_sweep.c.x += bB.m_invMass * impulseX;
+         bB.m_sweep.c.y += bB.m_invMass * impulseY;
+         bB.m_sweep.a += bB.m_invI * (r2X * impulseY - r2Y * impulseX);
+         bA.SynchronizeTransform();
+         bB.SynchronizeTransform();
+      }
+      return positionError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop;
+   }
+   Box2D.postDefs.push(function () {
+      Box2D.Dynamics.Joints.b2RevoluteJoint.tImpulse = new b2Vec2();
+   });
+   Box2D.inherit(b2RevoluteJointDef, Box2D.Dynamics.Joints.b2JointDef);
+   b2RevoluteJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype;
+   b2RevoluteJointDef.b2RevoluteJointDef = function () {
+      Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments);
+      this.localAnchorA = new b2Vec2();
+      this.localAnchorB = new b2Vec2();
+   };
+   b2RevoluteJointDef.prototype.b2RevoluteJointDef = function () {
+      this.__super.b2JointDef.call(this);
+      this.type = b2Joint.e_revoluteJoint;
+      this.localAnchorA.Set(0.0, 0.0);
+      this.localAnchorB.Set(0.0, 0.0);
+      this.referenceAngle = 0.0;
+      this.lowerAngle = 0.0;
+      this.upperAngle = 0.0;
+      this.maxMotorTorque = 0.0;
+      this.motorSpeed = 0.0;
+      this.enableLimit = false;
+      this.enableMotor = false;
+   }
+   b2RevoluteJointDef.prototype.Initialize = function (bA, bB, anchor) {
+      this.bodyA = bA;
+      this.bodyB = bB;
+      this.localAnchorA = this.bodyA.GetLocalPoint(anchor);
+      this.localAnchorB = this.bodyB.GetLocalPoint(anchor);
+      this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle();
+   }
+   Box2D.inherit(b2WeldJoint, Box2D.Dynamics.Joints.b2Joint);
+   b2WeldJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype;
+   b2WeldJoint.b2WeldJoint = function () {
+      Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments);
+      this.m_localAnchorA = new b2Vec2();
+      this.m_localAnchorB = new b2Vec2();
+      this.m_impulse = new b2Vec3();
+      this.m_mass = new b2Mat33();
+   };
+   b2WeldJoint.prototype.GetAnchorA = function () {
+      return this.m_bodyA.GetWorldPoint(this.m_localAnchorA);
+   }
+   b2WeldJoint.prototype.GetAnchorB = function () {
+      return this.m_bodyB.GetWorldPoint(this.m_localAnchorB);
+   }
+   b2WeldJoint.prototype.GetReactionForce = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return new b2Vec2(inv_dt * this.m_impulse.x, inv_dt * this.m_impulse.y);
+   }
+   b2WeldJoint.prototype.GetReactionTorque = function (inv_dt) {
+      if (inv_dt === undefined) inv_dt = 0;
+      return inv_dt * this.m_impulse.z;
+   }
+   b2WeldJoint.prototype.b2WeldJoint = function (def) {
+      this.__super.b2Joint.call(this, def);
+      this.m_localAnchorA.SetV(def.localAnchorA);
+      this.m_localAnchorB.SetV(def.localAnchorB);
+      this.m_referenceAngle = def.referenceAngle;
+      this.m_impulse.SetZero();
+      this.m_mass = new b2Mat33();
+   }
+   b2WeldJoint.prototype.InitVelocityConstraints = function (step) {
+      var tMat;
+      var tX = 0;
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      tMat = bA.m_xf.R;
+      var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x;
+      var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * rAX + tMat.col2.x * rAY);
+      rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY);
+      rAX = tX;
+      tMat = bB.m_xf.R;
+      var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x;
+      var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * rBX + tMat.col2.x * rBY);
+      rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY);
+      rBX = tX;
+      var mA = bA.m_invMass;
+      var mB = bB.m_invMass;
+      var iA = bA.m_invI;
+      var iB = bB.m_invI;
+      this.m_mass.col1.x = mA + mB + rAY * rAY * iA + rBY * rBY * iB;
+      this.m_mass.col2.x = (-rAY * rAX * iA) - rBY * rBX * iB;
+      this.m_mass.col3.x = (-rAY * iA) - rBY * iB;
+      this.m_mass.col1.y = this.m_mass.col2.x;
+      this.m_mass.col2.y = mA + mB + rAX * rAX * iA + rBX * rBX * iB;
+      this.m_mass.col3.y = rAX * iA + rBX * iB;
+      this.m_mass.col1.z = this.m_mass.col3.x;
+      this.m_mass.col2.z = this.m_mass.col3.y;
+      this.m_mass.col3.z = iA + iB;
+      if (step.warmStarting) {
+         this.m_impulse.x *= step.dtRatio;
+         this.m_impulse.y *= step.dtRatio;
+         this.m_impulse.z *= step.dtRatio;
+         bA.m_linearVelocity.x -= mA * this.m_impulse.x;
+         bA.m_linearVelocity.y -= mA * this.m_impulse.y;
+         bA.m_angularVelocity -= iA * (rAX * this.m_impulse.y - rAY * this.m_impulse.x + this.m_impulse.z);
+         bB.m_linearVelocity.x += mB * this.m_impulse.x;
+         bB.m_linearVelocity.y += mB * this.m_impulse.y;
+         bB.m_angularVelocity += iB * (rBX * this.m_impulse.y - rBY * this.m_impulse.x + this.m_impulse.z);
+      }
+      else {
+         this.m_impulse.SetZero();
+      }
+   }
+   b2WeldJoint.prototype.SolveVelocityConstraints = function (step) {
+      var tMat;
+      var tX = 0;
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      var vA = bA.m_linearVelocity;
+      var wA = bA.m_angularVelocity;
+      var vB = bB.m_linearVelocity;
+      var wB = bB.m_angularVelocity;
+      var mA = bA.m_invMass;
+      var mB = bB.m_invMass;
+      var iA = bA.m_invI;
+      var iB = bB.m_invI;
+      tMat = bA.m_xf.R;
+      var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x;
+      var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * rAX + tMat.col2.x * rAY);
+      rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY);
+      rAX = tX;
+      tMat = bB.m_xf.R;
+      var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x;
+      var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * rBX + tMat.col2.x * rBY);
+      rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY);
+      rBX = tX;
+      var Cdot1X = vB.x - wB * rBY - vA.x + wA * rAY;
+      var Cdot1Y = vB.y + wB * rBX - vA.y - wA * rAX;
+      var Cdot2 = wB - wA;
+      var impulse = new b2Vec3();
+      this.m_mass.Solve33(impulse, (-Cdot1X), (-Cdot1Y), (-Cdot2));
+      this.m_impulse.Add(impulse);
+      vA.x -= mA * impulse.x;
+      vA.y -= mA * impulse.y;
+      wA -= iA * (rAX * impulse.y - rAY * impulse.x + impulse.z);
+      vB.x += mB * impulse.x;
+      vB.y += mB * impulse.y;
+      wB += iB * (rBX * impulse.y - rBY * impulse.x + impulse.z);
+      bA.m_angularVelocity = wA;
+      bB.m_angularVelocity = wB;
+   }
+   b2WeldJoint.prototype.SolvePositionConstraints = function (baumgarte) {
+      if (baumgarte === undefined) baumgarte = 0;
+      var tMat;
+      var tX = 0;
+      var bA = this.m_bodyA;
+      var bB = this.m_bodyB;
+      tMat = bA.m_xf.R;
+      var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x;
+      var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * rAX + tMat.col2.x * rAY);
+      rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY);
+      rAX = tX;
+      tMat = bB.m_xf.R;
+      var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x;
+      var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y;
+      tX = (tMat.col1.x * rBX + tMat.col2.x * rBY);
+      rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY);
+      rBX = tX;
+      var mA = bA.m_invMass;
+      var mB = bB.m_invMass;
+      var iA = bA.m_invI;
+      var iB = bB.m_invI;
+      var C1X = bB.m_sweep.c.x + rBX - bA.m_sweep.c.x - rAX;
+      var C1Y = bB.m_sweep.c.y + rBY - bA.m_sweep.c.y - rAY;
+      var C2 = bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle;
+      var k_allowedStretch = 10.0 * b2Settings.b2_linearSlop;
+      var positionError = Math.sqrt(C1X * C1X + C1Y * C1Y);
+      var angularError = b2Math.Abs(C2);
+      if (positionError > k_allowedStretch) {
+         iA *= 1.0;
+         iB *= 1.0;
+      }
+      this.m_mass.col1.x = mA + mB + rAY * rAY * iA + rBY * rBY * iB;
+      this.m_mass.col2.x = (-rAY * rAX * iA) - rBY * rBX * iB;
+      this.m_mass.col3.x = (-rAY * iA) - rBY * iB;
+      this.m_mass.col1.y = this.m_mass.col2.x;
+      this.m_mass.col2.y = mA + mB + rAX * rAX * iA + rBX * rBX * iB;
+      this.m_mass.col3.y = rAX * iA + rBX * iB;
+      this.m_mass.col1.z = this.m_mass.col3.x;
+      this.m_mass.col2.z = this.m_mass.col3.y;
+      this.m_mass.col3.z = iA + iB;
+      var impulse = new b2Vec3();
+      this.m_mass.Solve33(impulse, (-C1X), (-C1Y), (-C2));
+      bA.m_sweep.c.x -= mA * impulse.x;
+      bA.m_sweep.c.y -= mA * impulse.y;
+      bA.m_sweep.a -= iA * (rAX * impulse.y - rAY * impulse.x + impulse.z);
+      bB.m_sweep.c.x += mB * impulse.x;
+      bB.m_sweep.c.y += mB * impulse.y;
+      bB.m_sweep.a += iB * (rBX * impulse.y - rBY * impulse.x + impulse.z);
+      bA.SynchronizeTransform();
+      bB.SynchronizeTransform();
+      return positionError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop;
+   }
+   Box2D.inherit(b2WeldJointDef, Box2D.Dynamics.Joints.b2JointDef);
+   b2WeldJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype;
+   b2WeldJointDef.b2WeldJointDef = function () {
+      Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments);
+      this.localAnchorA = new b2Vec2();
+      this.localAnchorB = new b2Vec2();
+   };
+   b2WeldJointDef.prototype.b2WeldJointDef = function () {
+      this.__super.b2JointDef.call(this);
+      this.type = b2Joint.e_weldJoint;
+      this.referenceAngle = 0.0;
+   }
+   b2WeldJointDef.prototype.Initialize = function (bA, bB, anchor) {
+      this.bodyA = bA;
+      this.bodyB = bB;
+      this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchor));
+      this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchor));
+      this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle();
+   }
+})();
+(function () {
+   var b2DebugDraw = Box2D.Dynamics.b2DebugDraw;
+   b2DebugDraw.b2DebugDraw = function () {
+      this.m_drawScale = 1.0;
+      this.m_lineThickness = 1.0;
+      this.m_alpha = 1.0;
+      this.m_fillAlpha = 1.0;
+      this.m_xformScale = 1.0;
+      var __this = this;
+      //#WORKAROUND
+      this.m_sprite = {
+         graphics: {
+            clear: function () {
+               __this.m_ctx.clearRect(0, 0, __this.m_ctx.canvas.width, __this.m_ctx.canvas.height)
+            }
+         }
+      };
+   };
+   b2DebugDraw.prototype._color = function (color, alpha) {
+      return "rgba(" + ((color & 0xFF0000) >> 16) + "," + ((color & 0xFF00) >> 8) + "," + (color & 0xFF) + "," + alpha + ")";
+   };
+   b2DebugDraw.prototype.b2DebugDraw = function () {
+      this.m_drawFlags = 0;
+   };
+   b2DebugDraw.prototype.SetFlags = function (flags) {
+      if (flags === undefined) flags = 0;
+      this.m_drawFlags = flags;
+   };
+   b2DebugDraw.prototype.GetFlags = function () {
+      return this.m_drawFlags;
+   };
+   b2DebugDraw.prototype.AppendFlags = function (flags) {
+      if (flags === undefined) flags = 0;
+      this.m_drawFlags |= flags;
+   };
+   b2DebugDraw.prototype.ClearFlags = function (flags) {
+      if (flags === undefined) flags = 0;
+      this.m_drawFlags &= ~flags;
+   };
+   b2DebugDraw.prototype.SetSprite = function (sprite) {
+      this.m_ctx = sprite;
+   };
+   b2DebugDraw.prototype.GetSprite = function () {
+      return this.m_ctx;
+   };
+   b2DebugDraw.prototype.SetDrawScale = function (drawScale) {
+      if (drawScale === undefined) drawScale = 0;
+      this.m_drawScale = drawScale;
+   };
+   b2DebugDraw.prototype.GetDrawScale = function () {
+      return this.m_drawScale;
+   };
+   b2DebugDraw.prototype.SetLineThickness = function (lineThickness) {
+      if (lineThickness === undefined) lineThickness = 0;
+      this.m_lineThickness = lineThickness;
+      this.m_ctx.strokeWidth = lineThickness;
+   };
+   b2DebugDraw.prototype.GetLineThickness = function () {
+      return this.m_lineThickness;
+   };
+   b2DebugDraw.prototype.SetAlpha = function (alpha) {
+      if (alpha === undefined) alpha = 0;
+      this.m_alpha = alpha;
+   };
+   b2DebugDraw.prototype.GetAlpha = function () {
+      return this.m_alpha;
+   };
+   b2DebugDraw.prototype.SetFillAlpha = function (alpha) {
+      if (alpha === undefined) alpha = 0;
+      this.m_fillAlpha = alpha;
+   };
+   b2DebugDraw.prototype.GetFillAlpha = function () {
+      return this.m_fillAlpha;
+   };
+   b2DebugDraw.prototype.SetXFormScale = function (xformScale) {
+      if (xformScale === undefined) xformScale = 0;
+      this.m_xformScale = xformScale;
+   };
+   b2DebugDraw.prototype.GetXFormScale = function () {
+      return this.m_xformScale;
+   };
+   b2DebugDraw.prototype.DrawPolygon = function (vertices, vertexCount, color) {
+      if (!vertexCount) return;
+      var s = this.m_ctx;
+      var drawScale = this.m_drawScale;
+      s.beginPath();
+      s.strokeStyle = this._color(color.color, this.m_alpha);
+      s.moveTo(vertices[0].x * drawScale, vertices[0].y * drawScale);
+      for (var i = 1; i < vertexCount; i++) {
+         s.lineTo(vertices[i].x * drawScale, vertices[i].y * drawScale);
+      }
+      s.lineTo(vertices[0].x * drawScale, vertices[0].y * drawScale);
+      s.closePath();
+      s.stroke();
+   };
+   b2DebugDraw.prototype.DrawSolidPolygon = function (vertices, vertexCount, color) {
+      if (!vertexCount) return;
+      var s = this.m_ctx;
+      var drawScale = this.m_drawScale;
+      s.beginPath();
+      s.strokeStyle = this._color(color.color, this.m_alpha);
+      s.fillStyle = this._color(color.color, this.m_fillAlpha);
+      s.moveTo(vertices[0].x * drawScale, vertices[0].y * drawScale);
+      for (var i = 1; i < vertexCount; i++) {
+         s.lineTo(vertices[i].x * drawScale, vertices[i].y * drawScale);
+      }
+      s.lineTo(vertices[0].x * drawScale, vertices[0].y * drawScale);
+      s.closePath();
+      s.fill();
+      s.stroke();
+   };
+   b2DebugDraw.prototype.DrawCircle = function (center, radius, color) {
+      if (!radius) return;
+      var s = this.m_ctx;
+      var drawScale = this.m_drawScale;
+      s.beginPath();
+      s.strokeStyle = this._color(color.color, this.m_alpha);
+      s.arc(center.x * drawScale, center.y * drawScale, radius * drawScale, 0, Math.PI * 2, true);
+      s.closePath();
+      s.stroke();
+   };
+   b2DebugDraw.prototype.DrawSolidCircle = function (center, radius, axis, color) {
+      if (!radius) return;
+      var s = this.m_ctx,
+         drawScale = this.m_drawScale,
+         cx = center.x * drawScale,
+         cy = center.y * drawScale;
+      s.moveTo(0, 0);
+      s.beginPath();
+      s.strokeStyle = this._color(color.color, this.m_alpha);
+      s.fillStyle = this._color(color.color, this.m_fillAlpha);
+      s.arc(cx, cy, radius * drawScale, 0, Math.PI * 2, true);
+      s.moveTo(cx, cy);
+      s.lineTo((center.x + axis.x * radius) * drawScale, (center.y + axis.y * radius) * drawScale);
+      s.closePath();
+      s.fill();
+      s.stroke();
+   };
+   b2DebugDraw.prototype.DrawSegment = function (p1, p2, color) {
+      var s = this.m_ctx,
+         drawScale = this.m_drawScale;
+      s.strokeStyle = this._color(color.color, this.m_alpha);
+      s.beginPath();
+      s.moveTo(p1.x * drawScale, p1.y * drawScale);
+      s.lineTo(p2.x * drawScale, p2.y * drawScale);
+      s.closePath();
+      s.stroke();
+   };
+   b2DebugDraw.prototype.DrawTransform = function (xf) {
+      var s = this.m_ctx,
+         drawScale = this.m_drawScale;
+      s.beginPath();
+      s.strokeStyle = this._color(0xff0000, this.m_alpha);
+      s.moveTo(xf.position.x * drawScale, xf.position.y * drawScale);
+      s.lineTo((xf.position.x + this.m_xformScale * xf.R.col1.x) * drawScale, (xf.position.y + this.m_xformScale * xf.R.col1.y) * drawScale);
+
+      s.strokeStyle = this._color(0xff00, this.m_alpha);
+      s.moveTo(xf.position.x * drawScale, xf.position.y * drawScale);
+      s.lineTo((xf.position.x + this.m_xformScale * xf.R.col2.x) * drawScale, (xf.position.y + this.m_xformScale * xf.R.col2.y) * drawScale);
+      s.closePath();
+      s.stroke();
+   };
+})(); //post-definitions
+var i;
+for (i = 0; i < Box2D.postDefs.length; ++i) Box2D.postDefs[i]();
+delete Box2D.postDefs;

+ 133 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CBasket.js

@@ -0,0 +1,133 @@
+function CBasket(iX, iY, oParentContainer){
+    var _iActualTime = new Date().getTime();
+    
+    var _oPhysicBasket;
+    var _oPhysicsObject;
+    var _oBasketBack;
+    var _oBasketFront;
+    var _oBasketMultiplier;
+    
+    var _oParentContainer = oParentContainer;
+    
+    var _iMultiplier;
+    var _oSpriteHero;
+    var _oHero;
+    
+    var _oContainerPlayer;
+    var _iStartY;
+    var _iEndY;
+    
+    var _iX = iX;
+    var _iY = iY+8;
+    
+    var _oParent = this;
+    
+    this.init = function(){        
+        _oPhysicsObject = new CPhysicsObject();
+        
+        _oPhysicBasket = _oPhysicsObject.addPoligon(_iX, _iY, BASKET, 0);
+        
+        var oSprite = s_oSpriteLibrary.getSprite('basket_back');
+        _oBasketBack = createBitmap(oSprite);
+        _oBasketBack.x = _iX;
+        _oBasketBack.y = _iY;
+        _oBasketBack.regX = oSprite.width/2;
+        _oBasketBack.regY = oSprite.height;
+        _oParentContainer.addChild(_oBasketBack);
+        
+    };
+    
+    this.spawnFront = function(){
+        var oSprite = s_oSpriteLibrary.getSprite('basket_front');
+        _oBasketFront = createBitmap(oSprite);
+        _oBasketFront.x = _iX;
+        _oBasketFront.y = _iY;
+        _oBasketFront.regX = oSprite.width/2;
+        _oBasketFront.regY = oSprite.height;
+        _oParentContainer.addChild(_oBasketFront);
+    };
+    
+    this.spawnBasketMultiplier = function(iMultiplier){
+        var oSprite = s_oSpriteLibrary.getSprite('multiplier_'+iMultiplier);
+        _oBasketMultiplier = createBitmap(oSprite);
+        _oBasketMultiplier.x = _iX;
+        _oBasketMultiplier.y = _iY-8;
+        _oBasketMultiplier.regX = oSprite.width/2;
+        _oBasketMultiplier.regY = oSprite.width/2;
+        _oParentContainer.addChild(_oBasketMultiplier);
+    };
+
+    this.setMultiplier = function(iMultiplier, oContainerPlayerFaces){
+        _iMultiplier = iMultiplier;
+        
+        _oContainerPlayer = new createjs.Container();
+        _oParentContainer.addChild(_oContainerPlayer);
+        
+        switch(_iMultiplier){
+            case 25:
+                _oSpriteHero = s_oSpriteLibrary.getSprite('unhappy');
+                _iEndY = _iY-_oBasketBack.regY-100;
+                break;
+            case 50:
+                _oSpriteHero = s_oSpriteLibrary.getSprite('almost_happy');
+                _iEndY = _iY-_oBasketBack.regY-150;
+                break;
+            case 100:
+                _oSpriteHero = s_oSpriteLibrary.getSprite('happy');
+                _iEndY =  _iY-_oBasketBack.regY-200;
+                break;
+        }
+        _iStartY = _iY-_oBasketBack.regY-10;
+        
+        _oHero = createBitmap(_oSpriteHero);
+        _oHero.x = _iX-_oBasketBack.regX;
+        _oHero.y = _iStartY;
+        _oHero.visible = false;
+        oContainerPlayerFaces.addChild(_oHero);
+    };
+    
+    this.getMultiplier = function(){
+        return _iMultiplier;
+    };
+    
+    this.applyTremble = function(){        
+        var iNewTime = new Date().getTime();
+        if(iNewTime - _iActualTime > 500){
+            var iRotationRange = 3;
+            var iRotation = Math.round(Math.random()*iRotationRange)+1;
+            
+            createjs.Tween.get(_oBasketBack).to({ rotation: iRotation }, 100).call(function() {
+                createjs.Tween.get(_oBasketBack).to({ rotation: -iRotation }, 100).call(function() {
+                    createjs.Tween.get(_oBasketBack).to({ rotation: 0 }, 100).call(function() {
+                    });
+                });
+            });
+
+            createjs.Tween.get(_oBasketFront).to({ rotation: iRotation }, 100).call(function() {
+                createjs.Tween.get(_oBasketFront).to({ rotation: -iRotation }, 100).call(function() {
+                    createjs.Tween.get(_oBasketFront).to({ rotation: 0 }, 100).call(function() {
+                    });
+                });
+            });
+            _iActualTime = iNewTime;
+        }
+    };
+        
+    this.applyScaleMultiplier = function(){
+        createjs.Tween.get(_oBasketMultiplier).to({scaleX: 2, scaleY: 2 }, 200, createjs.Ease.cubicOut).call(function() {
+            createjs.Tween.get(_oBasketMultiplier).to({scaleX: 1, scaleY: 1 }, 200, createjs.Ease.cubicIn).call(function() {
+            });
+        });
+        this._playExultation();
+    };
+    
+    this._playExultation = function(){
+        
+        _oHero.visible = true;
+        createjs.Tween.get(_oHero).to({y: _iEndY},850, createjs.Ease.cubicOut).to({y: _iStartY},650, createjs.Ease.cubicIn).call(function(){_oHero.visible = false;});
+        
+    };
+    
+    this.init();
+    
+}

+ 123 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CConfirmPanel.js

@@ -0,0 +1,123 @@
+function CConfirmPanel(szText, iHelpType){
+    
+    var _iHelpType = iHelpType;
+    var _iTextY = -90;
+    var _iButtonY = 150;
+    
+    var _oParent = this;
+    
+    var _aCbCompleted = new Array();
+    var _aCbOwner = new Array();
+    var _aParams = new Array();
+    
+    var _oBg;
+    var _oContainer;
+    var _oContainerPos = {x: CANVAS_WIDTH/2, y: CANVAS_HEIGHT/2};
+
+    var _szText = szText;
+    var _oMsgText;
+    
+    var _oShape;
+    
+    var _oButNo;
+    var _oButYes;
+    
+    this._init = function(){
+        
+        if(iHelpType === CONFIRMATION_EXIT){
+            _iTextY = -20;
+            _iButtonY = 80;
+        }
+        
+        _oContainer = new createjs.Container();
+        _oContainer.x = _oContainerPos.x;
+        _oContainer.y = CANVAS_HEIGHT*1.5;
+                
+        _oShape = new createjs.Shape();
+        _oShape.graphics.beginFill("#000000").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
+        _oShape.alpha = 0.7;
+        _oShape.on("mousedown", this._onClick);
+        s_oStage.addChild(_oShape);
+        
+        var oSpriteBg = s_oSpriteLibrary.getSprite('msg_box');
+        _oBg = createBitmap(oSpriteBg);
+        _oBg.regX = oSpriteBg.width/2;
+        _oBg.regY = oSpriteBg.height/2;
+        _oContainer.addChild(_oBg);
+
+        _oMsgText = new createjs.Text(_szText," 30px "+FONT, "#000");
+        _oMsgText.x = 2;
+        _oMsgText.y = _iTextY+12;
+        _oMsgText.textAlign = "center";
+        _oMsgText.textBaseline = "alphabetic";
+        _oMsgText.lineWidth = 300;   
+        _oContainer.addChild(_oMsgText);
+
+        _oMsgText = new createjs.Text(_szText," 30px "+FONT, "#ffc949");
+        _oMsgText.x = 0;
+        _oMsgText.y = _iTextY+10;
+        _oMsgText.textAlign = "center";
+        _oMsgText.textBaseline = "alphabetic";
+        _oMsgText.lineWidth = 300;     
+        _oContainer.addChild(_oMsgText);
+
+        _oButNo = new CGfxButton(-50,_iButtonY,s_oSpriteLibrary.getSprite('but_exit'), _oContainer);
+        _oButNo.pulseAnimation();
+
+        _oButYes = new CGfxButton(50,_iButtonY,s_oSpriteLibrary.getSprite('but_next'), _oContainer);
+
+        
+        s_oStage.addChild(_oContainer);
+       
+        this.show();
+    };
+    
+    this._initListener = function(){
+        _oButNo.addEventListener(ON_MOUSE_DOWN, this.buttonNoDown, this);
+        _oButYes.addEventListener(ON_MOUSE_DOWN, this.buttonYesDown, this);
+    };
+    
+    this.addEventListener = function( iEvent, cbCompleted, cbOwner ){
+        _aCbCompleted[iEvent]=cbCompleted;
+        _aCbOwner[iEvent] = cbOwner; 
+    };
+    
+    this.buttonNoDown = function(){        
+        if(_aCbCompleted[ON_BUT_NO_DOWN]){
+            _aCbCompleted[ON_BUT_NO_DOWN].call(_aCbOwner[ON_BUT_NO_DOWN],_aParams);
+        }
+    };
+    
+    this.buttonYesDown = function(){        
+        if(_aCbCompleted[ON_BUT_YES_DOWN]){
+            _aCbCompleted[ON_BUT_YES_DOWN].call(_aCbOwner[ON_BUT_YES_DOWN],_aParams);
+        }
+    };
+    
+    this._onClick = function(){
+        
+    };
+    
+    this.show = function(){
+        createjs.Tween.get(_oContainer).to({y: _oContainerPos.y }, 500, createjs.Ease.quadOut).call(function() {_oParent._initListener();});
+    };
+            
+    this.unload = function(){        
+        createjs.Tween.get(_oContainer).to({y: CANVAS_HEIGHT*1.5 }, 500).call(function() {
+            s_oStage.removeChild(_oContainer);
+        });
+             
+        createjs.Tween.get(_oShape).to({alpha:0 }, 500).call(function() {
+            s_oStage.removeChild(_oShape);
+        });
+        
+    };
+    
+    this._init();
+    
+    s_oVariousHelp = this;
+            
+    return this;
+}
+
+var s_oVariousHelp = null;

+ 68 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CCreditsPanel.js

@@ -0,0 +1,68 @@
+function CCreditsPanel(){
+    
+    var _oBg;
+    var _oButLogo;
+    var _oButExit;
+    var _oMsgText;
+    
+    var _oHitArea;
+    
+    var _oLink;
+    
+    var _pStartPosExit;
+    
+    this._init = function(){
+        
+        _oHitArea = new createjs.Shape();
+        _oHitArea.graphics.beginFill("#000").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
+        _oHitArea.alpha = 0.7;
+        _oHitArea.on("click", this._onLogoButRelease);
+        s_oStage.addChild(_oHitArea);
+        
+        _oBg = createBitmap(s_oSpriteLibrary.getSprite('msg_box'));
+        s_oStage.addChild(_oBg);
+                
+        var oSprite = s_oSpriteLibrary.getSprite('but_exit');
+        _pStartPosExit = {x: CANVAS_WIDTH - (oSprite.height/2)- 110, y: 270};
+        _oButExit = new CGfxButton(_pStartPosExit.x, _pStartPosExit.y, oSprite, s_oStage);
+        _oButExit.addEventListener(ON_MOUSE_UP, this.unload, this);
+       
+        _oMsgText = new CFormatText(CANVAS_WIDTH/2, 430, TEXT_CREDITS_DEVELOPED, "#ffc949", s_oStage, "#000", 40);
+		
+        oSprite = s_oSpriteLibrary.getSprite('logo_credits');
+        _oButLogo = createBitmap(oSprite);
+        _oButLogo.regX = oSprite.width/2;
+        _oButLogo.regY = oSprite.height/2;
+        _oButLogo.x = CANVAS_WIDTH/2;
+        _oButLogo.y = 520;
+        s_oStage.addChild(_oButLogo);
+        
+        _oLink = new CFormatText(CANVAS_WIDTH/2, 600, "www.codethislab.com", "#ffc949", s_oStage, "#000", 30);
+       
+    };
+    
+    this.unload = function(){
+        _oHitArea.off("click", this._onLogoButRelease);
+        
+        _oButExit.unload(); 
+        _oButExit = null;
+        
+        _oMsgText.unload();
+        
+        _oLink.unload();
+
+        s_oStage.removeChild(_oBg);
+        s_oStage.removeChild(_oButLogo);
+        s_oStage.removeChild(_oHitArea);
+    };
+    
+    this._onLogoButRelease = function(){
+        window.open("http://www.codethislab.com/index.php?&l=en");
+    };
+    
+    this._init();
+    
+    
+};
+
+

+ 217 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CEndPanel.js

@@ -0,0 +1,217 @@
+function CEndPanel(oSpriteBg){
+    
+    var _iFrameRate = 1000/10;
+    var _iSetTimeout;
+    
+    var _oBg;
+    var _oGroup;
+    
+    var _oMsgTextStroke;
+    var _oMsgText;
+    var _oScoreTextStroke;
+    var _oScoreText;
+    var _oButRestart;
+    var _oButNextLevel;
+    var _oButHome;
+    var _oShape;
+
+    
+    var _aSpritesAnimation = new Array();
+    
+    var _oParent = this;
+    
+    this._init = function(oSpriteBg){
+        
+        _oBg = createBitmap(oSpriteBg);
+        _oBg.x = 0;
+        _oBg.y = 0;
+        
+        _oShape = new createjs.Shape();
+        _oShape.graphics.beginFill("#000000").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
+        _oShape.alpha = 0.7;
+        _oShape.on("mousedown", this._onClick);
+        s_oStage.addChild(_oShape);
+        
+        _oMsgTextStroke = new createjs.Text(""," 40px "+FONT, "#000");
+        _oMsgTextStroke.x = CANVAS_WIDTH/2+2;
+        _oMsgTextStroke.y = (CANVAS_HEIGHT/2)-48;
+        _oMsgTextStroke.textAlign = "center";
+        _oMsgTextStroke.textBaseline = "alphabetic";
+        _oMsgTextStroke.lineWidth = 400; 
+        
+        _oMsgText = new createjs.Text(""," 40px "+FONT, "#ffc949");
+        _oMsgText.x = CANVAS_WIDTH/2;
+        _oMsgText.y = (CANVAS_HEIGHT/2)-50;
+        _oMsgText.textAlign = "center";
+        _oMsgText.textBaseline = "alphabetic";
+        _oMsgText.lineWidth = 400;      
+        
+        _oScoreTextStroke = new createjs.Text(""," 30px "+FONT, "#000");
+        _oScoreTextStroke.x = CANVAS_WIDTH/2+2;
+        _oScoreTextStroke.y = (CANVAS_HEIGHT/2) + 84;
+        _oScoreTextStroke.textAlign = "center";
+        _oScoreTextStroke.textBaseline = "alphabetic";
+        _oScoreTextStroke.lineWidth = 400;
+        
+        _oScoreText = new createjs.Text(""," 30px "+FONT, "#ffc949");
+        _oScoreText.x = CANVAS_WIDTH/2;
+        _oScoreText.y = (CANVAS_HEIGHT/2) + 82;
+        _oScoreText.textAlign = "center";
+        _oScoreText.textBaseline = "alphabetic";
+        _oScoreText.lineWidth = 400;
+        
+        _oGroup = new createjs.Container();
+        _oGroup.y = CANVAS_HEIGHT;
+        _oGroup.visible=false;
+        
+        _oGroup.addChild( _oBg, _oScoreTextStroke, _oScoreText, _oMsgTextStroke, _oMsgText );
+
+        s_oStage.addChild(_oGroup);
+        for( var i=1; i < 87; i++){
+            _aSpritesAnimation.push(createBitmap(s_oSpriteLibrary.getSprite('msg_box_animation_'+i)));
+            s_oStage.addChild(_aSpritesAnimation[i-1]);
+            _aSpritesAnimation[i-1].visible = false;
+        }
+        
+        this.playAnimation(0);
+    };
+    
+    this.playAnimation = function(i){
+        if(i === 0){
+            _aSpritesAnimation[_aSpritesAnimation.length-1].visible = false;
+            _aSpritesAnimation[i].visible = true;
+        }
+        if(i > 0){
+            _aSpritesAnimation[i-1].visible = false;
+            _aSpritesAnimation[i].visible = true;
+        }
+        if(i < _aSpritesAnimation.length-1){
+            _iSetTimeout = setTimeout(function(){_oParent.playAnimation(i+1);},_iFrameRate); 
+        }else{
+            _iSetTimeout = setTimeout(function(){_oParent.playAnimation(0);},_iFrameRate); 
+        }
+    };
+    
+    this.unloadExit = function(){
+        _oButHome.unload();
+        _oButRestart.unload();
+        
+        clearTimeout(_iSetTimeout);
+    };
+    
+    this.unloadNextLevel = function(){
+        _oButHome.unload();
+        _oButRestart.unload();
+        _oButNextLevel.unload();
+        
+        clearTimeout(_iSetTimeout);
+    };
+    
+    this._initListener = function(){
+        _oButHome.addEventListener(ON_MOUSE_UP, this._onExit, this);
+        _oButRestart.addEventListener(ON_MOUSE_UP, this._onRestartExit, this);
+    };
+    
+    this._initListenerNextLevel = function(){
+        _oButHome.addEventListener(ON_MOUSE_UP, this._onExit, this);
+        _oButRestart.addEventListener(ON_MOUSE_UP, this._onRestartNextLevel, this);
+        _oButNextLevel.addEventListener(ON_MOUSE_UP, this._onNextLevel, this);
+    };
+    
+    this.show = function(iScore){
+        setVolume("soundtrack", 0);
+	playSound("game_over",1,false);
+        _oMsgTextStroke.text = TEXT_GAMEOVER;
+        _oMsgText.text = TEXT_GAMEOVER;
+        
+        _oScoreTextStroke.text = TEXT_SCORE + iScore;
+        _oScoreText.text = TEXT_SCORE + iScore;
+        
+        _oGroup.visible = true;
+        
+        _oButHome = new CGfxButton(CANVAS_WIDTH/2-40, CANVAS_HEIGHT/2+160, s_oSpriteLibrary.getSprite('but_home'), _oGroup);
+        
+        _oButRestart = new CGfxButton(CANVAS_WIDTH/2+45, CANVAS_HEIGHT/2+160, s_oSpriteLibrary.getSprite('but_restart'), _oGroup);
+        _oButRestart.pulseAnimation();
+                
+        createjs.Tween.get(_oGroup).to({ y: 0 }, 500, createjs.Ease.quadOut).call(function() {_oParent._initListener();});
+        
+        $(s_oMain).trigger("share_event",[iScore]);
+        $(s_oMain).trigger("save_score",[iScore]);
+    };
+    
+    this.nextLevel = function(iScore){
+        setVolume("soundtrack", 0);
+	playSound("next_level",1,false);
+        _oMsgTextStroke.text = TEXT_LEVEL_COMPLETED;
+        _oMsgText.text = TEXT_LEVEL_COMPLETED;
+        
+        _oScoreTextStroke.text = TEXT_SCORE + iScore;
+        _oScoreText.text = TEXT_SCORE + iScore;
+        
+        _oGroup.visible = true;
+        
+        _oButHome = new CGfxButton(CANVAS_WIDTH/2-80, CANVAS_HEIGHT/2+160, s_oSpriteLibrary.getSprite('but_home'), _oGroup);
+        
+        _oButRestart = new CGfxButton(CANVAS_WIDTH/2, CANVAS_HEIGHT/2+160, s_oSpriteLibrary.getSprite('but_restart'), _oGroup);
+        
+        _oButNextLevel = new CGfxButton(CANVAS_WIDTH/2+75, CANVAS_HEIGHT/2+160, s_oSpriteLibrary.getSprite('but_next'), _oGroup);
+        _oButNextLevel.pulseAnimation();
+        
+        createjs.Tween.get(_oGroup).to({ y: 0 }, 500, createjs.Ease.quadOut).call(function() {_oParent._initListenerNextLevel();});
+        
+        $(s_oMain).trigger("share_event",[iScore]);
+        $(s_oMain).trigger("save_score",[iScore]);
+    };
+    
+    this._onExit = function(){
+        _oParent.unloadExit();
+
+        s_oStage.removeChild(_oShape);
+        s_oStage.removeChild(_oGroup);
+        
+        s_oGame.onExit();
+        
+        stopSound("next_level");
+        stopSound("game_over");
+    };
+    
+    this._onNextLevel = function(){
+        _oParent.unloadNextLevel();
+
+        s_oStage.removeChild(_oGroup);
+        
+        s_oGame.onNextLevel();
+        $(s_oMain).trigger("show_interlevel_ad");
+    };
+    
+    this._onRestartExit = function(){
+        _oParent.unloadExit();
+
+        s_oStage.removeChild(_oGroup);
+        
+        s_oGame.onRestart();
+        
+        stopSound("next_level");
+        stopSound("game_over");
+    };
+    
+    this._onClick = function(){
+        
+    };
+    
+    this._onRestartNextLevel = function(){
+        _oParent.unloadNextLevel();
+
+        s_oStage.removeChild(_oGroup);
+        
+        s_oGame.onRestart();
+        
+        stopSound("next_level");
+        stopSound("game_over");
+    };
+    
+    this._init(oSpriteBg);
+    
+    return this;
+}

+ 143 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CFormatText.js

@@ -0,0 +1,143 @@
+function CFormatText (iX, iY, szText, szColor, oParentContainer, szGlow, iSize){
+    
+    var _szText;
+    
+    var _oTextOutline;
+    var _oText;
+    var _oTextContainer;
+    
+    var _oSlideText;
+    
+    var _oParent;
+    
+    this._init = function(iX, iY, szText, szColor, oParentContainer, szGlow, iSize){    
+        
+        _szText = szText;
+        
+        _oTextContainer = new createjs.Container();
+        _oTextContainer.x = iX;
+        _oTextContainer.y = iY;
+        oParentContainer.addChild(_oTextContainer);
+        
+        var iDim = iSize;
+        
+        var szFontTag = iDim + "px";
+
+        _oTextOutline = new createjs.Text();
+        _oTextOutline.text = _szText;
+        _oTextOutline.font = szFontTag+ " "+ FONT;
+        _oTextOutline.color = szGlow;
+        _oTextOutline.textAlign = "center";
+        _oTextOutline.textBaseline = "middle";
+        _oTextOutline.lineWidth = 600;
+        _oTextOutline.outline = 2;
+        _oTextContainer.addChild(_oTextOutline);
+
+        _oText = new createjs.Text();
+        _oText.text = _szText;
+        _oText.font = szFontTag+" " + FONT;
+        _oText.color = szColor;
+        _oText.textAlign = "center";
+        _oText.textBaseline = "middle";
+        _oText.lineWidth = 600;
+        _oTextContainer.addChild(_oText);
+       
+    };
+ 
+    this.unload = function(){
+        oParentContainer.removeChild(_oTextContainer);
+    };
+
+    this.disableOutline = function(){
+        _oTextContainer.removeChild(_oTextOutline);
+    };
+    
+    this.setVisible = function(bVal){
+        _oTextContainer.visible = bVal;
+    };
+    
+    this.isVisible = function(){
+        return _oTextContainer.visible;
+    };
+
+    this.setOutline = function(iVal){
+        _oTextOutline.outline = iVal;
+    };
+
+    this.setShadow = function(bVal){
+        if(!bVal){
+            _oTextOutline.shadow = null;
+        } else {
+            _oTextOutline.shadow = new createjs.Shadow("#333333", 2, 2, 6);
+        }
+    };
+
+    this.setAlign = function(szType){
+        _oTextOutline.textAlign = szType;
+        _oText.textAlign = szType;
+    };
+
+    this.setWidth = function(iWidth){
+        _oTextOutline.lineWidth = iWidth;
+        _oText.lineWidth = iWidth;
+    };
+
+    this.setText = function(szText){
+        _oText.text = szText;
+        _oTextOutline.text = szText;
+    };
+
+    this.setColor= function(szColor, szColorOutline){
+        _oText.color = szColor;
+        _oTextOutline.color = szColorOutline;
+    };
+
+    this.setFont = function(szFont){
+        var szFontTag = iSize + "px";
+        
+        _oText.font = szFontTag+ " "+ szFont;
+        _oTextOutline.font = szFontTag+ " "+ szFont;
+        
+    };
+
+    this.getText = function(){
+        return _oTextContainer;
+    };
+    
+    this.setPos = function(iY){
+        _oTextContainer.y = iY;
+    };
+    
+    this.getPos = function(){
+        return {x: _oTextContainer.x,  y: _oTextContainer.y};
+    };
+    
+    this.playText = function(){      
+        
+        _oSlideText = "";
+        
+        this.setText("");
+        this._slideText(0);
+        
+    };
+    
+    this._slideText = function(iIndex){
+        
+        _oSlideText += szText[iIndex];
+        
+        this.setText(_oSlideText);
+        if(iIndex < szText.length-1){
+            setTimeout(function(){_oParent._slideText(iIndex+1);}, 40);
+        }  
+    };
+    
+    this.setPosition = function(iXPos,iYPos){
+         _oTextContainer.x = iXPos;
+         _oTextContainer.y = iYPos;
+    };
+    
+    _oParent = this;
+    
+    this._init(iX, iY, szText, szColor, oParentContainer, szGlow, iSize);
+    
+}

+ 555 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CGame.js

@@ -0,0 +1,555 @@
+function CGame(oData, iLevel){
+    var _iTotalScore = 0;
+    var _iActualScore = 0;
+    var _iScoreInLevel = 0;
+    var _iLevel = iLevel;
+    var _iPlayerLeft = 0;
+    var _iLastCursorXPosition = 0;
+    var _iObjectsToPick = 0;
+    var _iObjectsPicked = 0;
+    
+    var _oInterface;
+    var _oEndPanel = null;
+    var _oParent   = this;
+    
+    var _oShapeKeyListener;
+    var _oPlayer;
+    var _oCurtain;
+    var _oCurtainBG;
+    
+    var _oGameContainer;
+    var _oContainerPlayer;
+    var _oContainerPlayerFaces;
+    
+    var _bUpdate       = false;
+    var _bClicked      = false;
+    var _bGameOver     = false;
+    var _bHaveTakenAll = false;
+    
+    var _aDirectionRevoluteRectangle             = new Array();          //true: right
+    var _aDirectionRectangle                     = new Array();          //false: left
+    var _aXStartRectangleMoving                  = new Array();
+    var _aXStartRevoluteRectangleMoving          = new Array();
+    var _aHalfSpriteWidthRectangleMoving         = new Array();
+    var _aHalfSpriteWidthRevoluteRectangleMoving = new Array();
+    
+    var _aWall                          = new Array();
+    var _aCircle                        = new Array();
+    var _aBallSprite                    = new Array();
+    var _aRectangle                     = new Array();
+    var _aRectangleMoving               = new Array();
+    var _aRevoluteRectangle             = new Array();
+    var _aRevoluteRectangleMoving       = new Array();
+    var _aRectangleMovingSprite         = new Array();
+    var _aRevoluteRectangleSprite       = new Array();
+    var _aRevoluteRectangleMovingSprite = new Array();
+    var _aBasket                        = new Array();
+    var _aObjectToPick                  = new Array();
+    
+    var _aLevelInfo;
+    
+    var _oPhysicsObject;
+    
+    //INIT
+    this._init = function(){
+        for(var i=0; i < s_aScores.length; i++){
+            if(i !== _iLevel){
+                _iTotalScore += s_aScores[i];
+            }
+        }
+
+        $(s_oMain).trigger("start_level", _iLevel);
+        setVolume("soundtrack", 1);
+        
+        _oGameContainer = new createjs.Container();
+        s_oStage.addChild(_oGameContainer);
+        
+        _oCurtainBG = createBitmap(s_oSpriteLibrary.getSprite('curtain_bg'));
+        _oCurtainBG.alpha = 0;
+        s_oStage.addChild(_oCurtainBG);
+        _oCurtain = createBitmap(s_oSpriteLibrary.getSprite('curtain'));
+        _oCurtain.y = CANVAS_HEIGHT;
+        s_oStage.addChild(_oCurtain);
+
+        createjs.Tween.get(_oCurtain).to({y: 0},1000, createjs.Ease.backOut).wait(400).call(function(){
+            _oParent._levelInit();
+            createjs.Tween.get(_oCurtain).to({y: CANVAS_HEIGHT},500, createjs.Ease.backIn).call(function(){
+                _oParent._removeCurtain();
+            });
+        });
+
+        createjs.Tween.get(_oCurtainBG).to({alpha: 1},1000, createjs.Ease.backOut).wait(400).call(function(){
+            createjs.Tween.get(_oCurtainBG).to({alpha: 0},500, createjs.Ease.backIn).call(function(){
+            });
+        });
+
+    };
+    
+    this._levelInit = function(){
+        
+        var oBg = createBitmap(s_oSpriteLibrary.getSprite('bg_game'));
+        _oGameContainer.addChild(oBg); //Draws on canvas
+        
+        s_oPhysicsController = new CPhysicsController();
+        
+        _oPhysicsObject = new CPhysicsObject();
+        
+        _aLevelInfo = LEVELS;
+        _iPlayerLeft = _aLevelInfo[_iLevel].num_balls;
+        _iObjectsToPick = _aLevelInfo[_iLevel].objects_to_pick_to_win;
+        
+        for(var i=0; i < _aLevelInfo[_iLevel].objects.length; i++){
+            var oObject = _aLevelInfo[_iLevel].objects[i];
+            switch(oObject.type){
+                case WALL:
+                    this._createParticleWall(oObject.x, oObject.y, oObject.wall_type, oObject.angle, oObject.density, oObject.friction, oObject.restitution);
+                    break;
+                case CIRCLE:
+                    this._createCircle(s_oSpriteLibrary.getSprite('ball_'+oObject.sprite), oObject.x, oObject.y, oObject.density, oObject.friction, oObject.restitution, false);
+                    break;
+                case RECTANGLE:
+                    this._createRectangle(s_oSpriteLibrary.getSprite('rectangle_'+oObject.sprite),  oObject.x, oObject.y, oObject.angle, oObject.density, oObject.friction, oObject.restitution);
+                    if(oObject.sprite === 0){
+                        this._createCircle(s_oSpriteLibrary.getSprite('rectangle_'+oObject.sprite), oObject.x, oObject.y, oObject.density, oObject.friction, oObject.restitution, true);
+                    }
+                    break;
+                case RECTANGLE_MOVING:
+                    this._createMovingRectangle(s_oSpriteLibrary.getSprite('rectangle_'+oObject.sprite),  oObject.x, oObject.y, oObject.angle, oObject.density, oObject.friction, oObject.restitution);
+                    break;
+                case REVOLUTE_RECTANGLE:
+                    this._createRevoluteRectangle(s_oSpriteLibrary.getSprite('revolute_rectangle_'+oObject.sprite),  oObject.x, oObject.y, oObject.density, oObject.friction, oObject.restitution);
+                    break;
+                case REVOLUTE_RECTANGLE_MOVING:
+                    this._createMovingRevoluteRectangle(s_oSpriteLibrary.getSprite('revolute_rectangle_'+oObject.sprite),  oObject.x, oObject.y, oObject.density, oObject.friction, oObject.restitution);
+                    break;
+            }
+        }
+        
+        var iDensity = 3;
+        var iFriction = 10;
+        var iRestitution = 0.3;
+        
+        this._spawnWall(-77, CANVAS_HEIGHT/2, 0, iDensity, iFriction, iRestitution );                    //left
+        this._spawnWall(CANVAS_WIDTH+77, CANVAS_HEIGHT/2, 0,iDensity, iFriction, iRestitution );         //right
+        this._spawnWall(CANVAS_WIDTH/2, CANVAS_HEIGHT-28, 90, iDensity, iFriction, iRestitution );       //bottom
+        
+        this._spawnObjectsToPick(_aLevelInfo[_iLevel].objectsToPick);
+        
+        this._spawnBasketsBack();
+        
+        _oContainerPlayer = new createjs.Container();
+        _oGameContainer.addChild(_oContainerPlayer);
+        
+        _oPlayer = new CPlayer(s_oSpriteLibrary.getSprite('player'), 300, 250, iDensity, iFriction, iRestitution, _oContainerPlayer, _oPhysicsObject );
+        
+        _oContainerPlayerFaces = new createjs.Container();
+        _oGameContainer.addChild(_oContainerPlayerFaces);
+        
+        this._spawnBasketsFront();
+        
+        _oInterface = new CInterface(_iObjectsToPick, _iTotalScore, _iPlayerLeft, _iLevel+1, _oGameContainer);
+        
+        _oShapeKeyListener = new createjs.Shape();
+        _oShapeKeyListener.graphics.beginFill("White").drawRect(0,160,CANVAS_WIDTH,CANVAS_HEIGHT-160);
+        _oShapeKeyListener.alpha = 0.01;
+        _oGameContainer.addChild(_oShapeKeyListener);
+        
+        s_oStage.on("stagemousemove", this._movingMouse);
+        setTimeout(function(){_oShapeKeyListener.on("pressup", _oParent._onClick);},200);
+        _bUpdate = true;
+    };
+    
+    this._removeCurtain = function(){
+        s_oStage.removeChild(_oCurtain);
+        s_oStage.removeChild(_oCurtainBG);
+    };
+    
+    this._movingMouse = function(evt){
+        _iLastCursorXPosition = evt.stageX/s_iScaleFactor;
+        if(_bClicked){
+            return;
+        }
+        if(_iLastCursorXPosition > 35 && _iLastCursorXPosition < CANVAS_WIDTH-35){
+            _oPlayer.movePlayer(evt.stageX/s_iScaleFactor);
+        }
+    };
+    
+    this._onClick = function(evt){
+        if(_bClicked){
+            return;
+        }
+        _iLastCursorXPosition = evt.stageX/s_iScaleFactor;
+        _oPlayer.movePlayer(evt.stageX/s_iScaleFactor);
+        
+        _oPlayer.activatePlayer();
+        _bClicked = true;
+    };
+    
+    this._spawnWall = function(iX, iY, iAngle, iDensity, iFriction, iRestitution){
+        //OBJECT WITH PHYSICS
+        var oSprite = s_oSpriteLibrary.getSprite('wall');
+        _aWall.push(_oPhysicsObject.addWall(oSprite.width/2, oSprite.height/2, iX, iY, iAngle, iDensity, iFriction, iRestitution)); 
+        
+        //VISIBLE OBJECT
+        var oWallSprite = createBitmap(oSprite);
+        oWallSprite.x = iX;
+        oWallSprite.y = iY;
+        oWallSprite.rotation = iAngle;
+        oWallSprite.regX = oSprite.width/2;
+        oWallSprite.regY = oSprite.height/2;
+        _oGameContainer.addChild(oWallSprite); //Draws on canvas
+    };
+    
+    this._spawnBasketsBack = function(){
+        var iX = BASKETS_X_START;
+        var iY = BASKET_Y;
+        for(var i = 0; i < 5; i++){
+            _aBasket.push(new CBasket(iX, iY, _oGameContainer));
+            iX += DISTANCE_BEETWEEN_BASKETS;
+        }
+    };
+    
+    this._spawnBasketsFront = function(){
+        for(var i = 0; i < 5; i++){
+            _aBasket[i].spawnFront();
+            var iMultiplier = 0;
+            if(i === 0 || i === 4){
+                iMultiplier = 25;
+            }else if( i === 1 || i === 3){
+                iMultiplier = 50;
+            }else{
+                iMultiplier = 100;
+            }
+            _aBasket[i].setMultiplier(iMultiplier, _oContainerPlayerFaces);
+            _aBasket[i].spawnBasketMultiplier(iMultiplier);
+        }
+    };
+        
+    this._spawnObjectsToPick = function(aObjectsToPick){
+        for(var i=0; i < aObjectsToPick.length; i++){
+            _aObjectToPick.push(new CObjectToPick(aObjectsToPick[i].x, aObjectsToPick[i].y, aObjectsToPick[i].type, _oGameContainer));
+        }
+    };
+    
+    this._createCircle = function(oSprite, iX, iY, iDensity, iFriction, iRestitution, bIsRectangle){
+        //OBJECT WITH PHYSICS
+        if(!bIsRectangle){
+            _aCircle.push(_oPhysicsObject.addStaticCircle(oSprite.width/2, iX, iY, iDensity, iFriction, iRestitution)); 
+            var oInfos = s_oPhysicsController.getElementPosition(_aCircle[_aCircle.length-1]);
+        }else{
+            _aCircle.push(_oPhysicsObject.addStaticCircle(oSprite.height/2, iX, iY-oSprite.width/2, iDensity, iFriction, iRestitution)); 
+            var oInfos = s_oPhysicsController.getElementPosition(_aCircle[_aCircle.length-1]);
+        }
+        //VISIBLE OBJECT
+        if(!bIsRectangle){
+            _aBallSprite.push(createBitmap(oSprite));
+            this.addObjectToStage(_aBallSprite, _aBallSprite.length-1, oInfos, oSprite);
+        }
+    };
+    
+    this._createRectangle = function(oSprite, iX, iY, iAngle, iDensity, iFriction, iRestitution){
+        //OBJECT WITH PHYSICS
+        _aRectangle.push(_oPhysicsObject.addRectangle(oSprite.width/2, oSprite.height/2, iX, iY, iAngle, iDensity, iFriction, iRestitution));  
+        var oInfos = s_oPhysicsController.getElementPosition(_aRectangle[_aRectangle.length-1]);
+        
+        //VISIBLE OBJECT
+        var oRectangleSprite = createBitmap(oSprite);
+        oRectangleSprite.x = oInfos.x;
+        oRectangleSprite.y = oInfos.y;
+        oRectangleSprite.rotation = oInfos.angle;
+        oRectangleSprite.regX = oSprite.width/2;
+        oRectangleSprite.regY = oSprite.height/2;
+        _oGameContainer.addChild(oRectangleSprite); //Draws on canvas
+    };
+    
+    this._createMovingRectangle = function(oSprite, iX, iY, iDensity, iFriction, iRestitution){
+        //OBJECT WITH PHYSICS
+        _aRectangleMoving.push(_oPhysicsObject.addRectangle( oSprite.width/2, oSprite.height/2, iX, iY, iDensity, iFriction, iRestitution));  
+        var oInfos = s_oPhysicsController.getElementPosition(_aRectangleMoving[_aRectangleMoving.length-1]);
+        
+        _aHalfSpriteWidthRectangleMoving.push(oSprite.width/2);
+        _aXStartRectangleMoving.push(oInfos.x);
+        _aDirectionRectangle.push(false);
+        
+        var iValue = Math.round(Math.random());
+        if(iValue === 1){
+            _aDirectionRectangle.push(true);
+        }else{
+            _aDirectionRectangle.push(false);
+        }
+        
+        //VISIBLE OBJECT
+        _aRectangleMovingSprite.push(createBitmap(oSprite));
+        this.addObjectToStage(_aRectangleMovingSprite, _aRectangleMovingSprite.length-1, oInfos, oSprite);
+    };
+    
+    this._createRevoluteRectangle = function(oSprite, iX, iY, iDensity, iFriction, iRestitution){
+        //OBJECT WITH PHYSICS
+        _aRevoluteRectangle.push(_oPhysicsObject.addRevoluteRectangle(oSprite.width/2, oSprite.height/2, iX, iY, iDensity, iFriction, iRestitution, false));  
+        var oInfos = s_oPhysicsController.getElementPosition(_aRevoluteRectangle[_aRevoluteRectangle.length-1].fixture1);
+        
+        //VISIBLE OBJECT
+        _aRevoluteRectangleSprite.push(createBitmap(oSprite));
+        this.addObjectToStage(_aRevoluteRectangleSprite, _aRevoluteRectangleSprite.length-1, oInfos, oSprite);
+    };
+    
+    this._createMovingRevoluteRectangle = function(oSprite, iX, iY, iDensity, iFriction, iRestitution){
+        //OBJECT WITH PHYSICS
+        _aRevoluteRectangleMoving.push(_oPhysicsObject.addRevoluteRectangle( oSprite.width/2, oSprite.height/2, iX, iY, iDensity, iFriction, iRestitution, true));  
+        var oInfos = s_oPhysicsController.getElementPosition(_aRevoluteRectangleMoving[_aRevoluteRectangleMoving.length-1].fixture2);
+        
+        _aHalfSpriteWidthRevoluteRectangleMoving.push(oSprite.width/2);
+        _aXStartRevoluteRectangleMoving.push(oInfos.x);
+        var iValue = Math.round(Math.random());
+        if(iValue === 1){
+            _aDirectionRevoluteRectangle.push(true);
+        }else{
+            _aDirectionRevoluteRectangle.push(false);
+        }
+        //VISIBLE OBJECT
+        _aRevoluteRectangleMovingSprite.push(createBitmap(oSprite));
+        this.addObjectToStage(_aRevoluteRectangleMovingSprite, _aRevoluteRectangleMovingSprite.length-1, oInfos, oSprite);
+    };
+    
+    this.addObjectToStage = function(aArraySelected, iArrayPosition, oInfos, oSprite){
+        aArraySelected[iArrayPosition].x = oInfos.x;
+        aArraySelected[iArrayPosition].y = oInfos.y;
+        aArraySelected[iArrayPosition].rotation = oInfos.angle;
+        aArraySelected[iArrayPosition].regX = oSprite.width/2;
+        aArraySelected[iArrayPosition].regY = oSprite.height/2;
+        _oGameContainer.addChild(aArraySelected[iArrayPosition]); //Draws on canvas
+    };
+    
+    this.removeObject = function(i){
+        
+        if(i < _aObjectToPick.length-1){
+            _aObjectToPick.splice(i, 1);
+        }else{
+            _aObjectToPick.pop();
+        }
+        
+        if(_iObjectsToPick <= _iObjectsPicked){
+            _bHaveTakenAll = true;
+        }
+    };
+    
+    
+    this.moveBasket = function(){
+        var oSprite = s_oSpriteLibrary.getSprite('basket_front');
+        var oPlayerX = _oPlayer.getX();
+        for( var i = 0; i <= 5; i++){
+            if(oPlayerX < (BASKETS_X_START+(i*DISTANCE_BEETWEEN_BASKETS))+oSprite.width/2 && oPlayerX > (BASKETS_X_START+(i*DISTANCE_BEETWEEN_BASKETS))-oSprite.width/2 ){
+                _aBasket[i].applyTremble();
+                i = 10;
+            }
+        }
+    };
+    
+    this.checkInWichBasketBallHasFallen = function(){
+        var oSprite = s_oSpriteLibrary.getSprite('basket_front');
+        var oPlayerX = _oPlayer.getX();
+        for( var i = 0; i <= 5; i++){
+            if(oPlayerX < (BASKETS_X_START+(i*DISTANCE_BEETWEEN_BASKETS))+oSprite.width/2 && oPlayerX > (BASKETS_X_START+(i*DISTANCE_BEETWEEN_BASKETS))-oSprite.width/2 ){
+                _aBasket[i].applyScaleMultiplier();
+                var iAmount = _iActualScore * _aBasket[i].getMultiplier();
+                _iScoreInLevel += iAmount;
+                _oInterface.refreshScore(iAmount);
+                _iActualScore = 0;
+                return;
+            }   
+        }
+    };
+    
+    this._checkIfPlayerHasStopped = function(){
+        if(_oPlayer.checkIfPlayerHasStopped(_bClicked)){
+            _oPlayer.unload();
+            if(_iPlayerLeft > 0){
+                _iPlayerLeft--;
+            }
+            _oInterface.refrashNumPlayerLeft(_iPlayerLeft);
+            if(!_bGameOver){
+                this.checkInWichBasketBallHasFallen();
+            }
+            
+            if(_iPlayerLeft > 0){
+                _oPlayer = new CPlayer(s_oSpriteLibrary.getSprite('player'), _iLastCursorXPosition, 250, 3.0, 1, 0.5, _oContainerPlayer, _oPhysicsObject);
+                _bClicked = false;
+            }else if(!_bGameOver){
+                if(_bHaveTakenAll){
+                    setTimeout(function(){_oParent.allObjectsTaken();}, 500);
+                    _bGameOver = true;
+                }else{
+                    setTimeout(function(){_oParent.gameOver();},500);
+					submitScore('0');
+                    _bGameOver = true;
+                }
+            }
+        }
+    };
+    
+    this._checkIfPlayerHasCollidedWithObjectToPick = function(){
+        var oPlayerRectangle = _oPlayer.getRectangle();
+        
+        for(var i=0; i < _aObjectToPick.length; i++){
+            if(_aObjectToPick[i].checkIfPlayerHasCollided(oPlayerRectangle)){
+                _iObjectsPicked++;
+                _iActualScore += 1;
+                _aObjectToPick[i].addEventListenerWithParams(ON_TWEEN_ENDED, this.refreshScoreInfos, this, _iObjectsPicked);
+                _aObjectToPick[i].moveToGUI(_oInterface.getTargetY());
+                this.removeObject(i);
+                i = _aObjectToPick.length;
+                playSound("pick_object",1,false);
+            }
+        }
+    };
+    
+    this.refreshScoreInfos = function(iObjectsPicked){
+        _oInterface.refreshGoal(iObjectsPicked, _iObjectsToPick);
+        _oInterface.applyScaleToTarget(iObjectsPicked, _iObjectsToPick);
+    };
+    
+    this._moveRectangle = function(){
+        //let the revolute rectangles rotate and move.
+        for(var i=0; i < _aRectangleMoving.length; i++){
+            var oInfos = s_oPhysicsController.getElementPosition(_aRectangleMoving[i]);
+            _aRectangleMovingSprite[i].x = oInfos.x;
+            var iNewX = 0;
+            
+            if(_aDirectionRectangle[i]){
+                iNewX = oInfos.x+1;
+                if(oInfos.x > _aXStartRectangleMoving[i]+_aHalfSpriteWidthRectangleMoving[i]){
+                    _aDirectionRectangle[i] = false;
+                }
+            }else{
+                iNewX = oInfos.x-1;
+                if(oInfos.x < _aXStartRectangleMoving[i]-_aHalfSpriteWidthRectangleMoving[i]){
+                    _aDirectionRectangle[i] = true;
+                }
+            }
+            s_oPhysicsController.moveObject(_aRectangleMoving[i], iNewX, oInfos.y);
+        }
+    };
+    
+    this._rotateRevoluteRectangle = function(){
+        //let the revolute rectangles rotate.
+        for(var i=0; i < _aRevoluteRectangle.length; i++){
+            var iAngle = s_oPhysicsController.getElementAngle(_aRevoluteRectangle[i].fixture1);
+            _aRevoluteRectangleSprite[i].rotation = iAngle;
+            s_oPhysicsController.decreaseSpeedRotation(_aRevoluteRectangle[i].fixture1);
+        }
+    };
+    
+    this._moveRevoluteRectangle = function(){
+        //let the revolute rectangles rotate and move.
+        for(var i=0; i < _aRevoluteRectangleMoving.length; i++){
+            var oInfos = s_oPhysicsController.getElementPosition(_aRevoluteRectangleMoving[i].fixture2);
+            var iAngle = s_oPhysicsController.getElementAngle(_aRevoluteRectangleMoving[i].fixture1);
+            _aRevoluteRectangleMovingSprite[i].x = oInfos.x;
+            _aRevoluteRectangleMovingSprite[i].rotation = iAngle;
+            var iNewX = 0;
+            
+            if(_aDirectionRevoluteRectangle[i]){
+                iNewX = oInfos.x+1;
+                if(oInfos.x > _aXStartRevoluteRectangleMoving[i]+_aHalfSpriteWidthRevoluteRectangleMoving[i]){
+                    _aDirectionRevoluteRectangle[i] = false;
+                }
+            }else{
+                iNewX = oInfos.x-1;
+                if(oInfos.x < _aXStartRevoluteRectangleMoving[i]-_aHalfSpriteWidthRevoluteRectangleMoving[i]){
+                    _aDirectionRevoluteRectangle[i] = true;
+                }
+            }
+            if(s_oPhysicsController.getSpeedRotation(_aRevoluteRectangleMoving[i].fixture1) > 3){
+                s_oPhysicsController.decreaseSpeedRotation(_aRevoluteRectangleMoving[i].fixture1);
+            }
+            s_oPhysicsController.moveObject(_aRevoluteRectangleMoving[i].fixture2, iNewX, oInfos.y);
+        }
+    };
+    
+    this.unload = function(){
+        _oInterface.unload();
+        
+        createjs.Tween.removeAllTweens();
+        s_oStage.removeAllChildren(); 
+    };
+ 
+    this.onExit = function(){
+		console.log("onExit");
+        this.unload();
+        s_oMain.gotoMenu();
+        
+        $(s_oMain).trigger("end_level", _iLevel);
+        $(s_oMain).trigger("show_interlevel_ad");
+        $(s_oMain).trigger("end_session");
+		submitScore('0');
+    };
+ 
+    this.onRestart = function(){
+        this.unload();
+        
+        $(s_oMain).trigger("restart_level", _iLevel);
+        
+        s_oMain.gotoGame(_iLevel);
+    };
+    
+    this.gameOver = function(){  
+        _oEndPanel = CEndPanel(s_oSpriteLibrary.getSprite('msg_box_game_over'));
+        _oEndPanel.show(_iTotalScore+_iScoreInLevel);
+    };
+    
+    this.allObjectsTaken = function(){
+        //s_iLevelReached = _iLevel+2;
+        //_oEndPanel = CEndPanel(s_oSpriteLibrary.getSprite('msg_box'));
+        //_oEndPanel.nextLevel(_iTotalScore+_iScoreInLevel);
+        //if(_iScoreInLevel > s_aScores[iLevel]){
+        //    s_aScores[iLevel] = _iScoreInLevel;
+        //}
+        //
+        //localStorage.setItem("LevelReached", s_iLevelReached);
+        //localStorage.setItem("Scores",  JSON.stringify(s_aScores));
+        console.log("Submit score");
+		submitScore('40');
+    };
+    
+    this.onNextLevel = function(){
+		console.log("Next level");
+        this.unload();
+        if(_iLevel+1 < _aLevelInfo.length){
+            s_oMain.gotoGame(_iLevel+1);
+        }else{
+            s_oMain.gotoMenu();
+        }
+    };
+    
+    //UPDATE
+    this.update = function(){
+        if(!_bUpdate){
+            return;
+        }
+        _oPlayer.refreshPosition();
+
+        this._checkIfPlayerHasCollidedWithObjectToPick();
+
+        this._checkIfPlayerHasStopped();
+
+        this._rotateRevoluteRectangle();
+
+        this._moveRevoluteRectangle();
+
+        this._moveRectangle();
+        
+        s_oPhysicsController.update();
+        
+        s_oRollingTextManager.update();
+    };
+
+    s_oGame=this;
+    
+    LEVELS = oData.levels;
+    
+    _oParent=this;
+    
+    this._init();
+}
+
+var s_oGame;

+ 140 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CGfxButton.js

@@ -0,0 +1,140 @@
+function CGfxButton(iXPos,iYPos,oSprite,oParentContainer){
+    
+    var _iScale;
+    
+    var _oParentContainer = oParentContainer;
+    
+    var _aCbCompleted;
+    var _aCbOwner;
+    var _aParams = [];
+    var _oButton;
+    
+    var _oTween = null;
+    var _oParent = this;
+    
+    this._init =function(iXPos,iYPos,oSprite){
+        _iScale = 1;
+        
+        _aCbCompleted=new Array();
+        _aCbOwner =new Array();
+        
+        _oButton = createBitmap( oSprite);
+        _oButton.x = iXPos;
+        _oButton.y = iYPos; 
+                                   
+        _oButton.regX = oSprite.width/2;
+        _oButton.regY = oSprite.height/2;
+        _oButton.cursor = "pointer";
+       
+        if(!_oParentContainer){
+            _oParentContainer = s_oStage;
+        }
+        
+        _oParentContainer.addChild(_oButton);
+        
+        this._initListener();
+    };
+    
+    this.unload = function(){
+        _oButton.off("mousedown", this.buttonDown);
+        _oButton.off("pressup" , this.buttonRelease); 
+       
+        if(_oTween){
+            createjs.Tween.removeTweens(_oTween);
+        }
+        _oParentContainer.removeChild(_oButton);
+    };
+    
+    this.setVisible = function(bVisible){
+        _oButton.visible = bVisible;
+    };
+    
+    this._initListener = function(){
+       _oButton.on("mousedown", this.buttonDown);
+       _oButton.on("pressup" , this.buttonRelease);      
+    };
+    
+    this.addEventListener = function( iEvent,cbCompleted, cbOwner ){
+        _aCbCompleted[iEvent]=cbCompleted;
+        _aCbOwner[iEvent] = cbOwner; 
+    };
+    
+    this.addEventListenerWithParams = function(iEvent,cbCompleted, cbOwner,aParams){
+        _aCbCompleted[iEvent]=cbCompleted;
+        _aCbOwner[iEvent] = cbOwner;
+        _aParams = aParams;
+    };
+    
+    this.buttonRelease = function(){
+        _oButton.scaleX = _iScale;
+        _oButton.scaleY = _iScale;
+        
+        playSound("click",1,false);
+        
+        if(_aCbCompleted[ON_MOUSE_UP]){
+            _aCbCompleted[ON_MOUSE_UP].call(_aCbOwner[ON_MOUSE_UP],_aParams);
+        }
+    };
+    
+    this.buttonDown = function(){
+        _oButton.scaleX = _iScale*0.9;
+        _oButton.scaleY = _iScale*0.9;
+        
+        
+        
+        if(_aCbCompleted[ON_MOUSE_DOWN]){
+            _aCbCompleted[ON_MOUSE_DOWN].call(_aCbOwner[ON_MOUSE_DOWN],_aParams);
+        }
+    };
+    
+    this.setScale = function(iValue){
+        _iScale = iValue;
+        _oButton.scaleX = iValue;
+        _oButton.scaleY = iValue;
+    };
+    
+    this.setPosition = function(iXPos,iYPos){
+        _oButton.x = iXPos;
+        _oButton.y = iYPos;
+    };
+    
+    this.moveInPosition = function(iXPos,iYPos){
+        createjs.Tween.get(_oButton).to({x: iXPos, y: iYPos},1000, createjs.Ease.quadOut).call(function(){});
+    };
+    
+    this.setX = function(iXPos){
+         _oButton.x = iXPos;
+    };
+    
+    this.setY = function(iYPos){
+         _oButton.y = iYPos;
+    };
+    
+    this.getButtonImage = function(){
+        return _oButton;
+    };
+    
+    this.pulseAnimation = function(){
+        _oTween = createjs.Tween.get(_oButton).to({scaleX: _iScale*0.9, scaleY: _iScale*0.9},850, createjs.Ease.quadOut).to({scaleX: _iScale, scaleY: _iScale},650, createjs.Ease.quadIn).call(function(){
+            _oParent.pulseAnimation();
+        });
+    };
+            
+    this.trebleAnimation = function(){
+        _oTween = createjs.Tween.get(_oButton).to({rotation: 5},75, createjs.Ease.quadOut).to({rotation: -5},140, createjs.Ease.quadIn).to({rotation: 0},75, createjs.Ease.quadIn).wait(750).call(function(){
+            _oParent.trebleAnimation();
+        });
+    };
+    
+    this.getX = function(){
+        return _oButton.x;
+    };
+    
+    this.getY = function(){
+        return _oButton.y;
+    };
+
+    this._init(iXPos,iYPos,oSprite);
+    
+    return this;
+}

+ 152 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CHelp.js

@@ -0,0 +1,152 @@
+function CHelp(){
+    
+    var _oParent = this;
+    
+    var _oBg;
+    var _oGroup1;
+    
+    var _oButPlay;
+    
+    var _oCursorMovingContainer;
+    var _oTargetContainer;
+
+    var _oMsgTextOutline;
+    var _oMsgText;
+    var _oMsgTextReleaseOutline;
+    var _oMsgTextRelease;
+    
+    this._init = function(){
+        _oBg = createBitmap(s_oSpriteLibrary.getSprite('bg_menu'));
+        s_oStage.addChild(_oBg);
+        
+        var oShape = new createjs.Shape();
+        oShape.graphics.beginFill("#000000").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
+        oShape.alpha = 0.7;
+        s_oStage.addChild(oShape);
+        
+        _oGroup1 = new createjs.Container();
+        _oGroup1.y = CANVAS_WIDTH;
+        _oGroup1.alpha = 0;
+        
+        _oBg = createBitmap(s_oSpriteLibrary.getSprite('msg_box'));
+        _oGroup1.addChild(_oBg);
+                
+        _oMsgTextOutline = new createjs.Text(""," 25px "+FONT, "#000");
+        _oMsgTextOutline.x = CANVAS_WIDTH/2+2;
+        _oMsgTextOutline.y = (CANVAS_HEIGHT/2)-113;
+        _oMsgTextOutline.textAlign = "center";
+        _oMsgTextOutline.textBaseline = "alphabetic";
+        _oMsgTextOutline.lineWidth = 400;     
+        _oGroup1.addChild(_oMsgTextOutline);
+                
+        _oMsgText = new createjs.Text(""," 25px "+FONT, "#ffc949");
+        _oMsgText.x = CANVAS_WIDTH/2;
+        _oMsgText.y = (CANVAS_HEIGHT/2)-115;
+        _oMsgText.textAlign = "center";
+        _oMsgText.textBaseline = "alphabetic";
+        _oMsgText.lineWidth = 400;     
+        _oGroup1.addChild(_oMsgText);
+                
+        _oMsgTextReleaseOutline = new createjs.Text(""," 25px "+FONT, "#000");
+        _oMsgTextReleaseOutline.x = CANVAS_WIDTH/2+2;
+        _oMsgTextReleaseOutline.y = (CANVAS_HEIGHT/2)+52;
+        _oMsgTextReleaseOutline.textAlign = "center";
+        _oMsgTextReleaseOutline.textBaseline = "alphabetic";
+        _oMsgTextReleaseOutline.lineWidth = 400;     
+        _oGroup1.addChild(_oMsgTextReleaseOutline);
+                
+        _oMsgTextRelease = new createjs.Text(""," 25px "+FONT, "#ffc949");
+        _oMsgTextRelease.x = CANVAS_WIDTH/2;
+        _oMsgTextRelease.y = (CANVAS_HEIGHT/2)+50;
+        _oMsgTextRelease.textAlign = "center";
+        _oMsgTextRelease.textBaseline = "alphabetic";
+        _oMsgTextRelease.lineWidth = 400;     
+        _oGroup1.addChild(_oMsgTextRelease);
+        
+        _oCursorMovingContainer = new createjs.Container();
+        _oCursorMovingContainer.x = 150;
+        _oCursorMovingContainer.y = 440;
+        _oGroup1.addChild(_oCursorMovingContainer);
+        
+        var oPlayer = createBitmap(s_oSpriteLibrary.getSprite('player'));
+        _oCursorMovingContainer.addChild(oPlayer);
+        
+        var oCursor = createBitmap(s_oSpriteLibrary.getSprite('cursor_help'));
+        oCursor.x = 8;
+        oCursor.y = 20;
+        _oCursorMovingContainer.addChild(oCursor);
+        
+        _oTargetContainer = new createjs.Container();
+        _oTargetContainer.x = 250;
+        _oTargetContainer.y = 600;
+        _oGroup1.addChild(_oTargetContainer);
+        
+        var oTargetSprite = createBitmap(s_oSpriteLibrary.getSprite('target'));
+        oTargetSprite.scaleX = oTargetSprite.scaleY = 0.6;
+        _oTargetContainer.addChild(oTargetSprite); //Draws on canvas
+        
+        var oGoalTextStroke = new createjs.Text("12/30"," 25px "+FONT, "#000");
+        oGoalTextStroke.x = 35+2;
+        oGoalTextStroke.y = 25;
+        oGoalTextStroke.textAlign = "left";
+        oGoalTextStroke.textBaseline = "alphabetic";
+        oGoalTextStroke.lineWidth = 650;
+        _oTargetContainer.addChild(oGoalTextStroke); //Draws on canvas
+        
+        var oGoalText = new createjs.Text("12/30"," 25px "+FONT, "#ffc949");
+        oGoalText.x = 35;
+        oGoalText.y = 23;
+        oGoalText.textAlign = "left";
+        oGoalText.textBaseline = "alphabetic";
+        oGoalText.lineWidth = 650;
+        _oTargetContainer.addChild(oGoalText); //Draws on canvas
+        
+        s_oStage.addChild(_oGroup1);
+        
+        _oButPlay = createBitmap(s_oSpriteLibrary.getSprite('but_next'));
+        _oButPlay.x = CANVAS_WIDTH/2-45;
+        _oButPlay.y = CANVAS_HEIGHT/2+190;
+        _oButPlay.cursor = "pointer";
+        _oGroup1.addChild(_oButPlay);
+        
+        this.show();
+        this.startCursorAnimationRight();
+    };
+        
+    this._initListener = function(){
+        _oButPlay.addEventListener("click",this._onExit);
+    };
+        
+    this.show = function(){
+        _oMsgTextOutline.text = TEXT_HELP_PANEL_MOVE;
+        _oMsgText.text = TEXT_HELP_PANEL_MOVE;
+        _oMsgTextReleaseOutline.text = TEXT_HELP_PANEL_RELEASE;
+        _oMsgTextRelease.text = TEXT_HELP_PANEL_RELEASE;
+        
+        createjs.Tween.get(_oGroup1).to({alpha:1 }, 500).call(function() {_oParent._initListener();});
+        createjs.Tween.get(_oGroup1).to({y: 0 }, 500, createjs.Ease.quadOut).call(function() {});
+    };
+    
+    this.startCursorAnimationRight = function(){
+        createjs.Tween.get(_oCursorMovingContainer).to({ x: 450 }, 2000).call(function() {_oParent.startCursorAnimationLeft();});
+    };
+    
+    this.startCursorAnimationLeft = function(){
+        createjs.Tween.get(_oCursorMovingContainer).to({ x: 150 }, 2000).call(function() {_oParent.startCursorAnimationRight();});
+    };
+    
+    this._onExit = function(){
+        _oParent.unload();
+        s_oMain.gotoGame(0);
+    };
+    
+    this.unload = function(){
+        createjs.Tween.removeAllTweens();
+        s_oStage.removeAllChildren();
+        
+    };
+    
+    this._init();
+    
+    return this;
+}

+ 303 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CInterface.js

@@ -0,0 +1,303 @@
+function CInterface(iGoal, iScore, iPlayerLeft, iLevel, oParentContainer){
+    var _oAudioToggle;
+    var _oButExit;
+    var _oButRestart;
+    var _oButFullscreen;
+    var _fRequestFullScreen = null;
+    var _fCancelFullScreen = null;
+    
+    var _oConfirmPanel = null;
+    
+    var _bTargetSprinteInAnimation = false;
+    
+    var _oParentcontainer = oParentContainer;
+    
+    var _pStartPosExit;
+    var _pStartPosAudio;
+    var _pStartPosRestart;
+    var _pStartPosFullscreen;
+    
+    var _oTargetSprite;
+    var _oTargetSpritePos        = {x: CANVAS_WIDTH/2-263, y: 42};
+    var _oGoalText;
+    var _oGoalTextStroke;
+    var _oGoalPos                = {x: CANVAS_WIDTH/2-240, y: 50};
+    var _oScoreText;
+    var _oScoreTextStroke;
+    var _oScorePos               = {x: CANVAS_WIDTH-300, y: CANVAS_HEIGHT-8};
+    var _oNumScoreText;
+    var _oNumScoreTextStroke;
+    var _oNumScorePos            = {x: CANVAS_WIDTH-150, y: CANVAS_HEIGHT-8};
+    var _oPlayerSprite;
+    var _oPlayerSpritePos        = {x: CANVAS_WIDTH/2-280, y: 75};
+    var _oPlayerLeftText;
+    var _oPlayerLeftTextStroke;
+    var _oPlayerLeftPos          = {x: CANVAS_WIDTH/2-240, y: 100};
+    var _oLevelText;
+    var _oLevelTextStroke;
+    var _oLevelPos               = {x: 60, y: CANVAS_HEIGHT-8};
+    
+    this._init = function(iGoal, iScore, iPlayerLeft, iLevel){    
+        var oSprite = s_oSpriteLibrary.getSprite('but_exit');
+        _pStartPosExit = {x: CANVAS_WIDTH - (oSprite.width/2)- 10, y: (oSprite.height/2) + 10};
+        _oButExit = new CGfxButton(_pStartPosExit.x, _pStartPosExit.y, oSprite, _oParentcontainer);
+        _oButExit.addEventListener(ON_MOUSE_UP, this._showConfirmPanelOnExit, this);
+        
+        var oSprite = s_oSpriteLibrary.getSprite('but_restart');
+        _pStartPosRestart = {x:_pStartPosExit.x-oSprite.width - 10,y:_pStartPosExit.y};
+        _oButRestart = new CGfxButton(_pStartPosRestart.x, _pStartPosRestart.y, oSprite, _oParentcontainer);
+        _oButRestart.addEventListener(ON_MOUSE_UP, this._showConfirmPanelOnRestart, this);
+        
+        
+        
+        if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
+            var oSprite = s_oSpriteLibrary.getSprite('audio_icon');
+            _pStartPosAudio = {x: _pStartPosExit.x - oSprite.width/2 - 10, y: _pStartPosRestart.y};
+            _oAudioToggle = new CToggle(_pStartPosAudio.x,_pStartPosAudio.y,oSprite,s_bAudioActive, _oParentcontainer);
+            _oAudioToggle.addEventListener(ON_MOUSE_UP, this._onAudioToggle, this);    
+            
+            oSprite = s_oSpriteLibrary.getSprite('but_fullscreen');
+            _pStartPosFullscreen = {x:_pStartPosAudio.x - oSprite.width/2 - 10,y:oSprite.height/2 + 10};
+        }else{
+            oSprite = s_oSpriteLibrary.getSprite('but_fullscreen');
+            _pStartPosFullscreen = {x: _pStartPosExit.x - oSprite.width/2 - 10, y: _pStartPosRestart.y};
+        }
+        
+        var doc = window.document;
+        var docEl = doc.documentElement;
+        _fRequestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;
+        _fCancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen;
+        
+        if(ENABLE_FULLSCREEN === false){
+            _fRequestFullScreen = false;
+        }
+        
+        if (_fRequestFullScreen && screenfull.enabled){
+            _oButFullscreen = new CToggle(_pStartPosFullscreen.x, _pStartPosFullscreen.y, oSprite, s_bFullscreen, _oParentcontainer);
+            _oButFullscreen.addEventListener(ON_MOUSE_UP, this._onFullscreenRelease, this);
+        }
+        
+        var oSprite = s_oSpriteLibrary.getSprite('target');
+        _oTargetSprite = createBitmap(oSprite);
+        _oTargetSprite.x = _oTargetSpritePos.x;
+        _oTargetSprite.y = _oTargetSpritePos.y;
+        _oTargetSprite.regX = oSprite.width/2;
+        _oTargetSprite.regY = oSprite.height/2;
+        _oTargetSprite.scaleX = _oTargetSprite.scaleY = 0.5;
+        _oParentcontainer.addChild(_oTargetSprite); //Draws on canvas
+        
+        _oGoalTextStroke = new createjs.Text("0/"+iGoal," 30px "+FONT, "#000");
+        _oGoalTextStroke.x = _oGoalPos.x+2;
+        _oGoalTextStroke.y = _oGoalPos.y;
+        _oGoalTextStroke.textAlign = "left";
+        _oGoalTextStroke.textBaseline = "alphabetic";
+        _oGoalTextStroke.lineWidth = 650;
+        _oParentcontainer.addChild(_oGoalTextStroke); //Draws on canvas
+        
+        _oGoalText = new createjs.Text("0/"+iGoal," 30px "+FONT, "#ffc949");
+        _oGoalText.x = _oGoalPos.x;
+        _oGoalText.y = _oGoalPos.y;
+        _oGoalText.textAlign = "left";
+        _oGoalText.textBaseline = "alphabetic";
+        _oGoalText.lineWidth = 650;
+        _oParentcontainer.addChild(_oGoalText); //Draws on canvas
+        
+        _oScoreTextStroke = new createjs.Text("SCORE: "," 25px "+FONT, "#000");
+        _oScoreTextStroke.x = _oScorePos.x+2;
+        _oScoreTextStroke.y = _oScorePos.y+2;
+        _oScoreTextStroke.textAlign = "left";
+        _oScoreTextStroke.textBaseline = "alphabetic";
+        _oScoreTextStroke.lineWidth = 650;
+        _oParentcontainer.addChild(_oScoreTextStroke); //Draws on canvas
+        
+        _oScoreText = new createjs.Text("SCORE: "," 25px "+FONT, "#ffc949");
+        _oScoreText.x = _oScorePos.x;
+        _oScoreText.y = _oScorePos.y;
+        _oScoreText.textAlign = "left";
+        _oScoreText.textBaseline = "alphabetic";
+        _oScoreText.lineWidth = 650;
+        _oParentcontainer.addChild(_oScoreText); //Draws on canvas
+        
+        _oNumScoreTextStroke = new createjs.Text(iScore," 25px "+FONT, "#000");
+        _oNumScoreTextStroke.x = _oNumScorePos.x+2;
+        _oNumScoreTextStroke.y = _oNumScorePos.y+2;
+        _oNumScoreTextStroke.textAlign = "left";
+        _oNumScoreTextStroke.textBaseline = "alphabetic";
+        _oNumScoreTextStroke.lineWidth = 650;
+        _oParentcontainer.addChild(_oNumScoreTextStroke); //Draws on canvas
+        
+        _oNumScoreText = new createjs.Text(iScore," 25px "+FONT, "#ffc949");
+        _oNumScoreText.x = _oNumScorePos.x;
+        _oNumScoreText.y = _oNumScorePos.y;
+        _oNumScoreText.textAlign = "left";
+        _oNumScoreText.textBaseline = "alphabetic";
+        _oNumScoreText.lineWidth = 650;
+        _oParentcontainer.addChild(_oNumScoreText); //Draws on canvas
+        
+        _oPlayerSprite = createBitmap(s_oSpriteLibrary.getSprite('player'));
+        _oPlayerSprite.x = _oPlayerSpritePos.x;
+        _oPlayerSprite.y = _oPlayerSpritePos.y;
+        _oParentcontainer.addChild(_oPlayerSprite); //Draws on canvas
+        
+        _oPlayerLeftTextStroke = new createjs.Text("x"+iPlayerLeft," 30px "+FONT, "#000");
+        _oPlayerLeftTextStroke.x = _oPlayerLeftPos.x+2;
+        _oPlayerLeftTextStroke.y = _oPlayerLeftPos.y;
+        _oPlayerLeftTextStroke.textAlign = "left";
+        _oPlayerLeftTextStroke.textBaseline = "alphabetic";
+        _oPlayerLeftTextStroke.lineWidth = 650;
+        _oParentcontainer.addChild(_oPlayerLeftTextStroke); //Draws on canvas
+        
+        _oPlayerLeftText = new createjs.Text("x"+iPlayerLeft," 30px "+FONT, "#ffc949");
+        _oPlayerLeftText.x = _oPlayerLeftPos.x;
+        _oPlayerLeftText.y = _oPlayerLeftPos.y;
+        _oPlayerLeftText.textAlign = "left";
+        _oPlayerLeftText.textBaseline = "alphabetic";
+        _oPlayerLeftText.lineWidth = 650;
+        _oParentcontainer.addChild(_oPlayerLeftText); //Draws on canvas
+        
+        _oLevelTextStroke = new createjs.Text("Level: "+iLevel," 25px "+FONT, "#000");
+        _oLevelTextStroke.x = _oLevelPos.x+2;
+        _oLevelTextStroke.y = _oLevelPos.y+2;
+        _oLevelTextStroke.textAlign = "left";
+        _oLevelTextStroke.textBaseline = "alphabetic";
+        _oLevelTextStroke.lineWidth = 650;
+        _oParentcontainer.addChild(_oLevelTextStroke); //Draws on canvas
+        
+        _oLevelText = new createjs.Text("Level: "+iLevel," 25px "+FONT, "#ffc949");
+        _oLevelText.x = _oLevelPos.x;
+        _oLevelText.y = _oLevelPos.y;
+        _oLevelText.textAlign = "left";
+        _oLevelText.textBaseline = "alphabetic";
+        _oLevelText.lineWidth = 650;
+        _oParentcontainer.addChild(_oLevelText); //Draws on canvas
+        
+        this.refreshButtonPos(s_iOffsetX,s_iOffsetY);
+    };
+    
+    this.unload = function(){
+        if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
+            _oAudioToggle.unload();
+            _oAudioToggle = null;
+        }
+        
+        if (_fRequestFullScreen && screenfull.enabled){
+            _oButFullscreen.unload();
+        }
+        
+        _oButExit.unload();
+        _oButRestart.unload();
+        
+        s_oInterface = null;
+    };
+    
+    this.applyScaleToTarget = function(){
+        if(_bTargetSprinteInAnimation){
+            return;
+        }
+        _bTargetSprinteInAnimation = true;
+        createjs.Tween.get(_oTargetSprite).to({ scaleX: 0.9, scaleY: 0.9}, 200).call(function() {
+            createjs.Tween.get(_oTargetSprite).to({ scaleX: 0.5, scaleY: 0.5 }, 200).call(function() {
+                _bTargetSprinteInAnimation = false;
+            });
+        });
+    };
+    
+    this.refreshButtonPos = function(iNewX,iNewY){
+        _oButExit.setPosition(_pStartPosExit.x - iNewX,iNewY + _pStartPosExit.y);
+        _oButRestart.setPosition(_pStartPosRestart.x - iNewX,iNewY + _pStartPosRestart.y)
+        if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
+            _oAudioToggle.setPosition(_pStartPosAudio.x - iNewX,iNewY + _pStartPosAudio.y);
+        }    
+        
+        if (_fRequestFullScreen && screenfull.enabled){
+            _oButFullscreen.setPosition(_pStartPosFullscreen.x - iNewX,_pStartPosFullscreen.y + iNewY);
+        }
+        
+        _oTargetSprite.y = _oTargetSpritePos.y+iNewY;
+        _oGoalTextStroke.y = _oGoalPos.y+iNewY;
+        _oGoalText.y = _oGoalPos.y+iNewY;
+        _oScoreTextStroke.y = _oScorePos.y-iNewY;
+        _oScoreText.y = _oScorePos.y-iNewY;
+        _oNumScoreTextStroke.y = _oNumScorePos.y-iNewY;
+        _oNumScoreText.y = _oNumScorePos.y-iNewY;
+        _oPlayerSprite.y = _oPlayerSpritePos.y+iNewY;
+        _oPlayerLeftTextStroke.y = _oPlayerLeftPos.y+iNewY;
+        _oPlayerLeftText.y = _oPlayerLeftPos.y+iNewY;
+        _oLevelTextStroke.y = _oLevelPos.y-iNewY;
+        _oLevelText.y = _oLevelPos.y-iNewY;
+        
+        
+    };
+
+    this.refreshGoal = function(iObjectPicked, iGoal){
+        _oGoalTextStroke.text = iObjectPicked+"/"+iGoal;
+        _oGoalText.text = iObjectPicked+"/"+iGoal;
+    };
+
+    this.refreshScore = function(iScore){
+        s_oRollingTextManager.add(_oNumScoreText,_oNumScoreTextStroke,iScore,1000,EASE_CUBIC_IN,null);
+    };
+
+    this.refrashNumPlayerLeft = function(iPlayerLeft){
+        _oPlayerLeftTextStroke.text = "x"+iPlayerLeft;
+        _oPlayerLeftText.text = "x"+iPlayerLeft;
+    };
+    
+    this._onAudioToggle = function(){
+        Howler.mute(s_bAudioActive);
+        s_bAudioActive = !s_bAudioActive;
+    };
+    
+    this._showConfirmPanelOnExit = function(){
+        _oConfirmPanel = new CConfirmPanel(TEXT_EXIT, CONFIRMATION_EXIT);
+        _oConfirmPanel.addEventListener(ON_BUT_NO_DOWN, this._onUnloadPanel, this);
+        _oConfirmPanel.addEventListener(ON_BUT_YES_DOWN, this._onExit, this);
+    };
+    
+    this._showConfirmPanelOnRestart = function(){
+        _oConfirmPanel = new CConfirmPanel(TEXT_EXIT, CONFIRMATION_EXIT);
+        _oConfirmPanel.addEventListener(ON_BUT_NO_DOWN, this._onUnloadPanel, this);
+        _oConfirmPanel.addEventListener(ON_BUT_YES_DOWN, this._onRestart, this);
+    };
+    
+    this.getTargetY = function(){
+        return _oTargetSprite.y;
+    };
+    
+    this._onUnloadPanel = function(){
+        _oConfirmPanel.unload(); 
+        _oConfirmPanel = null;
+    };
+    
+    this._onExit = function(){
+        s_oGame.onExit();  
+    };
+    
+    this._onRestart = function(){
+        s_oGame.onRestart();  
+    };
+    
+    this.resetFullscreenBut = function(){
+	if (_fRequestFullScreen && screenfull.enabled){
+		_oButFullscreen.setActive(s_bFullscreen);
+	}
+    };
+    
+    this._onFullscreenRelease = function(){
+        if(s_bFullscreen) { 
+		_fCancelFullScreen.call(window.document);
+	}else{
+		_fRequestFullScreen.call(window.document.documentElement);
+	}
+	
+	sizeHandler();
+    };
+    
+    s_oInterface = this;
+    
+    this._init(iGoal, iScore, iPlayerLeft, iLevel);
+    
+    return this;
+}
+
+var s_oInterface = null;

+ 23 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CLang.js

@@ -0,0 +1,23 @@
+TEXT_LEVEL = "SELECT LEVEL";
+
+TEXT_RESET = "ARE YOU SURE? ALL YOUR PREVIOUS SCORES WILL BE DELETED!";
+TEXT_EXIT = "ARE YOU SURE?";
+
+TEXT_CREDITS_DEVELOPED = "Developed by";
+
+TEXT_GAMEOVER  = "GAME OVER";
+TEXT_SCORE     = "YOUR SCORE IS: ";
+TEXT_PAUSE      = "PAUSE";
+
+TEXT_HELP_PANEL_MOVE    = "MOVE YOUR SQUIRREL ON THE LEFT OR THE RIGHT OF THE SCREEN";
+TEXT_HELP_PANEL_RELEASE = "THEN DROP IT TO COLLECT AS MANY POINTS AND ACORNS TO REACH THE TARGET";
+
+TEXT_LEVEL_COMPLETED = "LEVEL COMPLETED!";
+var TEXT_ERR_LS             = "YOUR WEB BROWSER DOES NOT SUPPORT STORING SETTING LOCALLY. IN SAFARI, THE MOST COMMON CAUSE OF THIS IS USING 'PRIVATE BROWSING MODE'. SOME INFO MAY NOT SAVE OR SOME FEATURE MAY NOT WORK PROPERLY.";
+
+TEXT_SHARE_IMAGE = "200x200.jpg";
+TEXT_SHARE_TITLE = "Congratulations!";
+TEXT_SHARE_MSG1 = "You collected <strong>";
+TEXT_SHARE_MSG2 = " points</strong>!<br><br>Share your score with your friends!";
+TEXT_SHARE_SHARE1 = "My score is ";
+TEXT_SHARE_SHARE2 = " points! Can you do better?";

+ 149 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CLevelBut.js

@@ -0,0 +1,149 @@
+function CLevelBut(iXPos, iYPos, oSprite, bActive, Level, oParentContainer){
+    
+    var _bActive;
+    var _aCbCompleted;
+    var _aCbOwner;
+    var _aButton = new Array();
+    var _aParams = [];
+    var _oButton;
+    
+    var _oParentcontainer = oParentContainer;
+    
+    var _oTween;
+    var _iScale = 1;
+    
+    this._init = function(iXPos,iYPos,oSprite,bActive){
+        _aCbCompleted=new Array();
+        _aCbOwner =new Array();
+        if(bActive){
+            var iWidth = oSprite.width/2-5;
+        }else{
+            var iWidth = oSprite.width/2;
+        }
+        var oData = {   
+                        images: [oSprite], 
+                        // width, height & registration point of each sprite
+                        frames: {width: iWidth, height: oSprite.height, regX: (oSprite.width/2)/2, regY: oSprite.height/2}, 
+                        animations: {state_true:[0],state_false:[1]}
+                   };
+                   
+        var oSpriteSheet = new createjs.SpriteSheet(oData);
+         
+        _bActive = bActive;
+        _oButton = createSprite(oSpriteSheet, "state_"+_bActive,(oSprite.width/2)/2,oSprite.height/2,oSprite.width/2,oSprite.height);
+         
+        _oButton.mouseEnabled = bActive;
+        _oButton.x = iXPos;
+        _oButton.y = iYPos; 
+        _oButton.cursor = "pointer";
+        _oButton.stop();
+        
+        _oParentcontainer.addChild(_oButton);
+        _aButton.push(_oButton);
+        
+        var _oLevelText = new createjs.Text(Level,"30px "+FONT, "#000000");
+        _oLevelText.x = iXPos-3;
+        _oLevelText.y = iYPos+7;
+        _oLevelText.textAlign = "center";
+        _oLevelText.textBaseline = "alphabetic";
+        _oLevelText.lineWidth = 200;
+        _oParentcontainer.addChild(_oLevelText);
+        
+        _oLevelText = new createjs.Text(Level,"30px "+FONT, "#f6de9b");
+        _oLevelText.x = iXPos-5;
+        _oLevelText.y = iYPos+5;
+        _oLevelText.textAlign = "center";
+        _oLevelText.textBaseline = "alphabetic";
+        _oLevelText.lineWidth = 200;
+        _oParentcontainer.addChild(_oLevelText);
+        
+        this._initListener();
+    };
+    
+    this.unload = function(){
+       _oButton.off("mousedown", this.buttonDown);
+       _oButton.off("pressup" , this.buttonRelease);
+       
+        if(_oTween){
+            createjs.Tween.removeTweens(_oTween);
+        }
+       _oParentcontainer.removeChild(_oButton);
+    };
+    
+    this._initListener = function(){
+       _oButton.on("mousedown", this.buttonDown);
+       _oButton.on("pressup" , this.buttonRelease);      
+    };
+    
+    this.viewBut = function(oButton){
+        _oParentcontainer.addChild(oButton);
+    };
+    
+    this.addEventListener = function( iEvent,cbCompleted, cbOwner ){
+        _aCbCompleted[iEvent]=cbCompleted;
+        _aCbOwner[iEvent] = cbOwner; 
+    };
+    
+    this.addEventListenerWithParams = function(iEvent,cbCompleted, cbOwner,aParams){
+        _aCbCompleted[iEvent]=cbCompleted;
+        _aCbOwner[iEvent] = cbOwner;
+        _aParams = aParams;
+    };
+    
+    this.pulseAnimation = function(){
+        _oTween = createjs.Tween.get(_oButton).to({scaleX: _iScale*0.9, scaleY: _iScale*0.9},850, createjs.Ease.quadOut).to({scaleX: _iScale, scaleY: _iScale},650, createjs.Ease.quadIn).call(function(){
+            _oParent.pulseAnimation();
+        });
+    };
+    
+    this.ifClickable = function(){
+        if(_oButton.mouseEnabled === true){
+            return 1;
+        }
+        return 0;
+    };
+    
+    this.setActive = function(iLevel, bActive){
+        _bActive = bActive;
+        _aButton[iLevel].gotoAndStop("state_"+_bActive);
+        _aButton[iLevel].mouseEnabled = true;
+    };
+    
+    this.buttonRelease = function(){
+        _oButton.scaleX = 1;
+        _oButton.scaleY = 1;
+        
+        
+        playSound("click",1,false);
+        
+        
+        _bActive = !_bActive;
+        _oButton.gotoAndStop("state_"+_bActive);
+
+        if(_aCbCompleted[ON_MOUSE_UP]){
+            _aCbCompleted[ON_MOUSE_UP].call(_aCbOwner[ON_MOUSE_UP],_aParams);
+        }
+    };
+    
+    this.buttonDown = function(){
+        _oButton.scaleX = 0.9;
+        _oButton.scaleY = 0.9;
+
+       if(_aCbCompleted[ON_MOUSE_DOWN]){
+           _aCbCompleted[ON_MOUSE_DOWN].call(_aCbOwner[ON_MOUSE_DOWN],_aParams);
+       }
+    };
+    
+    this.setPosition = function(iXPos,iYPos){
+         _oButton.x = iXPos;
+         _oButton.y = iYPos;
+    };
+    
+    this.setVisible = function(bVisible){
+        _oButton.visible = bVisible;
+    };
+    
+    var _oParent = this;
+    
+    this._init(iXPos,iYPos,oSprite,bActive);
+}

+ 261 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CLevelMenu.js

@@ -0,0 +1,261 @@
+function CLevelMenu(){
+    
+    var _iFrameRate = 1000/10;
+    var _iSetTimeout;
+    
+    var _bNumActive;
+    
+    var _oContainer;
+    
+    var _oDifficultyText;
+    var _aLevels = new Array();
+    var _oModeNumOff;
+    var _oModeNumOn;
+    
+    var _oBg;
+    var _oButExit;
+    var _oAudioToggle;
+    var _oButFullscreen;
+    var _fRequestFullScreen = null;
+    var _fCancelFullScreen = null;
+    
+    var _oParent = this;
+    
+    var _pStartPosExit;
+    var _pStartPosAudio;
+    var _pStartPosFullscreen;
+    
+    var _aSpritesAnimation = new Array();
+    
+    this._init = function(){
+        
+        _oBg = createBitmap(s_oSpriteLibrary.getSprite('bg_menu'));
+        s_oStage.addChild(_oBg)
+        
+        _bNumActive = false;
+        
+        var oHitArea = new createjs.Shape();
+        oHitArea.graphics.beginFill("#000").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
+        oHitArea.alpha = 0.7;
+        s_oStage.addChild(oHitArea);
+        
+        _oContainer = new createjs.Container();
+        _oContainer.y = CANVAS_HEIGHT;
+        s_oStage.addChild(_oContainer);
+        
+        _oBg = createBitmap(s_oSpriteLibrary.getSprite('msg_box'));
+        _oContainer.addChild(_oBg);
+        
+        _oDifficultyText = new createjs.Text(TEXT_LEVEL," 40px "+FONT, "#000");
+        _oDifficultyText.x = CANVAS_WIDTH/2+2;
+        _oDifficultyText.y = 372;
+        _oDifficultyText.textAlign = "center";
+        _oDifficultyText.textBaseline = "alphabetic";
+        _oDifficultyText.lineWidth = 1000;
+        _oContainer.addChild(_oDifficultyText);
+        
+        _oDifficultyText = new createjs.Text(TEXT_LEVEL," 40px "+FONT, "#ffc949");
+        _oDifficultyText.x = CANVAS_WIDTH/2;
+        _oDifficultyText.y = 370;
+        _oDifficultyText.textAlign = "center";
+        _oDifficultyText.textBaseline = "alphabetic";
+        _oDifficultyText.lineWidth = 1000;
+        _oContainer.addChild(_oDifficultyText);
+        
+        var oModePos = {x: CANVAS_WIDTH/2+70, y: 460};
+        
+        var offset_x = 0;
+        var offset_y = 0;
+        
+        for(var i = 0; i < LEVEL_NUM; i++, offset_x += 90 ){
+            if(offset_x > 300){
+                offset_x = 0;
+                offset_y += 90;
+            }
+
+            if( i < s_iLevelReached){
+                _aLevels.push(new CLevelBut((oModePos.x - 200)+offset_x,oModePos.y+offset_y, s_oSpriteLibrary.getSprite('level_sprite'), true, i+1, _oContainer));
+                if(i === s_iLevelReached-1){
+                    _aLevels[i].pulseAnimation();
+                }
+            }else{
+                _aLevels.push(new CLevelBut((oModePos.x - 200)+offset_x,oModePos.y+offset_y, s_oSpriteLibrary.getSprite('level_sprite'), false, i+1, _oContainer));
+            }
+            if(i === 0){
+                _aLevels[i].addEventListenerWithParams(ON_MOUSE_UP, this._onClickHelp, this, i);
+            }else{
+                _aLevels[i].addEventListenerWithParams(ON_MOUSE_UP, this._onClick, this, i);
+            }
+            s_bFirstTime = true;
+        } 
+        
+        var oSprite = s_oSpriteLibrary.getSprite('but_exit');
+        _pStartPosExit = {x: CANVAS_WIDTH - (oSprite.height/2)- 10, y: (oSprite.height/2) + 10};
+        _oButExit = new CGfxButton(_pStartPosExit.x, _pStartPosExit.y, oSprite, s_oStage);
+        _oButExit.addEventListener(ON_MOUSE_UP, this._onExit, this);
+        
+        if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
+            var oSprite = s_oSpriteLibrary.getSprite('audio_icon');
+            _pStartPosAudio = {x: _pStartPosExit.x - oSprite.width/2 -10, y: (oSprite.height/2) + 10};
+            _oAudioToggle = new CToggle(_pStartPosAudio.x,_pStartPosAudio.y,oSprite,s_bAudioActive);
+            _oAudioToggle.addEventListener(ON_MOUSE_UP, this._onAudioToggle, this);   
+            
+            oSprite = s_oSpriteLibrary.getSprite('but_fullscreen');
+            _pStartPosFullscreen = {x:_pStartPosAudio.x - oSprite.width/2 - 10,y:oSprite.height/2 + 10};
+        }else{
+            oSprite = s_oSpriteLibrary.getSprite('but_fullscreen');
+            _pStartPosFullscreen = {x: _pStartPosExit.x - oSprite.width/2 -10, y: (oSprite.height/2) + 10};
+        }
+        
+        var doc = window.document;
+        var docEl = doc.documentElement;
+        _fRequestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;
+        _fCancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen;
+        
+        if(ENABLE_FULLSCREEN === false){
+            _fRequestFullScreen = false;
+        }
+        
+        if (_fRequestFullScreen && screenfull.enabled){
+            _oButFullscreen = new CToggle(_pStartPosFullscreen.x, _pStartPosFullscreen.y, oSprite, s_bFullscreen, s_oStage);
+            _oButFullscreen.addEventListener(ON_MOUSE_UP, this._onFullscreenRelease, this);
+        }
+        
+        for( var i=1; i < 87; i++){
+            _aSpritesAnimation.push(createBitmap(s_oSpriteLibrary.getSprite('msg_box_animation_'+i)));
+            s_oStage.addChild(_aSpritesAnimation[i-1]);
+            _aSpritesAnimation[i-1].visible = false;
+        }
+        
+        this.playAnimation(0);
+        
+        createjs.Tween.get(_oContainer).to({y: 0 }, 500, createjs.Ease.quadOut).call(function() {});
+        
+        this.refreshButtonPos(s_iOffsetX,s_iOffsetY);
+        
+    };  
+    
+    this.playAnimation = function(i){
+        if(i === 0){
+            _aSpritesAnimation[_aSpritesAnimation.length-1].visible = false;
+            _aSpritesAnimation[i].visible = true;
+        }
+        if(i > 0){
+            _aSpritesAnimation[i-1].visible = false;
+            _aSpritesAnimation[i].visible = true;
+        }
+        if(i < _aSpritesAnimation.length-1){
+            _iSetTimeout = setTimeout(function(){_oParent.playAnimation(i+1);},_iFrameRate); 
+        }else{
+            _iSetTimeout = setTimeout(function(){_oParent.playAnimation(0);},_iFrameRate); 
+        }
+    };
+    
+    this.unload = function(){
+        s_oStage.removeAllChildren();  
+        for(var i = 0; i < LEVEL_NUM; i++ ){
+            _aLevels[i].unload();
+        }
+        clearTimeout(_iSetTimeout);
+        
+        if (_fRequestFullScreen && screenfull.enabled){
+            _oButFullscreen.unload();
+        }
+        
+        s_oLevelMenu = null;
+    };
+    
+    this.refreshButtonPos = function(iNewX,iNewY){
+        _oButExit.setPosition(_pStartPosExit.x - iNewX,iNewY + _pStartPosExit.y);
+        if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
+            _oAudioToggle.setPosition(_pStartPosAudio.x - iNewX,iNewY + _pStartPosAudio.y);
+        } 
+        
+        if (_fRequestFullScreen && screenfull.enabled){
+            _oButFullscreen.setPosition(_pStartPosFullscreen.x - iNewX,_pStartPosFullscreen.y + iNewY);
+        }
+    };
+    
+    this._onNumModeToggle = function(iData){
+        if(iData === NUM_ACTIVE){
+            _bNumActive = true;
+            _oModeNumOff.setActive(false);
+            _oModeNumOn.setActive(true);
+            
+        }else {
+            _bNumActive = false;
+            _oModeNumOff.setActive(true);
+            _oModeNumOn.setActive(false);
+        }
+    };
+    
+    this._onAudioToggle = function(){
+        Howler.mute(s_bAudioActive);
+        s_bAudioActive = !s_bAudioActive;
+    };
+    
+    this.doUnload = function(iLevel, iType){
+        createjs.Tween.get(_oContainer).to({y: CANVAS_HEIGHT }, 500).call(function() {
+            s_oLevelMenu.unload();
+            switch(iType){
+                case 0:
+                    s_oMain.gotoHelp(iLevel);
+                    break;
+                case 1:
+                    s_oMain.gotoGame(iLevel);
+                    break;
+                case 2:
+                    s_oMain.gotoMenu();
+                    break;
+            }
+        });
+    };
+    
+    this._onClickHelp = function(i){
+        var iLevel = i;
+        var clickable = _aLevels[i].ifClickable();
+        if(clickable){
+            this.doUnload(iLevel, 0);
+        } 
+    };
+    
+    this._onClick = function(i){
+        var iLevel = i;
+        var clickable = _aLevels[i].ifClickable();
+        if(clickable){
+            this.doUnload(iLevel, 1);
+        } 
+    };
+    
+     
+    this._onExit = function(){
+        $(s_oMain).trigger("show_interlevel_ad");
+        $(s_oMain).trigger("end_session");
+        this.doUnload(0, 2);
+		submitScore('0');
+    };   
+    
+    this.resetFullscreenBut = function(){
+	if (_fRequestFullScreen && screenfull.enabled){
+		_oButFullscreen.setActive(s_bFullscreen);
+	}
+    };
+    
+    this._onFullscreenRelease = function(){
+        if(s_bFullscreen) { 
+		_fCancelFullScreen.call(window.document);
+	}else{
+		_fRequestFullScreen.call(window.document.documentElement);
+	}
+	
+	sizeHandler();
+    };
+    
+    s_oLevelMenu = this;        
+    this._init();
+    
+    
+    
+};
+
+var s_oLevelMenu = null;

+ 291 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CMain.js

@@ -0,0 +1,291 @@
+function CMain(oData){
+    var _bUpdate;
+    var _iCurResource = 0;
+    var RESOURCE_TO_LOAD = 0;
+    var _iState = STATE_LOADING;
+    var _oData;
+    
+    var _oPreloader;
+    var _oMenu;
+    var _oHelp;
+    var _oGame;
+    var _oLevelMenu;
+
+    this.initContainer = function(){
+        s_oCanvas = document.getElementById("canvas");
+        s_oStage = new createjs.Stage(s_oCanvas);
+        createjs.Touch.enable(s_oStage);
+        
+        s_bMobile = jQuery.browser.mobile;
+        if(s_bMobile === false){
+            s_oStage.enableMouseOver(20);  
+            $('body').on('contextmenu', '#canvas', function(e){ return false; });
+        }
+		
+        s_iPrevTime = new Date().getTime();
+
+	createjs.Ticker.addEventListener("tick", this._update);
+        createjs.Ticker.setFPS(FPS);
+        
+        if(navigator.userAgent.match(/Windows Phone/i)){
+                DISABLE_SOUND_MOBILE = true;
+        }
+        
+        s_oSpriteLibrary  = new CSpriteLibrary();
+
+        //ADD PRELOADER
+        _oPreloader = new CPreloader();
+        
+        s_oRollingTextManager = new CRollingTextManager();
+    };
+    
+    this.preloaderReady = function(){
+        if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
+            this._initSounds();
+        }
+        
+        this._loadImages();
+        _bUpdate = true;
+    };
+    
+    this.soundLoaded = function(){
+        _iCurResource++;
+        var iPerc = Math.floor(_iCurResource/RESOURCE_TO_LOAD *100);
+        _oPreloader.refreshLoader(iPerc);
+
+         if(_iCurResource === RESOURCE_TO_LOAD){
+            _oPreloader.unload();
+            
+            try{
+                localStorage.setItem("ls_available","ok");
+            }catch(evt){
+                // localStorage not defined
+                s_bStorageAvailable = false;
+            }
+            
+            if (!isIOS()) {
+                s_oSoundTrack = playSound("soundtrack", 1, true);
+            }
+            
+            s_oMain.gotoMenu();
+         }
+    };
+    
+    this._initSounds = function(){
+    
+        var aSoundsInfo = new Array();
+        aSoundsInfo.push({path: './sounds/',filename:'click',loop:false,volume:1, ingamename: 'click'});
+        aSoundsInfo.push({path: './sounds/',filename:'hit_basket',loop:false,volume:1, ingamename: 'hit_basket'});
+        aSoundsInfo.push({path: './sounds/',filename:'hit_obstacles',loop:false,volume:1, ingamename: 'hit_obstacles'});
+        aSoundsInfo.push({path: './sounds/',filename:'soundtrack',loop:true,volume:1, ingamename: 'soundtrack'});
+        aSoundsInfo.push({path: './sounds/',filename:'pick_object',loop:true,volume:1, ingamename: 'pick_object'});
+        aSoundsInfo.push({path: './sounds/',filename:'game_over',loop:false,volume:1, ingamename: 'game_over'});
+        aSoundsInfo.push({path: './sounds/',filename:'next_level',loop:true,volume:1, ingamename: 'next_level'});
+        
+        RESOURCE_TO_LOAD += aSoundsInfo.length;
+
+        s_aSounds = new Array();
+        for(var i=0; i<aSoundsInfo.length; i++){
+            s_aSounds[aSoundsInfo[i].ingamename] = new Howl({ 
+                                                            src: [aSoundsInfo[i].path+aSoundsInfo[i].filename+'.mp3', aSoundsInfo[i].path+aSoundsInfo[i].filename+'.ogg'],
+                                                            autoplay: false,
+                                                            preload: true,
+                                                            loop: aSoundsInfo[i].loop, 
+                                                            volume: aSoundsInfo[i].volume,
+                                                            onload: s_oMain.soundLoaded
+                                                        });
+        }
+        
+    };
+
+    this._loadImages = function(){
+        s_oSpriteLibrary.init( this._onImagesLoaded,this._onAllImagesLoaded, this );
+
+        s_oSpriteLibrary.addSprite("but_play","./sprites/but_play.png");
+        s_oSpriteLibrary.addSprite("but_continue","./sprites/but_continue.png");
+        s_oSpriteLibrary.addSprite("but_restart","./sprites/but_restart.png");
+        s_oSpriteLibrary.addSprite("but_home","./sprites/but_home.png");
+        s_oSpriteLibrary.addSprite("msg_box_game_over","./sprites/msg_box_game_over.png");
+        s_oSpriteLibrary.addSprite("msg_box","./sprites/msg_box.png");
+        
+        s_oSpriteLibrary.addSprite("curtain","./sprites/curtain.png");
+        s_oSpriteLibrary.addSprite("curtain_bg","./sprites/curtain_bg.jpg");
+        
+        for( var i=1; i < 87; i++){
+            s_oSpriteLibrary.addSprite("msg_box_animation_"+i,"./sprites/msg_box/"+i+"-msg-box-animation.png");
+        }
+        
+        s_oSpriteLibrary.addSprite("bg_menu","./sprites/bg_menu.jpg");
+        for( var i=0; i < 22; i++){
+            s_oSpriteLibrary.addSprite("bg_menu_animation_"+i,"./sprites/bg_menu_animation/"+i+"-main-menu-animation.png");
+        }
+        
+        s_oSpriteLibrary.addSprite("bg_game","./sprites/bg_game.jpg");
+        
+        s_oSpriteLibrary.addSprite("cursor_help","./sprites/cursor_help.png");
+        
+        s_oSpriteLibrary.addSprite("but_exit","./sprites/but_exit.png");
+        s_oSpriteLibrary.addSprite("but_restart","./sprites/but_restart.png");
+        s_oSpriteLibrary.addSprite("audio_icon","./sprites/audio_icon.png");
+        s_oSpriteLibrary.addSprite("but_next","./sprites/but_next.png");
+        s_oSpriteLibrary.addSprite("level_sprite","./sprites/levelsprite.png");
+        
+        s_oSpriteLibrary.addSprite("target","./sprites/target.png");
+        
+        s_oSpriteLibrary.addSprite("ball_0","./sprites/ball_0.png");
+        s_oSpriteLibrary.addSprite("ball_1","./sprites/ball_1.png");
+        s_oSpriteLibrary.addSprite("player","./sprites/player.png");
+        s_oSpriteLibrary.addSprite("object_to_pick","./sprites/object_to_pick.png");
+        s_oSpriteLibrary.addSprite("rectangle_0","./sprites/rectangle_0.png");
+        s_oSpriteLibrary.addSprite("rectangle_1","./sprites/rectangle_1.png");
+        s_oSpriteLibrary.addSprite("rectangle_2","./sprites/rectangle_2.png");
+        s_oSpriteLibrary.addSprite("rectangle_3","./sprites/rectangle_3.png");
+        s_oSpriteLibrary.addSprite("revolute_rectangle_0","./sprites/revolute_rectangle_0.png");
+        s_oSpriteLibrary.addSprite("revolute_rectangle_1","./sprites/revolute_rectangle_1.png");
+        
+        s_oSpriteLibrary.addSprite("unhappy","./sprites/player_unhappy.png");
+        s_oSpriteLibrary.addSprite("almost_happy","./sprites/player_almost_happy.png");
+        s_oSpriteLibrary.addSprite("happy","./sprites/player_happy.png");
+        
+        s_oSpriteLibrary.addSprite("logo_credits","./sprites/logo_credits.png");
+        s_oSpriteLibrary.addSprite("but_credits","./sprites/but_info.png");
+        
+        s_oSpriteLibrary.addSprite("wall","./sprites/wall.png");
+        s_oSpriteLibrary.addSprite("basket_back","./sprites/basket_back.png");
+        s_oSpriteLibrary.addSprite("basket_front","./sprites/basket_front.png");
+        
+        s_oSpriteLibrary.addSprite("multiplier_25","./sprites/multiplier_25.png");
+        s_oSpriteLibrary.addSprite("multiplier_50","./sprites/multiplier_50.png");
+        s_oSpriteLibrary.addSprite("multiplier_100","./sprites/multiplier_100.png");
+        s_oSpriteLibrary.addSprite("but_fullscreen","./sprites/but_fullscreen.png");
+        
+
+        RESOURCE_TO_LOAD += s_oSpriteLibrary.getNumSprites();
+        s_oSpriteLibrary.loadSprites();
+    };
+    
+    this._onImagesLoaded = function(){
+        _iCurResource++;
+        var iPerc = Math.floor(_iCurResource/RESOURCE_TO_LOAD *100);
+        _oPreloader.refreshLoader(iPerc);
+        
+        if(_iCurResource === RESOURCE_TO_LOAD){
+            _oPreloader.unload();
+            
+            try{
+                localStorage.setItem("ls_available","ok");
+            }catch(evt){
+                // localStorage not defined
+                s_bStorageAvailable = false;
+            }
+            
+            if (!isIOS()) {
+                s_oSoundTrack = playSound("soundtrack", 1, true);
+            }
+            
+            this.gotoMenu();
+        }
+    };
+    
+    this._onAllImagesLoaded = function(){
+        
+    };
+    
+    this.gotoMenu = function(){
+        _oMenu = new CMenu();
+        _iState = STATE_MENU;
+    };    
+
+    this.gotoGame = function(iLevel){        
+        _oGame = new CGame(_oData, iLevel);   						
+        _iState = STATE_GAME;
+        
+    };
+    
+    this.gotoLevelMenu = function(){
+        _oLevelMenu = new CLevelMenu();
+        _iState = STATE_MENU;
+    };
+    
+    this.gotoHelp = function(){
+        _oHelp = new CHelp();
+        _iState = STATE_HELP;
+    };
+	
+    this.stopUpdate = function(){
+        _bUpdate = false;
+        createjs.Ticker.paused = true;
+        $("#block_game").css("display","block");
+        
+        if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
+            Howler.mute(true);
+        }
+        
+    };
+
+    this.startUpdate = function(){
+        s_iPrevTime = new Date().getTime();
+        _bUpdate = true;
+        createjs.Ticker.paused = false;
+        $("#block_game").css("display","none");
+        
+        if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
+            if(s_bAudioActive){
+                Howler.mute(false);
+            }
+        }
+        
+    };
+    
+    this._update = function(event){
+		if(_bUpdate === false){
+			return;
+		}
+        var iCurTime = new Date().getTime();
+        s_iTimeElaps = iCurTime - s_iPrevTime;
+        s_iCntTime += s_iTimeElaps;
+        s_iCntFps++;
+        s_iPrevTime = iCurTime;
+        
+        if ( s_iCntTime >= 1000 ){
+            s_iCurFps = s_iCntFps;
+            s_iCntTime-=1000;
+            s_iCntFps = 0;
+        }
+                
+        if(_iState === STATE_GAME){
+            _oGame.update();
+        }
+        
+        s_oStage.update(event);
+
+    };
+    
+    s_oMain = this;
+    
+    _oData = oData;
+    ENABLE_FULLSCREEN = oData.fullscreen;
+    ENABLE_CHECK_ORIENTATION = oData.check_orientation;
+    
+    this.initContainer();
+}
+var s_bMobile;
+var s_bAudioActive = true;
+var s_iCntTime = 0;
+var s_iTimeElaps = 0;
+var s_iPrevTime = 0;
+var s_iCntFps = 0;
+var s_iCurFps = 0;
+var s_oPhysicsController;
+var s_iLevelReached = 1;
+var s_aScores = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
+var s_oRollingTextManager;
+
+var s_oDrawLayer;
+var s_oStage;
+var s_oMain;
+var s_oSpriteLibrary;
+var s_oSoundTrack = null;
+var s_oCanvas;
+var s_bFullscreen = false;
+var s_bStorageAvailable = true;

+ 238 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CMenu.js

@@ -0,0 +1,238 @@
+function CMenu(){
+    var _iFrameRate = 1000/10;
+    var _iSetTimeout;
+    
+    var _oResetPanel = null;
+    var _oBg;
+    var _oButPlay;
+    var _oButContinue;
+    var _oFade;
+    var _oAudioToggle;
+    var _oButInfo;
+    var _oButFullscreen;
+    var _fRequestFullScreen = null;
+    var _fCancelFullScreen = null;
+    
+    var _pStartPosAudio;
+    var _pStartPosInfo;
+    var _pStartPosFullscreen;
+    
+    var _aSpritesAnimation = new Array();
+    
+    this._init = function(){
+        setVolume("soundtrack", 1);
+        _oBg = createBitmap(s_oSpriteLibrary.getSprite('bg_menu'));
+        s_oStage.addChild(_oBg);
+            
+        if(localStorage.getItem("LevelReached") !== null){
+            s_iLevelReached = localStorage.getItem("LevelReached");
+            s_aScores = JSON.parse(localStorage.getItem("Scores"));
+        }
+            
+        if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
+            var oSprite = s_oSpriteLibrary.getSprite('audio_icon');
+            _pStartPosAudio = {x: CANVAS_WIDTH - (oSprite.height/2)- 10, y: (oSprite.height/2) + 10};            
+            _oAudioToggle = new CToggle(_pStartPosAudio.x,_pStartPosAudio.y,oSprite,s_bAudioActive);
+            _oAudioToggle.addEventListener(ON_MOUSE_UP, this._onAudioToggle, this);    
+        }
+        
+        var oSprite = s_oSpriteLibrary.getSprite('but_credits');
+        _pStartPosInfo = {x: (oSprite.height/2)+ 10, y: (oSprite.height/2) + 10}; 
+        _oButInfo = new CGfxButton(_pStartPosInfo.x,_pStartPosInfo.y,oSprite);
+        _oButInfo.addEventListener(ON_MOUSE_UP, this._onCredits, this);
+        
+        var doc = window.document;
+        var docEl = doc.documentElement;
+        _fRequestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;
+        _fCancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen;
+        
+        if(ENABLE_FULLSCREEN === false){
+            _fRequestFullScreen = false;
+        }
+        
+        if (_fRequestFullScreen && screenfull.enabled){
+            oSprite = s_oSpriteLibrary.getSprite('but_fullscreen');
+            _pStartPosFullscreen = {x:_pStartPosInfo.x + oSprite.width/2 + 10,y:oSprite.height/2 + 10};
+
+            _oButFullscreen = new CToggle(_pStartPosFullscreen.x, _pStartPosFullscreen.y, oSprite, s_bFullscreen, s_oStage);
+            _oButFullscreen.addEventListener(ON_MOUSE_UP, this._onFullscreenRelease, this);
+        }
+        
+        for( var i=1; i < 22; i++){
+            _aSpritesAnimation.push(createBitmap(s_oSpriteLibrary.getSprite('bg_menu_animation_'+i)));
+            s_oStage.addChild(_aSpritesAnimation[i-1]);
+            _aSpritesAnimation[i-1].visible = false;
+        }
+        
+        this.playAnimation(0);
+
+        _oFade = new createjs.Shape();
+        _oFade.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);
+        
+        s_oStage.addChild(_oFade);
+        
+        createjs.Tween.get(_oFade).to({alpha:0}, 1000).call(function(){_oFade.visible = false;});  
+
+        if(!s_bStorageAvailable){
+            new CMsgBox(TEXT_ERR_LS,s_oStage);
+        }
+        
+        this.refreshButtonPos(s_iOffsetX,s_iOffsetY);
+    };
+    
+    this.playAnimation = function(i){
+        if(i === 0){
+            _aSpritesAnimation[i].visible = true;
+            
+            if(localStorage.getItem("LevelReached") === null){
+                var oSprite = s_oSpriteLibrary.getSprite('but_play');
+                _oButPlay = new CGfxButton((CANVAS_WIDTH/2),CANVAS_HEIGHT+100,oSprite);
+                _oButPlay.moveInPosition((CANVAS_WIDTH/2),CANVAS_HEIGHT -225);
+                _oButPlay.addEventListener(ON_MOUSE_UP, this._onButPlayRelease, this);
+                _oButPlay.pulseAnimation();
+            }else{
+                var oSprite = s_oSpriteLibrary.getSprite('but_play');
+                _oButPlay = new CGfxButton((CANVAS_WIDTH/2-125),CANVAS_HEIGHT +100,oSprite);
+                _oButPlay.moveInPosition((CANVAS_WIDTH/2-125),CANVAS_HEIGHT -225);
+                _oButPlay.addEventListener(ON_MOUSE_UP, this._onButPlayRelease, this);
+
+                var oSprite = s_oSpriteLibrary.getSprite('but_continue');
+                _oButContinue = new CGfxButton((CANVAS_WIDTH/2+125),CANVAS_HEIGHT +100,oSprite);
+                _oButContinue.moveInPosition((CANVAS_WIDTH/2+125),CANVAS_HEIGHT -225);
+                _oButContinue.addEventListener(ON_MOUSE_UP, this._onButContinueRelease, this);
+                _oButContinue.pulseAnimation();
+            }
+        }
+        if(i > 0){
+            _aSpritesAnimation[i-1].visible = false;
+            _aSpritesAnimation[i].visible = true;
+        }
+        if(i < _aSpritesAnimation.length-1){
+            _iSetTimeout = setTimeout(function(){s_oMenu.playAnimation(i+1);},_iFrameRate); 
+        }
+        
+    };
+    
+    this.unload = function(){
+        _oButPlay.unload(); 
+        if(_oButContinue){
+            _oButContinue.unload();
+        }
+        _oButPlay = null;
+        _oFade.visible = false;
+        
+        clearTimeout(_iSetTimeout);
+        
+        if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
+            _oAudioToggle.unload();
+            _oAudioToggle = null;
+        }
+        
+        if (_fRequestFullScreen && screenfull.enabled){
+            _oButFullscreen.unload();
+        }
+        
+        s_oStage.removeAllChildren();
+        s_oMenu = null;
+    };
+    
+    this.refreshButtonPos = function(iNewX,iNewY){
+        if(DISABLE_SOUND_MOBILE === false || s_bMobile === false){
+            _oAudioToggle.setPosition(_pStartPosAudio.x - iNewX,iNewY + _pStartPosAudio.y);
+        }
+        if (_fRequestFullScreen && screenfull.enabled){
+            _oButFullscreen.setPosition(_pStartPosFullscreen.x + iNewX,_pStartPosFullscreen.y + iNewY);
+        }
+        _oButInfo.setPosition(_pStartPosInfo.x + iNewX,iNewY + _pStartPosInfo.y);
+    };
+    
+    this._onAudioToggle = function(){
+        Howler.mute(s_bAudioActive);
+        s_bAudioActive = !s_bAudioActive;
+    };
+    
+    this._onButPlayRelease = function(){
+        
+        $(s_oMain).trigger("start_session");
+        
+        if (isIOS() && (s_oSoundTrack === null || s_oSoundTrack === undefined)){
+            s_oSoundTrack = playSound('soundtrack', 1, true);
+        }
+        
+		s_oMain.gotoGame(1);
+        //if(1=1 or localStorage.getItem("LevelReached") === null){
+        //    this.unload();
+        //    s_oMain.gotoLevelMenu();
+        //}else{
+        //    if(_oResetPanel === null){
+        //        _oResetPanel = new CConfirmPanel(TEXT_RESET, CONFIRMATION_RESET);
+        //        _oResetPanel.addEventListener(ON_BUT_NO_DOWN, this._onButReset, this);
+        //        _oResetPanel.addEventListener(ON_BUT_YES_DOWN, this._onButContinue, this);
+        //    }
+        //}
+    };
+    
+    this._onCredits = function(){
+        new CCreditsPanel();
+    };
+    
+    this._onButReset = function(){
+        _oResetPanel.unload();
+        _oResetPanel = null;
+    };
+    
+    this._onButContinue = function(){
+        this.removeLocalStorage();
+        this.unload();
+        
+        
+        s_oMain.gotoGame(1);
+        //s_oMain.gotoLevelMenu();        
+    };
+    
+    this._onButContinueRelease = function(){
+        this.unload();
+        
+        if (isIOS() && (s_oSoundTrack === null || s_oSoundTrack === undefined)){
+            s_oSoundTrack = playSound('soundtrack', 1, true);
+        }
+        s_oMain.gotoGame(1);
+        //s_oMain.gotoLevelMenu();
+    };
+    
+    this.unloadVariousHelp = function(){
+        _oResetPanel.unload();
+        _oResetPanel = null;
+    };
+    
+    this.removeLocalStorage = function(){
+        
+        localStorage.removeItem("LevelReached");
+        localStorage.removeItem("Scores");
+        
+        s_iLevelReached = 1;
+        s_aScores = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; 
+    }
+	
+    this.resetFullscreenBut = function(){
+	if (_fRequestFullScreen && screenfull.enabled){
+		_oButFullscreen.setActive(s_bFullscreen);
+	}
+    };
+    
+    this._onFullscreenRelease = function(){
+        if(s_bFullscreen) { 
+		_fCancelFullScreen.call(window.document);
+	}else{
+		_fRequestFullScreen.call(window.document.documentElement);
+	}
+	
+	sizeHandler();
+    };
+    
+    s_oMenu = this;
+    
+    this._init();
+}
+
+var s_oMenu = null;

+ 66 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CMsgBox.js

@@ -0,0 +1,66 @@
+function CMsgBox(szText,oParentContainer){
+    var _oMsgStroke;
+    var _oMsg;
+    var _oButOk;
+    var _oThis;
+    var _oContainer;
+    var _oParentContainer;
+
+    this._init = function (szText) {
+        _oContainer = new createjs.Container();
+        _oParentContainer.addChild(_oContainer);
+
+        var oFade;
+
+        oFade = new createjs.Shape();
+        oFade.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
+        oFade.alpha = 0.5;
+
+        oFade.on("click", function () {});
+
+        _oContainer.addChild(oFade);
+
+        var oSpriteBg = s_oSpriteLibrary.getSprite('msg_box');
+        var oBg = createBitmap(oSpriteBg);
+
+        oBg.x = CANVAS_WIDTH * 0.5;
+        oBg.y = CANVAS_HEIGHT * 0.5;
+        oBg.regX = oSpriteBg.width * 0.5;
+        oBg.regY = oSpriteBg.height * 0.5;
+        _oContainer.addChild(oBg);
+
+        _oMsgStroke = new createjs.Text(szText, "30px " + FONT, "#000");
+        _oMsgStroke.x = CANVAS_WIDTH / 2;
+        _oMsgStroke.y = 360;
+        _oMsgStroke.textAlign = "center";
+        _oMsgStroke.textBaseline = "middle";
+        _oMsgStroke.lineWidth = 400;
+        _oMsgStroke.outline = 2;
+        _oContainer.addChild(_oMsgStroke);
+
+        _oMsg = new createjs.Text(_oMsgStroke.text, "30px " + FONT, "#ffc949");
+        _oMsg.x = _oMsgStroke.x;
+        _oMsg.y = _oMsgStroke.y;
+        _oMsg.textAlign = "center";
+        _oMsg.textBaseline = "middle";
+        _oMsg.lineWidth = 400;
+        _oContainer.addChild(_oMsg);
+
+        _oButOk = new CGfxButton(CANVAS_WIDTH / 2, 700, s_oSpriteLibrary.getSprite('but_next'), _oContainer);
+        _oButOk.addEventListener(ON_MOUSE_UP, this._onButOk, this);
+    };
+
+    this._onButOk = function () {
+        _oThis.unload();
+    };
+
+    this.unload = function () {
+        _oButOk.unload();
+        _oParentContainer.removeChild(_oContainer);
+    };
+    
+    _oThis = this;
+    _oParentContainer = oParentContainer;
+
+    this._init(szText);
+}

+ 87 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CObjectToPick.js

@@ -0,0 +1,87 @@
+function CObjectToPick(iX, iY, iObject, oParentContainer){
+    
+    var _oParentContainer = oParentContainer;
+    
+    var _oObjectToPick;
+    var _oObjectToPickRectangle;
+    
+    var _aCbCompleted = new Array();
+    var _aCbOwner = new Array();
+    var _aParams = new Array();
+    
+    var _iX = iX;
+    var _iY = iY;
+    
+    this.init = function(){
+        var oSprite = s_oSpriteLibrary.getSprite('object_to_pick');
+        var oData = {   
+            images: [oSprite], 
+            // width, height & registration point of each sprite
+            frames: {width: oSprite.width/NUM_OBJ_TO_PICK_IN_ROW, height: oSprite.height, regX: 0, regY: 0}, 
+            animations: {obj_0:[0], obj_1:[1], obj_2:[2], obj_3:[3], obj_4:[4], obj_5:[5]}
+        };
+        var oSpriteSheet = new createjs.SpriteSheet(oData);
+
+        _oObjectToPick = createSprite(oSpriteSheet, "obj_"+iObject, 0, 0, oSprite.width/NUM_OBJ_TO_PICK_IN_ROW, oSprite.height);
+        _oObjectToPick.x = _iX;
+        _oObjectToPick.y = _iY;
+
+        _oParentContainer.addChild(_oObjectToPick);
+        
+        _oObjectToPickRectangle = new createjs.Rectangle(_iX, _iY, oSprite.width/NUM_OBJ_TO_PICK_IN_ROW, oSprite.height);/*
+        var shape = new createjs.Shape();
+        shape.graphics.beginFill("#ffff00").drawRect(_iX, _iY, oSprite.width/NUM_OBJ_TO_PICK_IN_ROW, oSprite.height);
+        shape.alpha = 0.5;
+        _oParentContainer.addChild(shape);*/
+        
+    };
+    
+    this.checkIfPlayerHasCollided = function(oPlayerRectangle){
+        if(_oObjectToPickRectangle.intersects ( oPlayerRectangle )){
+            return true;
+        }
+        return false;
+    };
+    
+    this.addEventListener = function( iEvent, cbCompleted, cbOwner ){
+        _aCbCompleted[iEvent]=cbCompleted;
+        _aCbOwner[iEvent] = cbOwner; 
+    };
+    
+    this.addEventListenerWithParams = function(iEvent,cbCompleted, cbOwner,aParams){
+        _aCbCompleted[iEvent]=cbCompleted;
+        _aCbOwner[iEvent] = cbOwner;
+        _aParams = aParams;
+    };
+    
+    this.tweenEnded = function(){      
+        if(_aCbCompleted[ON_TWEEN_ENDED]){
+            _aCbCompleted[ON_TWEEN_ENDED].call(_aCbOwner[ON_TWEEN_ENDED],_aParams);
+        }
+    };
+    
+    this.moveToGUI = function(iY, iObjectsTaken){
+        var oParent = this;
+        createjs.Tween.get(_oObjectToPick).to({x: CANVAS_WIDTH/2-280},1000, createjs.Ease.quadOut).call(function(){
+            oParent.unload(iY);
+            oParent.tweenEnded(iObjectsTaken);
+        });
+                
+        createjs.Tween.get(_oObjectToPick).to({y: _oObjectToPick.y+50},300, createjs.Ease.quadOut).call(function(){
+            createjs.Tween.get(_oObjectToPick).to({y: iY},700, createjs.Ease.quadOut).call(function(){
+            });
+        });
+    };
+    
+    this.unload = function(iY){
+        _oParentContainer.removeChild(_oObjectToPick);
+        _oObjectToPickRectangle = null;
+    };
+    
+    this.getRectangle = function(){
+        return _oObjectToPickRectangle;
+    };
+
+    this.init();
+    
+}

+ 115 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CPhysicsController.js

@@ -0,0 +1,115 @@
+function CPhysicsController(){
+    var b2Vec2 = Box2D.Common.Math.b2Vec2;
+    var b2BodyDef = Box2D.Dynamics.b2BodyDef;
+    var b2Body = Box2D.Dynamics.b2Body;
+    var b2FixtureDef = Box2D.Dynamics.b2FixtureDef;
+    var b2Fixture = Box2D.Dynamics.b2Fixture;
+    var b2World = Box2D.Dynamics.b2World;
+    var b2DebugDraw = Box2D.Dynamics.b2DebugDraw;
+    var b2MassData = Box2D.Collision.Shapes.b2MassData;
+    var b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape;
+    var b2CircleShape = Box2D.Collision.Shapes.b2CircleShape;
+
+    var _oGravity;
+    var _oWorld;
+    var _oPhysicController = this;
+    
+    var canvas = document.getElementById("canvas");
+    var context = canvas.getContext("2d");
+        
+    this.init = function(){
+        _oGravity = new b2Vec2(0, 9.8);
+        _oWorld = new b2World(_oGravity,  true);
+        
+        //setup debug draw
+        var oDebugDraw = new b2DebugDraw();
+        oDebugDraw.SetSprite(context);
+        oDebugDraw.SetDrawScale(WORLD_SCALE);
+        oDebugDraw.SetFillAlpha(0.5);
+        oDebugDraw.SetLineThickness(1.0);
+        oDebugDraw.SetFlags(b2DebugDraw.e_shapeBit);
+        _oWorld.SetDebugDraw(oDebugDraw);
+        
+        this.createAContactListener();
+        
+    };
+    
+    this.createAContactListener = function () {
+        var listener = new Box2D.Dynamics.b2ContactListener;
+
+        listener.BeginContact = function (contact) {
+            var oInfo = contact.GetFixtureA().GetBody();
+            playSound("hit_obstacles",1,false);
+            
+            if(oInfo.GetPosition().y*WORLD_SCALE >= BASKET_Y){
+                playSound("hit_basket",1,false);
+                s_oGame.moveBasket();
+            }
+        };
+        _oWorld.SetContactListener(listener);
+    };
+    
+    this.startComputing = function(oElement){
+        oElement.GetBody().SetActive(true);
+    };
+    
+    this.movePlayer = function(oBox, iX, iY){
+        var oPos = {x: iX / WORLD_SCALE, y: iY / WORLD_SCALE};
+        oBox.GetBody().SetPosition(oPos);
+    };
+    
+    this.applyImpulse = function(oElement){
+        oElement.GetBody().ApplyImpulse( {x:0.8,y:1}, oElement.GetBody().GetWorldCenter() );
+    };
+    
+    this.decreaseSpeedRotation = function(oElement){
+        var iNewAngularVelocity = oElement.GetBody().GetAngularVelocity()*0.99;
+        oElement.GetBody().SetAngularVelocity(iNewAngularVelocity);
+    };
+    
+    this.getSpeedRotation = function(oElement){
+        return oElement.GetBody().GetAngularVelocity();
+    };
+    
+    this.moveObject = function(oElement, iNewX, iY){
+        var oPos = {x: iNewX/WORLD_SCALE, y:iY/WORLD_SCALE};
+        oElement.GetBody().SetPosition(oPos);
+    };
+    
+    this.destroyBody = function(oElement){
+        _oWorld.DestroyBody(oElement.GetBody());
+    };
+    
+    this.getInstance = function(){
+        if(_oPhysicController===null){
+            _oPhysicController=new CPhysicsController();
+        }
+        return _oPhysicController;
+    };
+    
+    this.update = function() {
+        // Update the box2d world
+        _oWorld.Step(1 / 40, 3, 3);
+        _oWorld.DrawDebugData();
+        _oWorld.ClearForces();
+        
+        //setInterval(this.update, 1000/10)
+    };
+
+    this.getWorld = function(){
+        return _oWorld;
+    };
+    
+    this.getElementPosition = function(oElement) {
+        var oPos = oElement.GetBody().GetPosition();
+        return {x: oPos.x*WORLD_SCALE, y: oPos.y*WORLD_SCALE, angle: oElement.GetBody().GetAngle()*180/Math.PI};
+    };
+    
+    this.getElementAngle = function(oElement) {
+        return oElement.GetBody().GetAngle()*180/Math.PI;
+    };
+    
+    
+    this.init();
+    
+}

+ 228 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CPhysicsObject.js

@@ -0,0 +1,228 @@
+function CPhysicsObject(){
+    var b2Vec2 = Box2D.Common.Math.b2Vec2;
+    var b2BodyDef = Box2D.Dynamics.b2BodyDef;
+    var b2Body = Box2D.Dynamics.b2Body;
+    var b2FixtureDef = Box2D.Dynamics.b2FixtureDef;
+    var b2Fixture = Box2D.Dynamics.b2Fixture;
+    var b2World = Box2D.Dynamics.b2World;
+    var b2MassData = Box2D.Collision.Shapes.b2MassData;
+    var b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape;
+    var b2CircleShape = Box2D.Collision.Shapes.b2CircleShape;
+    var b2DebugDraw = Box2D.Dynamics.b2DebugDraw;
+    var b2RevoluteJointDef = Box2D.Dynamics.Joints.b2RevoluteJointDef;
+		
+    var _bContactOccured;      //maybe this is to delete.
+
+    var _oWorld;
+
+    var _oGame;
+    var _oPhysicController;
+    
+    this.init = function(){
+        _bContactOccured=false;
+
+        _oPhysicController = s_oPhysicsController.getInstance();
+        _oGame = s_oGame;
+        _oWorld = _oPhysicController.getWorld();
+        
+    };
+
+    this.addWall = function(iWidth,iHeight,iX,iY, iAngle, density, friction, restitution) {
+        // Create some objects in the world
+        var oFixDef = new b2FixtureDef;
+        oFixDef.density = density;
+        oFixDef.friction = friction;
+        oFixDef.restitution = restitution;
+
+        var oBodyDef = new b2BodyDef;
+        //create ground
+        oBodyDef.type = b2Body.b2_staticBody;
+        oFixDef.shape = new b2PolygonShape;
+        oFixDef.shape.SetAsBox(iWidth/ WORLD_SCALE, iHeight/ WORLD_SCALE);
+        oBodyDef.position.Set(iX/ WORLD_SCALE, iY/ WORLD_SCALE);
+        oBodyDef.angle = iAngle*Math.PI/180;
+        _oWorld.CreateBody(oBodyDef).CreateFixture(oFixDef); 
+    };
+    
+    this.addPoligon = function(iX, iY, iType, iAngle, density, friction, restitution) {
+        // Create some objects in the world
+        var oFixDef = new b2FixtureDef;
+        oFixDef.density = density;
+        oFixDef.friction = friction;
+        oFixDef.restitution = restitution;
+
+        var oBodyDef = new b2BodyDef;
+        //create ground
+        oBodyDef.type = b2Body.b2_staticBody;
+        oFixDef.shape = new b2PolygonShape;
+        
+        var points = [];
+        for (var i = 0; i < POLIGON_POINTS[iType].length; i++) {
+            var vec = new b2Vec2();
+            vec.Set(POLIGON_POINTS[iType][i].x/ WORLD_SCALE, POLIGON_POINTS[iType][i].y/ WORLD_SCALE);
+            points.push(vec);
+        }
+        
+        oFixDef.shape.SetAsArray(points, points.length);
+        
+        oBodyDef.position.Set(iX/ WORLD_SCALE, iY/ WORLD_SCALE);
+        oBodyDef.angle = iAngle*Math.PI/180;
+        _oWorld.CreateBody(oBodyDef).CreateFixture(oFixDef); 
+        
+        if(iType === BASKET){
+            iType += 1;
+            // Create some objects in the world
+            var oFixDef = new b2FixtureDef;
+            oFixDef.density = 3.0;
+            oFixDef.friction = 1;
+            oFixDef.restitution = 0.5;
+
+            var oBodyDef = new b2BodyDef;
+            //create ground
+            oBodyDef.type = b2Body.b2_staticBody;
+            oFixDef.shape = new b2PolygonShape;
+
+            var points = [];
+            for (var i = 0; i < POLIGON_POINTS[iType].length; i++) {
+                var vec = new b2Vec2();
+                vec.Set(POLIGON_POINTS[iType][i].x/ WORLD_SCALE, POLIGON_POINTS[iType][i].y/ WORLD_SCALE);
+                points.push(vec);
+            }
+
+            oFixDef.shape.SetAsArray(points, points.length);
+
+            oBodyDef.position.Set(iX/ WORLD_SCALE, iY/ WORLD_SCALE);
+            oBodyDef.angle = iAngle*Math.PI/180;
+            _oWorld.CreateBody(oBodyDef).CreateFixture(oFixDef); 
+        }
+    };
+    
+    this.addPlayer = function(iWidth,iX,iY, density, friction, restitution) {
+        // Create some objects in the world
+        var oFixDef = new b2FixtureDef;
+        oFixDef.density = density;
+        oFixDef.friction = friction;
+        oFixDef.restitution = restitution;
+
+        var oBodyDef = new b2BodyDef;
+
+        //create some objects
+        oBodyDef.type = b2Body.b2_dynamicBody;
+        oFixDef.shape = new b2CircleShape( iWidth/WORLD_SCALE );         //radius
+        oBodyDef.allowSleep = false;
+        oBodyDef.position.x = iX/WORLD_SCALE;
+        oBodyDef.position.y = iY/WORLD_SCALE;
+        var oCrateFixture = _oWorld.CreateBody(oBodyDef).CreateFixture(oFixDef);
+        oCrateFixture.GetBody().SetActive(false);
+        return oCrateFixture;
+   };
+
+    this.addCircle = function(iWidth,iX,iY, density, friction, restitution) {
+        // Create some objects in the world
+        var oFixDef = new b2FixtureDef;
+        oFixDef.density = density;
+        oFixDef.friction = friction;
+        oFixDef.restitution = restitution;
+
+        var oBodyDef = new b2BodyDef;
+
+        //create some objects
+        oBodyDef.type = b2Body.b2_dynamicBody;
+        oFixDef.shape = new b2CircleShape( iWidth/WORLD_SCALE );         //radius
+        oBodyDef.position.x = iX/WORLD_SCALE;
+        oBodyDef.position.y = iY/WORLD_SCALE;
+        var oCrateFixture = _oWorld.CreateBody(oBodyDef).CreateFixture(oFixDef);
+        return oCrateFixture;
+   };
+
+    this.addStaticCircle = function(iWidth, iX, iY, density, friction, restitution) {
+        // Create some objects in the world
+        var oFixDef = new b2FixtureDef;
+        oFixDef.density = density;
+        oFixDef.friction = friction;
+        oFixDef.restitution = restitution;
+
+        var oBodyDef = new b2BodyDef;
+
+        //create some objects
+        oBodyDef.type = b2Body.b2_staticBody;
+        oFixDef.shape = new b2CircleShape( iWidth/WORLD_SCALE );         //radius
+        oBodyDef.position.x = iX/WORLD_SCALE;
+        oBodyDef.position.y = iY/WORLD_SCALE;
+        var oCrateFixture = _oWorld.CreateBody(oBodyDef).CreateFixture(oFixDef);
+        return oCrateFixture;
+   };
+
+    this.addRevoluteRectangle = function(iWidth,iHeight,iX,iY, density, friction, restitution, bHadToMove) {
+        // Create some objects in the world
+        var oFixDef = new b2FixtureDef;
+        oFixDef.density = density;
+        oFixDef.friction = friction;
+        oFixDef.restitution = restitution;
+
+        var oBodyDef = new b2BodyDef;
+        //create ground
+        oBodyDef.type = b2Body.b2_dynamicBody;
+        if(bHadToMove){
+            oBodyDef.angularVelocity = 3;
+        }
+        oFixDef.shape = new b2PolygonShape;
+        oFixDef.shape.SetAsBox(iWidth/WORLD_SCALE, iHeight/WORLD_SCALE);
+        oBodyDef.position.Set(iX/WORLD_SCALE, iY/WORLD_SCALE);
+        var Body1 = _oWorld.CreateBody(oBodyDef);
+        var oCrateFixture1 = Body1.CreateFixture(oFixDef);
+        
+        var oPivotfixDef = new b2FixtureDef;
+        oPivotfixDef.density = 3.0;
+        oPivotfixDef.friction = 1;
+        oPivotfixDef.restitution = 0.1;
+        var oPivotoBodyDef = new b2BodyDef;
+        //create ground
+        oPivotoBodyDef.type = b2Body.b2_staticBody;
+        oPivotfixDef.shape = new b2CircleShape(10/WORLD_SCALE);
+        oPivotoBodyDef.position.Set(iX/WORLD_SCALE, iY/WORLD_SCALE);
+        var pivotBody = _oWorld.CreateBody(oPivotoBodyDef);
+        var oCrateFixture2 = pivotBody.CreateFixture(oPivotfixDef);
+        
+        //Revolute joint
+        var jointDef = new b2RevoluteJointDef();
+        jointDef.Initialize(Body1, pivotBody, Body1.GetWorldCenter());
+        _oWorld.CreateJoint(jointDef);
+        return {fixture1: oCrateFixture1, fixture2:oCrateFixture2};
+    };
+
+    this.addRectangle = function(iWidth,iHeight,iX,iY,iAngle, density, friction, restitution) {        
+        // Create some objects in the world
+        var oFixDef = new b2FixtureDef;
+        oFixDef.density = density;
+        oFixDef.friction = friction;
+        oFixDef.restitution = restitution;
+
+        var oBodyDef = new b2BodyDef;
+        //create ground
+        oBodyDef.type = b2Body.b2_staticBody;
+        oFixDef.shape = new b2PolygonShape;
+        oFixDef.shape.SetAsBox(iWidth/WORLD_SCALE, iHeight/WORLD_SCALE);
+        oBodyDef.position.Set(iX/WORLD_SCALE, iY/WORLD_SCALE);
+        oBodyDef.angle = iAngle*Math.PI/180;
+        var Body1 = _oWorld.CreateBody(oBodyDef);
+        var oCrateFixture = Body1.CreateFixture(oFixDef);
+        
+        return oCrateFixture;
+   };
+
+    this.setRotation = function(iRot){
+        this.rotation = iRot;
+    };
+
+    this.hitten = function(iImpactForce){
+        
+    };
+
+    this._update = function(evt){
+        
+    };
+   
+    this.init();
+    
+}

+ 84 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CPlayer.js

@@ -0,0 +1,84 @@
+function CPlayer(oSprite, iX, iY, iDensity, iFriction, iRestitution, oContainerPlayer, oPhysicsObject){
+    
+    var _oSprite = oSprite;
+    
+    var _oPlayerCircle;
+    var _oPlayerSprite;
+    var _oPlayerRectangle;
+    
+    var _iX = iX;
+    var _iY = iY;
+    
+    var _oContainerPlayer = oContainerPlayer;
+    var _oShape;
+    
+    var _oPhysicsObject = oPhysicsObject;
+    
+    this.init = function(){
+        //OBJECT WITH PHYSICS
+        _oPlayerCircle = _oPhysicsObject.addPlayer(_oSprite.width/2-5, _iX, _iY, iDensity, iFriction, iRestitution); 
+        var oInfos = s_oPhysicsController.getElementPosition(_oPlayerCircle);
+        
+        //VISIBLE OBJECT
+        _oPlayerSprite = createBitmap(oSprite);
+        _oPlayerSprite.x = oInfos.x;
+        _oPlayerSprite.y = oInfos.y;
+        _oPlayerSprite.rotation = oInfos.angle;
+        _oPlayerSprite.regX = _oSprite.width/2;
+        _oPlayerSprite.regY = _oSprite.height/2;
+        _oContainerPlayer.addChild(_oPlayerSprite); //Draws on canvas
+        
+        _oPlayerRectangle = new createjs.Rectangle(_iX-_oSprite.width/2, _iY-_oSprite.height/2, _oSprite.width, _oSprite.height);/*
+        _oShape = new createjs.Shape();
+        _oShape.graphics.beginFill("#00ff00").drawRect(_iX-_oSprite.width/2, _iY-_oSprite.height/2, _oSprite.width, _oSprite.height);
+        _oShape.alpha = 0.5;
+        _oContainerPlayer.addChild(_oShape);*/
+        
+    };
+    
+    this.refreshPosition = function(){
+        var oInfos = s_oPhysicsController.getElementPosition(_oPlayerCircle);
+        _oPlayerSprite.x = oInfos.x;
+        _oPlayerSprite.y = oInfos.y;
+        _oPlayerSprite.rotation = oInfos.angle;
+        
+        _oPlayerRectangle.setValues(_oPlayerSprite.x-_oSprite.width/2, _oPlayerSprite.y-_oSprite.height/2, _oSprite.width, _oSprite.height);/*
+        _oContainerPlayer.removeChild(_oShape);
+        _oShape = new createjs.Shape();
+        _oShape.graphics.beginFill("#0000ff").drawRect(_oPlayerSprite.x-_oSprite.width/2, _oPlayerSprite.y-_oSprite.height/2, _oSprite.width, _oSprite.height);
+        _oShape.alpha = 0.5;
+        _oContainerPlayer.addChild(_oShape);*/
+        
+    };
+
+    this.movePlayer = function(iNewX){
+        s_oPhysicsController.movePlayer(_oPlayerCircle, iNewX, _iY); 
+    };
+       
+    this.activatePlayer = function(){
+        s_oPhysicsController.startComputing(_oPlayerCircle);         
+    };
+    
+    this.checkIfPlayerHasStopped = function(bClicked){
+        if(Math.abs(_oPlayerCircle.GetBody().GetLinearVelocity().y) <= EPSILON && bClicked && _oPlayerSprite.y >= BASKET_Y-20){
+            return true;
+        }
+        return false;
+    };
+    
+    this.unload = function(){
+        _oContainerPlayer.removeAllChildren();
+        s_oPhysicsController.destroyBody(_oPlayerCircle);
+    };
+    
+    this.getX = function(){
+        return _oPlayerSprite.x;
+    };
+    
+    this.getRectangle = function(){
+        return _oPlayerRectangle;
+    };
+    
+    this.init();
+    
+}

+ 83 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CPreloader.js

@@ -0,0 +1,83 @@
+function CPreloader(){
+    var _iMaskWidth;
+	var _iMaskHeight;
+    var _oLoadingText;
+    var _oProgressBar;
+    var _oMaskPreloader;
+    var _oFade;
+    var _oContainer;
+    
+    this._init = function(){
+       s_oSpriteLibrary.init( this._onImagesLoaded,this._onAllImagesLoaded, this );
+       s_oSpriteLibrary.addSprite("bg_preloader","./sprites/bg_preloader.jpg");
+       s_oSpriteLibrary.addSprite("progress_bar","./sprites/progress_bar.png");
+       s_oSpriteLibrary.loadSprites();
+       
+       _oContainer = new createjs.Container();
+       s_oStage.addChild(_oContainer); 
+    };
+    
+    this.unload = function(){
+	_oContainer.removeAllChildren();
+    };
+    
+    this.hide = function(){
+        var oParent = this;
+        setTimeout(function(){createjs.Tween.get(_oFade).to({alpha:1}, 500).call(function(){oParent.unload();s_oMain.gotoMenu();}); }, 1000);
+    };
+    
+    this._onImagesLoaded = function(){
+        
+    };
+    
+    this._onAllImagesLoaded = function(){
+        this.attachSprites();
+        
+        s_oMain.preloaderReady();
+    };
+    
+    this.attachSprites = function(){
+        
+        var oBg = createBitmap(s_oSpriteLibrary.getSprite('bg_preloader'));
+        _oContainer.addChild(oBg);
+       
+        var oSprite = s_oSpriteLibrary.getSprite('progress_bar');
+       _oProgressBar  = createBitmap(oSprite);
+       _oProgressBar.x = CANVAS_WIDTH/2 - (oSprite.width/2);
+       _oProgressBar.y = CANVAS_HEIGHT - 150;
+       _oContainer.addChild(_oProgressBar);
+       
+       _iMaskWidth = oSprite.width;
+	   _iMaskHeight = oSprite.height;
+       _oMaskPreloader = new createjs.Shape();
+       _oMaskPreloader.graphics.beginFill("rgba(255,255,255,0.01)").drawRect(_oProgressBar.x, _oProgressBar.y, 1,_iMaskHeight);
+	   
+       _oContainer.addChild(_oMaskPreloader);
+       
+       _oProgressBar.mask = _oMaskPreloader;
+       
+       _oLoadingText = new createjs.Text("","30px "+FONT, "#fff");
+       _oLoadingText.x = CANVAS_WIDTH/2;
+       _oLoadingText.y = CANVAS_HEIGHT - 150;
+       _oLoadingText.shadow = new createjs.Shadow("#000", 2, 2, 2);
+       _oLoadingText.textBaseline = "alphabetic";
+       _oLoadingText.textAlign = "center";
+       _oContainer.addChild(_oLoadingText);
+       _oFade = new createjs.Shape();
+       _oFade.graphics.beginFill("black").drawRect(0,0,CANVAS_WIDTH,CANVAS_HEIGHT);
+       _oFade.alpha = 0;
+        
+        _oContainer.addChild(_oFade);
+    };
+    
+    this.refreshLoader = function(iPerc){
+        _oLoadingText.text = iPerc+"%";
+        
+        
+        _oMaskPreloader.graphics.clear();
+        var iNewMaskWidth = Math.floor((iPerc*_iMaskWidth)/100);
+        _oMaskPreloader.graphics.beginFill("rgba(255,255,255,0.01)").drawRect(_oProgressBar.x, _oProgressBar.y, iNewMaskWidth,_iMaskHeight);
+    };
+    
+    this._init();   
+}

+ 119 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CRollingTextController.js

@@ -0,0 +1,119 @@
+function CRollingTextController(oTarget,oTargetStroke,iAmountToIncrease,iTime,szEasing){
+    var _iCntFrames;
+    var _iMaxFrames;
+    var _iCurStart;
+    var _iTotWin;
+    var _iTime;
+    var _iNextAmount;
+    var _szCurEasing;
+    var _aCbCompleted;
+    var _aCbOwner;
+    
+    var _oTarget;
+    var _oTargetStroke;
+    
+    this._init = function(oTarget,oTargetStroke,iAmountToIncrease,iTime,szEasing){
+        _aCbCompleted=new Array();
+        _aCbOwner =new Array();
+        
+        _iTime = iTime;
+        this.setUpdateInfo(iAmountToIncrease);
+        
+        _szCurEasing = szEasing;
+        
+        _oTarget = oTarget;
+        _oTargetStroke = oTargetStroke;
+    };
+    
+    this.setUpdateInfo = function(iAmountToIncrease){
+        _iCurStart = parseFloat(oTarget.text);
+        _iTotWin = _iCurStart + iAmountToIncrease;
+
+        _iCntFrames = 0;
+        _iMaxFrames = Math.round(_iTime/FPS);
+        _iNextAmount = 0;
+    };
+    
+    this.addEventListener = function( iEvent,cbCompleted, cbOwner ){
+        _aCbCompleted[iEvent] = cbCompleted;
+        _aCbOwner[iEvent] = cbOwner; 
+    };
+    
+    this.increaseValue = function(iNewAmount){
+        _iNextAmount = iNewAmount;
+    };
+    
+    this.getTarget = function(){
+        return _oTarget;
+    };
+    
+    this.update = function(){
+        _iCntFrames++;
+        if ( _iCntFrames > _iMaxFrames ){
+            _iCntFrames = 0;
+            
+            _oTarget.text =  _iTotWin.toFixed(0);
+            if(_oTargetStroke !== null){
+                _oTargetStroke.text =  _iTotWin.toFixed(0);
+            } 
+            
+            //CALLBACK
+            if(_aCbCompleted[ON_CONTROLLER_END] !== null){
+                _aCbCompleted[ON_CONTROLLER_END].call(_aCbOwner[ON_CONTROLLER_END],this);
+            }
+            
+            if(_iNextAmount > 0){
+                this.setUpdateInfo(_iNextAmount);
+            }else{
+                _aCbCompleted[ON_CONTROLLER_REMOVE].call(_aCbOwner[ON_CONTROLLER_REMOVE],this);
+            }
+            
+            return;
+        }
+        
+        var fLerpY;
+        switch(_szCurEasing){
+            case EASE_BACKIN: {
+                    fLerpY = s_oTweenController.easeInBack( _iCntFrames, 0 ,1, _iMaxFrames);
+                    break;
+            }
+            case EASE_BACKOUT:{
+                    fLerpY = s_oTweenController.easeOutBack( _iCntFrames, 0 ,1, _iMaxFrames);
+                    break;
+            }
+            case EASE_CUBIC_IN:{
+                    fLerpY = s_oTweenController.easeInCubic( _iCntFrames, 0 ,1, _iMaxFrames);
+                    break;
+            }
+            case EASE_CUBIC_OUT:{
+                    fLerpY = s_oTweenController.easeOutCubic( _iCntFrames, 0 ,1, _iMaxFrames);
+                    break;
+            }
+            case EASE_ELASTIC_OUT:{
+                    fLerpY = s_oTweenController.easeOutElastic( _iCntFrames, 0 ,1, _iMaxFrames);
+                    break;
+            }
+            case EASE_LINEAR:{
+                    fLerpY = s_oTweenController.easeLinear( _iCntFrames, 0 ,1, _iMaxFrames);
+                    break;
+            }
+            case EASE_QUART_BACKIN:{
+                    fLerpY = s_oTweenController.easeBackInQuart( _iCntFrames, 0 ,1, _iMaxFrames);
+                    break;
+            }
+            default:{
+                    fLerpY = s_oTweenController.easeLinear( _iCntFrames, 0 ,1, _iMaxFrames);
+            }
+        }
+        
+        var iValue = s_oTweenController.tweenValue( _iCurStart, _iTotWin, fLerpY);
+
+
+        _oTarget.text =  iValue.toFixed(0);
+        if(_oTargetStroke !== null){
+            _oTargetStroke.text =  iValue.toFixed(0);
+        }        
+    };
+    
+    this._init(oTarget,oTargetStroke,iAmountToIncrease,iTime,szEasing);
+};

+ 57 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CRollingTextManager.js

@@ -0,0 +1,57 @@
+function CRollingTextManager(){
+    
+    var _aControllerList = new Array();
+    var _aControllerToRemove = new Array();
+    s_oTweenController = new CTweenController();
+    
+    this.add = function(oTarget,oTargetStroke,iAmountToIncrease,iTime,szEasing,oCallback,oCallbackOwner){
+        
+        var iCheck = this._checkIfControllerExist(oTarget);
+        
+        if( iCheck === -1){
+            
+            var oController = new CRollingTextController(oTarget,oTargetStroke,iAmountToIncrease,iTime,szEasing);
+            oController.addEventListener(ON_CONTROLLER_END,oCallback,oCallbackOwner);
+            oController.addEventListener(ON_CONTROLLER_REMOVE,this._onRemoveController,this);
+
+            _aControllerList.push(oController);
+        }else{
+            _aControllerList[iCheck].increaseValue(iAmountToIncrease);
+        }
+        
+    };
+    
+    this._checkIfControllerExist = function(oTarget){
+        for(var i=0;i<_aControllerList.length;i++){
+            if(_aControllerList[i].getTarget() === oTarget){
+                return i;
+            }
+        }
+        
+        return -1;
+    };
+    
+    this._onRemoveController = function(oController){
+        _aControllerToRemove.push(oController);
+    };
+    
+    this.update = function(){
+        for(var i=0;i<_aControllerList.length;i++){
+            _aControllerList[i].update();
+        }
+        
+        //REMOVE UNUSED CONTROLLERS
+        for(var j=0;j<_aControllerToRemove.length;j++){
+            for(var k=0;k<_aControllerList.length;k++){
+                if(_aControllerToRemove[j] === _aControllerList[k]){
+                    _aControllerList.splice(k,1);
+                    break;
+                }
+            }
+        }
+        
+        _aControllerToRemove = new Array();
+    };
+}
+
+var s_oTweenController;

+ 120 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CTextButton.js

@@ -0,0 +1,120 @@
+function CTextButton(iXPos,iYPos,oSprite,szText,szFont,szColor,iFontSize){
+    
+    var _aCbCompleted;
+    var _aCbOwner;
+    var _oButton;
+    var _oText;
+    var _oTextBack;
+    
+    this._init =function(iXPos,iYPos,oSprite,szText,szFont,szColor,iFontSize){
+        
+        _aCbCompleted=new Array();
+        _aCbOwner =new Array();
+
+        var oButtonBg = createBitmap( oSprite);
+
+        var iStepShadow = Math.ceil(iFontSize/20);
+
+        _oTextBack = new createjs.Text(szText,iFontSize+"px "+szFont, "#000000");
+        _oTextBack.textAlign = "center";
+        _oTextBack.textBaseline = "alphabetic";
+        var oBounds = _oTextBack.getBounds();    
+        _oTextBack.x = oSprite.width/2 + iStepShadow;
+        _oTextBack.y = Math.floor((oSprite.height)/2) +(oBounds.height/3) + iStepShadow;
+
+        _oText = new createjs.Text(szText,iFontSize+"px "+szFont, szColor);
+        _oText.textAlign = "center";
+        _oText.textBaseline = "alphabetic";
+        var oBounds = _oText.getBounds();    
+        _oText.x = oSprite.width/2;
+        _oText.y = Math.floor((oSprite.height)/2) +(oBounds.height/3);
+
+        _oButton = new createjs.Container();
+        _oButton.x = iXPos;
+        _oButton.y = iYPos;
+        _oButton.regX = oSprite.width/2;
+        _oButton.regY = oSprite.height/2;
+        _oButton.addChild(oButtonBg,_oTextBack,_oText);
+
+        s_oStage.addChild(_oButton);
+
+        this._initListener();
+    };
+    
+    this.unload = function(){
+       _oButton.off("mousedown");
+       _oButton.off("pressup");
+       
+       s_oStage.removeChild(_oButton);
+    };
+    
+    this.setVisible = function(bVisible){
+        _oButton.visible = bVisible;
+    };
+    
+    this._initListener = function(){
+       oParent = this;
+
+       _oButton.on("mousedown", this.buttonDown);
+       _oButton.on("pressup" , this.buttonRelease);      
+    };
+    
+    this.addEventListener = function( iEvent,cbCompleted, cbOwner ){
+        _aCbCompleted[iEvent]=cbCompleted;
+        _aCbOwner[iEvent] = cbOwner; 
+    };
+    
+    this.buttonRelease = function(){
+        _oButton.scaleX = 1;
+        _oButton.scaleY = 1;
+
+        if(_aCbCompleted[ON_MOUSE_UP]){
+            _aCbCompleted[ON_MOUSE_UP].call(_aCbOwner[ON_MOUSE_UP]);
+        }
+    };
+    
+    this.buttonDown = function(){
+        _oButton.scaleX = 0.9;
+        _oButton.scaleY = 0.9;
+
+       if(_aCbCompleted[ON_MOUSE_DOWN]){
+           _aCbCompleted[ON_MOUSE_DOWN].call(_aCbOwner[ON_MOUSE_DOWN]);
+       }
+    };
+    
+    
+    this.setTextPosition = function(iY){
+        _oText.y= iY;
+        _oTextBack.y = iY+2;
+    };
+    
+    this.setPosition = function(iXPos,iYPos){
+         _oButton.x = iXPos;
+         _oButton.y = iYPos;
+    };
+    
+    this.setX = function(iXPos){
+         _oButton.x = iXPos;
+    };
+    
+    this.setY = function(iYPos){
+         _oButton.y = iYPos;
+    };
+    
+    this.getButtonImage = function(){
+        return _oButton;
+    };
+
+    this.getX = function(){
+        return _oButton.x;
+    };
+    
+    this.getY = function(){
+        return _oButton.y;
+    };
+
+    this._init(iXPos,iYPos,oSprite,szText,szFont,szColor,iFontSize);
+    
+    return this;
+    
+}

+ 102 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CToggle.js

@@ -0,0 +1,102 @@
+function CToggle(iXPos,iYPos,oSprite,bActive,oParentContainer){
+    var _oParentContainer = oParentContainer;
+    
+    var _bActive;
+    var _aCbCompleted;
+    var _aCbOwner;
+    var _aParams = [];
+    var _oButton;
+    
+    this._init = function(iXPos,iYPos,oSprite,bActive){
+        _aCbCompleted=new Array();
+        _aCbOwner =new Array();
+        
+        var oData = {   
+                        images: [oSprite], 
+                        // width, height & registration point of each sprite
+                        frames: {width: oSprite.width/2, height: oSprite.height, regX: (oSprite.width/2)/2, regY: oSprite.height/2}, 
+                        animations: {state_true:[0],state_false:[1]}
+                   };
+                   
+         var oSpriteSheet = new createjs.SpriteSheet(oData);
+         
+         _bActive = bActive;
+		_oButton = createSprite(oSpriteSheet, "state_"+_bActive,(oSprite.width/2)/2,oSprite.height/2,oSprite.width/2,oSprite.height);
+         
+        _oButton.x = iXPos;
+        _oButton.y = iYPos; 
+        _oButton.stop();
+        _oButton.cursor = "pointer";
+        
+        if(!_oParentContainer){
+            _oParentContainer = s_oStage;
+        }
+        
+        _oParentContainer.addChild(_oButton);
+        
+        this._initListener();
+    };
+    
+    this.unload = function(){
+       _oButton.off("mousedown", this.buttonDown);
+       _oButton.off("pressup" , this.buttonRelease);
+	   
+       _oParentContainer.removeChild(_oButton);
+    };
+    
+    this._initListener = function(){
+       _oButton.on("mousedown", this.buttonDown);
+       _oButton.on("pressup" , this.buttonRelease);      
+    };
+    
+    this.addEventListener = function( iEvent,cbCompleted, cbOwner ){
+        _aCbCompleted[iEvent]=cbCompleted;
+        _aCbOwner[iEvent] = cbOwner; 
+    };
+    
+    this.addEventListenerWithParams = function(iEvent,cbCompleted, cbOwner,aParams){
+        _aCbCompleted[iEvent]=cbCompleted;
+        _aCbOwner[iEvent] = cbOwner;
+        _aParams = aParams;
+    };
+    
+    this.setActive = function(bActive){
+        _bActive = bActive;
+        _oButton.gotoAndStop("state_"+_bActive);
+    };
+    
+    this.buttonRelease = function(){
+        _oButton.scaleX = 1;
+        _oButton.scaleY = 1;
+        
+        playSound("click",1,false);
+        
+        _bActive = !_bActive;
+        _oButton.gotoAndStop("state_"+_bActive);
+
+        if(_aCbCompleted[ON_MOUSE_UP]){
+            _aCbCompleted[ON_MOUSE_UP].call(_aCbOwner[ON_MOUSE_UP],_aParams);
+        }
+    };
+    
+    this.buttonDown = function(){
+        _oButton.scaleX = 0.9;
+        _oButton.scaleY = 0.9;
+
+        
+       if(_aCbCompleted[ON_MOUSE_DOWN]){
+           _aCbCompleted[ON_MOUSE_DOWN].call(_aCbOwner[ON_MOUSE_DOWN],_aParams);
+       }
+    };
+    
+    this.setPosition = function(iXPos,iYPos){
+         _oButton.x = iXPos;
+         _oButton.y = iYPos;
+    };
+    
+    this.setVisible = function(bVisible){
+        _oButton.visible = bVisible;
+    };
+    
+    this._init(iXPos,iYPos,oSprite,bActive);
+}

+ 63 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/CTweenController.js

@@ -0,0 +1,63 @@
+//THIS CLASS MANAGES THE TWEEN AND EASING FOR THE REEL MOVEMENTS
+var EASE_LINEAR = 0;
+var EASE_CUBIC_IN = 1;
+var EASE_QUART_BACKIN = 2;
+var EASE_BACKIN = 3;
+var EASE_CUBIC_OUT = 4;
+var EASE_ELASTIC_OUT = 5;
+var EASE_BACKOUT = 6;
+
+function CTweenController(){
+    
+    this.tweenValue = function( fStart, fEnd, fLerp ){
+        return fStart + fLerp *( fEnd-fStart);     
+    };
+    
+    this.easeLinear = function(t, b, c, d) {
+            return c*t/d + b;
+    };
+    
+    this.easeInCubic = function(t, b, c, d) {
+	var tc=(t/=d)*t*t;
+	return b+c*(tc);
+    };
+
+
+    this.easeBackInQuart =  function(t, b, c, d) {
+	var ts=(t/=d)*t;
+	var tc=ts*t;
+	return b+c*(2*ts*ts + 2*tc + -3*ts);
+    };
+    
+    this.easeInBack = function(t, b, c, d ) {
+        return c*(t/=d)*t*((1.70158+1)*t - 1.70158) + b;
+    };
+    
+    this.easeOutCubic = function(t, b, c, d){
+        return c*((t=t/d-1)*t*t + 1) + b;
+    };
+    
+    this.easeOutElastic = function(t, b, c, d){
+	var s = 0;
+        var a;
+        var p;
+        
+        if (t === 0) {
+                return b;
+        }
+        if ((t /= d) === 1) {
+                return b + c;  
+        }
+
+        p=d*.3;
+        a = c; 
+        s = p / 4; 
+
+        return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b);
+    };
+    
+    this.easeOutBack =  function(t, b, c, d) {
+        var s = 1.70158;
+        return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
+    };
+}

File diff suppressed because it is too large
+ 11 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/createjs-2015.11.26.min.js


File diff suppressed because it is too large
+ 9 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/ctl_utils.js


File diff suppressed because it is too large
+ 1 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/howler.min.js


File diff suppressed because it is too large
+ 1 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/jquery-3.2.1.min.js


+ 163 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/screenfull.js

@@ -0,0 +1,163 @@
+(function () {
+	'use strict';
+
+	var document = typeof window !== 'undefined' && typeof window.document !== 'undefined' ? window.document : {};
+	var isCommonjs = typeof module !== 'undefined' && module.exports;
+	var keyboardAllowed = typeof Element !== 'undefined' && 'ALLOW_KEYBOARD_INPUT' in Element;
+
+	var fn = (function () {
+		var val;
+
+		var fnMap = [
+			[
+				'requestFullscreen',
+				'exitFullscreen',
+				'fullscreenElement',
+				'fullscreenEnabled',
+				'fullscreenchange',
+				'fullscreenerror'
+			],
+			// New WebKit
+			[
+				'webkitRequestFullscreen',
+				'webkitExitFullscreen',
+				'webkitFullscreenElement',
+				'webkitFullscreenEnabled',
+				'webkitfullscreenchange',
+				'webkitfullscreenerror'
+
+			],
+			// Old WebKit (Safari 5.1)
+			[
+				'webkitRequestFullScreen',
+				'webkitCancelFullScreen',
+				'webkitCurrentFullScreenElement',
+				'webkitCancelFullScreen',
+				'webkitfullscreenchange',
+				'webkitfullscreenerror'
+
+			],
+			[
+				'mozRequestFullScreen',
+				'mozCancelFullScreen',
+				'mozFullScreenElement',
+				'mozFullScreenEnabled',
+				'mozfullscreenchange',
+				'mozfullscreenerror'
+			],
+			[
+				'msRequestFullscreen',
+				'msExitFullscreen',
+				'msFullscreenElement',
+				'msFullscreenEnabled',
+				'MSFullscreenChange',
+				'MSFullscreenError'
+			]
+		];
+
+		var i = 0;
+		var l = fnMap.length;
+		var ret = {};
+
+		for (; i < l; i++) {
+			val = fnMap[i];
+			if (val && val[1] in document) {
+				for (i = 0; i < val.length; i++) {
+					ret[fnMap[0][i]] = val[i];
+				}
+				return ret;
+			}
+		}
+
+		return false;
+	})();
+
+	var eventNameMap = {
+		change: fn.fullscreenchange,
+		error: fn.fullscreenerror
+	};
+
+	var screenfull = {
+		request: function (elem) {
+			var request = fn.requestFullscreen;
+
+			elem = elem || document.documentElement;
+
+			// Work around Safari 5.1 bug: reports support for
+			// keyboard in fullscreen even though it doesn't.
+			// Browser sniffing, since the alternative with
+			// setTimeout is even worse.
+			if (/5\.1[.\d]* Safari/.test(navigator.userAgent)) {
+				elem[request]();
+			} else {
+				elem[request](keyboardAllowed && Element.ALLOW_KEYBOARD_INPUT);
+			}
+		},
+		exit: function () {
+			document[fn.exitFullscreen]();
+		},
+		toggle: function (elem) {
+			if (this.isFullscreen) {
+				this.exit();
+			} else {
+				this.request(elem);
+			}
+		},
+		onchange: function (callback) {
+			this.on('change', callback);
+		},
+		onerror: function (callback) {
+			this.on('error', callback);
+		},
+		on: function (event, callback) {
+			var eventName = eventNameMap[event];
+			if (eventName) {
+				document.addEventListener(eventName, callback, false);
+			}
+		},
+		off: function (event, callback) {
+			var eventName = eventNameMap[event];
+			if (eventName) {
+				document.removeEventListener(eventName, callback, false);
+			}
+		},
+		raw: fn
+	};
+
+	if (!fn) {
+		if (isCommonjs) {
+			module.exports = false;
+		} else {
+			window.screenfull = false;
+		}
+
+		return;
+	}
+
+	Object.defineProperties(screenfull, {
+		isFullscreen: {
+			get: function () {
+				return Boolean(document[fn.fullscreenElement]);
+			}
+		},
+		element: {
+			enumerable: true,
+			get: function () {
+				return document[fn.fullscreenElement];
+			}
+		},
+		enabled: {
+			enumerable: true,
+			get: function () {
+				// Coerce to boolean in case of old WebKit
+				return Boolean(document[fn.fullscreenEnabled]);
+			}
+		}
+	});
+
+	if (isCommonjs) {
+		module.exports = screenfull;
+	} else {
+		window.screenfull = screenfull;
+	}
+})();

+ 64 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/settings.js

@@ -0,0 +1,64 @@
+var CANVAS_WIDTH = 640;
+var CANVAS_HEIGHT = 960;
+
+var FONT = "survivantregular";
+
+var EDGEBOARD_X = 20;
+var EDGEBOARD_Y = 95;
+
+var FPS = 30;
+var FPS_TIME              = 1000/FPS;
+var DISABLE_SOUND_MOBILE  = false;
+
+var LEVEL_NUM = 10;
+var WORLD_SCALE = 100;
+
+var BASKET_Y = CANVAS_HEIGHT-135;
+var DISTANCE_BEETWEEN_BASKETS = 120;
+var BASKETS_X_START = 82;
+
+var NUM_OBJ_TO_PICK_IN_ROW = 6;
+
+var EPSILON = 0.00001;
+
+var WALL = 0;
+var CIRCLE = 1;
+var RECTANGLE = 2;
+var RECTANGLE_MOVING = 3;
+var REVOLUTE_RECTANGLE = 4;
+var REVOLUTE_RECTANGLE_MOVING = 5;
+var PARTICULAR_REVOLUTE_RECTANGLE = 6;
+
+var BASKET = 0;
+
+var CONFIRMATION_EXIT = 0;
+var CONFIRMATION_RESET = 1;
+
+//0 POLIGON FOR BASKET
+
+var POLIGON_POINTS = new Array();
+
+    POLIGON_POINTS.push([{x: "-20.5000", y: "15.0000"}, {x: "-39.5000", y: "11.0000"},  //BASKET LEFT
+                         {x: "-57.5000", y: "-57.0000"}, {x: "-35.5000", y: "-50.0000"}]);
+    POLIGON_POINTS.push([{x: "59.0000", y: "-57.0000"}, {x: "40.5000", y: "12.0000"},  //BASKET RIGHT
+                         {x: "22.5000", y: "12.0000"}, {x: "32.5000", y: "-50.0000"}]);
+
+var STATE_LOADING  = 0;
+var STATE_MENU     = 1;
+var STATE_HELP     = 1;
+var STATE_GAME     = 3;
+
+var ON_MOUSE_DOWN        = 0;
+var ON_MOUSE_UP          = 1;
+var ON_MOUSE_OVER        = 2;
+var ON_MOUSE_OUT         = 3;
+var ON_DRAG_START        = 4;
+var ON_DRAG_END          = 5;
+var ON_BUT_NO_DOWN       = 6;
+var ON_BUT_YES_DOWN      = 7;
+var ON_CONTROLLER_END    = 8;
+var ON_CONTROLLER_REMOVE = 9;
+var ON_TWEEN_ENDED       = 10;
+
+var ENABLE_FULLSCREEN;
+var ENABLE_CHECK_ORIENTATION;

+ 71 - 0
WebChallenge/WebChallenge/wwwroot/games/G11/js/sprite_lib.js

@@ -0,0 +1,71 @@
+/* 
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+function CSpriteLibrary(){
+
+    var _oLibSprites;
+    var _iNumSprites;
+    var _iCntSprites;
+    var _cbCompleted;
+    var _cbTotalCompleted;
+    var _cbOwner;
+    
+    this.init = function( cbCompleted,cbTotalCompleted, cbOwner ){
+        _iNumSprites = 0;
+        _iCntSprites = 0;
+        _cbCompleted = cbCompleted;
+        _cbTotalCompleted = cbTotalCompleted;
+        _cbOwner     = cbOwner;
+		
+        _oLibSprites = {};
+    }
+    
+    this.addSprite = function( szKey, szPath ){
+        if ( _oLibSprites.hasOwnProperty(szKey) ){
+            return;
+        }
+        
+        _oLibSprites[szKey] = { szPath:szPath, oSprite: new Image() };
+        _iNumSprites++;
+        
+    }
+    
+    this.getSprite = function( szKey ){
+        if (!_oLibSprites.hasOwnProperty(szKey)){
+            return null;
+        }else{
+            return _oLibSprites[szKey].oSprite;
+        }
+    }
+    
+    this._onSpritesLoaded = function(){
+        _cbTotalCompleted.call(_cbOwner);
+    }
+    
+    
+    
+    this._onSpriteLoaded = function(){
+        _cbCompleted.call(_cbOwner);
+        if (++_iCntSprites == _iNumSprites) {
+            this._onSpritesLoaded();
+        }
+        
+    }    
+
+    this.loadSprites = function(){
+        for (var szKey in _oLibSprites) {
+            _oLibSprites[szKey].oSprite["oSpriteLibrary"] = this;
+            _oLibSprites[szKey].oSprite.onload = function(){
+                this.oSpriteLibrary._onSpriteLoaded();
+            };
+            _oLibSprites[szKey].oSprite.src = _oLibSprites[szKey].szPath;
+        } 
+    }
+    
+    this.getNumSprites=function(){
+        return _iNumSprites;
+    }
+}
+

BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sounds/click.mp3


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sounds/click.ogg


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sounds/game_over.mp3


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sounds/game_over.ogg


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sounds/hit_basket.mp3


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sounds/hit_basket.ogg


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sounds/hit_obstacles.mp3


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sounds/hit_obstacles.ogg


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sounds/next_level.mp3


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sounds/next_level.ogg


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sounds/pick_object.mp3


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sounds/pick_object.ogg


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sounds/soundtrack.mp3


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sounds/soundtrack.ogg


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/audio_icon.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/ball_0.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/ball_1.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/basket_back.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/basket_front.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_game.jpg


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu.jpg


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/0-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/1-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/10-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/11-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/12-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/13-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/14-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/15-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/16-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/17-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/18-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/19-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/2-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/20-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/21-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/3-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/4-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/5-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/6-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/7-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/8-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_menu_animation/9-main-menu-animation.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_preloader.jpg


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/bg_tile.jpg


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_continue.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_exit.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_fullscreen.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_home.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_info.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_next.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_play.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/but_restart.png


BIN
WebChallenge/WebChallenge/wwwroot/games/G11/sprites/cursor_help.png


Some files were not shown because too many files changed in this diff