diff --git a/views/archive/j/audio-game/css/audiogame.css b/views/archive/j/audio-game/css/audiogame.css new file mode 100644 index 00000000..b64964a0 --- /dev/null +++ b/views/archive/j/audio-game/css/audiogame.css @@ -0,0 +1,114 @@ +body { + background: #837400; + color: #333; + padding: 50px; +} + +#game { + position: relative; + width: 768px; + height: 440px; + overflow: hidden; +} + +#game, footer { + width: 768px; + margin: 0 auto; +} + +.scene { + position: absolute; + width: 100%; + height: 100%; +} + +#menu-scene { + background: #ccc url(../images/menu_bg.jpg); + display: -webkit-box; + -webkit-box-pack:center; + -webkit-box-align: center; + + display: -moz-box; + -moz-box-pack:center; + -moz-box-align: center; + + display: box; + box-pack:center; + box-align: center; +} + +#game-scene { + background: #efefef url(../images/game_bg.jpg); + top: -440px; +} + +#game-scene.show-scene { + top: 0; + -webkit-transition: top .3s linear; + -moz-transition: top .3s linear; + transition: top .3s linear; +} + + +#game-canvas, #game-background-canvas { + position: absolute; +} + + +/* Menu Scene Elements */ +a[href='#game'] { + width: 146px; + height: 78px; + background: url(../images/play_button.png); + overflow: hidden; + display: block; +} + +a[href='#game']:hover { + background-position: -146px; +} + +a[href='#game']:active { + background-position: -292px; +} + +a[href='#game'] span { + display: block; + margin-top: -999px; +} + +/* Game Scene Elements */ + +.hit-line { + background: url(../images/hit_line.png); + position: absolute; + width: 50px; + height: 50px; +} + + +.show { + opacity: 1; +} + +.hide{ + opacity: 0; + -webkit-transition: opacity .2s linear; + -moz-transition: opacity .2s linear; + transition: opacity .2s linear; +} + +#hit-line-1 { + left: 259px; + top: 335px; +} + +#hit-line-2 { + left: 359px; + top: 335px; +} + +#hit-line-3 { + left: 459px; + top: 335px; +} diff --git a/views/archive/j/audio-game/images/dot.png b/views/archive/j/audio-game/images/dot.png new file mode 100644 index 00000000..affcf3a6 Binary files /dev/null and b/views/archive/j/audio-game/images/dot.png differ diff --git a/views/archive/j/audio-game/images/game_bg.jpg b/views/archive/j/audio-game/images/game_bg.jpg new file mode 100644 index 00000000..d06e4fc0 Binary files /dev/null and b/views/archive/j/audio-game/images/game_bg.jpg differ diff --git a/views/archive/j/audio-game/images/hit_line.png b/views/archive/j/audio-game/images/hit_line.png new file mode 100644 index 00000000..8f616d24 Binary files /dev/null and b/views/archive/j/audio-game/images/hit_line.png differ diff --git a/views/archive/j/audio-game/images/menu_bg.jpg b/views/archive/j/audio-game/images/menu_bg.jpg new file mode 100644 index 00000000..8f192419 Binary files /dev/null and b/views/archive/j/audio-game/images/menu_bg.jpg differ diff --git a/views/archive/j/audio-game/images/play_button.png b/views/archive/j/audio-game/images/play_button.png new file mode 100644 index 00000000..3abd992a Binary files /dev/null and b/views/archive/j/audio-game/images/play_button.png differ diff --git a/views/archive/j/audio-game/index.htm b/views/archive/j/audio-game/index.htm new file mode 100644 index 00000000..b75ccedb --- /dev/null +++ b/views/archive/j/audio-game/index.htm @@ -0,0 +1,53 @@ + + + + + HTML5 Audio Game + + + +
+ + +
+ + Sorry, your web browser does not support canvas content. + + + Sorry, your web browser does not support canvas content. + +
+
+
+
+
+ + + + + + + + + + + + + + diff --git a/views/archive/j/audio-game/js/html5games.audio.js b/views/archive/j/audio-game/js/html5games.audio.js new file mode 100644 index 00000000..986d780b --- /dev/null +++ b/views/archive/j/audio-game/js/html5games.audio.js @@ -0,0 +1,314 @@ +function MusicNote(time,line){ + this.time = time; + this.line = line; +} + +function Dot(distance, line) { + this.distance = distance; + this.line = line; + this.missed = false; +} + + +// a global object variable to store all game scope variable. +var audiogame = {}; + +// toggle the game between play mode and record mode. +audiogame.isRecordMode = false; + +// an array to store all music notes data. +audiogame.musicNotes = []; + +audiogame.leveldata = "1.592,3;1.984,2;2.466,1;2.949,2;4.022,3;4.443,2;4.594,1;5.498,3;5.92,2;6.04,1;7.034,2;7.395,3;7.968,2;8.45,1;8.962,2;10.018,3;10.258,2;10.44,2;10.711,1;10.977,2;11.556,3;12.008,1;13.588,3;14.013,2;14.495,1;14.946,2;16.003,3;16.395,2;16.546,1;17.48,3;17.85,2;18.001,1;19.026,2;19.508,3;19.96,2;20.412,1;20.955,2;22.01,3;22.252,2;22.432,2;22.673,1;23.518,3;23.788,2;24.029,1;25.024,3;25.506,2;26.019,1;26.531,2;27.043,3;28.038,3;28.52,2;28.972,1;29.454,2;29.967,3;30.51,2;31.022,3;31.474,2;31.956,3;32.408,2;32.89,3;33.433,2;34.006,3;34.398,2;34.518,1;35.453,3;35.875,2;36.026,1;37.111,2;37.504,3;38.016,1;38.529,3;38.981,2;39.524,3;40.007,2;40.459,1;40.971,2;41.483,3;41.936,2;42.448,1;42.992,2;43.444,3;43.956,2;44.378,3;44.92,2;45.945,3;46.337,2;46.488,1;47.513,3;47.875,2;47.995,1;49.141,2;49.533,3;50.045,2;50.557,1;51.039,2;51.521,3;52.004,2;52.486,1;52.998,2;53.481,3;53.993,2;54.505,1;54.988,2;55.44,3;55.952,2;56.434,3;56.916,2;57.429,1;57.911,2;58.454,3;58.966,2;59.539,3;60.051,2;61.256,3;61.739,2;62.222,1;62.704,2;63.216,3;63.699,2;64.212,1;64.755,2;65.267,3;65.749,2;66.261,3;66.743,2;67.256,3;67.738,2;68.251,1;68.764,2;69.247,3;69.729,2;70.271,3;70.753,2;71.265,1;71.717,2;72.289,3;73.223,3;73.736,2;74.249,1;74.731,2;75.274,3;75.756,2;76.268,3;76.78,2;77.262,3;77.744,2;78.257,3;78.77,2;79.252,1;79.765,2;80.277,3;80.729,2;81.241,1;81.754,2;82.266,3;82.779,3;83.261,2;83.744,1;84.256,2;84.799,3;85.643,3;86.276,2;86.758,3;87.24,2;87.722,3;88.236,2;88.778,1;89.26,2;89.773,3;90.256,2;90.708,1;91.191,2;91.763,3;92.216,2;92.729,3;93.241,2;93.753,1;94.235,3;94.748,3;95.29,2;95.742,3;96.224,2;96.827,3;97.671,3;98.334,3;98.906,3;100.022,3;100.444,2;100.564,1;101.468,3;101.859,2;102.01,1;102.975,2;103.367,3;103.518,2;103.88,3;104.031,2;104.393,3;104.544,2;104.905,3;105.057,2;105.961,3;106.205,2;106.416,2;106.657,1;106.928,2;107.169,3;107.441,2;107.712,1;107.984,3;108.527,2;109.009,1;109.401,2;109.521,3;110.034,2;110.546,3;111.029,2;111.964,3;112.084,2;112.265,1;112.416,2;112.988,3;113.501,3;113.892,2;114.043,1;114.525,2;115.037,3;115.399,2;115.55,1;115.852,3;116.002,2;116.365,3;116.485,2;116.847,3;116.998,2;117.963,3;118.354,2;118.506,1;119.503,3;119.865,2;120.015,1;"; + + +// the visual dots drawn on the canvas. +audiogame.dots = []; +audiogame.startingTime = 0; + +// reference of the dot image +audiogame.dotImage = new Image(); +audiogame.totalDotsCount = 0; +audiogame.totalSuccessCount = 0; + +// storing the success count of last 5 results. +audiogame.successCount = 5; + +function setupLevelData() +{ + var notes = audiogame.leveldata.split(";"); + + // store the total number of dots + audiogame.totalDotsCount = notes.length; + + for(var i in notes) + { + var note = notes[i].split(","); + var time = parseFloat(note[0]); + var line = parseInt(note[1]); + var musicNote = new MusicNote(time,line); + audiogame.musicNotes.push(musicNote); + } +} + +// init function when the DOM is ready +$(function(){ + // get the references of the audio element. + audiogame.melody = document.getElementById("melody"); + $(audiogame.melody).bind('ended', onMelodyEnded); + audiogame.base = document.getElementById("base"); + audiogame.buttonOverSound = document.getElementById("buttonover"); + audiogame.buttonOverSound.volume = .3; + audiogame.buttonActiveSound = document.getElementById("buttonactive"); + audiogame.buttonActiveSound.volume = .3; + + // load the dot image + audiogame.dotImage.src = "images/dot.png"; + + // listen the button event that links to #game + $("a[href='#game']") + .hover(function(){ + audiogame.buttonOverSound.currentTime = 0; + audiogame.buttonOverSound.play(); + },function(){ + audiogame.buttonOverSound.pause(); + }) + .click(function(){ + audiogame.buttonActiveSound.currentTime = 0; + audiogame.buttonActiveSound.play(); + + $("#game-scene").addClass('show-scene'); + + startGame(); + + return false; + }); + + // keydown + $(document).keydown(function(e){ + var line = e.which-73; + $('#hit-line-'+line).removeClass('hide'); + $('#hit-line-'+line).addClass('show'); + + if (audiogame.isRecordMode) + { + // print the stored music notes data when press ";" (186) + if (e.which == 186) + { + var musicNotesString = ""; + for(var i in audiogame.musicNotes) + { + musicNotesString += audiogame.musicNotes[i].time+","+audiogame.musicNotes[i].line+";"; + } + console.log(musicNotesString); + } + + var currentTime = audiogame.melody.currentTime.toFixed(3); + var note = new MusicNote(currentTime, e.which-73); + audiogame.musicNotes.push(note); + } + else + { + // our target is J(74), K(75), L(76) + var hitLine = e.which-73; + + // check if hit a music note dot + for(var i in audiogame.dots) + { + if (hitLine == audiogame.dots[i].line && Math.abs(audiogame.dots[i].distance) < 20) + { + // remove the hit dot from the dots array + audiogame.dots.splice(i, 1); + + // increase the success count + audiogame.successCount++; + + // keep only 5 success count max. + audiogame.successCount = Math.min(5, audiogame.successCount); + + // increase the total success count + audiogame.totalSuccessCount ++; + } + } + } + }); + $(document).keyup(function(e){ + var line = e.which-73; + $('#hit-line-'+line).removeClass('show'); + $('#hit-line-'+line).addClass('hide'); + }); + + if (!audiogame.isRecordMode) + { + setupLevelData(); + } + + drawBackground(); + + if (!audiogame.isRecordMode) + { + setInterval(gameloop, 30); + } + +}); + +function playMusic() +{ + // play both the melody and base + audiogame.melody.play(); + audiogame.base.play(); +} + +function startGame() +{ + // starting game + var date = new Date(); + audiogame.startingTime = date.getTime(); + setTimeout(playMusic, 3550); +} + +function drawBackground() +{ + // get the reference of the canvas and the context. + var game = document.getElementById("game-background-canvas"); + var ctx = game.getContext('2d'); + + // set the line style of the three vertical lines. + ctx.lineWidth = 10; + ctx.strokeStyle = "#000"; + + var center = game.width/2; + + // draw the three lines + // the left line is placed 100 pixels on the left of center. + ctx.beginPath(); + ctx.moveTo(center-100, 50); + ctx.lineTo(center-100, ctx.canvas.height - 50); + ctx.stroke(); + + // the middle line is placed at the center + ctx.beginPath(); + ctx.moveTo(center, 50); + ctx.lineTo(center, ctx.canvas.height - 50); + ctx.stroke(); + + // the right line is placed 100 pixels on the right of center. + ctx.beginPath(); + ctx.moveTo(center+100, 50); + ctx.lineTo(center+100, ctx.canvas.height - 50); + ctx.stroke(); + + // draw the horizontal line + ctx.beginPath(); + ctx.moveTo(center-150, ctx.canvas.height - 80); + ctx.lineTo(center+150, ctx.canvas.height - 80); + // reset the line style to 1px width and grey before actually drawing the horizontal line. + ctx.lineWidth = 1; + ctx.strokeStyle = "rgba(50,50,50,.8)"; + ctx.stroke(); +} + +// logic that run every 30ms. +function gameloop() +{ + var game = document.getElementById("game-canvas"); + var ctx = game.getContext('2d'); + + // show new dots + // if the game is started + if (audiogame.startingTime != 0) + { + for(var i in audiogame.musicNotes) + { + var date = new Date(); + var elapsedTime = (date.getTime() - audiogame.startingTime)/1000; + var note = audiogame.musicNotes[i]; + + var timeDiff = note.time - elapsedTime; + if (timeDiff >= 0 && timeDiff <= .03) + { + var dot = new Dot(ctx.canvas.height-150, note.line); + audiogame.dots.push(dot); + } + } + } + + // check missed dots + for(var i in audiogame.dots) + { + if (!audiogame.dots[i].missed && audiogame.dots[i].distance < -10) + { + audiogame.dots[i].missed = true; + + // reduce the success count + audiogame.successCount--; + + // reset the success count to 0 if it is lower than 0. + audiogame.successCount = Math.max(0, audiogame.successCount); + + } + + // remove missed dots after moved to the bottom + if (audiogame.dots[i].distance < -100) + { + audiogame.dots.splice(i, 1); + } + } + + // calculate the percentage of the success in last 5 music dots + var successPercent = audiogame.successCount / 5; + + // prevent the successPercent to exceed range(fail safe) + successPercent = Math.max(0, Math.min(1, successPercent)); + + // change the volume of the melody according to the success percentange + audiogame.melody.volume = successPercent; + + + // move the dots + for(var i in audiogame.dots) + { + audiogame.dots[i].distance -= 2.5; + } + + // only clear the dirty area, that is the middle area + ctx.clearRect(ctx.canvas.width/2-200, 0, 400, ctx.canvas.height); + + + // draw the music note dots + for(var i in audiogame.dots) + { + + // prepare the radial gradients fill style + var circle_gradient = ctx.createRadialGradient(-3,-3,1,0,0,20); + circle_gradient.addColorStop(0, "#fff"); + circle_gradient.addColorStop(1, "#cc0"); + ctx.fillStyle = circle_gradient; + + // draw the path + //console.log(ctx.canvas.height-80-audiogame.dots[i].distance); + ctx.save(); + var center = game.width/2; + var dot = audiogame.dots[i]; + var x = center-100 + if (dot.line == 2) + { + x = center; + } + else if (dot.line == 3) + { + x = center+100; + } + ctx.translate(x, ctx.canvas.height-80-audiogame.dots[i].distance); + ctx.drawImage(audiogame.dotImage, -audiogame.dotImage.width/2, -audiogame.dotImage.height/2); + ctx.restore(); + } + +} + +// show game over scene on melody ended. +function onMelodyEnded() +{ + console.log('song ended'); + console.log('success percent: ',audiogame.totalSuccessCount / audiogame.totalDotsCount * 100 + '%'); +} \ No newline at end of file diff --git a/views/archive/j/audio-game/js/jquery-1.6.min.js b/views/archive/j/audio-game/js/jquery-1.6.min.js new file mode 100644 index 00000000..b0d55a9b --- /dev/null +++ b/views/archive/j/audio-game/js/jquery-1.6.min.js @@ -0,0 +1,16 @@ +/*! + * jQuery JavaScript Library v1.6 + * http://jquery.com/ + * + * Copyright 2011, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * + * Date: Mon May 2 13:50:00 2011 -0400 + */ +(function(a,b){function cw(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function ct(a){if(!ch[a]){var b=f("<"+a+">").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d===""){ci||(ci=c.createElement("iframe"),ci.frameBorder=ci.width=ci.height=0),c.body.appendChild(ci);if(!cj||!ci.createElement)cj=(ci.contentWindow||ci.contentDocument).document,cj.write("");b=cj.createElement(a),cj.body.appendChild(b),d=f.css(b,"display"),c.body.removeChild(ci)}ch[a]=d}return ch[a]}function cs(a,b){var c={};f.each(cn.concat.apply([],cn.slice(0,b)),function(){c[this]=a});return c}function cr(){co=b}function cq(){setTimeout(cr,0);return co=f.now()}function cg(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function cf(){try{return new a.XMLHttpRequest}catch(b){}}function b_(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g=0===c})}function V(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function N(a,b){return(a&&a!=="*"?a+".":"")+b.replace(z,"`").replace(A,"&")}function M(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;ic)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function K(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function E(){return!0}function D(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){name="data-"+c.replace(j,"$1-$2").toLowerCase(),d=a.getAttribute(name);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(e){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function H(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(H,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=d.userAgent,x,y,z,A=Object.prototype.toString,B=Object.prototype.hasOwnProperty,C=Array.prototype.push,D=Array.prototype.slice,E=String.prototype.trim,F=Array.prototype.indexOf,G={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)==="<"&&a.charAt(a.length-1)===">"&&a.length>=3?g=[null,a,null]:g=i.exec(a);if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6",length:0,size:function(){return this.length},toArray:function(){return D.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?C.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),y.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(D.apply(this,arguments),"slice",D.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:C,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;y.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!y){y=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",z,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",z),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&H()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):G[A.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;if(a.constructor&&!B.call(a,"constructor")&&!B.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a);return c===b||B.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(b,c,d){a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),d=c.documentElement,(!d||!d.nodeName||d.nodeName==="parsererror")&&e.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c
a",b=a.getElementsByTagName("*"),d=a.getElementsByTagName("a")[0];if(!b||!b.length||!d)return{};e=c.createElement("select"),f=e.appendChild(c.createElement("option")),g=a.getElementsByTagName("input")[0],i={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(d.getAttribute("style")),hrefNormalized:d.getAttribute("href")==="/a",opacity:/^0.55$/.test(d.style.opacity),cssFloat:!!d.style.cssFloat,checkOn:g.value==="on",optSelected:f.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},g.checked=!0,i.noCloneChecked=g.cloneNode(!0).checked,e.disabled=!0,i.optDisabled=!f.disabled;try{delete a.test}catch(r){i.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function click(){i.noCloneEvent=!1,a.detachEvent("onclick",click)}),a.cloneNode(!0).fireEvent("onclick")),g=c.createElement("input"),g.value="t",g.setAttribute("type","radio"),i.radioValue=g.value==="t",g.setAttribute("checked","checked"),a.appendChild(g),j=c.createDocumentFragment(),j.appendChild(a.firstChild),i.checkClone=j.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",k=c.createElement("body"),l={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"};for(p in l)k.style[p]=l[p];k.appendChild(a),c.documentElement.appendChild(k),i.appendChecked=g.checked,i.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,i.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
",i.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
t
",m=a.getElementsByTagName("td"),q=m[0].offsetHeight===0,m[0].style.display="",m[1].style.display="none",i.reliableHiddenOffsets=q&&m[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(h=c.createElement("div"),h.style.width="0",h.style.marginRight="0",a.appendChild(h),i.reliableMarginRight=(parseInt(c.defaultView.getComputedStyle(h,null).marginRight,10)||0)===0),k.innerHTML="",c.documentElement.removeChild(k);if(a.attachEvent)for(p in{submit:1,change:1,focusin:1})o="on"+p,q=o in a,q||(a.setAttribute(o,"return;"),q=typeof a[o]=="function"),i[p+"Bubbles"]=q;return i}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([a-z])([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g=f.expando,h=typeof c=="string",i,j=a.nodeType,k=j?f.cache:a,l=j?a[f.expando]:a[f.expando]&&f.expando;if((!l||e&&l&&!k[l][g])&&h&&d===b)return;l||(j?a[f.expando]=l=++f.uuid:l=f.expando),k[l]||(k[l]={},j||(k[l].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?k[l][g]=f.extend(k[l][g],c):k[l]=f.extend(k[l],c);i=k[l],e&&(i[g]||(i[g]={}),i=i[g]),d!==b&&(i[c]=d);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[c]:i}},removeData:function(b,c,d){if(!!f.acceptData(b)){var e=f.expando,g=b.nodeType,h=g?f.cache:b,i=g?b[f.expando]:f.expando;if(!h[i])return;if(c){var j=d?h[i][e]:h[i];if(j){delete j[c];if(!l(j))return}}if(d){delete h[i][e];if(!l(h[i]))return}var k=h[i][e];f.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=k):g&&(f.support.deleteExpando?delete b[f.expando]:b.removeAttribute?b.removeAttribute(f.expando):b[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;return(e.value||"").replace(p,"")}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||"set"in c&&c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b=a.selectedIndex,c=[],d=a.options,e=a.type==="select-one";if(b<0)return null;for(var g=e?b:0,h=e?b+1:d.length;g=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex",readonly:"readOnly"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);var h,i,j=g!==1||!f.isXMLDoc(a);c=j&&f.attrFix[c]||c,i=f.attrHooks[c]||(v&&(f.nodeName(a,"form")||u.test(c))?v:b);if(d!==b){if(d===null||d===!1&&!t.test(c)){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;d===!0&&!t.test(c)&&(d=c),a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j)return i.get(a,c);h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){a.nodeType===1&&(b=f.attrFix[b]||b,f.support.getSetAttribute?a.removeAttribute(b):(f.attr(a,b,""),a.removeAttributeNode(a.getAttributeNode(b))))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.getAttribute("value");a.setAttribute("type",b),c&&(a.value=c);return b}}},tabIndex:{get:function(a){var c=a.getAttributeNode("tabIndex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}}},propFix:{},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);c=i&&f.propFix[c]||c,h=f.propHooks[c];return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==b?g:a[c]},propHooks:{}}),f.support.getSetAttribute||(f.attrFix=f.extend(f.attrFix,{"for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder"}),v=f.attrHooks.name=f.attrHooks.value=f.valHooks.button={get:function(a,c){var d;if(c==="value"&&!f.nodeName(a,"button"))return a.getAttribute(c);d=a.getAttributeNode(c);return d&&d.specified?d.nodeValue:b},set:function(a,b,c){var d=a.getAttributeNode(c);if(d){d.nodeValue=b;return b}}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var w=Object.prototype.hasOwnProperty,x=/\.(.*)$/,y=/^(?:textarea|input|select)$/i,z=/\./g,A=/ /g,B=/[^\w\s.|`]/g,C=function(a){return a.replace(B,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=D;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=D);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),C).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},J=function J(a){var c=a.target,d,e;if(!!y.test(c.nodeName)&&!c.readOnly){d=f._data(c,"_change_data"),e=I(c),(a.type!=="focusout"||c.type!=="radio")&&f._data(c,"_change_data",e);if(d===b||e===d)return;if(d!=null||e)a.type="change",a.liveFired=b,f.event.trigger(a,arguments[1],c)}};f.event.special.change={filters:{focusout:J,beforedeactivate:J,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&J.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&J.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",I(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in H)f.event.add(this,c+".specialChange",H[c]);return y.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return y.test(this.nodeName)}},H=f.event.special.change.filters,H.focus=H.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){return a.nodeName.toLowerCase()==="input"&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g0)for(h=g;h0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=T.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a=="string")return f.inArray(this[0],a?f(a):this.parent().children());return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(V(c[0])||V(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=S.call(arguments);O.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!U[a]?f.unique(e):e,(this.length>1||Q.test(d))&&P.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var X=/ jQuery\d+="(?:\d+|null)"/g,Y=/^\s+/,Z=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,$=/<([\w:]+)/,_=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};be.optgroup=be.option,be.tbody=be.tfoot=be.colgroup=be.caption=be.thead,be.th=be.td,f.support.htmlSerialize||(be._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(X,""):null;if(typeof a=="string"&&!bb.test(a)&&(f.support.leadingWhitespace||!Y.test(a))&&!be[($.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Z,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bh(a,d),e=bi(a),g=bi(d);for(h=0;e[h];++h)bh(e[h],g[h])}if(b){bg(a,d);if(c){e=bi(a),g=bi(d);for(h=0;e[h];++h)bg(e[h],g[h])}}return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[];for(var i=0,j;(j=a[i])!=null;i++){typeof j=="number"&&(j+="");if(!j)continue;if(typeof j=="string")if(!ba.test(j))j=b.createTextNode(j);else{j=j.replace(Z,"<$1>");var k=($.exec(j)||["",""])[1].toLowerCase(),l=be[k]||be._default,m=l[0],n=b.createElement("div");n.innerHTML=l[1]+j+l[2];while(m--)n=n.lastChild;if(!f.support.tbody){var o=_.test(j),p=k==="table"&&!o?n.firstChild&&n.firstChild.childNodes:l[1]===""&&!o?n.childNodes:[];for(var q=p.length-1;q>=0;--q)f.nodeName(p[q],"tbody")&&!p[q].childNodes.length&&p[q].parentNode.removeChild(p[q])}!f.support.leadingWhitespace&&Y.test(j)&&n.insertBefore(b.createTextNode(Y.exec(j)[0]),n.firstChild),j=n.childNodes}var r;if(!f.support.appendChecked)if(j[0]&&typeof (r=j.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bn.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle;c.zoom=1;var e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.filter=bm.test(g)?g.replace(bm,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bx(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(by=function(a,c){var d,e,g;c=c.replace(bp,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bz=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bq.test(d)&&br.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bx=by||bz,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bC=/%20/g,bD=/\[\]$/,bE=/\r?\n/g,bF=/#.*$/,bG=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bH=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bI=/^(?:about|app|app\-storage|.+\-extension|file|widget):$/,bJ=/^(?:GET|HEAD)$/,bK=/^\/\//,bL=/\?/,bM=/)<[^<]*)*<\/script>/gi,bN=/^(?:select|textarea)/i,bO=/\s+/,bP=/([?&])_=[^&]*/,bQ=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bR=f.fn.load,bS={},bT={},bU,bV;try{bU=e.href}catch(bW){bU=c.createElement("a"),bU.href="",bU=bU.href}bV=bQ.exec(bU.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bR)return bR.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bM,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bN.test(this.nodeName)||bH.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bE,"\r\n")}}):{name:b.name,value:c.replace(bE,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?f.extend(!0,a,f.ajaxSettings,b):(b=a,a=f.extend(!0,f.ajaxSettings,b));for(var c in{context:1,url:1})c in b?a[c]=b[c]:c in f.ajaxSettings&&(a[c]=f.ajaxSettings[c]);return a},ajaxSettings:{url:bU,isLocal:bI.test(bV[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML}},ajaxPrefilter:bX(bS),ajaxTransport:bX(bT),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a?4:0;var o,r,u,w=l?b$(d,v,l):b,x,y;if(a>=200&&a<300||a===304){if(d.ifModified){if(x=v.getResponseHeader("Last-Modified"))f.lastModified[k]=x;if(y=v.getResponseHeader("Etag"))f.etag[k]=y}if(a===304)c="notmodified",o=!0;else try{r=b_(d,w),c="success",o=!0}catch(z){c="parsererror",u=z}}else{u=c;if(!c||a)c="error",a<0&&(a=0)}v.status=a,v.statusText=c,o?h.resolveWith(e,[r,c,v]):h.rejectWith(e,[v,c,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,c]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bG.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bF,"").replace(bK,bV[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bO),d.crossDomain==null&&(r=bQ.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bV[1]&&r[2]==bV[2]&&(r[3]||(r[1]==="http:"?80:443))==(bV[3]||(bV[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bY(bS,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bJ.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bL.test(d.url)?"&":"?")+d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bP,"$1_="+x);d.url=y+(y===d.url?(bL.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", */*; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bY(bT,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){status<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)bZ(g,a[g],c,e);return d.join("&").replace(bC,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var ca=f.now(),cb=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+ca++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cb.test(b.url)||e&&cb.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cb,l),b.url===j&&(e&&(k=k.replace(cb,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cc=a.ActiveXObject?function(){for(var a in ce)ce[a](0,1)}:!1,cd=0,ce;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&cf()||cg()}:cf,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cc&&delete ce[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cd,cc&&(ce||(ce={},f(a).unload(cc)),ce[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ch={},ci,cj,ck=/^(?:toggle|show|hide)$/,cl=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cm,cn=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],co,cp=a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cs("show",3),a,b,c);for(var g=0,h=this.length;g=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a=f.timers,b=a.length;while(b--)a[b]()||a.splice(b,1);a.length||f.fx.stop()},interval:13,stop:function(){clearInterval(cm),cm=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){f.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit:a.elem[a.prop]=a.now}}}),f.expr&&f.expr.filters&&(f.expr.filters.animated=function(a){return f.grep(f.timers,function(b){return a===b.elem}).length});var cu=/^t(?:able|d|h)$/i,cv=/^(?:body|html)$/i;"getBoundingClientRect"in c.documentElement?f.fn.offset=function(a){var b=this[0],c;if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);try{c=b.getBoundingClientRect()}catch(d){}var e=b.ownerDocument,g=e.documentElement;if(!c||!f.contains(g,b))return c?{top:c.top,left:c.left}:{top:0,left:0};var h=e.body,i=cw(e),j=g.clientTop||h.clientTop||0,k=g.clientLeft||h.clientLeft||0,l=i.pageYOffset||f.support.boxModel&&g.scrollTop||h.scrollTop,m=i.pageXOffset||f.support.boxModel&&g.scrollLeft||h.scrollLeft,n=c.top+l-j,o=c.left+m-k;return{top:n,left:o}}:f.fn.offset=function(a){var b=this[0];if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);f.offset.initialize();var c,d=b.offsetParent,e=b,g=b.ownerDocument,h=g.documentElement,i=g.body,j=g.defaultView,k=j?j.getComputedStyle(b,null):b.currentStyle,l=b.offsetTop,m=b.offsetLeft;while((b=b.parentNode)&&b!==i&&b!==h){if(f.offset.supportsFixedPosition&&k.position==="fixed")break;c=j?j.getComputedStyle(b,null):b.currentStyle,l-=b.scrollTop,m-=b.scrollLeft,b===d&&(l+=b.offsetTop,m+=b.offsetLeft,f.offset.doesNotAddBorder&&(!f.offset.doesAddBorderForTableAndCells||!cu.test(b.nodeName))&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),e=d,d=b.offsetParent),f.offset.subtractsBorderForOverflowNotVisible&&c.overflow!=="visible"&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),k=c}if(k.position==="relative"||k.position==="static")l+=i.offsetTop,m+=i.offsetLeft;f.offset.supportsFixedPosition&&k.position==="fixed"&&(l+=Math.max(h.scrollTop,i.scrollTop),m+=Math.max(h.scrollLeft,i.scrollLeft));return{top:l,left:m}},f.offset={initialize:function(){var a=c.body,b=c.createElement("div"),d,e,g,h,i=parseFloat(f.css(a,"marginTop"))||0,j="
";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cv.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cv.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cw(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cw(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){return this[0]?parseFloat(f.css(this[0],d,"padding")):null},f.fn["outer"+c]=function(a){return this[0]?parseFloat(f.css(this[0],d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c];return e.document.compatMode==="CSS1Compat"&&g||e.document.body["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var h=f.css(e,d),i=parseFloat(h);return f.isNaN(i)?h:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window); \ No newline at end of file diff --git a/views/archive/j/audio-game/media/button_active.mp3 b/views/archive/j/audio-game/media/button_active.mp3 new file mode 100644 index 00000000..567861fd Binary files /dev/null and b/views/archive/j/audio-game/media/button_active.mp3 differ diff --git a/views/archive/j/audio-game/media/button_active.ogg b/views/archive/j/audio-game/media/button_active.ogg new file mode 100644 index 00000000..216e5999 Binary files /dev/null and b/views/archive/j/audio-game/media/button_active.ogg differ diff --git a/views/archive/j/audio-game/media/button_over.ogg b/views/archive/j/audio-game/media/button_over.ogg new file mode 100644 index 00000000..88afb7a4 Binary files /dev/null and b/views/archive/j/audio-game/media/button_over.ogg differ diff --git a/views/archive/j/audio-game/media/button_over.wav b/views/archive/j/audio-game/media/button_over.wav new file mode 100644 index 00000000..9e06c92c Binary files /dev/null and b/views/archive/j/audio-game/media/button_over.wav differ diff --git a/views/archive/j/audio-game/media/minuet_in_g.mp3 b/views/archive/j/audio-game/media/minuet_in_g.mp3 new file mode 100644 index 00000000..0e005dcc Binary files /dev/null and b/views/archive/j/audio-game/media/minuet_in_g.mp3 differ diff --git a/views/archive/j/audio-game/media/minuet_in_g.ogg b/views/archive/j/audio-game/media/minuet_in_g.ogg new file mode 100644 index 00000000..41f73043 Binary files /dev/null and b/views/archive/j/audio-game/media/minuet_in_g.ogg differ diff --git a/views/archive/j/audio-game/media/minuet_in_g_melody.mp3 b/views/archive/j/audio-game/media/minuet_in_g_melody.mp3 new file mode 100644 index 00000000..d4c447a5 Binary files /dev/null and b/views/archive/j/audio-game/media/minuet_in_g_melody.mp3 differ diff --git a/views/archive/j/audio-game/media/minuet_in_g_melody.ogg b/views/archive/j/audio-game/media/minuet_in_g_melody.ogg new file mode 100644 index 00000000..f702ad23 Binary files /dev/null and b/views/archive/j/audio-game/media/minuet_in_g_melody.ogg differ diff --git a/views/archive/j/audio-game/readme.md b/views/archive/j/audio-game/readme.md new file mode 100644 index 00000000..b79254b1 --- /dev/null +++ b/views/archive/j/audio-game/readme.md @@ -0,0 +1,9 @@ +# Audio Game + +This game makes use of audio tag and keyboard input to create a music notes dropping game. + +This is originally from the book [HTML5 Games Development by Examples][1]. + +Please note that this code was written in 2012 and I didn't followed some best practice in Javasscript programming. It is suggested to learn the concept and update the code to follow latest JavaScript practice. + +[1]: http://www.packtpub.com/html5-games-development-using-css-javascript-beginners-guide/book diff --git a/views/archive/j/ball-shooting/images/assets.fla b/views/archive/j/ball-shooting/images/assets.fla new file mode 100644 index 00000000..16f7cd4e Binary files /dev/null and b/views/archive/j/ball-shooting/images/assets.fla differ diff --git a/views/archive/j/ball-shooting/images/lv1.png b/views/archive/j/ball-shooting/images/lv1.png new file mode 100644 index 00000000..bb4f5816 Binary files /dev/null and b/views/archive/j/ball-shooting/images/lv1.png differ diff --git a/views/archive/j/ball-shooting/images/lv2.png b/views/archive/j/ball-shooting/images/lv2.png new file mode 100644 index 00000000..4510433a Binary files /dev/null and b/views/archive/j/ball-shooting/images/lv2.png differ diff --git a/views/archive/j/ball-shooting/images/lv3.png b/views/archive/j/ball-shooting/images/lv3.png new file mode 100644 index 00000000..28d1018a Binary files /dev/null and b/views/archive/j/ball-shooting/images/lv3.png differ diff --git a/views/archive/j/ball-shooting/images/lv4.png b/views/archive/j/ball-shooting/images/lv4.png new file mode 100644 index 00000000..934b34d7 Binary files /dev/null and b/views/archive/j/ball-shooting/images/lv4.png differ diff --git a/views/archive/j/ball-shooting/images/lv5.jpg b/views/archive/j/ball-shooting/images/lv5.jpg new file mode 100644 index 00000000..8d02b883 Binary files /dev/null and b/views/archive/j/ball-shooting/images/lv5.jpg differ diff --git a/views/archive/j/ball-shooting/images/lv6.jpg b/views/archive/j/ball-shooting/images/lv6.jpg new file mode 100644 index 00000000..befe248f Binary files /dev/null and b/views/archive/j/ball-shooting/images/lv6.jpg differ diff --git a/views/archive/j/ball-shooting/index.html b/views/archive/j/ball-shooting/index.html new file mode 100644 index 00000000..e67637ca --- /dev/null +++ b/views/archive/j/ball-shooting/index.html @@ -0,0 +1,53 @@ + + + + + + + Shoot the ball + + + + +
+ + +
+
+
+

Shoot the ball

+
+
+
+

How to Play?

+ +
+
+
+

This is a game example for my HTML5 game develapment book.

+
+
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/views/archive/j/ball-shooting/scripts/assets.js b/views/archive/j/ball-shooting/scripts/assets.js new file mode 100644 index 00000000..e019c3ab --- /dev/null +++ b/views/archive/j/ball-shooting/scripts/assets.js @@ -0,0 +1,421 @@ +(function (lib, img, cjs) { + +var p; // shortcut to reference prototypes + +// library properties: +lib.properties = { + width: 550, + height: 400, + fps: 24, + color: "#FFFFFF", + manifest: [ + {src:"../images/lv1.png", id:"lv1"}, + {src:"../images/lv2.png", id:"lv2"}, + {src:"../images/lv3.png", id:"lv3"}, + {src:"../images/lv4.png", id:"lv4"}, + {src:"../images/lv5.jpg", id:"lv5"}, + {src:"../images/lv6.jpg", id:"lv6"} + ] +}; + +// stage content: +(lib.assets = function() { + this.initialize(); + + // Layer 1 + this.instance = new lib.ScoreBoard(); + this.instance.setTransform(215,197.4,1,1,0,0,0,76.9,17.8); + + // Layer 1 + this.instance_1 = new lib.LevelSelection(); + this.instance_1.setTransform(344.6,298.8); + + // Layer 1 + this.instance_2 = new lib.BouncyBall(); + this.instance_2.setTransform(408.2,88.7); + + this.instance_3 = new lib.PowerArrow(); + this.instance_3.setTransform(180,94.9); + + this.instance_4 = new lib.HoopSensor(); + this.instance_4.setTransform(56.9,98); + + this.instance_5 = new lib.BrownSquare(); + this.instance_5.setTransform(361.7,71.9); + + this.instance_6 = new lib.Cross(); + this.instance_6.setTransform(490,97.6); + + this.instance_7 = new lib.HoopBoard(); + this.instance_7.setTransform(23.4,57.3); + + this.instance_8 = new lib.HoopSquare(); + this.instance_8.setTransform(28.4,97.3); + + this.instance_9 = new lib.SlowBall(); + this.instance_9.setTransform(411.2,132.3); + this.instance_9.cache(-16,-16,32,32); + + this.addChild(this.instance_9,this.instance_8,this.instance_7,this.instance_6,this.instance_5,this.instance_4,this.instance_3,this.instance_2,this.instance_1,this.instance); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(292.9,216.8,806.7,642.1); + + +// symbols: +(lib.lv1 = function() { + this.initialize(img.lv1); +}).prototype = p = new cjs.Bitmap(); +p.nominalBounds = new cjs.Rectangle(0,0,894,668); + + +(lib.lv2 = function() { + this.initialize(img.lv2); +}).prototype = p = new cjs.Bitmap(); +p.nominalBounds = new cjs.Rectangle(0,0,924,688); + + +(lib.lv3 = function() { + this.initialize(img.lv3); +}).prototype = p = new cjs.Bitmap(); +p.nominalBounds = new cjs.Rectangle(0,0,918,652); + + +(lib.lv4 = function() { + this.initialize(img.lv4); +}).prototype = p = new cjs.Bitmap(); +p.nominalBounds = new cjs.Rectangle(0,0,904,660); + + +(lib.lv5 = function() { + this.initialize(img.lv5); +}).prototype = p = new cjs.Bitmap(); +p.nominalBounds = new cjs.Rectangle(0,0,912,678); + + +(lib.lv6 = function() { + this.initialize(img.lv6); +}).prototype = p = new cjs.Bitmap(); +p.nominalBounds = new cjs.Rectangle(0,0,920,696); + + +(lib.SlowBall = function() { + this.initialize(); + + // Layer 1 + this.shape = new cjs.Shape(); + this.shape.graphics.f().s("#CC6633").ss(1,1,1).p("Ag8BzQgQgJgOgOQgngmAAg2QAAg0AngmQAOgOAQgJQAcgQAgAAQAhAAAcAPQAQAJAPAPQAmAmAAA0QAAA2gmAmQgPAOgRAJQgbAPghAAQggAAgcgPgAA9hyIgBDlAg8hxIAADk"); + + this.shape_1 = new cjs.Shape(); + this.shape_1.graphics.f("#C27400").s().p("AA9hyQAQAJAPAPQAmAmgBA0QABA1gmAnQgPAOgRAJgAhaBcQgngnABg1QgBg0AngmQAOgOAQgJIAADjQgQgIgOgOg"); + + this.shape_2 = new cjs.Shape(); + this.shape_2.graphics.f("#FF9900").s().p("Ag8BzIAAjkQAcgPAgAAQAhAAAcAOIgBDlQgbAPghgBQggAAgcgOg"); + + this.addChild(this.shape_2,this.shape_1,this.shape); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(-14,-14,28,28); + + +(lib.ScoreBoard = function() { + this.initialize(); + + // Layer 1 + this.textField = new cjs.Text("0", "bold 19px 'Arial'", "#333333"); + this.textField.name = "textField"; + this.textField.lineHeight = 23; + this.textField.lineWidth = 35; + this.textField.setTransform(8.6,3.1); + + this.shape = new cjs.Shape(); + this.shape.graphics.f().s("#000000").p("AESCJQAAAGgCAFQgCAFgEAAIhkgBQgmgBgdACIghABQhAABiEABQgWgDgMAAIhkAAQgDAAgDgFQgDgEAAgHIAAhBQgChJAChKIAAhCQAAgGADgEQADgEADAAIISAAQAEAAACAEQACAEAAAGIAABCQgBAZABAxQACAugCAbg"); + this.shape.setTransform(27.5,15.7); + + this.shape_1 = new cjs.Shape(); + this.shape_1.graphics.f("#FFFCE2").s().p("AikCZIhkAAQgDAAgDgFQgDgEAAgHIAAhBQgChJAChKIAAhCQAAgGADgEQADgEADAAIISAAQAEAAACAEQACAEAAAGIAABCQgBAZABAxQACAugCAbIAABBQAAAGgCAFQgCAFgEAAIhkgBQgmgBgdACIghABIjEACQgWgDgMAAg"); + this.shape_1.setTransform(27.5,15.7); + + this.addChild(this.shape_1,this.shape,this.textField); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(-1,-1,57.1,34.6); + + +(lib.RightButton = function() { + this.initialize(); + + // Layer 1 + this.shape = new cjs.Shape(); + this.shape.graphics.f().s("#000000").p("AB8gBIj3i+IAAF/ID3i+g"); + + this.shape_1 = new cjs.Shape(); + this.shape_1.graphics.f("#FFFCE2").s().p("Ah7i/ID3C+IAAADIj3C+g"); + + this.addChild(this.shape_1,this.shape); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(-13.4,-20.2,27,40.6); + + +(lib.PowerBar = function() { + this.initialize(); + + // Layer 1 + this.shape = new cjs.Shape(); + this.shape.graphics.f("#FF3300").s().p("AgvAKIAAgSIBfAAIAAASg"); + this.shape.setTransform(0,-1); + + this.addChild(this.shape); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(-4.8,-2,9.8,2); + + +(lib.PlayButton = function() { + this.initialize(); + + // Layer 1 + this.text = new cjs.Text("Play Level", "26px 'Andola'"); + this.text.lineHeight = 32; + this.text.setTransform(-70.6,-11.9); + + this.shape = new cjs.Shape(); + this.shape.graphics.f().s("#000000").p("ANCDbQAAAKgGAGQgHAHgKAAQhAAAjxgCQiHgBhvADQjZAFkQgBQlHgDjCgBIg8AAQgJAAgIgHQgGgGAAgKIAAhlQAEhOgBhAQgDiJAAg0QAAgKAGgGQAHgHAKAAIBrAAQC/gNFpAFQFwAGBbgGQDZABB+ADQCAAEAgAAQAKAAAHAHQAGAHAAAJIAABlQgEBOABBAQADCKAAAzg"); + + this.shape_1 = new cjs.Shape(); + this.shape_1.graphics.f("#FFFCE2").s().p("AjlD2IoJgEIg8AAQgJAAgIgHQgGgGAAgKIAAhlQAEhOgBhAQgDiJAAg0QAAgKAGgGQAHgHAKAAIBrAAQC/gNFpAFQFwAGBbgGQDZABB+ADICgAEQAKAAAHAHQAGAHAAAJIAABlQgEBOABBAQADCKAAAzQAAAKgGAGQgHAHgKAAIkxgCQiHgBhvADQi4AEjeAAIhTAAg"); + + this.addChild(this.shape_1,this.shape,this.text); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(-84.4,-26.9,169,56.1); + + +(lib.Levels = function(mode,startPosition,loop) { + this.initialize(mode,startPosition,loop,{}); + + // Layer 1 + this.instance = new lib.lv1(); + this.instance.setTransform(-168.4,-70.2,0.21,0.21); + + this.shape = new cjs.Shape(); + this.shape.graphics.f("#000000").s().p("Aj3EAQgFgBgCgDQgDgDgCgEQgBgFAAgFIABgLIABACIAPACIgBANIANABIADgYIgehjIAZgBIAKAoIAEAXIAEAAQAGgcAGglIARACIgOA8IgLAxQgDATgJAIQgFAEgKAAQgFAAgEgCgAiqD/IgDiEIAPABIADAKQAGgKAFgEIAHgDQAEgCAGAAQAIAAAGAEQAHADAEAHQAEAGACAHQACAIAAAIQAAAOgCAKQgDAKgEAHQgEAHgHAEQgGADgJAAQgGAAgLgFIAAAxgAiXDAIAfgBIAAguIgfAAgApzDXIgegCIACiIQAYgBAXAAQAJAAAHABQAGACAFADQAHAEADAGQADAGAAAIQAAAagYAKIAAAFQAHABAGADQAFADAEAEQAEAFACAFQACAGAAAHQAAAJgDAHQgCAGgFAEQgEAFgHACQgHADgIAAIgdgCgApxDIIAhgDIgBgpIghgBgAp7CJIAigCIACgpIgjAAgAIkDWQgEgBgDgDQgDgDgBgEQgCgEAAgGQAAgHACgHQADgKAFgDQAEgDAMgCQALgDAUgCIgBgTQgRgFgFAAIgDAAIgDAAIgBANIgNgBIgKAAQAAgGADgGQADgFAGgEIAMgGQAHgCAHAAQAJAAAGADQAHACAEAEQAFAFACAGQACAHAAAIIgBAcQABAVACANIgHAAIgPACIgEgMQgIAHgHAEQgIADgIAAQgFAAgEgCgAI9CsIgNAEIAAAXIAYgCIABgbIgMACgAD2DUQgHgFgGgJQgEgHgCgJQgCgIAAgLQAAgJACgJQACgIAEgGQAFgIAHgEQAHgEAKAAQAFAAAEACQAFABADACIAIAGIAGAIQAEAIACAJQADAKAAAKQAAAJgDAIQgDAHgFAHQgFAHgHAEQgHADgJAAQgJAAgIgEgAEVDBIgEg6IgXADIgEAxIAMAEQAGACAIAAIAFAAgAg5DUQgIgDgFgIQgFgGgCgJQgDgIAAgLQAAgKACgJQACgJAFgHQAFgIAHgEQAIgFAJAAQAGAAAEACIAIADIAHAGIAGAHQAIAPAAAWQgYAAgfADIACAYIAbABIABgLIAXgBQgBAHgDAGQgDAFgEAEQgFAEgGACQgFACgHAAQgKAAgIgEgAgaCfIgBgaIgaABIAAAZIAbAAgAkqDWQgFgBgDgDQgEgDgCgFQgCgEAAgGIAAgMQAAgKAEgeIgMgCIABgPIAMABIAKggIAKAAIgBAbIAWABIgBAVIgWAAIgBA4IASAAIgBgNIALAAIAAAJIgBAKQgCAFgDACQgDADgEACQgFABgGAAQgGAAgEgCgAobDWQgEgBgDgDQgCgDgCgEQgBgEAAgGQAAgHACgHQACgKAFgDQAEgDAMgCQAMgDATgCIgBgTQgQgFgFAAIgEAAIgDAAIAAANIgNgBIgKAAQAAgGADgGQADgFAGgEIAMgGQAGgCAHAAQAJAAAHADQAGACAFAEQAEAFACAGQACAHAAAIIAAAcQABAVACANIgHAAIgQACIgEgMQgHAHgIAEQgHADgIAAQgFAAgFgCgAoBCsIgOAEIAAAXIAZgCIABgbIgMACgABvDUIACiJIAfAAIAgBFQAEAIAEAQIAEgBIgChYIAUABIgBCDIgdAAIgXgvQgIgUgKgdIgEABIgBBggAJ4DSIABiJIAZACIgBCIgAHwDSIAAgCIAAgQQAAgZgCgZIgYgBIAABEIgagBIAAhBIgZACIgBBAIgYACIABgpIgBgwIATAAIABARQAGgLAFgFQAEgEAFgCQAEgCAFAAQAFAAAEACQADACADADQAEAFAEAKQAFgLAFgFQADgCAFgCIAKgBQAZAAABAgIAAA/gAE+DPIABg7IAAgaIAQAAIABAMIAEAAQADgJAFgFQAFgFAIAAQAFAAADACQAEACACADQACADABAFQACAFAAAHIgBATIgUAAIAAgWIgSAAIADBIQgSgEgIAAgAmZDSIAAiJIAZACIgBCIgAnGDSIAAiJIAZACIgBCIgAAVDQQgEgBgCgDQgFgFAAgIQAAgKAEgFQAFgFAIAAQAEAAADACQADACACADQADAGAAAJQAAAGgEAFQgEAGgGAAQgEAAgDgCgAAPCTQgEgFAAgIQAAgJAEgFQADgFAIAAQAIAAAEAGQAEAFAAAIQAAAIgEAIQgCADgIAAQgIAAgFgGgAing/QgNgEgKgJIgKgKQgEgFgDgHQgDgGgBgHIgBgQQAAgLAFgTIAGgMQADgGAFgFIALgIIAMgHQAJgDAVgCQAJAAAIACQAIABAHADIAMAHIAKAKIAIAMIAFANQAFAVAAAMQgsAAg1ADIAAAGIACATIApABIABgOIAygCQgCAMgGAJQgFAKgKAGQgIAFgLADQgLADgNAAQgQAAgOgFgAh1iOIgCgbIgmABIAAAaIAoAAgAnMg/QgNgEgKgJIgKgKQgEgFgDgHQgDgGgBgHIgBgQQAAgLAFgTIAGgMQADgGAFgFIALgIIAMgHQAJgDAVgCQAJAAAIACQAIABAHADIAMAHIAKAKIAIAMIAFANQAFAVAAAMQgsAAg1ADIAAAGIACATIApABIABgOIAygCQgCAMgGAJQgFAKgKAGQgIAFgLADQgLADgNAAQgQAAgOgFgAmaiOIgCgbIgmABIAAAaIAoAAgAqLhBIADhhIgBhaIA7gCIgBCTIBNgBIgCAvgACkhDQAFgrACgmQADglAAgfIgcgCIAEgeQASAAATgCIAngHQgEAkgBAeIgBB/gAgthDQAChBgBh8IAyACIgCC+gAk5hDIgoh/IA2gCQACARAGAeIAKAuQAEgXAUhCIAlAAQgEARgJAYQgWA2gKAeg"); + this.shape.setTransform(100.4,-42.1); + + this.instance_1 = new lib.lv2(); + this.instance_1.setTransform(-168.4,-70.2,0.203,0.203); + + this.shape_1 = new cjs.Shape(); + this.shape_1.graphics.f("#000000").s().p("Aj3EDQgFgCgCgCQgDgDgCgFQgBgEAAgGIABgKIABABIAPADIgBANIANABIADgYIgehkIAZgBIAKApIAEAXIAEAAQAGgcAGgmIARADIgOA7IgLAyQgDATgJAHQgFAFgKAAQgFgBgEgBgAiqECIgDiEIAPABIADAKQAGgLAFgDIAHgEQAEgBAGAAQAIAAAGADQAHAEAEAHQAEAGACAHQACAIAAAIQAAAOgCAKQgDAKgEAHQgEAHgHAEQgGADgJAAQgGAAgLgGIAAAygAiXDDIAfgCIAAguIgfAAgApzDZIgegBIACiIQAYgBAXAAQAJAAAHABQAGABAFAEQAHAEADAGQADAGAAAIQAAAZgYAKIAAAGQAHABAGADQAFADAEAEQAEAFACAFQACAGAAAHQAAAJgDAGQgCAHgFAEQgEAEgHADQgHACgIAAIgdgCgApxDLIAhgDIgBgpIghgBgAp7CMIAigCIACgpIgjAAgAIkDZQgEgCgDgCQgDgDgBgEQgCgFAAgFQAAgHACgIQADgJAFgDQAEgDAMgDQALgCAUgCIgBgTQgRgFgFAAIgDAAIgDAAIgBAMIgNgBIgKABQAAgHADgFQADgGAGgDIAMgGQAHgCAHAAQAJAAAGACQAHACAEAFQAFAEACAHQACAGAAAJIgBAcQABAVACANIgHAAIgPACIgEgMQgIAHgHAEQgIADgIAAQgFAAgEgCgAI9CuIgNAFIAAAWIAYgCIABgaIgMABgAD2DXQgHgFgGgJQgEgHgCgJQgCgJAAgKQAAgJACgJQACgIAEgGQAFgIAHgEQAHgEAKAAQAFAAAEABQAFABADADIAIAGIAGAIQAEAIACAJQADAJAAALQAAAJgDAHQgDAIgFAHQgFAHgHAEQgHADgJAAQgJAAgIgEgAEVDEIgEg6IgXADIgEAxIAMAEQAGACAIAAIAFAAgAg5DXQgIgDgFgIQgFgGgCgJQgDgIAAgLQAAgKACgJQACgJAFgHQAFgIAHgEQAIgFAJAAQAGAAAEABIAIAEIAHAFIAGAIQAIAOAAAWQgYABgfACIACAZIAbAAIABgKIAXgBQgBAHgDAFQgDAGgEAEQgFAEgGACQgFACgHAAQgKAAgIgEgAgaCiIgBgbIgaABIAAAaIAbAAgAkqDZQgFgCgDgCQgEgDgCgFQgCgEAAgGIAAgNQAAgJAEgeIgMgCIABgPIAMAAIAKgfIAKgBIgBAcIAWABIgBAVIgWAAIgBA3IASAAIgBgMIALAAIAAAJIgBAKQgCAFgDACQgDADgEABQgFACgGAAQgGAAgEgCgAobDZQgEgCgDgCQgCgDgCgEQgBgFAAgFQAAgHACgIQACgJAFgDQAEgDAMgDQAMgCATgCIgBgTQgQgFgFAAIgEAAIgDAAIAAAMIgNgBIgKABQAAgHADgFQADgGAGgDIAMgGQAGgCAHAAQAJAAAHACQAGACAFAFQAEAEACAHQACAGAAAJIAAAcQABAVACANIgHAAIgQACIgEgMQgHAHgIAEQgHADgIAAQgFAAgFgCgAoBCuIgOAFIAAAWIAZgCIABgaIgMABgABvDXIACiJIAfAAIAgBEQAEAJAEAQIAEgBIgChYIAUAAIgBCEIgdAAIgXgwQgIgTgKgdIgEABIgBBggAJ4DVIABiJIAZACIgBCIgAHwDVIAAgDIAAgPQAAgZgCgaIgYAAIAABEIgagCIAAhAIgZABIgBBBIgYACIABgpIgBgwIATAAIABARQAGgMAFgEQAEgEAFgCQAEgCAFAAQAFAAAEACQADACADADQAEAFAEAKQAFgLAFgFQADgCAFgCIAKgBQAZAAABAgIAAA/gAE+DSIABg7IAAgaIAQAAIABALIAEABQADgJAFgFQAFgFAIAAQAFAAADACQAEACACADQACADABAFQACAFAAAGIgBATIgUAAIAAgVIgSAAIADBIQgSgEgIAAgAmZDVIAAiJIAZACIgBCIgAnGDVIAAiJIAZACIgBCIgAAVDTQgEgBgCgDQgFgFAAgJQAAgJAEgFQAFgFAIAAQAEAAADABQADADACADQADAGAAAJQAAAFgEAGQgEAGgGAAQgEAAgDgCgAAPCWQgEgFAAgJQAAgJAEgEQADgFAIAAQAIAAAEAGQAEAFAAAIQAAAIgEAIQgCACgIAAQgIABgFgGgAing8QgNgEgKgJIgKgKQgEgFgDgHQgDgHgBgGIgBgQQAAgLAFgTIAGgMQADgGAFgFIALgJIAMgGQAJgDAVgCQAJAAAIABQAIACAHADIAMAHIAKAKIAIAMIAFANQAFAUAAANQgsgBg1ADIAAAHIACATIApAAIABgOIAygBQgCAMgGAJQgFAKgKAFQgIAGgLADQgLADgNAAQgQAAgOgFgAh1iMIgCgaIgmABIAAAZIAoAAgAnMg8QgNgEgKgJIgKgKQgEgFgDgHQgDgHgBgGIgBgQQAAgLAFgTIAGgMQADgGAFgFIALgJIAMgGQAJgDAVgCQAJAAAIABQAIACAHADIAMAHIAKAKIAIAMIAFANQAFAUAAANQgsgBg1ADIAAAHIACATIApAAIABgOIAygBQgCAMgGAJQgFAKgKAFQgIAGgLADQgLADgNAAQgQAAgOgFgAmaiMIgCgaIgmABIAAAZIAoAAgAqLg+IADhiIgBhaIA7gBIgBCTIBNgBIgCAugAgthAQAChBgBh8IAyACIgCC+gACzhDIg4ACIABgnQABgPADgIQACgLAGgHQAGgIAJgGQAIgEAPgFIAkgLIAAguIgjAAIgBAnIgxgBIAAgTQAAgNAFgKQAGgKAMgIQAKgGAMgEQAMgCANAAQAQAAAMADQAMAFAIAIQAJAHAEANQAFALAAAQQAAAMgEAJQgDAJgGAHQgFAGgJAFQgJAGgMAEQgTAHgVAGQgDAAAAARIAaAAQAcAAAigEQgCAjABANQg6gDgUAAgAk5hAIgoiAIA2gCQACASAGAdIAKAvQAEgXAUhCIAlAAQgEARgJAYQgWA2gKAeg"); + this.shape_1.setTransform(100.4,-42.4); + + this.instance_2 = new lib.lv3(); + this.instance_2.setTransform(-168.4,-70.2,0.205,0.205); + + this.shape_2 = new cjs.Shape(); + this.shape_2.graphics.f("#000000").s().p("AJSEDQgFgCgCgCQgDgDgCgFQgBgEAAgGIABgKIABABIAQADIgBANIAMABIADgYIgehkIAZgBIALApIADAXIAFAAQAFgcAGgmIARADIgNA7IgMAyQgDATgJAHQgFAFgKAAQgFgBgEgBgAj0EDQgFgCgDgCQgDgDgBgFQgCgEAAgGIACgKIABABIAPADIgBANIANABIADgYIgehkIAYgBIALApIADAXIAFAAQAGgcAGgmIARADIgOA7IgLAyQgEATgIAHQgGAFgJAAQgGgBgDgBgAioECIgCiEIAPABIADAKQAGgLAEgDIAIgEQAEgBAFAAQAJAAAGADQAGAEAFAHQAEAGACAHQACAIAAAIQAAAOgCAKQgDAKgEAHQgEAHgHAEQgHADgIAAQgGAAgLgGIAAAygAiUDDIAfgCIAAguIgfAAgACODZIgdgBIABiIQAYgBAXAAQAJAAAHABQAHABAEAEQAHAEADAGQADAGAAAIQAAAZgYAKIAAAGQAHABAGADQAFADAEAEQAEAFACAFQACAGAAAHQAAAJgDAGQgCAHgFAEQgEAEgHADQgHACgIAAIgdgCgACQDLIAhgDIAAgpIgigBgACGCMIAjgCIABgpIgjAAgApwDZIgegBIACiIQAYgBAXAAQAIAAAIABQAGABAFAEQAHAEADAGQACAGAAAIQAAAZgXAKIAAAGQAHABAFADQAGADAEAEQAEAFACAFQACAGAAAHQgBAJgCAGQgCAHgFAEQgFAEgGADQgHACgIAAIgdgCgApuDLIAhgDIgBgpIghgBgAp4CMIAigCIACgpIgjAAgAIJDXQgHgEgGgIQgFgHgDgJQgCgJAAgJQAAgLACgIQACgJAEgHQAFgIAIgEQAHgEALAAQAIAAAHADQAHACAFAGQAFAFAEAIQACAHAAAIIgWgBIgBgTIgaACIgBAdQAAAPABAMIAMACQAJgBACgBIABgMIAYAAQgBAJgCAGQgCAGgFAFQgEAFgHACQgGADgIAAQgKAAgIgEgADyDXQgHgFgGgJQgEgHgCgJQgCgJAAgKQAAgJACgJQACgIAEgGQAFgIAHgEQAHgEAKAAQAEAAAFABQAFABADADIAIAGIAFAIQAEAIADAJQACAJAAALQAAAJgCAHQgDAIgFAHQgGAHgGAEQgIADgIAAQgKAAgHgEgAD2CNIgFAxIAMAEQAHACAIAAIAFAAIgEg6gAg2DXQgIgDgFgIQgGgGgBgJQgDgIAAgLQAAgKACgJQACgJAEgHQAGgIAHgEQAIgFAJAAQAGAAAEABIAIAEIACABIAAAxIgkACIABAZIAbAAIABgKIAHAAIARgBQgBAHgEAFQgCAGgEAEIgGAEIAAgZIAAAZIgFACQgGACgHAAQgJAAgIgEgAgzCIIAAAaIAcAAIgCgbgAkoDZQgEgCgEgCQgDgDgCgFQgCgEAAgGIAAgNQAAgJAEgeIgMgCIABgPIALAAIAKgfIALgBIgBAcIAWABIgBAVIgWAAIgBA3IASAAIgBgMIAKAAIAAAJIAAAKQgCAFgDACQgDADgEABQgFACgGAAQgGAAgFgCgAoYDZQgEgCgDgCQgCgDgCgEQgBgFgBgFQAAgHACgIQADgJAFgDQAEgDAMgDQALgCAUgCIgBgTQgQgFgFAAIgEAAIgDAAIgBAMIgMgBIgKABQAAgHADgFQACgGAHgDIALgGQAHgCAHAAQAJAAAGACQAHACAFAFQAEAEACAHQACAGAAAJIAAAcQABAVACANIgIAAIgPACIgEgMQgIAHgHAEQgIADgHAAQgGAAgEgCgAn/CuIgNAFIAAAWIAZgCIABgaIgNABgAFIDYQgFgDgDgFQgDgDgCgGIgBgMIgBg/QALABAPAAIgCBGIAbAAIAAhJIAYABIAABXIgSgBIgBgKQgIAJgGAGQgIAEgIAAQgGAAgFgCgAHIDYIABgkIgCgjIgZACIABAgIgBAgIgVACIAAhXIARABIACANQAJgKAJgFQAIgFAIAAQAFAAAFADQAEADACAFQADAGAAAPIgBBAgAmWDVIAAiJIAZACIgBCIgAnDDVIAAiJIAZACIgBCIgAAYDTQgEgBgCgDQgFgFAAgJQAAgJAEgFQAEgFAJAAQAEAAACABQAEADACADQADAGAAAJQAAAFgEAGQgFAGgFAAQgFAAgCgCgAgTCtIAAgxIAFAEIAFAIQAJAOAAAWIgTABgAASCWQgFgFABgJQAAgJADgEQAEgFAIAAQAIAAAEAGQAEAFAAAIQAAAIgEAIQgDACgHAAQgJABgEgGgAgTB8IAAAAgACig6QgNgDgIgGQgFgDgDgFQgEgEgDgHQgDgHgCgVIABgHIA3ACIgCAeIAnAAIgDgtIgpgEIADgkIAfAAIAEgpIgkgEIgCAhIgwgDQAAgMAEgSQAGgNAJgJQAJgJANgFQAJgDAVgBQAPAAANADQAMADAIAIQAJAIAGALQAEALAAAQQAAAHgCAHQgDAGgFAFQgDAFgGADIgPAHQALACAHAFQAIAEAGAFQAEAGADAHQADAIAAAJQAAAIgBAGQgCAHgDAFQgDAGgEAEIgLAJQgKAHgNADQgNADgPAAQgSAAgNgDgAikg8QgOgEgKgJIgKgKQgDgFgDgHQgDgHgBgGIgBgQQAAgLAEgTIAGgMQAEgGAFgFIAKgJIANgGQAJgDAVgCQAIAAAJABQAHACAHADIANAHIAKAKIAIAMIAFANQAEAUABANQgsgBg2ADIAAAHIACATIAqAAIABgOIAygBQgCAMgGAJQgFAKgKAFQgIAGgLADQgLADgNAAQgRAAgNgFgAiailIAAAZIAoAAIgDgagAnJg8QgOgEgJgJIgKgKQgEgFgDgHQgDgHgBgGIgCgQQAAgLAGgTIAFgMQAEgGAFgFIALgJIAMgGQAJgDAUgCQAKAAAHABQAIACAIADIAMAHIAKAKIAIAMIAFANQAFAUgBANQgrgBg2ADIAAAHIADATIAoAAIACgOIAygBQgCAMgGAJQgFAKgKAFQgJAGgLADQgKADgNAAQgQAAgOgFgAm/ilIAAAZIAoAAIgCgagAqJg+IADhiIgBhaIA8gBIgBCTIBMgBIgCAugAgTg/IAAi9IAbABIgBC+gAgqhAQAChBgCh8IAXABIAAC9gAk2hAIgoiAIA1gCQADASAFAdIAKAvQAFgXAUhCIAlAAQgEARgJAYQgWA2gKAeg"); + this.shape_2.setTransform(100.1,-42.4); + + this.instance_3 = new lib.lv4(); + this.instance_3.setTransform(-168.4,-70.2,0.208,0.208); + + this.shape_3 = new cjs.Shape(); + this.shape_3.graphics.f("#000000").s().p("Aj3EEQgFgBgCgCQgDgDgCgFQgBgEAAgGIABgKIABABIAPACIgBAOIANABIADgZIgehjIAZgBIAKAoIAEAYIAEAAQAGgdAGglIARADIgOA7IgLAxQgDATgJAIQgFAEgKAAQgFAAgEgCgAiqEDIgDiEIAPACIADAKQAGgLAFgEIAHgDQAEgBAGAAQAIAAAGADQAHAEAEAGQAEAHACAHQACAHAAAIQAAAOgCAKQgDAKgEAIQgEAGgHAEQgGADgJAAQgGAAgLgFIAAAxgAiXDEIAfgBIAAguIgfAAgApzDbIgegCIACiIQAYgBAXAAQAJAAAHABQAGACAFAEQAHAEADAFQADAGAAAJQAAAZgYAKIAAAFQAHABAGAEQAFACAEAEQAEAFACAFQACAGAAAIQAAAIgDAHQgCAGgFAFQgEAEgHADQgHACgIAAIgdgCgApxDMIAhgCIgBgqIghgBgAp7CNIAigBIACgqIgjAAgAIkDbQgEgCgDgDQgDgDgBgEQgCgEAAgGQAAgGACgIQADgKAFgDQAEgDAMgCQALgDAUgCIgBgTQgRgFgFAAIgDAAIgDAAIgBANIgNgBIgKABQAAgHADgGQADgFAGgEIAMgFQAHgCAHAAQAJAAAGACQAHACAEAFQAFAEACAHQACAGAAAIIgBAdQABAUACANIgHAAIgPADIgEgNQgIAIgHADQgIADgIABQgFAAgEgCgAI9CwIgNAEIAAAXIAYgCIABgaIgMABgAD2DYQgHgFgGgIQgEgIgCgJQgCgIAAgKQAAgKACgIQACgJAEgGQAFgIAHgEQAHgDAKAAQAFAAAEABQAFABADACIAIAHIAGAIQAEAHACAKQADAJAAALQAAAIgDAIQgDAIgFAGQgFAHgHAEQgHADgJABQgJgBgIgEgAEVDFIgEg5IgXACIgEAyIAMADQAGACAIAAIAFAAgAg5DYQgIgDgFgIQgFgGgCgJQgDgIAAgLQAAgKACgJQACgIAFgIQAFgIAHgEQAIgFAJABQAGAAAEABIAIADIAHAGIAGAIQAIAOAAAWQgYAAgfADIACAZIAbAAIABgKIAXgCQgBAIgDAFQgDAGgEAEQgFADgGADQgFACgHAAQgKAAgIgFgAgaCjIgBgaIgaABIAAAZIAbAAgAkqDbQgFgCgDgDQgEgDgCgFQgCgEAAgGIAAgMQAAgJAEgfIgMgCIABgPIAMABIAKggIAKAAIgBAbIAWABIgBAVIgWAAIgBA4IASAAIgBgNIALAAIAAAJIgBAKQgCAFgDACQgDADgEACQgFABgGABQgGAAgEgCgAobDbQgEgCgDgDQgCgDgCgEQgBgEAAgGQAAgGACgIQACgKAFgDQAEgDAMgCQAMgDATgCIgBgTQgQgFgFAAIgEAAIgDAAIAAANIgNgBIgKABQAAgHADgGQADgFAGgEIAMgFQAGgCAHAAQAJAAAHACQAGACAFAFQAEAEACAHQACAGAAAIIAAAdQABAUACANIgHAAIgQADIgEgNQgHAIgIADQgHADgIABQgFAAgFgCgAoBCwIgOAEIAAAXIAZgCIABgaIgMABgABvDYIACiJIAfAAIAgBFQAEAJAEAPIAEgBIgChXIAUAAIgBCDIgdAAIgXgvQgIgTgKgdIgEABIgBBfgAJ4DWIABiIIAZABIgBCIgAHwDWIAAgCIAAgQQAAgZgCgZIgYgBIAABEIgagBIAAhAIgZABIgBBAIgYACIABgoIgBgxIATAAIABARQAGgLAFgFQAEgEAFgBQAEgCAFAAQAFAAAEACQADABADADQAEAGAEAJQAFgLAFgFQADgCAFgBIAKgBQAZgBABAgIAAA/gAE+DUIABg8IAAgaIAQAAIABAMIAEABQADgKAFgFQAFgEAIAAQAFAAADACQAEABACADQACAEABAEQACAGAAAGIgBATIgUAAIAAgWIgSAAIADBIQgSgDgIAAgAmZDWIAAiIIAZABIgBCIgAnGDWIAAiIIAZABIgBCIgAAVDVQgEgCgCgDQgFgFAAgIQAAgKAEgFQAFgFAIABQAEgBADACQADACACAEQADAFAAAJQAAAGgEAFQgEAGgGAAQgEAAgDgBgAAPCXQgEgEAAgJQAAgJAEgFQADgEAIAAQAIgBAEAGQAEAFAAAJQAAAHgEAIQgCADgIAAQgIAAgFgGgAC5g2IABgxIhKAAIAAgoQASgeAUgdIArg7QARADAjADIABBwIAdAAIgCAnIgcAAIAAAygACeiTIAsAAIABhIQgcApgRAfgAing6QgNgFgKgJIgKgKQgEgFgDgGQgDgHgBgHIgBgQQAAgKAFgUIAGgLQADgHAFgEIALgJIAMgGQAJgEAVgCQAJAAAIACQAIACAHACIAMAIIAKAKIAIALIAFAOQAFAUAAAMQgsAAg1ADIAAAGIACATIApABIABgOIAygBQgCALgGAJQgFAKgKAGQgIAGgLADQgLACgNAAQgQAAgOgEgAh1iKIgCgaIgmABIAAAZIAoAAgAnMg6QgNgFgKgJIgKgKQgEgFgDgGQgDgHgBgHIgBgQQAAgKAFgUIAGgLQADgHAFgEIALgJIAMgGQAJgEAVgCQAJAAAIACQAIACAHACIAMAIIAKAKIAIALIAFAOQAFAUAAAMQgsAAg1ADIAAAGIACATIApABIABgOIAygBQgCALgGAJQgFAKgKAGQgIAGgLADQgLACgNAAQgQAAgOgEgAmaiKIgCgaIgmABIAAAZIAoAAgAqLg9IADhhIgBhaIA7gCIgBCUIBNgBIgCAugAgtg/QAChBgBh8IAyACIgCC+gAk5g/Igoh/IA2gCQACASAGAdIAKAuQAEgXAUhCIAlAAQgEARgJAZQgWA1gKAeg"); + this.shape_3.setTransform(100.4,-42.5); + + this.instance_4 = new lib.lv5(); + this.instance_4.setTransform(-168.4,-70.2,0.206,0.206); + + this.shape_4 = new cjs.Shape(); + this.shape_4.graphics.f("#000000").s().p("Aj3EAQgFgBgCgCQgDgDgCgFQgBgEAAgGIABgKIABABIAPACIgBAOIANABIADgZIgehjIAZgBIAKAoIAEAYIAEAAQAGgdAGglIARADIgOA7IgLAxQgDATgJAIQgFAEgKAAQgFAAgEgCgAiqD/IgDiEIAPACIADAKQAGgLAFgEIAHgDQAEgBAGAAQAIAAAGADQAHAEAEAGQAEAHACAHQACAHAAAIQAAAOgCAKQgDAKgEAIQgEAGgHAEQgGADgJAAQgGAAgLgFIAAAxgAiXDAIAfgBIAAguIgfAAgApzDXIgegCIACiIQAYgBAXAAQAJAAAHABQAGACAFAEQAHAEADAFQADAGAAAJQAAAZgYAKIAAAFQAHABAGAEQAFACAEAEQAEAFACAFQACAGAAAIQAAAIgDAHQgCAGgFAFQgEAEgHADQgHACgIAAIgdgCgApxDIIAhgCIgBgqIghgBgAp7CJIAigBIACgqIgjAAgAIkDXQgEgCgDgDQgDgDgBgEQgCgEAAgGQAAgGACgIQADgKAFgDQAEgDAMgCQALgDAUgCIgBgTQgRgFgFAAIgDAAIgDAAIgBANIgNgBIgKABQAAgHADgGQADgFAGgEIAMgFQAHgCAHAAQAJAAAGACQAHACAEAFQAFAEACAHQACAGAAAIIgBAdQABAUACANIgHAAIgPADIgEgNQgIAIgHADQgIADgIABQgFAAgEgCgAI9CsIgNAEIAAAXIAYgCIABgaIgMABgAD2DUQgHgFgGgIQgEgIgCgJQgCgIAAgKQAAgKACgIQACgJAEgGQAFgIAHgEQAHgDAKAAQAFAAAEABQAFABADACIAIAHIAGAIQAEAHACAKQADAJAAALQAAAIgDAIQgDAIgFAGQgFAHgHAEQgHADgJABQgJgBgIgEgAEVDBIgEg5IgXACIgEAyIAMADQAGACAIAAIAFAAgAg5DUQgIgDgFgIQgFgGgCgJQgDgIAAgLQAAgKACgJQACgIAFgIQAFgIAHgEQAIgFAJABQAGAAAEABIAIADIAHAGIAGAIQAIAOAAAWQgYAAgfADIACAZIAbAAIABgKIAXgCQgBAIgDAFQgDAGgEAEQgFADgGADQgFACgHAAQgKAAgIgFgAgaCfIgBgaIgaABIAAAZIAbAAgAkqDXQgFgCgDgDQgEgDgCgFQgCgEAAgGIAAgMQAAgJAEgfIgMgCIABgPIAMABIAKggIAKAAIgBAbIAWABIgBAVIgWAAIgBA4IASAAIgBgNIALAAIAAAJIgBAKQgCAFgDACQgDADgEACQgFABgGABQgGAAgEgCgAobDXQgEgCgDgDQgCgDgCgEQgBgEAAgGQAAgGACgIQACgKAFgDQAEgDAMgCQAMgDATgCIgBgTQgQgFgFAAIgEAAIgDAAIAAANIgNgBIgKABQAAgHADgGQADgFAGgEIAMgFQAGgCAHAAQAJAAAHACQAGACAFAFQAEAEACAHQACAGAAAIIAAAdQABAUACANIgHAAIgQADIgEgNQgHAIgIADQgHADgIABQgFAAgFgCgAoBCsIgOAEIAAAXIAZgCIABgaIgMABgABvDUIACiJIAfAAIAgBFQAEAJAEAPIAEgBIgChXIAUAAIgBCDIgdAAIgXgvQgIgTgKgdIgEABIgBBfgAJ4DSIABiIIAZABIgBCIgAHwDSIAAgCIAAgQQAAgZgCgZIgYgBIAABEIgagBIAAhAIgZABIgBBAIgYACIABgoIgBgxIATAAIABARQAGgLAFgFQAEgEAFgBQAEgCAFAAQAFAAAEACQADABADADQAEAGAEAJQAFgLAFgFQADgCAFgBIAKgBQAZgBABAgIAAA/gAE+DQIABg8IAAgaIAQAAIABAMIAEABQADgKAFgFQAFgEAIAAQAFAAADACQAEABACADQACAEABAEQACAGAAAGIgBATIgUAAIAAgWIgSAAIADBIQgSgDgIAAgAmZDSIAAiIIAZABIgBCIgAnGDSIAAiIIAZABIgBCIgAAVDRQgEgCgCgDQgFgFAAgIQAAgKAEgFQAFgFAIABQAEgBADACQADACACAEQADAFAAAJQAAAGgEAFQgEAGgGAAQgEAAgDgBgAAPCTQgEgEAAgJQAAgJAEgFQADgEAIAAQAIgBAEAGQAEAFAAAJQAAAHgEAIQgCADgIAAQgIAAgFgGgACng9QgNgEgKgGIgKgJQgEgFgDgGQgDgGgBgHQgCgGAAgIIA3gDIAAAeIALAAQAOAAALgCIAAg2IgtgBIgEALIgngCIAHh2IA9ADIA6gDQgDAXgBAUIgTABIg/gCIgCAnQAJgGAKgEQAKgDANAAQAOAAAMAEQAMAFAJAIQAJAIAEAMQAFALAAAOIgBAPQgCAHgDAGQgCAGgFAGIgJAKQgLAKgMAFQgNAEgPAAQgQAAgNgDgAing+QgNgFgKgJIgKgKQgEgFgDgGQgDgHgBgHIgBgQQAAgKAFgUIAGgLQADgHAFgEIALgJIAMgGQAJgEAVgCQAJAAAIACQAIACAHACIAMAIIAKAKIAIALIAFAOQAFAUAAAMQgsAAg1ADIAAAGIACATIApABIABgOIAygBQgCALgGAJQgFAKgKAGQgIAGgLADQgLACgNAAQgQAAgOgEgAh1iOIgCgaIgmABIAAAZIAoAAgAnMg+QgNgFgKgJIgKgKQgEgFgDgGQgDgHgBgHIgBgQQAAgKAFgUIAGgLQADgHAFgEIALgJIAMgGQAJgEAVgCQAJAAAIACQAIACAHACIAMAIIAKAKIAIALIAFAOQAFAUAAAMQgsAAg1ADIAAAGIACATIApABIABgOIAygBQgCALgGAJQgFAKgKAGQgIAGgLADQgLACgNAAQgQAAgOgEgAmaiOIgCgaIgmABIAAAZIAoAAgAqLhBIADhhIgBhaIA7gCIgBCUIBNgBIgCAugAgthDQAChBgBh8IAyACIgCC+gAk5hDIgoh/IA2gCQACASAGAdIAKAuQAEgXAUhCIAlAAQgEARgJAZQgWA1gKAeg"); + this.shape_4.setTransform(100.4,-42.1); + + this.instance_5 = new lib.lv6(); + this.instance_5.setTransform(-168.4,-70.2,0.204,0.204); + + this.shape_5 = new cjs.Shape(); + this.shape_5.graphics.f("#000000").s().p("Aj3EDQgFgCgCgCQgDgDgCgFQgBgEAAgGIABgKIABABIAPADIgBANIANABIADgYIgehkIAZgBIAKApIAEAXIAEAAQAGgcAGgmIARADIgOA7IgLAyQgDATgJAHQgFAFgKAAQgFgBgEgBgAiqECIgDiEIAPABIADAKQAGgLAFgDIAHgEQAEgBAGAAQAIAAAGADQAHAEAEAHQAEAGACAHQACAIAAAIQAAAOgCAKQgDAKgEAHQgEAHgHAEQgGADgJAAQgGAAgLgGIAAAygAiXDDIAfgCIAAguIgfAAgApzDZIgegBIACiIQAYgBAXAAQAJAAAHABQAGABAFAEQAHAEADAGQADAGAAAIQAAAZgYAKIAAAGQAHABAGADQAFADAEAEQAEAFACAFQACAGAAAHQAAAJgDAGQgCAHgFAEQgEAEgHADQgHACgIAAIgdgCgApxDLIAhgDIgBgpIghgBgAp7CMIAigCIACgpIgjAAgAIkDZQgEgCgDgCQgDgDgBgEQgCgFAAgFQAAgHACgIQADgJAFgDQAEgDAMgDQALgCAUgCIgBgTQgRgFgFAAIgDAAIgDAAIgBAMIgNgBIgKABQAAgHADgFQADgGAGgDIAMgGQAHgCAHAAQAJAAAGACQAHACAEAFQAFAEACAHQACAGAAAJIgBAcQABAVACANIgHAAIgPACIgEgMQgIAHgHAEQgIADgIAAQgFAAgEgCgAI9CuIgNAFIAAAWIAYgCIABgaIgMABgAD2DXQgHgFgGgJQgEgHgCgJQgCgJAAgKQAAgJACgJQACgIAEgGQAFgIAHgEQAHgEAKAAQAFAAAEABQAFABADADIAIAGIAGAIQAEAIACAJQADAJAAALQAAAJgDAHQgDAIgFAHQgFAHgHAEQgHADgJAAQgJAAgIgEgAEVDEIgEg6IgXADIgEAxIAMAEQAGACAIAAIAFAAgAg5DXQgIgDgFgIQgFgGgCgJQgDgIAAgLQAAgKACgJQACgJAFgHQAFgIAHgEQAIgFAJAAQAGAAAEABIAIAEIAHAFIAGAIQAIAOAAAWQgYABgfACIACAZIAbAAIABgKIAXgBQgBAHgDAFQgDAGgEAEQgFAEgGACQgFACgHAAQgKAAgIgEgAgaCiIgBgbIgaABIAAAaIAbAAgAkqDZQgFgCgDgCQgEgDgCgFQgCgEAAgGIAAgNQAAgJAEgeIgMgCIABgPIAMAAIAKgfIAKgBIgBAcIAWABIgBAVIgWAAIgBA3IASAAIgBgMIALAAIAAAJIgBAKQgCAFgDACQgDADgEABQgFACgGAAQgGAAgEgCgAobDZQgEgCgDgCQgCgDgCgEQgBgFAAgFQAAgHACgIQACgJAFgDQAEgDAMgDQAMgCATgCIgBgTQgQgFgFAAIgEAAIgDAAIAAAMIgNgBIgKABQAAgHADgFQADgGAGgDIAMgGQAGgCAHAAQAJAAAHACQAGACAFAFQAEAEACAHQACAGAAAJIAAAcQABAVACANIgHAAIgQACIgEgMQgHAHgIAEQgHADgIAAQgFAAgFgCgAoBCuIgOAFIAAAWIAZgCIABgaIgMABgABvDXIACiJIAfAAIAgBEQAEAJAEAQIAEgBIgChYIAUAAIgBCEIgdAAIgXgwQgIgTgKgdIgEABIgBBggAJ4DVIABiJIAZACIgBCIgAHwDVIAAgDIAAgPQAAgZgCgaIgYAAIAABEIgagCIAAhAIgZABIgBBBIgYACIABgpIgBgwIATAAIABARQAGgMAFgEQAEgEAFgCQAEgCAFAAQAFAAAEACQADACADADQAEAFAEAKQAFgLAFgFQADgCAFgCIAKgBQAZAAABAgIAAA/gAE+DSIABg7IAAgaIAQAAIABALIAEABQADgJAFgFQAFgFAIAAQAFAAADACQAEACACADQACADABAFQACAFAAAGIgBATIgUAAIAAgVIgSAAIADBIQgSgEgIAAgAmZDVIAAiJIAZACIgBCIgAnGDVIAAiJIAZACIgBCIgAAVDTQgEgBgCgDQgFgFAAgJQAAgJAEgFQAFgFAIAAQAEAAADABQADADACADQADAGAAAJQAAAFgEAGQgEAGgGAAQgEAAgDgCgAAPCWQgEgFAAgJQAAgJAEgEQADgFAIAAQAIAAAEAGQAEAFAAAIQAAAIgEAIQgCACgIAAQgIABgFgGgACug5QgKgDgJgEQgLgGgIgJQgIgJgEgNQgDgIgCgNQgBgMAAgRQAAgbAFgUQAFgVAKgNQAKgOAPgGQAPgIATABQAPAAANADQAMAFAIAIQAJAJAEALQAFAMAAAPIgqABIgBgVIgtgDIAAAxQAIgHAJgDQAKgDAKAAQANAAAKAEQAKADAIAIQAHAIAEAJQAEAKAAAMQgCAWgDAKIgGAMQgEAGgEAEIgLAJIgMAGQgUAFgLAAQgLAAgKgCgAClhhIAtADIADgwIgxAAgAing8QgNgEgKgJIgKgKQgEgFgDgHQgDgHgBgGIgBgQQAAgLAFgTIAGgMQADgGAFgFIALgJIAMgGQAJgDAVgCQAJAAAIABQAIACAHADIAMAHIAKAKIAIAMIAFANQAFAUAAANQgsgBg1ADIAAAHIACATIApAAIABgOIAygBQgCAMgGAJQgFAKgKAFQgIAGgLADQgLADgNAAQgQAAgOgFgAh1iMIgCgaIgmABIAAAZIAoAAgAnMg8QgNgEgKgJIgKgKQgEgFgDgHQgDgHgBgGIgBgQQAAgLAFgTIAGgMQADgGAFgFIALgJIAMgGQAJgDAVgCQAJAAAIABQAIACAHADIAMAHIAKAKIAIAMIAFANQAFAUAAANQgsgBg1ADIAAAHIACATIApAAIABgOIAygBQgCAMgGAJQgFAKgKAFQgIAGgLADQgLADgNAAQgQAAgOgFgAmaiMIgCgaIgmABIAAAZIAoAAgAqLg+IADhiIgBhaIA7gBIgBCTIBNgBIgCAugAgthAQAChBgBh8IAyACIgCC+gAk5hAIgoiAIA2gCQACASAGAdIAKAvQAEgXAUhCIAlAAQgEARgJAYQgWA2gKAeg"); + this.shape_5.setTransform(100.4,-42.4); + + this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.shape},{t:this.instance}]}).to({state:[{t:this.shape_1},{t:this.instance_1}]},1).to({state:[{t:this.shape_2},{t:this.instance_2}]},1).to({state:[{t:this.shape_3},{t:this.instance_3}]},1).to({state:[{t:this.shape_4},{t:this.instance_4}]},1).to({state:[{t:this.shape_5},{t:this.instance_5}]},1).wait(1)); + +}).prototype = p = new cjs.MovieClip(); +p.nominalBounds = new cjs.Rectangle(-168.4,-70.2,334.6,140.4); + + +(lib.LeftButton = function() { + this.initialize(); + + // Layer 1 + this.shape = new cjs.Shape(); + this.shape.graphics.f().s("#000000").p("Ah8ACID5C+IAAl/Ij5C+g"); + + this.shape_1 = new cjs.Shape(); + this.shape_1.graphics.f("#FFFCE2").s().p("Ah8ACIAAgDID5i+IAAF/g"); + + this.addChild(this.shape_1,this.shape); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(-13.5,-20.2,27,40.6); + + +(lib.HoopSquare = function() { + this.initialize(); + + // Layer 1 + this.shape = new cjs.Shape(); + this.shape.graphics.f("#C27400").s().p("AgxAyIAAhjIBjAAIAABjg"); + + this.addChild(this.shape); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(-5,-5,10,10); + + +(lib.HoopSensor = function() { + this.initialize(); + + // Layer 1 + this.shape = new cjs.Shape(); + this.shape.graphics.f("rgba(102,255,0,0.62)").s().p("AjGAdIAAg5IGNAAIAAA5g"); + + this.addChild(this.shape); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(-20,-3,40,6); + + +(lib.HoopBoard = function() { + this.initialize(); + + // Layer 1 + this.shape = new cjs.Shape(); + this.shape.graphics.f().s("#CC6633").ss(1,1,1).p("AgxmOIBjAAIAAMdIhjAAg"); + + this.shape_1 = new cjs.Shape(); + this.shape_1.graphics.f("#C27400").s().p("AgxGPIAAsdIBjAAIAAMdg"); + + this.addChild(this.shape_1,this.shape); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(-6,-41,12,82); + + +(lib.Cross = function() { + this.initialize(); + + // Layer 1 + this.shape = new cjs.Shape(); + this.shape.graphics.f().s("#CC6633").ss(1,1,1).p("ApXhjISvAAIAADHIyvAAg"); + this.shape.setTransform(0,0,1,1,90); + + this.shape_1 = new cjs.Shape(); + this.shape_1.graphics.f("#FFCC33").s().p("ApXBjIAAjFISvAAIAADFg"); + this.shape_1.setTransform(0,0,1,1,90); + + this.shape_2 = new cjs.Shape(); + this.shape_2.graphics.f().s("#CC6633").ss(1,1,1).p("ApXhjISvAAIAADHIyvAAg"); + + this.shape_3 = new cjs.Shape(); + this.shape_3.graphics.f("#FFCC33").s().p("ApXBjIAAjFISvAAIAADFg"); + + this.addChild(this.shape_3,this.shape_2,this.shape_1,this.shape); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(-61,-61,122,122); + + +(lib.BrownSquare = function() { + this.initialize(); + + // Layer 1 + this.shape = new cjs.Shape(); + this.shape.graphics.f().s("#CC6633").ss(1,1,1).p("AhjhjIDHAAIAADHIjHAAg"); + + this.shape_1 = new cjs.Shape(); + this.shape_1.graphics.f("#663333").s().p("AhiBjIAAjFIDFAAIAADFg"); + + this.addChild(this.shape_1,this.shape); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(-11,-11,22,22); + + +(lib.BouncyBall = function() { + this.initialize(); + + // Layer 1 + this.shape = new cjs.Shape(); + this.shape.graphics.f().s("#FFFF00").ss(1,1,1).p("AguhXQAVgMAZAAQAaAAAVAMQANAHALALQAdAdAAAoQAAApgdAeQgLALgNAHQgVALgaAAQgZAAgVgMQgMgGgLgLQgegeAAgpQAAgoAegdQALgLAMgHIAACvAAvhXIAACw"); + + this.shape_1 = new cjs.Shape(); + this.shape_1.graphics.f("#FFFF00").s().p("AguBYIAAivQAVgMAZABQAaAAAVALIAACwQgVALgagBQgZAAgVgLg"); + + this.shape_2 = new cjs.Shape(); + this.shape_2.graphics.f("#FFCC00").s().p("AAuhXQAOAHALALQAdAdgBAoQABApgdAeQgLALgOAGgAhFBHQgegeABgpQgBgoAegdQALgLAMgHIAACvQgMgHgLgKg"); + + this.addChild(this.shape_2,this.shape_1,this.shape); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(-11,-11,22,22); + + +(lib.PowerArrow = function() { + this.initialize(); + + // Layer 1 + this.powerBar = new lib.PowerBar(); + this.powerBar.setTransform(10.2,0.3,1,1,90); + + this.shape = new cjs.Shape(); + this.shape.graphics.f("rgba(102,255,0,0.4)").s().p("ACoCJIpMAAIAAkRIJMAAIAAiaID9EiIj9EjgAk+AzIHjAAIAAhfInjAAg"); + this.shape.setTransform(42.2,0); + + this.addChild(this.shape,this.powerBar); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(0,-29.2,84.3,58.4); + + +(lib.LevelSelection = function() { + this.initialize(); + + // Layer 1 + this.levels = new lib.Levels(); + this.levels.setTransform(239.9,171.9); + + // Layer 1 + this.playButton = new lib.PlayButton(); + this.playButton.setTransform(241.6,286.3,1,1,0,0,0,0,1.1); + + this.leftButton = new lib.LeftButton(); + this.leftButton.setTransform(22,191.7); + + this.rightButton = new lib.RightButton(); + this.rightButton.setTransform(456,191.7); + + this.text = new cjs.Text("Ball Game", "39px 'Andola'"); + this.text.lineHeight = 47; + this.text.setTransform(137.6,19.1); + + this.shape = new cjs.Shape(); + this.shape.graphics.f().s("#000000").ss(1,1,1).p("AewOuIAAFcMggBAAAQh3AIiWgCQhBgBjJgHQjDgHh6ADIjxAEQh1ACh2AAIoxAAIAAnKQgMikAEj6QAIkUAAiJIAA0NILMAAQCmgMEQAIQFVAJBcgCQAZAAA0ACQCZgCEzgGQEPgDC+AIQAZAAAxgCICWAAQCFgDDDABQBtABDZABIHbAAIAAUMQAKE+ABCXQACECgNDTg"); + this.shape.setTransform(237.7,194.5); + + this.shape_1 = new cjs.Shape(); + this.shape_1.graphics.f().s("#000000").ss(1,1,1).p("AezhPIhnCfMg6aAAAIhkie"); + this.shape_1.setTransform(237.7,331.4); + + this.shape_2 = new cjs.Shape(); + this.shape_2.graphics.f("#FFFFFF").s().p("AlRAAIgBAAIKlAAIh1AAg"); + this.shape_2.setTransform(74.5,323.4); + + this.shape_3 = new cjs.Shape(); + this.shape_3.graphics.f("#FFFFFF").s().p("AwCADQhAAAjKgFMAoZAAAIAAABMggBAAAQhfAEh0AAIg7AAg"); + this.shape_3.setTransform(305.2,323.7); + + this.shape_4 = new cjs.Shape(); + this.shape_4.graphics.f("#B1A793").s().p("A9OBQIhjieIIxAAQB1AAB1gBIIuAAQDJAHBBAAQCWACB3gIMAgBAAAIAAgBIADAAIhnCfg"); + this.shape_4.setTransform(237.7,331.4); + + this.shape_5 = new cjs.Shape(); + this.shape_5.graphics.f("#EEDEC2").s().p("ApoUMQjDgHh6ADIjxAEIscAAIAAnIQgMikAEj6QAIkUAAiJIAA0NILMAAQCmgMEQAIQFVAJBcgCIBNACIHMgIQEPgDC+AIQAZAAAxgCICWAAQCFgDDDABIFGACIHbAAIAAUMQAKE+ABCXQACECgNDTIAAFag"); + this.shape_5.setTransform(237.7,194.1); + + this.shape_6 = new cjs.Shape(); + this.shape_6.graphics.f("#DEF0E5").s().p("EglfAcIMAAAg4PMBK/AAAMAAAA4Pg"); + this.shape_6.setTransform(240,180); + + this.addChild(this.shape_6,this.shape_5,this.shape_4,this.shape_3,this.shape_2,this.shape_1,this.shape,this.text,this.rightButton,this.leftButton,this.playButton,this.levels); +}).prototype = p = new cjs.Container(); +p.nominalBounds = new cjs.Rectangle(0,0,480,360); + +})(lib = lib||{}, images = images||{}, createjs = createjs||{}); +var lib, images, createjs; \ No newline at end of file diff --git a/views/archive/j/ball-shooting/scripts/game.js b/views/archive/j/ball-shooting/scripts/game.js new file mode 100644 index 00000000..fc114c4f --- /dev/null +++ b/views/archive/j/ball-shooting/scripts/game.js @@ -0,0 +1,119 @@ +var game = this.game || (this.game={}); +var createjs = createjs || {}; +var images = images||{}; + +;(function(game, cjs, b2d){ + game.load = function() { + // load bitmap assets before starts the game + var loader = new createjs.LoadQueue(false); + loader.addEventListener("fileload", function(e){ + if (e.item.type === "image") { images[e.item.id] = e.result; } // assgin to images object for assets.js to use + }); + loader.addEventListener("complete", game.start); + loader.loadManifest(lib.properties.manifest); + }; + + game.start = function() { + console.log("Let's start."); + + cjs.EventDispatcher.initialize(game); // allow the game object to listen and dispatch custom events. + + game.canvas = document.getElementById('canvas'); + + game.stage = new cjs.Stage(game.canvas); + cjs.Touch.enable(game.stage, /*single touch=*/ true, /*allow default=*/ true); + + cjs.Ticker.setFPS(60); + cjs.Ticker.addEventListener('tick', game.stage); // add game.stage to ticker make the stage.update call automatically. + cjs.Ticker.addEventListener('tick', game.tick); // gameloop + + game.physics.createWorld(); + game.view.initPowerIndicator(); + + var levelSelection = new lib.LevelSelection(); + game.stage.addChild(levelSelection); + levelSelection.levels.stop(); + + levelSelection.rightButton.on('click', function(){ + var next = levelSelection.levels.currentFrame + 1; + levelSelection.levels.gotoAndStop(next); + }); + levelSelection.leftButton.on('click', function(){ + var prev = levelSelection.levels.currentFrame - 1; + levelSelection.levels.gotoAndStop(prev); + }); + + var isPlaying = false; + levelSelection.playButton.on('click', function() { + levelSelection.parent.removeChild(levelSelection); + + // game.physics.showDebugDraw(); + + game.score = 0; + + game.currentLevel = game.levels[levelSelection.levels.currentFrame]; + + game.physics.createLevel(); + + game.view.showScoreBoard(); + + isPlaying = true; + }); + + game.tickWhenDown = 0; + game.tickWhenUp = 0; + game.stage.on('stagemousedown', function(e){ + if (!isPlaying) { return; } + var position = game.physics.ballPosition(); + game.view.showPowerIndicator(position.x, position.y); + + var rotation = game.physics.launchAngle(e.stageX, e.stageY); + game.view.rotatePowerIndicator(rotation* 180 / Math.PI); + + game.tickWhenDown = cjs.Ticker.getTicks(); + game.view.updatePowerBar(0); + }); + game.stage.on('stagemousemove', function(e){ + if (!isPlaying) { return; } + var rotation = game.physics.launchAngle(e.stageX, e.stageY); + game.view.rotatePowerIndicator(rotation* 180 / Math.PI); + }); + game.stage.on('stagemouseup', function(e){ + if (!isPlaying) { return; } + game.view.hidePowerIndicator(); + game.tickWhenUp = cjs.Ticker.getTicks(); + ticksDiff = game.tickWhenUp - game.tickWhenDown; + + game.physics.shootBall(e.stageX, e.stageY, ticksDiff); + + setTimeout(game.spawnBall, 500); + }); + + }; + + game.increaseScore = function() { + game.score += 1; + game.view.updateScore(); + console.log(game.score); + }; + + game.spawnBall = function() { + game.physics.spawnBall(); + }; + + game.tick = function(){ + if (cjs.Ticker.getPaused()) { return; } // run when not paused + + game.physics.update(); + + // launch power preview + var ticksDiff = cjs.Ticker.getTicks() - game.tickWhenDown; + game.view.updatePowerBar(ticksDiff); + }; + + game.load(); + + +}).call(this, game, createjs, Box2D); + + diff --git a/views/archive/j/ball-shooting/scripts/helpers.js b/views/archive/j/ball-shooting/scripts/helpers.js new file mode 100644 index 00000000..be43bf6d --- /dev/null +++ b/views/archive/j/ball-shooting/scripts/helpers.js @@ -0,0 +1,7 @@ +var game = this.game || (this.game={}); +var createjs = createjs || {}; + +;(function(game, cjs){ + game.helper = game.helper || {}; + +}).call(this, game, createjs); \ No newline at end of file diff --git a/views/archive/j/ball-shooting/scripts/level.js b/views/archive/j/ball-shooting/scripts/level.js new file mode 100644 index 00000000..27a19c8e --- /dev/null +++ b/views/archive/j/ball-shooting/scripts/level.js @@ -0,0 +1,126 @@ +var game = this.game || (this.game={}); + +(function(game){ + + var degrees = Math.PI / 180 + + game.balls = { + 'slow ball': { + className: 'SlowBall', + radius: 13, + density: 0.6, + friction: 0.8, + restitution: 0.1 + }, + 'bouncy ball': { + className: 'BouncyBall', + radius: 10, + density: 1.1, + friction: 0.8, + restitution: 0.4 + } + }; + game.levels = [ + { + hoopPosition: {x:50, y:150}, + ballName: 'slow ball', + ballPosition: {x:350, y:250}, + ballRandomRange: {x:60, y:60}, + obstacles: [] + }, + { + hoopPosition: {x:50, y:200}, + ballName: 'slow ball', + ballPosition: {x:350, y:200}, + ballRandomRange: {x:160, y:0}, + obstacles: [] + }, + { + hoopPosition: {x:50, y:160}, + ballName: 'bouncy ball', + ballPosition: {x:350, y:250}, + ballRandomRange: {x:80, y:80}, + obstacles: [] + }, + { + hoopPosition: {x:50, y:160}, + ballName: 'slow ball', + ballPosition: {x:350, y:250}, + ballRandomRange: {x:80, y:80}, + obstacles: [ + { + type: 'rect', + graphicName: 'BrownSquare', + position: {x: 200, y: 160}, + dimension: {width: 10, height:10}, + angle: 0 + }, + { + type: 'rect', + graphicName: 'BrownSquare', + position: {x: 200, y: 120}, + dimension: {width: 10, height:10}, + angle: 0 + }, + ] + }, + { + hoopPosition: {x:50, y:160}, + ballName: 'slow ball', + ballPosition: {x:350, y:250}, + ballRandomRange: {x:80, y:80}, + obstacles: [ + { + type: 'cross', + graphicName: 'Cross', + position: {x: 165, y: 140}, + length: 60, + width: 10, + enableMotor: true, + maxTorque: 25, + motorSpeed: 3.0 + }, + ] + }, + { + hoopPosition: {x:50, y:150}, + ballName: 'slow ball', + ballPosition: {x:350, y:250}, + ballRandomRange: {x:60, y:60}, + obstacles: [ + { + type: 'cross', + graphicName: 'Cross', + position: {x: 165, y: 140}, + length: 60, + width: 10, + enableMotor: true, + maxTorque: 25, + motorSpeed: 3.0 + }, + { + type: 'rect', + graphicName: 'BrownSquare', + position: {x: 200, y: 55}, + dimension: {width: 10, height:10}, + angle: 0 + }, + { + type: 'rect', + graphicName: 'BrownSquare', + position: {x: 260, y: 100}, + dimension: {width: 10, height:10}, + angle: 0 + }, + { + type: 'rect', + graphicName: 'BrownSquare', + position: {x: 300, y: 100}, + dimension: {width: 10, height:10}, + angle: 0 + } + ] + } + ]; + game.currentLevel = game.levels[0]; // default the 1st level. +}).call(this, game); \ No newline at end of file diff --git a/views/archive/j/ball-shooting/scripts/physics.js b/views/archive/j/ball-shooting/scripts/physics.js new file mode 100644 index 00000000..4e798d15 --- /dev/null +++ b/views/archive/j/ball-shooting/scripts/physics.js @@ -0,0 +1,370 @@ +var game = this.game || (this.game={}); +var createjs = createjs || {}; + +;(function(game, cjs, b2d){ + + var b2Vec2 = Box2D.Common.Math.b2Vec2 + , b2AABB = Box2D.Collision.b2AABB + , b2BodyDef = Box2D.Dynamics.b2BodyDef + , b2Body = Box2D.Dynamics.b2Body + , b2FixtureDef = Box2D.Dynamics.b2FixtureDef + , b2Fixture = Box2D.Dynamics.b2Fixture + , b2World = Box2D.Dynamics.b2World + , b2MassData = Box2D.Collision.Shapes.b2MassData + , b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape + , b2CircleShape = Box2D.Collision.Shapes.b2CircleShape + , b2DebugDraw = Box2D.Dynamics.b2DebugDraw + , b2MouseJointDef = Box2D.Dynamics.Joints.b2MouseJointDef + , b2RevoluteJointDef = Box2D.Dynamics.Joints.b2RevoluteJointDef + ; + + var pxPerMeter = 30; // 30 pixels = 1 meter. Box3D uses meters and we use pixels. + var shouldDrawDebug = false; + + var physics = game.physics = {}; + + physics.bodiesToBeRemove = []; + + physics.createWorld = function() { + var gravity = new b2Vec2(0, 9.8); + this.world = new b2World(gravity, /*allow sleep= */ true); + }; + + physics.createLevel = function() { + + var level = game.currentLevel; + + this.createObstacles(level); + this.createHoop(level); + + this.createWorldBoundary(); + + this.setupContactListener(); + + // the first ball + game.spawnBall(); + }; + + physics.clearWorld = function() { + var body = this.world.GetBodyList(); + while (body) { + var sprite = body.GetUserData(); + if (sprite) { + sprite.parent.removeChild(sprite); + } + var b = body; + body = body.GetNext(); + this.world.DestroyBody(b); + } + }; + + physics.createWorldBoundary = function() { + var bodyDef = new b2BodyDef; + var fixDef = new b2FixtureDef; + + bodyDef.type = b2Body.b2_staticBody; + bodyDef.position.x = -800/pxPerMeter; + bodyDef.position.y = 500/pxPerMeter; + bodyDef.angle = 0; + + fixDef.isSensor = true; + fixDef.shape = new b2PolygonShape(); + fixDef.shape.SetAsBox(2000/pxPerMeter, 10/pxPerMeter); + + body = this.world.CreateBody(bodyDef); + body.CreateFixture(fixDef); + }; + + physics.createObstacles = function(level) { + var bodyDef = new b2BodyDef; + var fixDef = new b2FixtureDef; + + // default fixture + fixDef.density = 1.0; + fixDef.friction = 0.5; + fixDef.restitution = 0.2; + + // obstacles + var body, sprite; + for(var i=0, len=level.obstacles.length; i 0) { + degreeAddition = Math.PI; // Quadrant II + } else if (diffX < 0 && diffY < 0) { + degreeAddition = Math.PI; // Quadrant III + } else if (diffX > 0 && diffY < 0) { + degreeAddition = Math.PI * 2; // Quadrant IV + } + + var theta = Math.atan(diffY / diffX) + degreeAddition; + return theta; + }; + + physics.shootBall = function(stageX, stageY, ticksDiff) { + this.ball.SetType(b2Body.b2_dynamicBody); + + var theta = this.launchAngle(stageX, stageY); + + var r = Math.log(ticksDiff) * 50; // power + + var resultX = r * Math.cos(theta); + var resultY = r * Math.sin(theta); + + this.ball.ApplyTorque(30); // rotate it + + // shoot the ball + this.ball.ApplyImpulse(new b2Vec2(resultX/pxPerMeter, resultY/pxPerMeter), this.ball.GetWorldCenter()); + + this.ball = undefined; + }; + + physics.update = function() { + this.world.Step(1 / 60, 10, 10); + if (shouldDrawDebug) { + this.world.DrawDebugData(); + } + this.world.ClearForces(); + + // draw sprites + var body = this.world.GetBodyList(); + while (body) { + var sprite = body.GetUserData(); + + if (sprite) { + var position = body.GetWorldCenter(); + sprite.x = position.x * pxPerMeter; + sprite.y = position.y * pxPerMeter; + sprite.rotation = body.GetAngle() * 180 / Math.PI; // rad to degree + } + + body = body.GetNext(); + } + + // remove bodies + for (var i=0, len=this.bodiesToBeRemove.length; i=0&&b>=0)&&this.lowerBound.IsValid()&&this.upperBound.IsValid()};B.prototype.GetCenter=function(){return new p((this.lowerBound.x+ +this.upperBound.x)/2,(this.lowerBound.y+this.upperBound.y)/2)};B.prototype.GetExtents=function(){return new p((this.upperBound.x-this.lowerBound.x)/2,(this.upperBound.y-this.lowerBound.y)/2)};B.prototype.Contains=function(b){var e=true;return e=(e=(e=(e=e&&this.lowerBound.x<=b.lowerBound.x)&&this.lowerBound.y<=b.lowerBound.y)&&b.upperBound.x<=this.upperBound.x)&&b.upperBound.y<=this.upperBound.y};B.prototype.RayCast=function(b,e){var f=-Number.MAX_VALUE,m=Number.MAX_VALUE,r=e.p1.x,s=e.p1.y,v=e.p2.x- +e.p1.x,t=e.p2.y-e.p1.y,x=Math.abs(t),C=b.normal,J=0,T=0,P=J=0;P=0;if(Math.abs(v)J){P=T;T=J;J=P;P=1}if(T>f){C.x=P;C.y=0;f=T}m=Math.min(m,J);if(f>m)return false}if(xJ){P=T;T=J;J=P;P=1}if(T>f){C.y=P;C.x=0;f= +T}m=Math.min(m,J);if(f>m)return false}b.fraction=f;return true};B.prototype.TestOverlap=function(b){var e=b.lowerBound.y-this.upperBound.y,f=this.lowerBound.y-b.upperBound.y;if(b.lowerBound.x-this.upperBound.x>0||e>0)return false;if(this.lowerBound.x-b.upperBound.x>0||f>0)return false;return true};B.Combine=function(b,e){var f=new B;f.Combine(b,e);return f};B.prototype.Combine=function(b,e){this.lowerBound.x=Math.min(b.lowerBound.x,e.lowerBound.x);this.lowerBound.y=Math.min(b.lowerBound.y,e.lowerBound.y); +this.upperBound.x=Math.max(b.upperBound.x,e.upperBound.x);this.upperBound.y=Math.max(b.upperBound.y,e.upperBound.y)};Q.b2Bound=function(){};Q.prototype.IsLower=function(){return(this.value&1)==0};Q.prototype.IsUpper=function(){return(this.value&1)==1};Q.prototype.Swap=function(b){var e=this.value,f=this.proxy,m=this.stabbingCount;this.value=b.value;this.proxy=b.proxy;this.stabbingCount=b.stabbingCount;b.value=e;b.proxy=f;b.stabbingCount=m};V.b2BoundValues=function(){};V.prototype.b2BoundValues=function(){this.lowerValues= +new Vector_a2j_Number;this.lowerValues[0]=0;this.lowerValues[1]=0;this.upperValues=new Vector_a2j_Number;this.upperValues[0]=0;this.upperValues[1]=0};M.b2Collision=function(){};M.ClipSegmentToLine=function(b,e,f,m){if(m===undefined)m=0;var r,s=0;r=e[0];var v=r.v;r=e[1];var t=r.v,x=f.x*v.x+f.y*v.y-m;r=f.x*t.x+f.y*t.y-m;x<=0&&b[s++].Set(e[0]);r<=0&&b[s++].Set(e[1]);if(x*r<0){f=x/(x-r);r=b[s];r=r.v;r.x=v.x+f*(t.x-v.x);r.y=v.y+f*(t.y-v.y);r=b[s];r.id=(x>0?e[0]:e[1]).id;++s}return s};M.EdgeSeparation= +function(b,e,f,m,r){if(f===undefined)f=0;parseInt(b.m_vertexCount);var s=b.m_vertices;b=b.m_normals;var v=parseInt(m.m_vertexCount),t=m.m_vertices,x,C;x=e.R;C=b[f];b=x.col1.x*C.x+x.col2.x*C.y;m=x.col1.y*C.x+x.col2.y*C.y;x=r.R;var J=x.col1.x*b+x.col1.y*m;x=x.col2.x*b+x.col2.y*m;for(var T=0,P=Number.MAX_VALUE,X=0;XT){T=t;C=P}}v=M.EdgeSeparation(e,f,C,m,r);t=parseInt(C-1>=0?C-1:s-1);x=M.EdgeSeparation(e,f,t,m,r);J=parseInt(C+1v&&x>T){$=-1;P=t;X=x}else if(T>v){$=1;P=J;X=T}else{b[0]=C;return v}for(;;){C=$==-1?P-1>=0?P-1:s-1:P+1X){P=C;X=v}else break}b[0]=P;return X};M.FindIncidentEdge=function(b,e,f,m,r,s){if(m===undefined)m=0;parseInt(e.m_vertexCount);var v=e.m_normals,t=parseInt(r.m_vertexCount); +e=r.m_vertices;r=r.m_normals;var x;x=f.R;f=v[m];v=x.col1.x*f.x+x.col2.x*f.y;var C=x.col1.y*f.x+x.col2.y*f.y;x=s.R;f=x.col1.x*v+x.col1.y*C;C=x.col2.x*v+x.col2.y*C;v=f;x=0;for(var J=Number.MAX_VALUE,T=0;Tv)){var x=0;M.s_edgeBO[0]=x;var C=M.FindMaxSeparation(M.s_edgeBO, +m,r,e,f);x=M.s_edgeBO[0];if(!(C>v)){var J=0,T=0;if(C>0.98*t+0.0010){t=m;m=e;e=r;f=f;J=x;b.m_type=E.e_faceB;T=1}else{t=e;m=m;e=f;f=r;J=s;b.m_type=E.e_faceA;T=0}s=M.s_incidentEdge;M.FindIncidentEdge(s,t,e,J,m,f);x=parseInt(t.m_vertexCount);r=t.m_vertices;t=r[J];var P;P=J+1s*s)){b.m_type=E.e_circles;b.m_localPoint.SetV(e.m_p);b.m_localPlaneNormal.SetZero();b.m_pointCount=1;b.m_points[0].m_localPoint.SetV(m.m_p);b.m_points[0].m_id.key=0}};M.CollidePolygonAndCircle=function(b,e,f,m,r){var s=b.m_pointCount=0,v=0,t,x;x=r.R;t=m.m_p;var C=r.position.y+(x.col1.y*t.x+x.col2.y*t.y);s=r.position.x+(x.col1.x*t.x+x.col2.x*t.y)-f.position.x;v=C-f.position.y;x=f.R;f=s* +x.col1.x+v*x.col1.y;x=s*x.col2.x+v*x.col2.y;var J=0;C=-Number.MAX_VALUE;r=e.m_radius+m.m_radius;var T=parseInt(e.m_vertexCount),P=e.m_vertices;e=e.m_normals;for(var X=0;Xr)return;if(s>C){C=s;J=X}}s=parseInt(J);v=parseInt(s+1r*r)return;b.m_pointCount=1;b.m_type=E.e_faceA;b.m_localPlaneNormal.x=f-t.x;b.m_localPlaneNormal.y=x-t.y;b.m_localPlaneNormal.Normalize();b.m_localPoint.SetV(t)}else if(C<=0){if((f-P.x)*(f-P.x)+(x-P.y)*(x-P.y)>r*r)return;b.m_pointCount=1;b.m_type=E.e_faceA;b.m_localPlaneNormal.x=f-P.x;b.m_localPlaneNormal.y=x-P.y;b.m_localPlaneNormal.Normalize();b.m_localPoint.SetV(P)}else{J=0.5*(t.x+P.x);t=0.5*(t.y+P.y);C=(f-J)*e[s].x+ +(x-t)*e[s].y;if(C>r)return;b.m_pointCount=1;b.m_type=E.e_faceA;b.m_localPlaneNormal.x=e[s].x;b.m_localPlaneNormal.y=e[s].y;b.m_localPlaneNormal.Normalize();b.m_localPoint.Set(J,t)}}b.m_points[0].m_localPoint.SetV(m.m_p);b.m_points[0].m_id.key=0};M.TestOverlap=function(b,e){var f=e.lowerBound,m=b.upperBound,r=f.x-m.x,s=f.y-m.y;f=b.lowerBound;m=e.upperBound;var v=f.y-m.y;if(r>0||s>0)return false;if(f.x-m.x>0||v>0)return false;return true};Box2D.postDefs.push(function(){Box2D.Collision.b2Collision.s_incidentEdge= +M.MakeClipPointVector();Box2D.Collision.b2Collision.s_clipPoints1=M.MakeClipPointVector();Box2D.Collision.b2Collision.s_clipPoints2=M.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 p;Box2D.Collision.b2Collision.s_localNormal=new p;Box2D.Collision.b2Collision.s_planePoint=new p;Box2D.Collision.b2Collision.s_normal=new p;Box2D.Collision.b2Collision.s_tangent= +new p;Box2D.Collision.b2Collision.s_tangent2=new p;Box2D.Collision.b2Collision.s_v11=new p;Box2D.Collision.b2Collision.s_v12=new p;Box2D.Collision.b2Collision.b2CollidePolyTempVec=new p;Box2D.Collision.b2Collision.b2_nullFeature=255});L.b2ContactID=function(){this.features=new c};L.prototype.b2ContactID=function(){this.features._m_id=this};L.prototype.Set=function(b){this.key=b._key};L.prototype.Copy=function(){var b=new L;b.key=this.key;return b};Object.defineProperty(L.prototype,"key",{enumerable:false, +configurable:true,get:function(){return this._key}});Object.defineProperty(L.prototype,"key",{enumerable:false,configurable:true,set:function(b){if(b===undefined)b=0;this._key=b;this.features._referenceEdge=this._key&255;this.features._incidentEdge=(this._key&65280)>>8&255;this.features._incidentVertex=(this._key&16711680)>>16&255;this.features._flip=(this._key&4278190080)>>24&255}});I.b2ContactPoint=function(){this.position=new p;this.velocity=new p;this.normal=new p;this.id=new L};W.b2Distance= +function(){};W.Distance=function(b,e,f){++W.b2_gjkCalls;var m=f.proxyA,r=f.proxyB,s=f.transformA,v=f.transformB,t=W.s_simplex;t.ReadCache(e,m,s,r,v);var x=t.m_vertices,C=W.s_saveA,J=W.s_saveB,T=0;t.GetClosestPoint().LengthSquared();for(var P=0,X,$=0;$<20;){T=t.m_count;for(P=0;Pe+r&&b.distance>Number.MIN_VALUE){b.distance-=e+r;f=w.SubtractVV(b.pointB,b.pointA);f.Normalize();b.pointA.x+=e*f.x;b.pointA.y+=e*f.y;b.pointB.x-=r*f.x;b.pointB.y-=r*f.y}else{X=new p;X.x=0.5*(b.pointA.x+b.pointB.x);X.y=0.5*(b.pointA.y+b.pointB.y);b.pointA.x=b.pointB.x=X.x;b.pointA.y=b.pointB.y=X.y;b.distance=0}}};Box2D.postDefs.push(function(){Box2D.Collision.b2Distance.s_simplex=new h;Box2D.Collision.b2Distance.s_saveA= +new Vector_a2j_Number(3);Box2D.Collision.b2Distance.s_saveB=new Vector_a2j_Number(3)});Y.b2DistanceInput=function(){};k.b2DistanceOutput=function(){this.pointA=new p;this.pointB=new p};z.b2DistanceProxy=function(){};z.prototype.Set=function(b){switch(b.GetType()){case K.e_circleShape:b=b instanceof F?b:null;this.m_vertices=new Vector(1,true);this.m_vertices[0]=b.m_p;this.m_count=1;this.m_radius=b.m_radius;break;case K.e_polygonShape:b=b instanceof G?b:null;this.m_vertices=b.m_vertices;this.m_count= +b.m_vertexCount;this.m_radius=b.m_radius;break;default:y.b2Assert(false)}};z.prototype.GetSupport=function(b){for(var e=0,f=this.m_vertices[0].x*b.x+this.m_vertices[0].y*b.y,m=1;mf){e=m;f=r}}return e};z.prototype.GetSupportVertex=function(b){for(var e=0,f=this.m_vertices[0].x*b.x+this.m_vertices[0].y*b.y,m=1;mf){e=m;f=r}}return this.m_vertices[e]}; +z.prototype.GetVertexCount=function(){return this.m_count};z.prototype.GetVertex=function(b){if(b===undefined)b=0;y.b2Assert(0<=b&&b0?f.x:-f.x);f=y.b2_aabbExtension+y.b2_aabbMultiplier*(f.y>0?f.y:-f.y);b.aabb.lowerBound.x=e.lowerBound.x-m;b.aabb.lowerBound.y=e.lowerBound.y-f;b.aabb.upperBound.x=e.upperBound.x+ +m;b.aabb.upperBound.y=e.upperBound.y+f;this.InsertLeaf(b);return true};u.prototype.Rebalance=function(b){if(b===undefined)b=0;if(this.m_root!=null)for(var e=0;e>m&1?f.child2:f.child1;m=m+1&31}++this.m_path;this.RemoveLeaf(f);this.InsertLeaf(f)}};u.prototype.GetFatAABB=function(b){return b.aabb};u.prototype.GetUserData=function(b){return b.userData};u.prototype.Query=function(b,e){if(this.m_root!=null){var f=new Vector,m=0;for(f[m++]= +this.m_root;m>0;){var r=f[--m];if(r.aabb.TestOverlap(e))if(r.IsLeaf()){if(!b(r))break}else{f[m++]=r.child1;f[m++]=r.child2}}}};u.prototype.RayCast=function(b,e){if(this.m_root!=null){var f=e.p1,m=e.p2,r=w.SubtractVV(f,m);r.Normalize();r=w.CrossFV(1,r);var s=w.AbsV(r),v=e.maxFraction,t=new B,x=0,C=0;x=f.x+v*(m.x-f.x);C=f.y+v*(m.y-f.y);t.lowerBound.x=Math.min(f.x,x);t.lowerBound.y=Math.min(f.y,C);t.upperBound.x=Math.max(f.x,x);t.upperBound.y=Math.max(f.y,C);var J=new Vector,T=0;for(J[T++]=this.m_root;T> +0;){v=J[--T];if(v.aabb.TestOverlap(t)!=false){x=v.aabb.GetCenter();C=v.aabb.GetExtents();if(!(Math.abs(r.x*(f.x-x.x)+r.y*(f.y-x.y))-s.x*C.x-s.y*C.y>0))if(v.IsLeaf()){x=new S;x.p1=e.p1;x.p2=e.p2;x.maxFraction=e.maxFraction;v=b(x,v);if(v==0)break;if(v>0){x=f.x+v*(m.x-f.x);C=f.y+v*(m.y-f.y);t.lowerBound.x=Math.min(f.x,x);t.lowerBound.y=Math.min(f.y,C);t.upperBound.x=Math.max(f.x,x);t.upperBound.y=Math.max(f.y,C)}}else{J[T++]=v.child1;J[T++]=v.child2}}}}};u.prototype.AllocateNode=function(){if(this.m_freeList){var b= +this.m_freeList;this.m_freeList=b.parent;b.parent=null;b.child1=null;b.child2=null;return b}return new H};u.prototype.FreeNode=function(b){b.parent=this.m_freeList;this.m_freeList=b};u.prototype.InsertLeaf=function(b){++this.m_insertionCount;if(this.m_root==null){this.m_root=b;this.m_root.parent=null}else{var e=b.aabb.GetCenter(),f=this.m_root;if(f.IsLeaf()==false){do{var m=f.child1;f=f.child2;f=Math.abs((m.aabb.lowerBound.x+m.aabb.upperBound.x)/2-e.x)+Math.abs((m.aabb.lowerBound.y+m.aabb.upperBound.y)/ +2-e.y)=m?t:m;++e.m_pairCount;return true}, +r)}for(f=e.m_moveBuffer.length=0;fx){var J=r.x-this.p1.x,T=r.y-this.p1.y;r=J*f+T*t;if(0<=r&&r<=m*C){m=-s*T+v*J;if(-x*C<=m&&m<=C*(1+x)){r/=C;m=Math.sqrt(f*f+t*t);f/=m;t/=m;b[0]=r;e.Set(f, +t);return true}}}return false};Z.prototype.Extend=function(b){this.ExtendForward(b);this.ExtendBackward(b)};Z.prototype.ExtendForward=function(b){var e=this.p2.x-this.p1.x,f=this.p2.y-this.p1.y;b=Math.min(e>0?(b.upperBound.x-this.p1.x)/e:e<0?(b.lowerBound.x-this.p1.x)/e:Number.POSITIVE_INFINITY,f>0?(b.upperBound.y-this.p1.y)/f:f<0?(b.lowerBound.y-this.p1.y)/f:Number.POSITIVE_INFINITY);this.p2.x=this.p1.x+e*b;this.p2.y=this.p1.y+f*b};Z.prototype.ExtendBackward=function(b){var e=-this.p2.x+this.p1.x, +f=-this.p2.y+this.p1.y;b=Math.min(e>0?(b.upperBound.x-this.p2.x)/e:e<0?(b.lowerBound.x-this.p2.x)/e:Number.POSITIVE_INFINITY,f>0?(b.upperBound.y-this.p2.y)/f:f<0?(b.lowerBound.y-this.p2.y)/f:Number.POSITIVE_INFINITY);this.p1.x=this.p2.x+e*b;this.p1.y=this.p2.y+f*b};d.b2SeparationFunction=function(){this.m_localPoint=new p;this.m_axis=new p};d.prototype.Initialize=function(b,e,f,m,r){this.m_proxyA=e;this.m_proxyB=m;var s=parseInt(b.count);y.b2Assert(01){b=b.metric;s=this.GetMetric();if(s<0.5*b||2*b0?w.CrossFV(1,b):w.CrossVF(b,1);default:y.b2Assert(false);return new p}};h.prototype.GetClosestPoint= +function(){switch(this.m_count){case 0:y.b2Assert(false);return new p;case 1:return this.m_v1.w;case 2:return new p(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:y.b2Assert(false);return new p}};h.prototype.GetWitnessPoints=function(b,e){switch(this.m_count){case 0:y.b2Assert(false);break;case 1:b.SetV(this.m_v1.wA);e.SetV(this.m_v1.wB);break;case 2:b.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x;b.y=this.m_v1.a*this.m_v1.wA.y+ +this.m_v2.a*this.m_v2.wA.y;e.x=this.m_v1.a*this.m_v1.wB.x+this.m_v2.a*this.m_v2.wB.x;e.y=this.m_v1.a*this.m_v1.wB.y+this.m_v2.a*this.m_v2.wB.y;break;case 3:e.x=b.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;e.y=b.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:y.b2Assert(false)}};h.prototype.GetMetric=function(){switch(this.m_count){case 0:y.b2Assert(false);return 0;case 1:return 0;case 2:return w.SubtractVV(this.m_v1.w, +this.m_v2.w).Length();case 3:return w.CrossVV(w.SubtractVV(this.m_v2.w,this.m_v1.w),w.SubtractVV(this.m_v3.w,this.m_v1.w));default:y.b2Assert(false);return 0}};h.prototype.Solve2=function(){var b=this.m_v1.w,e=this.m_v2.w,f=w.SubtractVV(e,b);b=-(b.x*f.x+b.y*f.y);if(b<=0)this.m_count=this.m_v1.a=1;else{e=e.x*f.x+e.y*f.y;if(e<=0){this.m_count=this.m_v2.a=1;this.m_v1.Set(this.m_v2)}else{f=1/(e+b);this.m_v1.a=e*f;this.m_v2.a=b*f;this.m_count=2}}};h.prototype.Solve3=function(){var b=this.m_v1.w,e=this.m_v2.w, +f=this.m_v3.w,m=w.SubtractVV(e,b),r=w.Dot(b,m),s=w.Dot(e,m);r=-r;var v=w.SubtractVV(f,b),t=w.Dot(b,v),x=w.Dot(f,v);t=-t;var C=w.SubtractVV(f,e),J=w.Dot(e,C);C=w.Dot(f,C);J=-J;v=w.CrossVV(m,v);m=v*w.CrossVV(e,f);f=v*w.CrossVV(f,b);b=v*w.CrossVV(b,e);if(r<=0&&t<=0)this.m_count=this.m_v1.a=1;else if(s>0&&r>0&&b<=0){x=1/(s+r);this.m_v1.a=s*x;this.m_v2.a=r*x;this.m_count=2}else if(x>0&&t>0&&f<=0){s=1/(x+t);this.m_v1.a=x*s;this.m_v3.a=t*s;this.m_count=2;this.m_v2.Set(this.m_v3)}else if(s<=0&&J<=0){this.m_count= +this.m_v2.a=1;this.m_v1.Set(this.m_v2)}else if(x<=0&&C<=0){this.m_count=this.m_v3.a=1;this.m_v1.Set(this.m_v3)}else if(C>0&&J>0&&m<=0){s=1/(C+J);this.m_v2.a=C*s;this.m_v3.a=J*s;this.m_count=2;this.m_v1.Set(this.m_v3)}else{s=1/(m+f+b);this.m_v1.a=m*s;this.m_v2.a=f*s;this.m_v3.a=b*s;this.m_count=3}};l.b2SimplexCache=function(){this.indexA=new Vector_a2j_Number(3);this.indexB=new Vector_a2j_Number(3)};j.b2SimplexVertex=function(){};j.prototype.Set=function(b){this.wA.SetV(b.wA);this.wB.SetV(b.wB);this.w.SetV(b.w); +this.a=b.a;this.indexA=b.indexA;this.indexB=b.indexB};o.b2TimeOfImpact=function(){};o.TimeOfImpact=function(b){++o.b2_toiCalls;var e=b.proxyA,f=b.proxyB,m=b.sweepA,r=b.sweepB;y.b2Assert(m.t0==r.t0);y.b2Assert(1-m.t0>Number.MIN_VALUE);var s=e.m_radius+f.m_radius;b=b.tolerance;var v=0,t=0,x=0;o.s_cache.count=0;for(o.s_distanceInput.useRadii=false;;){m.GetTransform(o.s_xfA,v);r.GetTransform(o.s_xfB,v);o.s_distanceInput.proxyA=e;o.s_distanceInput.proxyB=f;o.s_distanceInput.transformA=o.s_xfA;o.s_distanceInput.transformB= +o.s_xfB;W.Distance(o.s_distanceOutput,o.s_cache,o.s_distanceInput);if(o.s_distanceOutput.distance<=0){v=1;break}o.s_fcn.Initialize(o.s_cache,e,o.s_xfA,f,o.s_xfB);var C=o.s_fcn.Evaluate(o.s_xfA,o.s_xfB);if(C<=0){v=1;break}if(t==0)x=C>s?w.Max(s-b,0.75*s):w.Max(C-b,0.02*s);if(C-x<0.5*b){if(t==0){v=1;break}break}var J=v,T=v,P=1;C=C;m.GetTransform(o.s_xfA,P);r.GetTransform(o.s_xfB,P);var X=o.s_fcn.Evaluate(o.s_xfA,o.s_xfB);if(X>=x){v=1;break}for(var $=0;;){var ba=0;ba=$&1?T+(x-C)*(P-T)/(X-C):0.5*(T+P); +m.GetTransform(o.s_xfA,ba);r.GetTransform(o.s_xfB,ba);var ca=o.s_fcn.Evaluate(o.s_xfA,o.s_xfB);if(w.Abs(ca-x)<0.025*b){J=ba;break}if(ca>x){T=ba;C=ca}else{P=ba;X=ca}++$;++o.b2_toiRootIters;if($==50)break}o.b2_toiMaxRootIters=w.Max(o.b2_toiMaxRootIters,$);if(J<(1+100*Number.MIN_VALUE)*v)break;v=J;t++;++o.b2_toiIters;if(t==1E3)break}o.b2_toiMaxIters=w.Max(o.b2_toiMaxIters,t);return v};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 l;Box2D.Collision.b2TimeOfImpact.s_distanceInput=new Y;Box2D.Collision.b2TimeOfImpact.s_xfA=new U;Box2D.Collision.b2TimeOfImpact.s_xfB=new U;Box2D.Collision.b2TimeOfImpact.s_fcn=new d;Box2D.Collision.b2TimeOfImpact.s_distanceOutput=new k});q.b2TOIInput=function(){this.proxyA=new z;this.proxyB=new z;this.sweepA= +new A;this.sweepB=new A};n.b2WorldManifold=function(){this.m_normal=new p};n.prototype.b2WorldManifold=function(){this.m_points=new Vector(y.b2_maxManifoldPoints);for(var b=0;bNumber.MIN_VALUE*Number.MIN_VALUE){x=Math.sqrt(x);this.m_normal.x=v/x;this.m_normal.y=t/x}else{this.m_normal.x=1;this.m_normal.y=0}v=e+f*this.m_normal.y;m=m-r*this.m_normal.y;this.m_points[0].x=0.5*(s+f*this.m_normal.x+(b-r*this.m_normal.x));this.m_points[0].y=0.5*(v+m);break;case E.e_faceA:t=e.R;v=b.m_localPlaneNormal;x=t.col1.x*v.x+t.col2.x*v.y;C=t.col1.y* +v.x+t.col2.y*v.y;t=e.R;v=b.m_localPoint;J=e.position.x+t.col1.x*v.x+t.col2.x*v.y;T=e.position.y+t.col1.y*v.x+t.col2.y*v.y;this.m_normal.x=x;this.m_normal.y=C;for(s=0;sthis.m_radius){D.SetV(u);return Math.PI*this.m_radius*this.m_radius}z=this.m_radius*this.m_radius;var O=H*H;H=z*(Math.asin(H/this.m_radius)+Math.PI/2)+H*Math.sqrt(z-O);z=-2/3*Math.pow(z-O,1.5)/H;D.x=u.x+k.x*z;D.y=u.y+k.y*z;return H};G.prototype.GetLocalPosition= +function(){return this.m_p};G.prototype.SetLocalPosition=function(k){this.m_p.SetV(k)};G.prototype.GetRadius=function(){return this.m_radius};G.prototype.SetRadius=function(k){if(k===undefined)k=0;this.m_radius=k};G.prototype.b2CircleShape=function(k){if(k===undefined)k=0;this.__super.b2Shape.call(this);this.m_type=U.e_circleShape;this.m_radius=k};K.b2EdgeChainDef=function(){};K.prototype.b2EdgeChainDef=function(){this.vertexCount=0;this.isALoop=true;this.vertices=[]};Box2D.inherit(y,Box2D.Collision.Shapes.b2Shape); +y.prototype.__super=Box2D.Collision.Shapes.b2Shape.prototype;y.b2EdgeShape=function(){Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments);this.s_supportVec=new V;this.m_v1=new V;this.m_v2=new V;this.m_coreV1=new V;this.m_coreV2=new V;this.m_normal=new V;this.m_direction=new V;this.m_cornerDir1=new V;this.m_cornerDir2=new V};y.prototype.TestPoint=function(){return false};y.prototype.RayCast=function(k,z,u){var D,H=z.p2.x-z.p1.x,O=z.p2.y-z.p1.y;D=u.R;var E=u.position.x+(D.col1.x*this.m_v1.x+ +D.col2.x*this.m_v1.y),R=u.position.y+(D.col1.y*this.m_v1.x+D.col2.y*this.m_v1.y),N=u.position.y+(D.col1.y*this.m_v2.x+D.col2.y*this.m_v2.y)-R;u=-(u.position.x+(D.col1.x*this.m_v2.x+D.col2.x*this.m_v2.y)-E);D=100*Number.MIN_VALUE;var S=-(H*N+O*u);if(S>D){E=z.p1.x-E;var aa=z.p1.y-R;R=E*N+aa*u;if(0<=R&&R<=z.maxFraction*S){z=-H*aa+O*E;if(-D*S<=z&&z<=S*(1+D)){R/=S;k.fraction=R;z=Math.sqrt(N*N+u*u);k.normal.x=N/z;k.normal.y=u/z;return true}}}return false};y.prototype.ComputeAABB=function(k,z){var u=z.R, +D=z.position.x+(u.col1.x*this.m_v1.x+u.col2.x*this.m_v1.y),H=z.position.y+(u.col1.y*this.m_v1.x+u.col2.y*this.m_v1.y),O=z.position.x+(u.col1.x*this.m_v2.x+u.col2.x*this.m_v2.y);u=z.position.y+(u.col1.y*this.m_v2.x+u.col2.y*this.m_v2.y);if(D0)if(k>0)return 0;else{O.x=-k/(E-k)*O.x+E/(E-k)*u.x;O.y=-k/(E-k)*O.y+E/(E-k)*u.y}else if(k>0){u.x=-k/(E-k)*O.x+E/(E-k)*u.x;u.y=-k/(E-k)*O.y+E/(E-k)*u.y}D.x=(H.x+O.x+u.x)/3;D.y=(H.y+O.y+u.y)/3;return 0.5*((O.x-H.x)*(u.y-H.y)-(O.y-H.y)*(u.x-H.x))};y.prototype.GetLength=function(){return this.m_length};y.prototype.GetVertex1=function(){return this.m_v1};y.prototype.GetVertex2= +function(){return this.m_v2};y.prototype.GetCoreVertex1=function(){return this.m_coreV1};y.prototype.GetCoreVertex2=function(){return this.m_coreV2};y.prototype.GetNormalVector=function(){return this.m_normal};y.prototype.GetDirectionVector=function(){return this.m_direction};y.prototype.GetCorner1Vector=function(){return this.m_cornerDir1};y.prototype.GetCorner2Vector=function(){return this.m_cornerDir2};y.prototype.Corner1IsConvex=function(){return this.m_cornerConvex1};y.prototype.Corner2IsConvex= +function(){return this.m_cornerConvex2};y.prototype.GetFirstVertex=function(k){var z=k.R;return new V(k.position.x+(z.col1.x*this.m_coreV1.x+z.col2.x*this.m_coreV1.y),k.position.y+(z.col1.y*this.m_coreV1.x+z.col2.y*this.m_coreV1.y))};y.prototype.GetNextEdge=function(){return this.m_nextEdge};y.prototype.GetPrevEdge=function(){return this.m_prevEdge};y.prototype.Support=function(k,z,u){if(z===undefined)z=0;if(u===undefined)u=0;var D=k.R,H=k.position.x+(D.col1.x*this.m_coreV1.x+D.col2.x*this.m_coreV1.y), +O=k.position.y+(D.col1.y*this.m_coreV1.x+D.col2.y*this.m_coreV1.y),E=k.position.x+(D.col1.x*this.m_coreV2.x+D.col2.x*this.m_coreV2.y);k=k.position.y+(D.col1.y*this.m_coreV2.x+D.col2.y*this.m_coreV2.y);if(H*z+O*u>E*z+k*u){this.s_supportVec.x=H;this.s_supportVec.y=O}else{this.s_supportVec.x=E;this.s_supportVec.y=k}return this.s_supportVec};y.prototype.b2EdgeShape=function(k,z){this.__super.b2Shape.call(this);this.m_type=U.e_edgeShape;this.m_nextEdge=this.m_prevEdge=null;this.m_v1=k;this.m_v2=z;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(-F.b2_toiSlop*(this.m_normal.x-this.m_direction.x)+this.m_v1.x,-F.b2_toiSlop*(this.m_normal.y-this.m_direction.y)+this.m_v1.y);this.m_coreV2.Set(-F.b2_toiSlop*(this.m_normal.x+this.m_direction.x)+this.m_v2.x,-F.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)}; +y.prototype.SetPrevEdge=function(k,z,u,D){this.m_prevEdge=k;this.m_coreV1=z;this.m_cornerDir1=u;this.m_cornerConvex1=D};y.prototype.SetNextEdge=function(k,z,u,D){this.m_nextEdge=k;this.m_coreV2=z;this.m_cornerDir2=u;this.m_cornerConvex2=D};w.b2MassData=function(){this.mass=0;this.center=new V(0,0);this.I=0};Box2D.inherit(A,Box2D.Collision.Shapes.b2Shape);A.prototype.__super=Box2D.Collision.Shapes.b2Shape.prototype;A.b2PolygonShape=function(){Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments)}; +A.prototype.Copy=function(){var k=new A;k.Set(this);return k};A.prototype.Set=function(k){this.__super.Set.call(this,k);if(Box2D.is(k,A)){k=k instanceof A?k:null;this.m_centroid.SetV(k.m_centroid);this.m_vertexCount=k.m_vertexCount;this.Reserve(this.m_vertexCount);for(var z=0;zNumber.MIN_VALUE);this.m_normals[u].SetV(B.CrossVF(D, +1));this.m_normals[u].Normalize()}this.m_centroid=A.ComputeCentroid(this.m_vertices,this.m_vertexCount)};A.AsVector=function(k,z){if(z===undefined)z=0;var u=new A;u.SetAsVector(k,z);return u};A.prototype.SetAsBox=function(k,z){if(k===undefined)k=0;if(z===undefined)z=0;this.m_vertexCount=4;this.Reserve(4);this.m_vertices[0].Set(-k,-z);this.m_vertices[1].Set(k,-z);this.m_vertices[2].Set(k,z);this.m_vertices[3].Set(-k,z);this.m_normals[0].Set(0,-1);this.m_normals[1].Set(1,0);this.m_normals[2].Set(0, +1);this.m_normals[3].Set(-1,0);this.m_centroid.SetZero()};A.AsBox=function(k,z){if(k===undefined)k=0;if(z===undefined)z=0;var u=new A;u.SetAsBox(k,z);return u};A.prototype.SetAsOrientedBox=function(k,z,u,D){if(k===undefined)k=0;if(z===undefined)z=0;if(u===undefined)u=null;if(D===undefined)D=0;this.m_vertexCount=4;this.Reserve(4);this.m_vertices[0].Set(-k,-z);this.m_vertices[1].Set(k,-z);this.m_vertices[2].Set(k,z);this.m_vertices[3].Set(-k,z);this.m_normals[0].Set(0,-1);this.m_normals[1].Set(1,0); +this.m_normals[2].Set(0,1);this.m_normals[3].Set(-1,0);this.m_centroid=u;k=new Q;k.position=u;k.R.Set(D);for(u=0;u0)return false}return true};A.prototype.RayCast=function(k,z,u){var D=0,H=z.maxFraction,O=0,E=0,R,N;O=z.p1.x-u.position.x;E=z.p1.y-u.position.y;R=u.R;var S=O*R.col1.x+E*R.col1.y,aa=O*R.col2.x+E*R.col2.y;O=z.p2.x-u.position.x;E=z.p2.y-u.position.y;R=u.R;z=O*R.col1.x+E*R.col1.y-S;R=O*R.col2.x+E*R.col2.y-aa;for(var Z=parseInt(-1),d=0;d0&&O=0){k.fraction=D;R=u.R;N=this.m_normals[Z];k.normal.x=R.col1.x*N.x+R.col2.x*N.y;k.normal.y=R.col1.y*N.x+R.col2.y*N.y;return true}return false};A.prototype.ComputeAABB=function(k,z){for(var u=z.R,D=this.m_vertices[0],H=z.position.x+(u.col1.x*D.x+u.col2.x*D.y),O=z.position.y+(u.col1.y*D.x+u.col2.y*D.y),E=H,R=O,N=1;NS?E:S;R=R>D?R:D}k.lowerBound.x=H-this.m_radius;k.lowerBound.y=O-this.m_radius;k.upperBound.x=E+this.m_radius;k.upperBound.y=R+this.m_radius};A.prototype.ComputeMass=function(k,z){if(z===undefined)z=0;if(this.m_vertexCount==2){k.center.x=0.5*(this.m_vertices[0].x+this.m_vertices[1].x);k.center.y=0.5*(this.m_vertices[0].y+this.m_vertices[1].y);k.mass=0;k.I=0}else{for(var u=0,D=0,H=0,O=0,E=1/3,R=0;R0)if(aa){if(!S){N=k-1;R++}}else if(S){z=k-1;R++}S=aa}switch(R){case 0:if(S){k=new w;this.ComputeMass(k,1);D.SetV(B.MulX(u,k.center));return k.mass}else return 0;case 1:if(N==-1)N=this.m_vertexCount-1;else z=this.m_vertexCount-1}k=parseInt((N+1)%this.m_vertexCount);H=parseInt((z+1)%this.m_vertexCount);O=(0-E[N])/(E[k]-E[N]);E=(0-E[z])/(E[H]-E[z]);N=new V(this.m_vertices[N].x* +(1-O)+this.m_vertices[k].x*O,this.m_vertices[N].y*(1-O)+this.m_vertices[k].y*O);z=new V(this.m_vertices[z].x*(1-E)+this.m_vertices[H].x*E,this.m_vertices[z].y*(1-E)+this.m_vertices[H].y*E);E=0;O=new V;R=this.m_vertices[k];for(k=k;k!=H;){k=(k+1)%this.m_vertexCount;S=k==H?z:this.m_vertices[k];aa=0.5*((R.x-N.x)*(S.y-N.y)-(R.y-N.y)*(S.x-N.x));E+=aa;O.x+=aa*(N.x+R.x+S.x)/3;O.y+=aa*(N.y+R.y+S.y)/3;R=S}O.Multiply(1/E);D.SetV(B.MulX(u,O));return E};A.prototype.GetVertexCount=function(){return this.m_vertexCount}; +A.prototype.GetVertices=function(){return this.m_vertices};A.prototype.GetNormals=function(){return this.m_normals};A.prototype.GetSupport=function(k){for(var z=0,u=this.m_vertices[0].x*k.x+this.m_vertices[0].y*k.y,D=1;Du){z=D;u=H}}return z};A.prototype.GetSupportVertex=function(k){for(var z=0,u=this.m_vertices[0].x*k.x+this.m_vertices[0].y*k.y,D=1;Du){z=D;u=H}}return this.m_vertices[z]};A.prototype.Validate=function(){return false};A.prototype.b2PolygonShape=function(){this.__super.b2Shape.call(this);this.m_type=U.e_polygonShape;this.m_centroid=new V;this.m_vertices=new Vector;this.m_normals=new Vector};A.prototype.Reserve=function(k){if(k===undefined)k=0;for(var z=parseInt(this.m_vertices.length);zd)d=q;if(j>h)h=j}l=(d-N)*(h-Z);if(l<0.95*z){z=l;k.R.col1.x=E;k.R.col1.y=R;k.R.col2.x=S;k.R.col2.y=aa;E=0.5*(N+d);R=0.5*(Z+h);S=k.R;k.center.x=O.x+(S.col1.x*E+S.col2.x*R);k.center.y=O.y+(S.col1.y*E+S.col2.y*R);k.extents.x=0.5*(d-N);k.extents.y=0.5*(h-Z)}}};Box2D.postDefs.push(function(){Box2D.Collision.Shapes.b2PolygonShape.s_mat=new p});U.b2Shape=function(){};U.prototype.Copy=function(){return null};U.prototype.Set=function(k){this.m_radius= +k.m_radius};U.prototype.GetType=function(){return this.m_type};U.prototype.TestPoint=function(){return false};U.prototype.RayCast=function(){return false};U.prototype.ComputeAABB=function(){};U.prototype.ComputeMass=function(){};U.prototype.ComputeSubmergedArea=function(){return 0};U.TestOverlap=function(k,z,u,D){var H=new L;H.proxyA=new W;H.proxyA.Set(k);H.proxyB=new W;H.proxyB.Set(u);H.transformA=z;H.transformB=D;H.useRadii=true;k=new Y;k.count=0;z=new I;M.Distance(z,k,H);return z.distance<10*Number.MIN_VALUE}; +U.prototype.b2Shape=function(){this.m_type=U.e_unknownShape;this.m_radius=F.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 F=Box2D.Common.b2Color,G=Box2D.Common.b2Settings,K=Box2D.Common.Math.b2Math;F.b2Color=function(){this._b=this._g=this._r=0};F.prototype.b2Color=function(y,w,A){if(y===undefined)y=0;if(w===undefined)w=0;if(A===undefined)A=0;this._r=Box2D.parseUInt(255*K.Clamp(y,0,1));this._g=Box2D.parseUInt(255*K.Clamp(w,0,1));this._b=Box2D.parseUInt(255*K.Clamp(A,0,1))};F.prototype.Set=function(y,w,A){if(y===undefined)y=0;if(w===undefined)w=0;if(A===undefined)A=0;this._r=Box2D.parseUInt(255*K.Clamp(y, +0,1));this._g=Box2D.parseUInt(255*K.Clamp(w,0,1));this._b=Box2D.parseUInt(255*K.Clamp(A,0,1))};Object.defineProperty(F.prototype,"r",{enumerable:false,configurable:true,set:function(y){if(y===undefined)y=0;this._r=Box2D.parseUInt(255*K.Clamp(y,0,1))}});Object.defineProperty(F.prototype,"g",{enumerable:false,configurable:true,set:function(y){if(y===undefined)y=0;this._g=Box2D.parseUInt(255*K.Clamp(y,0,1))}});Object.defineProperty(F.prototype,"b",{enumerable:false,configurable:true,set:function(y){if(y=== +undefined)y=0;this._b=Box2D.parseUInt(255*K.Clamp(y,0,1))}});Object.defineProperty(F.prototype,"color",{enumerable:false,configurable:true,get:function(){return this._r<<16|this._g<<8|this._b}});G.b2Settings=function(){};G.b2MixFriction=function(y,w){if(y===undefined)y=0;if(w===undefined)w=0;return Math.sqrt(y*w)};G.b2MixRestitution=function(y,w){if(y===undefined)y=0;if(w===undefined)w=0;return y>w?y:w};G.b2Assert=function(y){if(!y)throw"Assertion Failed";};Box2D.postDefs.push(function(){Box2D.Common.b2Settings.VERSION= +"2.1alpha";Box2D.Common.b2Settings.USHRT_MAX=65535;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;Box2D.Common.b2Settings.b2_polygonRadius=2*G.b2_linearSlop;Box2D.Common.b2Settings.b2_linearSlop=0.0050;Box2D.Common.b2Settings.b2_angularSlop=2/180*G.b2_pi;Box2D.Common.b2Settings.b2_toiSlop=8*G.b2_linearSlop;Box2D.Common.b2Settings.b2_maxTOIContactsPerIsland=32;Box2D.Common.b2Settings.b2_maxTOIJointsPerIsland= +32;Box2D.Common.b2Settings.b2_velocityThreshold=1;Box2D.Common.b2Settings.b2_maxLinearCorrection=0.2;Box2D.Common.b2Settings.b2_maxAngularCorrection=8/180*G.b2_pi;Box2D.Common.b2Settings.b2_maxTranslation=2;Box2D.Common.b2Settings.b2_maxTranslationSquared=G.b2_maxTranslation*G.b2_maxTranslation;Box2D.Common.b2Settings.b2_maxRotation=0.5*G.b2_pi;Box2D.Common.b2Settings.b2_maxRotationSquared=G.b2_maxRotation*G.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/180*G.b2_pi})})(); +(function(){var F=Box2D.Common.Math.b2Mat22,G=Box2D.Common.Math.b2Mat33,K=Box2D.Common.Math.b2Math,y=Box2D.Common.Math.b2Sweep,w=Box2D.Common.Math.b2Transform,A=Box2D.Common.Math.b2Vec2,U=Box2D.Common.Math.b2Vec3;F.b2Mat22=function(){this.col1=new A;this.col2=new A};F.prototype.b2Mat22=function(){this.SetIdentity()};F.FromAngle=function(p){if(p===undefined)p=0;var B=new F;B.Set(p);return B};F.FromVV=function(p,B){var Q=new F;Q.SetVV(p,B);return Q};F.prototype.Set=function(p){if(p===undefined)p=0; +var B=Math.cos(p);p=Math.sin(p);this.col1.x=B;this.col2.x=-p;this.col1.y=p;this.col2.y=B};F.prototype.SetVV=function(p,B){this.col1.SetV(p);this.col2.SetV(B)};F.prototype.Copy=function(){var p=new F;p.SetM(this);return p};F.prototype.SetM=function(p){this.col1.SetV(p.col1);this.col2.SetV(p.col2)};F.prototype.AddM=function(p){this.col1.x+=p.col1.x;this.col1.y+=p.col1.y;this.col2.x+=p.col2.x;this.col2.y+=p.col2.y};F.prototype.SetIdentity=function(){this.col1.x=1;this.col2.x=0;this.col1.y=0;this.col2.y= +1};F.prototype.SetZero=function(){this.col1.x=0;this.col2.x=0;this.col1.y=0;this.col2.y=0};F.prototype.GetAngle=function(){return Math.atan2(this.col1.y,this.col1.x)};F.prototype.GetInverse=function(p){var B=this.col1.x,Q=this.col2.x,V=this.col1.y,M=this.col2.y,L=B*M-Q*V;if(L!=0)L=1/L;p.col1.x=L*M;p.col2.x=-L*Q;p.col1.y=-L*V;p.col2.y=L*B;return p};F.prototype.Solve=function(p,B,Q){if(B===undefined)B=0;if(Q===undefined)Q=0;var V=this.col1.x,M=this.col2.x,L=this.col1.y,I=this.col2.y,W=V*I-M*L;if(W!= +0)W=1/W;p.x=W*(I*B-M*Q);p.y=W*(V*Q-L*B);return p};F.prototype.Abs=function(){this.col1.Abs();this.col2.Abs()};G.b2Mat33=function(){this.col1=new U;this.col2=new U;this.col3=new U};G.prototype.b2Mat33=function(p,B,Q){if(p===undefined)p=null;if(B===undefined)B=null;if(Q===undefined)Q=null;if(!p&&!B&&!Q){this.col1.SetZero();this.col2.SetZero();this.col3.SetZero()}else{this.col1.SetV(p);this.col2.SetV(B);this.col3.SetV(Q)}};G.prototype.SetVVV=function(p,B,Q){this.col1.SetV(p);this.col2.SetV(B);this.col3.SetV(Q)}; +G.prototype.Copy=function(){return new G(this.col1,this.col2,this.col3)};G.prototype.SetM=function(p){this.col1.SetV(p.col1);this.col2.SetV(p.col2);this.col3.SetV(p.col3)};G.prototype.AddM=function(p){this.col1.x+=p.col1.x;this.col1.y+=p.col1.y;this.col1.z+=p.col1.z;this.col2.x+=p.col2.x;this.col2.y+=p.col2.y;this.col2.z+=p.col2.z;this.col3.x+=p.col3.x;this.col3.y+=p.col3.y;this.col3.z+=p.col3.z};G.prototype.SetIdentity=function(){this.col1.x=1;this.col2.x=0;this.col3.x=0;this.col1.y=0;this.col2.y= +1;this.col3.y=0;this.col1.z=0;this.col2.z=0;this.col3.z=1};G.prototype.SetZero=function(){this.col1.x=0;this.col2.x=0;this.col3.x=0;this.col1.y=0;this.col2.y=0;this.col3.y=0;this.col1.z=0;this.col2.z=0;this.col3.z=0};G.prototype.Solve22=function(p,B,Q){if(B===undefined)B=0;if(Q===undefined)Q=0;var V=this.col1.x,M=this.col2.x,L=this.col1.y,I=this.col2.y,W=V*I-M*L;if(W!=0)W=1/W;p.x=W*(I*B-M*Q);p.y=W*(V*Q-L*B);return p};G.prototype.Solve33=function(p,B,Q,V){if(B===undefined)B=0;if(Q===undefined)Q=0; +if(V===undefined)V=0;var M=this.col1.x,L=this.col1.y,I=this.col1.z,W=this.col2.x,Y=this.col2.y,k=this.col2.z,z=this.col3.x,u=this.col3.y,D=this.col3.z,H=M*(Y*D-k*u)+L*(k*z-W*D)+I*(W*u-Y*z);if(H!=0)H=1/H;p.x=H*(B*(Y*D-k*u)+Q*(k*z-W*D)+V*(W*u-Y*z));p.y=H*(M*(Q*D-V*u)+L*(V*z-B*D)+I*(B*u-Q*z));p.z=H*(M*(Y*V-k*Q)+L*(k*B-W*V)+I*(W*Q-Y*B));return p};K.b2Math=function(){};K.IsValid=function(p){if(p===undefined)p=0;return isFinite(p)};K.Dot=function(p,B){return p.x*B.x+p.y*B.y};K.CrossVV=function(p,B){return p.x* +B.y-p.y*B.x};K.CrossVF=function(p,B){if(B===undefined)B=0;return new A(B*p.y,-B*p.x)};K.CrossFV=function(p,B){if(p===undefined)p=0;return new A(-p*B.y,p*B.x)};K.MulMV=function(p,B){return new A(p.col1.x*B.x+p.col2.x*B.y,p.col1.y*B.x+p.col2.y*B.y)};K.MulTMV=function(p,B){return new A(K.Dot(B,p.col1),K.Dot(B,p.col2))};K.MulX=function(p,B){var Q=K.MulMV(p.R,B);Q.x+=p.position.x;Q.y+=p.position.y;return Q};K.MulXT=function(p,B){var Q=K.SubtractVV(B,p.position),V=Q.x*p.R.col1.x+Q.y*p.R.col1.y;Q.y=Q.x* +p.R.col2.x+Q.y*p.R.col2.y;Q.x=V;return Q};K.AddVV=function(p,B){return new A(p.x+B.x,p.y+B.y)};K.SubtractVV=function(p,B){return new A(p.x-B.x,p.y-B.y)};K.Distance=function(p,B){var Q=p.x-B.x,V=p.y-B.y;return Math.sqrt(Q*Q+V*V)};K.DistanceSquared=function(p,B){var Q=p.x-B.x,V=p.y-B.y;return Q*Q+V*V};K.MulFV=function(p,B){if(p===undefined)p=0;return new A(p*B.x,p*B.y)};K.AddMM=function(p,B){return F.FromVV(K.AddVV(p.col1,B.col1),K.AddVV(p.col2,B.col2))};K.MulMM=function(p,B){return F.FromVV(K.MulMV(p, +B.col1),K.MulMV(p,B.col2))};K.MulTMM=function(p,B){var Q=new A(K.Dot(p.col1,B.col1),K.Dot(p.col2,B.col1)),V=new A(K.Dot(p.col1,B.col2),K.Dot(p.col2,B.col2));return F.FromVV(Q,V)};K.Abs=function(p){if(p===undefined)p=0;return p>0?p:-p};K.AbsV=function(p){return new A(K.Abs(p.x),K.Abs(p.y))};K.AbsM=function(p){return F.FromVV(K.AbsV(p.col1),K.AbsV(p.col2))};K.Min=function(p,B){if(p===undefined)p=0;if(B===undefined)B=0;return pB?p:B};K.MaxV=function(p,B){return new A(K.Max(p.x,B.x),K.Max(p.y,B.y))};K.Clamp=function(p,B,Q){if(p===undefined)p=0;if(B===undefined)B=0;if(Q===undefined)Q=0;return pQ?Q:p};K.ClampV=function(p,B,Q){return K.MaxV(B,K.MinV(p,Q))};K.Swap=function(p,B){var Q=p[0];p[0]=B[0];B[0]=Q};K.Random=function(){return Math.random()*2-1};K.RandomRange=function(p,B){if(p===undefined)p=0;if(B===undefined)B=0;var Q=Math.random();return Q= +(B-p)*Q+p};K.NextPowerOfTwo=function(p){if(p===undefined)p=0;p|=p>>1&2147483647;p|=p>>2&1073741823;p|=p>>4&268435455;p|=p>>8&16777215;p|=p>>16&65535;return p+1};K.IsPowerOfTwo=function(p){if(p===undefined)p=0;return p>0&&(p&p-1)==0};Box2D.postDefs.push(function(){Box2D.Common.Math.b2Math.b2Vec2_zero=new A(0,0);Box2D.Common.Math.b2Math.b2Mat22_identity=F.FromVV(new A(1,0),new A(0,1));Box2D.Common.Math.b2Math.b2Transform_identity=new w(K.b2Vec2_zero,K.b2Mat22_identity)});y.b2Sweep=function(){this.localCenter= +new A;this.c0=new A;this.c=new A};y.prototype.Set=function(p){this.localCenter.SetV(p.localCenter);this.c0.SetV(p.c0);this.c.SetV(p.c);this.a0=p.a0;this.a=p.a;this.t0=p.t0};y.prototype.Copy=function(){var p=new y;p.localCenter.SetV(this.localCenter);p.c0.SetV(this.c0);p.c.SetV(this.c);p.a0=this.a0;p.a=this.a;p.t0=this.t0;return p};y.prototype.GetTransform=function(p,B){if(B===undefined)B=0;p.position.x=(1-B)*this.c0.x+B*this.c.x;p.position.y=(1-B)*this.c0.y+B*this.c.y;p.R.Set((1-B)*this.a0+B*this.a); +var Q=p.R;p.position.x-=Q.col1.x*this.localCenter.x+Q.col2.x*this.localCenter.y;p.position.y-=Q.col1.y*this.localCenter.x+Q.col2.y*this.localCenter.y};y.prototype.Advance=function(p){if(p===undefined)p=0;if(this.t0Number.MIN_VALUE){var B=(p-this.t0)/(1-this.t0);this.c0.x=(1-B)*this.c0.x+B*this.c.x;this.c0.y=(1-B)*this.c0.y+B*this.c.y;this.a0=(1-B)*this.a0+B*this.a;this.t0=p}};w.b2Transform=function(){this.position=new A;this.R=new F};w.prototype.b2Transform=function(p,B){if(p===undefined)p= +null;if(B===undefined)B=null;if(p){this.position.SetV(p);this.R.SetM(B)}};w.prototype.Initialize=function(p,B){this.position.SetV(p);this.R.SetM(B)};w.prototype.SetIdentity=function(){this.position.SetZero();this.R.SetIdentity()};w.prototype.Set=function(p){this.position.SetV(p.position);this.R.SetM(p.R)};w.prototype.GetAngle=function(){return Math.atan2(this.R.col1.y,this.R.col1.x)};A.b2Vec2=function(){};A.prototype.b2Vec2=function(p,B){if(p===undefined)p=0;if(B===undefined)B=0;this.x=p;this.y=B}; +A.prototype.SetZero=function(){this.y=this.x=0};A.prototype.Set=function(p,B){if(p===undefined)p=0;if(B===undefined)B=0;this.x=p;this.y=B};A.prototype.SetV=function(p){this.x=p.x;this.y=p.y};A.prototype.GetNegative=function(){return new A(-this.x,-this.y)};A.prototype.NegativeSelf=function(){this.x=-this.x;this.y=-this.y};A.Make=function(p,B){if(p===undefined)p=0;if(B===undefined)B=0;return new A(p,B)};A.prototype.Copy=function(){return new A(this.x,this.y)};A.prototype.Add=function(p){this.x+=p.x; +this.y+=p.y};A.prototype.Subtract=function(p){this.x-=p.x;this.y-=p.y};A.prototype.Multiply=function(p){if(p===undefined)p=0;this.x*=p;this.y*=p};A.prototype.MulM=function(p){var B=this.x;this.x=p.col1.x*B+p.col2.x*this.y;this.y=p.col1.y*B+p.col2.y*this.y};A.prototype.MulTM=function(p){var B=K.Dot(this,p.col1);this.y=K.Dot(this,p.col2);this.x=B};A.prototype.CrossVF=function(p){if(p===undefined)p=0;var B=this.x;this.x=p*this.y;this.y=-p*B};A.prototype.CrossFV=function(p){if(p===undefined)p=0;var B= +this.x;this.x=-p*this.y;this.y=p*B};A.prototype.MinV=function(p){this.x=this.xp.x?this.x:p.x;this.y=this.y>p.y?this.y:p.y};A.prototype.Abs=function(){if(this.x<0)this.x=-this.x;if(this.y<0)this.y=-this.y};A.prototype.Length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};A.prototype.LengthSquared=function(){return this.x*this.x+this.y*this.y};A.prototype.Normalize=function(){var p=Math.sqrt(this.x*this.x+ +this.y*this.y);if(p0;a.SetNextEdge(c,g,e,f);c.SetPrevEdge(a,g,e,f);return b};k.prototype.CreateFixture=function(a){if(this.m_world.IsLocked()==true)return null;var c=new S;c.Create(this,this.m_xf,a);this.m_flags&k.e_activeFlag&&c.CreateProxy(this.m_world.m_contactManager.m_broadPhase,this.m_xf);c.m_next=this.m_fixtureList;this.m_fixtureList=c;++this.m_fixtureCount;c.m_body=this;c.m_density>0&&this.ResetMassData();this.m_world.m_flags|= +h.e_newFixture;return c};k.prototype.CreateFixture2=function(a,c){if(c===undefined)c=0;var g=new aa;g.shape=a;g.density=c;return this.CreateFixture(g)};k.prototype.DestroyFixture=function(a){if(this.m_world.IsLocked()!=true){for(var c=this.m_fixtureList,g=null;c!=null;){if(c==a){if(g)g.m_next=a.m_next;else this.m_fixtureList=a.m_next;break}g=c;c=c.m_next}for(c=this.m_contactList;c;){g=c.contact;c=c.next;var b=g.GetFixtureA(),e=g.GetFixtureB();if(a==b||a==e)this.m_world.m_contactManager.Destroy(g)}this.m_flags& +k.e_activeFlag&&a.DestroyProxy(this.m_world.m_contactManager.m_broadPhase);a.Destroy();a.m_body=null;a.m_next=null;--this.m_fixtureCount;this.ResetMassData()}};k.prototype.SetPositionAndAngle=function(a,c){if(c===undefined)c=0;var g;if(this.m_world.IsLocked()!=true){this.m_xf.R.Set(c);this.m_xf.position.SetV(a);g=this.m_xf.R;var b=this.m_sweep.localCenter;this.m_sweep.c.x=g.col1.x*b.x+g.col2.x*b.y;this.m_sweep.c.y=g.col1.y*b.x+g.col2.y*b.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=c;b=this.m_world.m_contactManager.m_broadPhase;for(g=this.m_fixtureList;g;g=g.m_next)g.Synchronize(b,this.m_xf,this.m_xf);this.m_world.m_contactManager.FindNewContacts()}};k.prototype.SetTransform=function(a){this.SetPositionAndAngle(a.position,a.GetAngle())};k.prototype.GetTransform=function(){return this.m_xf};k.prototype.GetPosition=function(){return this.m_xf.position};k.prototype.SetPosition=function(a){this.SetPositionAndAngle(a, +this.GetAngle())};k.prototype.GetAngle=function(){return this.m_sweep.a};k.prototype.SetAngle=function(a){if(a===undefined)a=0;this.SetPositionAndAngle(this.GetPosition(),a)};k.prototype.GetWorldCenter=function(){return this.m_sweep.c};k.prototype.GetLocalCenter=function(){return this.m_sweep.localCenter};k.prototype.SetLinearVelocity=function(a){this.m_type!=k.b2_staticBody&&this.m_linearVelocity.SetV(a)};k.prototype.GetLinearVelocity=function(){return this.m_linearVelocity};k.prototype.SetAngularVelocity= +function(a){if(a===undefined)a=0;if(this.m_type!=k.b2_staticBody)this.m_angularVelocity=a};k.prototype.GetAngularVelocity=function(){return this.m_angularVelocity};k.prototype.GetDefinition=function(){var a=new z;a.type=this.GetType();a.allowSleep=(this.m_flags&k.e_allowSleepFlag)==k.e_allowSleepFlag;a.angle=this.GetAngle();a.angularDamping=this.m_angularDamping;a.angularVelocity=this.m_angularVelocity;a.fixedRotation=(this.m_flags&k.e_fixedRotationFlag)==k.e_fixedRotationFlag;a.bullet=(this.m_flags& +k.e_bulletFlag)==k.e_bulletFlag;a.awake=(this.m_flags&k.e_awakeFlag)==k.e_awakeFlag;a.linearDamping=this.m_linearDamping;a.linearVelocity.SetV(this.GetLinearVelocity());a.position=this.GetPosition();a.userData=this.GetUserData();return a};k.prototype.ApplyForce=function(a,c){if(this.m_type==k.b2_dynamicBody){this.IsAwake()==false&&this.SetAwake(true);this.m_force.x+=a.x;this.m_force.y+=a.y;this.m_torque+=(c.x-this.m_sweep.c.x)*a.y-(c.y-this.m_sweep.c.y)*a.x}};k.prototype.ApplyTorque=function(a){if(a=== +undefined)a=0;if(this.m_type==k.b2_dynamicBody){this.IsAwake()==false&&this.SetAwake(true);this.m_torque+=a}};k.prototype.ApplyImpulse=function(a,c){if(this.m_type==k.b2_dynamicBody){this.IsAwake()==false&&this.SetAwake(true);this.m_linearVelocity.x+=this.m_invMass*a.x;this.m_linearVelocity.y+=this.m_invMass*a.y;this.m_angularVelocity+=this.m_invI*((c.x-this.m_sweep.c.x)*a.y-(c.y-this.m_sweep.c.y)*a.x)}};k.prototype.Split=function(a){for(var c=this.GetLinearVelocity().Copy(),g=this.GetAngularVelocity(), +b=this.GetWorldCenter(),e=this.m_world.CreateBody(this.GetDefinition()),f,m=this.m_fixtureList;m;)if(a(m)){var r=m.m_next;if(f)f.m_next=r;else this.m_fixtureList=r;this.m_fixtureCount--;m.m_next=e.m_fixtureList;e.m_fixtureList=m;e.m_fixtureCount++;m.m_body=e;m=r}else{f=m;m=m.m_next}this.ResetMassData();e.ResetMassData();f=this.GetWorldCenter();a=e.GetWorldCenter();f=F.AddVV(c,F.CrossFV(g,F.SubtractVV(f,b)));c=F.AddVV(c,F.CrossFV(g,F.SubtractVV(a,b)));this.SetLinearVelocity(f);e.SetLinearVelocity(c); +this.SetAngularVelocity(g);e.SetAngularVelocity(g);this.SynchronizeFixtures();e.SynchronizeFixtures();return e};k.prototype.Merge=function(a){var c;for(c=a.m_fixtureList;c;){var g=c.m_next;a.m_fixtureCount--;c.m_next=this.m_fixtureList;this.m_fixtureList=c;this.m_fixtureCount++;c.m_body=e;c=g}b.m_fixtureCount=0;var b=this,e=a;b.GetWorldCenter();e.GetWorldCenter();b.GetLinearVelocity().Copy();e.GetLinearVelocity().Copy();b.GetAngularVelocity();e.GetAngularVelocity();b.ResetMassData();this.SynchronizeFixtures()}; +k.prototype.GetMass=function(){return this.m_mass};k.prototype.GetInertia=function(){return this.m_I};k.prototype.GetMassData=function(a){a.mass=this.m_mass;a.I=this.m_I;a.center.SetV(this.m_sweep.localCenter)};k.prototype.SetMassData=function(a){A.b2Assert(this.m_world.IsLocked()==false);if(this.m_world.IsLocked()!=true)if(this.m_type==k.b2_dynamicBody){this.m_invI=this.m_I=this.m_invMass=0;this.m_mass=a.mass;if(this.m_mass<=0)this.m_mass=1;this.m_invMass=1/this.m_mass;if(a.I>0&&(this.m_flags&k.e_fixedRotationFlag)== +0){this.m_I=a.I-this.m_mass*(a.center.x*a.center.x+a.center.y*a.center.y);this.m_invI=1/this.m_I}var c=this.m_sweep.c.Copy();this.m_sweep.localCenter.SetV(a.center);this.m_sweep.c0.SetV(F.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-c.y);this.m_linearVelocity.y+=this.m_angularVelocity*+(this.m_sweep.c.x-c.x)}};k.prototype.ResetMassData=function(){this.m_invI=this.m_I=this.m_invMass=this.m_mass=0;this.m_sweep.localCenter.SetZero(); +if(!(this.m_type==k.b2_staticBody||this.m_type==k.b2_kinematicBody)){for(var a=y.Make(0,0),c=this.m_fixtureList;c;c=c.m_next)if(c.m_density!=0){var g=c.GetMassData();this.m_mass+=g.mass;a.x+=g.center.x*g.mass;a.y+=g.center.y*g.mass;this.m_I+=g.I}if(this.m_mass>0){this.m_invMass=1/this.m_mass;a.x*=this.m_invMass;a.y*=this.m_invMass}else this.m_invMass=this.m_mass=1;if(this.m_I>0&&(this.m_flags&k.e_fixedRotationFlag)==0){this.m_I-=this.m_mass*(a.x*a.x+a.y*a.y);this.m_I*=this.m_inertiaScale;A.b2Assert(this.m_I> +0);this.m_invI=1/this.m_I}else this.m_invI=this.m_I=0;c=this.m_sweep.c.Copy();this.m_sweep.localCenter.SetV(a);this.m_sweep.c0.SetV(F.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-c.y);this.m_linearVelocity.y+=this.m_angularVelocity*+(this.m_sweep.c.x-c.x)}};k.prototype.GetWorldPoint=function(a){var c=this.m_xf.R;a=new y(c.col1.x*a.x+c.col2.x*a.y,c.col1.y*a.x+c.col2.y*a.y);a.x+=this.m_xf.position.x; +a.y+=this.m_xf.position.y;return a};k.prototype.GetWorldVector=function(a){return F.MulMV(this.m_xf.R,a)};k.prototype.GetLocalPoint=function(a){return F.MulXT(this.m_xf,a)};k.prototype.GetLocalVector=function(a){return F.MulTMV(this.m_xf.R,a)};k.prototype.GetLinearVelocityFromWorldPoint=function(a){return new y(this.m_linearVelocity.x-this.m_angularVelocity*(a.y-this.m_sweep.c.y),this.m_linearVelocity.y+this.m_angularVelocity*(a.x-this.m_sweep.c.x))};k.prototype.GetLinearVelocityFromLocalPoint=function(a){var c= +this.m_xf.R;a=new y(c.col1.x*a.x+c.col2.x*a.y,c.col1.y*a.x+c.col2.y*a.y);a.x+=this.m_xf.position.x;a.y+=this.m_xf.position.y;return new y(this.m_linearVelocity.x-this.m_angularVelocity*(a.y-this.m_sweep.c.y),this.m_linearVelocity.y+this.m_angularVelocity*(a.x-this.m_sweep.c.x))};k.prototype.GetLinearDamping=function(){return this.m_linearDamping};k.prototype.SetLinearDamping=function(a){if(a===undefined)a=0;this.m_linearDamping=a};k.prototype.GetAngularDamping=function(){return this.m_angularDamping}; +k.prototype.SetAngularDamping=function(a){if(a===undefined)a=0;this.m_angularDamping=a};k.prototype.SetType=function(a){if(a===undefined)a=0;if(this.m_type!=a){this.m_type=a;this.ResetMassData();if(this.m_type==k.b2_staticBody){this.m_linearVelocity.SetZero();this.m_angularVelocity=0}this.SetAwake(true);this.m_force.SetZero();this.m_torque=0;for(a=this.m_contactList;a;a=a.next)a.contact.FlagForFiltering()}};k.prototype.GetType=function(){return this.m_type};k.prototype.SetBullet=function(a){if(a)this.m_flags|= +k.e_bulletFlag;else this.m_flags&=~k.e_bulletFlag};k.prototype.IsBullet=function(){return(this.m_flags&k.e_bulletFlag)==k.e_bulletFlag};k.prototype.SetSleepingAllowed=function(a){if(a)this.m_flags|=k.e_allowSleepFlag;else{this.m_flags&=~k.e_allowSleepFlag;this.SetAwake(true)}};k.prototype.SetAwake=function(a){if(a){this.m_flags|=k.e_awakeFlag;this.m_sleepTime=0}else{this.m_flags&=~k.e_awakeFlag;this.m_sleepTime=0;this.m_linearVelocity.SetZero();this.m_angularVelocity=0;this.m_force.SetZero();this.m_torque= +0}};k.prototype.IsAwake=function(){return(this.m_flags&k.e_awakeFlag)==k.e_awakeFlag};k.prototype.SetFixedRotation=function(a){if(a)this.m_flags|=k.e_fixedRotationFlag;else this.m_flags&=~k.e_fixedRotationFlag;this.ResetMassData()};k.prototype.IsFixedRotation=function(){return(this.m_flags&k.e_fixedRotationFlag)==k.e_fixedRotationFlag};k.prototype.SetActive=function(a){if(a!=this.IsActive()){var c;if(a){this.m_flags|=k.e_activeFlag;a=this.m_world.m_contactManager.m_broadPhase;for(c=this.m_fixtureList;c;c= +c.m_next)c.CreateProxy(a,this.m_xf)}else{this.m_flags&=~k.e_activeFlag;a=this.m_world.m_contactManager.m_broadPhase;for(c=this.m_fixtureList;c;c=c.m_next)c.DestroyProxy(a);for(a=this.m_contactList;a;){c=a;a=a.next;this.m_world.m_contactManager.Destroy(c.contact)}this.m_contactList=null}}};k.prototype.IsActive=function(){return(this.m_flags&k.e_activeFlag)==k.e_activeFlag};k.prototype.IsSleepingAllowed=function(){return(this.m_flags&k.e_allowSleepFlag)==k.e_allowSleepFlag};k.prototype.GetFixtureList= +function(){return this.m_fixtureList};k.prototype.GetJointList=function(){return this.m_jointList};k.prototype.GetControllerList=function(){return this.m_controllerList};k.prototype.GetContactList=function(){return this.m_contactList};k.prototype.GetNext=function(){return this.m_next};k.prototype.GetUserData=function(){return this.m_userData};k.prototype.SetUserData=function(a){this.m_userData=a};k.prototype.GetWorld=function(){return this.m_world};k.prototype.b2Body=function(a,c){this.m_flags=0; +if(a.bullet)this.m_flags|=k.e_bulletFlag;if(a.fixedRotation)this.m_flags|=k.e_fixedRotationFlag;if(a.allowSleep)this.m_flags|=k.e_allowSleepFlag;if(a.awake)this.m_flags|=k.e_awakeFlag;if(a.active)this.m_flags|=k.e_activeFlag;this.m_world=c;this.m_xf.position.SetV(a.position);this.m_xf.R.Set(a.angle);this.m_sweep.localCenter.SetZero();this.m_sweep.t0=1;this.m_sweep.a0=this.m_sweep.a=a.angle;var g=this.m_xf.R,b=this.m_sweep.localCenter;this.m_sweep.c.x=g.col1.x*b.x+g.col2.x*b.y;this.m_sweep.c.y=g.col1.y* +b.x+g.col2.y*b.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_contactList=this.m_controllerList=this.m_jointList=null;this.m_controllerCount=0;this.m_next=this.m_prev=null;this.m_linearVelocity.SetV(a.linearVelocity);this.m_angularVelocity=a.angularVelocity;this.m_linearDamping=a.linearDamping;this.m_angularDamping=a.angularDamping;this.m_force.Set(0,0);this.m_sleepTime=this.m_torque=0;this.m_type=a.type;if(this.m_type== +k.b2_dynamicBody)this.m_invMass=this.m_mass=1;else this.m_invMass=this.m_mass=0;this.m_invI=this.m_I=0;this.m_inertiaScale=a.inertiaScale;this.m_userData=a.userData;this.m_fixtureList=null;this.m_fixtureCount=0};k.prototype.SynchronizeFixtures=function(){var a=k.s_xf1;a.R.Set(this.m_sweep.a0);var c=a.R,g=this.m_sweep.localCenter;a.position.x=this.m_sweep.c0.x-(c.col1.x*g.x+c.col2.x*g.y);a.position.y=this.m_sweep.c0.y-(c.col1.y*g.x+c.col2.y*g.y);g=this.m_world.m_contactManager.m_broadPhase;for(c=this.m_fixtureList;c;c= +c.m_next)c.Synchronize(g,a,this.m_xf)};k.prototype.SynchronizeTransform=function(){this.m_xf.R.Set(this.m_sweep.a);var a=this.m_xf.R,c=this.m_sweep.localCenter;this.m_xf.position.x=this.m_sweep.c.x-(a.col1.x*c.x+a.col2.x*c.y);this.m_xf.position.y=this.m_sweep.c.y-(a.col1.y*c.x+a.col2.y*c.y)};k.prototype.ShouldCollide=function(a){if(this.m_type!=k.b2_dynamicBody&&a.m_type!=k.b2_dynamicBody)return false;for(var c=this.m_jointList;c;c=c.next)if(c.other==a)if(c.joint.m_collideConnected==false)return false; +return true};k.prototype.Advance=function(a){if(a===undefined)a=0;this.m_sweep.Advance(a);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 K;Box2D.Dynamics.b2Body.e_islandFlag=1;Box2D.Dynamics.b2Body.e_awakeFlag=2;Box2D.Dynamics.b2Body.e_allowSleepFlag=4;Box2D.Dynamics.b2Body.e_bulletFlag=8;Box2D.Dynamics.b2Body.e_fixedRotationFlag=16;Box2D.Dynamics.b2Body.e_activeFlag=32;Box2D.Dynamics.b2Body.b2_staticBody= +0;Box2D.Dynamics.b2Body.b2_kinematicBody=1;Box2D.Dynamics.b2Body.b2_dynamicBody=2});z.b2BodyDef=function(){this.position=new y;this.linearVelocity=new y};z.prototype.b2BodyDef=function(){this.userData=null;this.position.Set(0,0);this.angle=0;this.linearVelocity.Set(0,0);this.angularDamping=this.linearDamping=this.angularVelocity=0;this.awake=this.allowSleep=true;this.bullet=this.fixedRotation=false;this.type=k.b2_staticBody;this.active=true;this.inertiaScale=1};u.b2ContactFilter=function(){};u.prototype.ShouldCollide= +function(a,c){var g=a.GetFilterData(),b=c.GetFilterData();if(g.groupIndex==b.groupIndex&&g.groupIndex!=0)return g.groupIndex>0;return(g.maskBits&b.categoryBits)!=0&&(g.categoryBits&b.maskBits)!=0};u.prototype.RayCollide=function(a,c){if(!a)return true;return this.ShouldCollide(a instanceof S?a:null,c)};Box2D.postDefs.push(function(){Box2D.Dynamics.b2ContactFilter.b2_defaultFilter=new u});D.b2ContactImpulse=function(){this.normalImpulses=new Vector_a2j_Number(A.b2_maxManifoldPoints);this.tangentImpulses= +new Vector_a2j_Number(A.b2_maxManifoldPoints)};H.b2ContactListener=function(){};H.prototype.BeginContact=function(){};H.prototype.EndContact=function(){};H.prototype.PreSolve=function(){};H.prototype.PostSolve=function(){};Box2D.postDefs.push(function(){Box2D.Dynamics.b2ContactListener.b2_defaultListener=new H});O.b2ContactManager=function(){};O.prototype.b2ContactManager=function(){this.m_world=null;this.m_contactCount=0;this.m_contactFilter=u.b2_defaultFilter;this.m_contactListener=H.b2_defaultListener; +this.m_contactFactory=new j(this.m_allocator);this.m_broadPhase=new B};O.prototype.AddPair=function(a,c){var g=a instanceof S?a:null,b=c instanceof S?c:null,e=g.GetBody(),f=b.GetBody();if(e!=f){for(var m=f.GetContactList();m;){if(m.other==e){var r=m.contact.GetFixtureA(),s=m.contact.GetFixtureB();if(r==g&&s==b)return;if(r==b&&s==g)return}m=m.next}if(f.ShouldCollide(e)!=false)if(this.m_contactFilter.ShouldCollide(g,b)!=false){m=this.m_contactFactory.Create(g,b);g=m.GetFixtureA();b=m.GetFixtureB(); +e=g.m_body;f=b.m_body;m.m_prev=null;m.m_next=this.m_world.m_contactList;if(this.m_world.m_contactList!=null)this.m_world.m_contactList.m_prev=m;this.m_world.m_contactList=m;m.m_nodeA.contact=m;m.m_nodeA.other=f;m.m_nodeA.prev=null;m.m_nodeA.next=e.m_contactList;if(e.m_contactList!=null)e.m_contactList.prev=m.m_nodeA;e.m_contactList=m.m_nodeA;m.m_nodeB.contact=m;m.m_nodeB.other=e;m.m_nodeB.prev=null;m.m_nodeB.next=f.m_contactList;if(f.m_contactList!=null)f.m_contactList.prev=m.m_nodeB;f.m_contactList= +m.m_nodeB;++this.m_world.m_contactCount}}};O.prototype.FindNewContacts=function(){this.m_broadPhase.UpdatePairs(Box2D.generateCallback(this,this.AddPair))};O.prototype.Destroy=function(a){var c=a.GetFixtureA(),g=a.GetFixtureB();c=c.GetBody();g=g.GetBody();a.IsTouching()&&this.m_contactListener.EndContact(a);if(a.m_prev)a.m_prev.m_next=a.m_next;if(a.m_next)a.m_next.m_prev=a.m_prev;if(a==this.m_world.m_contactList)this.m_world.m_contactList=a.m_next;if(a.m_nodeA.prev)a.m_nodeA.prev.next=a.m_nodeA.next; +if(a.m_nodeA.next)a.m_nodeA.next.prev=a.m_nodeA.prev;if(a.m_nodeA==c.m_contactList)c.m_contactList=a.m_nodeA.next;if(a.m_nodeB.prev)a.m_nodeB.prev.next=a.m_nodeB.next;if(a.m_nodeB.next)a.m_nodeB.next.prev=a.m_nodeB.prev;if(a.m_nodeB==g.m_contactList)g.m_contactList=a.m_nodeB.next;this.m_contactFactory.Destroy(a);--this.m_contactCount};O.prototype.Collide=function(){for(var a=this.m_world.m_contactList;a;){var c=a.GetFixtureA(),g=a.GetFixtureB(),b=c.GetBody(),e=g.GetBody();if(b.IsAwake()==false&&e.IsAwake()== +false)a=a.GetNext();else{if(a.m_flags&l.e_filterFlag){if(e.ShouldCollide(b)==false){c=a;a=c.GetNext();this.Destroy(c);continue}if(this.m_contactFilter.ShouldCollide(c,g)==false){c=a;a=c.GetNext();this.Destroy(c);continue}a.m_flags&=~l.e_filterFlag}if(this.m_broadPhase.TestOverlap(c.m_proxy,g.m_proxy)==false){c=a;a=c.GetNext();this.Destroy(c)}else{a.Update(this.m_contactListener);a=a.GetNext()}}}};Box2D.postDefs.push(function(){Box2D.Dynamics.b2ContactManager.s_evalCP=new p});E.b2DebugDraw=function(){}; +E.prototype.b2DebugDraw=function(){};E.prototype.SetFlags=function(){};E.prototype.GetFlags=function(){};E.prototype.AppendFlags=function(){};E.prototype.ClearFlags=function(){};E.prototype.SetSprite=function(){};E.prototype.GetSprite=function(){};E.prototype.SetDrawScale=function(){};E.prototype.GetDrawScale=function(){};E.prototype.SetLineThickness=function(){};E.prototype.GetLineThickness=function(){};E.prototype.SetAlpha=function(){};E.prototype.GetAlpha=function(){};E.prototype.SetFillAlpha= +function(){};E.prototype.GetFillAlpha=function(){};E.prototype.SetXFormScale=function(){};E.prototype.GetXFormScale=function(){};E.prototype.DrawPolygon=function(){};E.prototype.DrawSolidPolygon=function(){};E.prototype.DrawCircle=function(){};E.prototype.DrawSolidCircle=function(){};E.prototype.DrawSegment=function(){};E.prototype.DrawTransform=function(){};Box2D.postDefs.push(function(){Box2D.Dynamics.b2DebugDraw.e_shapeBit=1;Box2D.Dynamics.b2DebugDraw.e_jointBit=2;Box2D.Dynamics.b2DebugDraw.e_aabbBit= +4;Box2D.Dynamics.b2DebugDraw.e_pairBit=8;Box2D.Dynamics.b2DebugDraw.e_centerOfMassBit=16;Box2D.Dynamics.b2DebugDraw.e_controllerBit=32});R.b2DestructionListener=function(){};R.prototype.SayGoodbyeJoint=function(){};R.prototype.SayGoodbyeFixture=function(){};N.b2FilterData=function(){this.categoryBits=1;this.maskBits=65535;this.groupIndex=0};N.prototype.Copy=function(){var a=new N;a.categoryBits=this.categoryBits;a.maskBits=this.maskBits;a.groupIndex=this.groupIndex;return a};S.b2Fixture=function(){this.m_filter= +new N};S.prototype.GetType=function(){return this.m_shape.GetType()};S.prototype.GetShape=function(){return this.m_shape};S.prototype.SetSensor=function(a){if(this.m_isSensor!=a){this.m_isSensor=a;if(this.m_body!=null)for(a=this.m_body.GetContactList();a;){var c=a.contact,g=c.GetFixtureA(),b=c.GetFixtureB();if(g==this||b==this)c.SetSensor(g.IsSensor()||b.IsSensor());a=a.next}}};S.prototype.IsSensor=function(){return this.m_isSensor};S.prototype.SetFilterData=function(a){this.m_filter=a.Copy();if(!this.m_body)for(a= +this.m_body.GetContactList();a;){var c=a.contact,g=c.GetFixtureA(),b=c.GetFixtureB();if(g==this||b==this)c.FlagForFiltering();a=a.next}};S.prototype.GetFilterData=function(){return this.m_filter.Copy()};S.prototype.GetBody=function(){return this.m_body};S.prototype.GetNext=function(){return this.m_next};S.prototype.GetUserData=function(){return this.m_userData};S.prototype.SetUserData=function(a){this.m_userData=a};S.prototype.TestPoint=function(a){return this.m_shape.TestPoint(this.m_body.GetTransform(), +a)};S.prototype.RayCast=function(a,c){return this.m_shape.RayCast(a,c,this.m_body.GetTransform())};S.prototype.GetMassData=function(a){if(a===undefined)a=null;if(a==null)a=new I;this.m_shape.ComputeMass(a,this.m_density);return a};S.prototype.SetDensity=function(a){if(a===undefined)a=0;this.m_density=a};S.prototype.GetDensity=function(){return this.m_density};S.prototype.GetFriction=function(){return this.m_friction};S.prototype.SetFriction=function(a){if(a===undefined)a=0;this.m_friction=a};S.prototype.GetRestitution= +function(){return this.m_restitution};S.prototype.SetRestitution=function(a){if(a===undefined)a=0;this.m_restitution=a};S.prototype.GetAABB=function(){return this.m_aabb};S.prototype.b2Fixture=function(){this.m_aabb=new U;this.m_shape=this.m_next=this.m_body=this.m_userData=null;this.m_restitution=this.m_friction=this.m_density=0};S.prototype.Create=function(a,c,g){this.m_userData=g.userData;this.m_friction=g.friction;this.m_restitution=g.restitution;this.m_body=a;this.m_next=null;this.m_filter=g.filter.Copy(); +this.m_isSensor=g.isSensor;this.m_shape=g.shape.Copy();this.m_density=g.density};S.prototype.Destroy=function(){this.m_shape=null};S.prototype.CreateProxy=function(a,c){this.m_shape.ComputeAABB(this.m_aabb,c);this.m_proxy=a.CreateProxy(this.m_aabb,this)};S.prototype.DestroyProxy=function(a){if(this.m_proxy!=null){a.DestroyProxy(this.m_proxy);this.m_proxy=null}};S.prototype.Synchronize=function(a,c,g){if(this.m_proxy){var b=new U,e=new U;this.m_shape.ComputeAABB(b,c);this.m_shape.ComputeAABB(e,g); +this.m_aabb.Combine(b,e);c=F.SubtractVV(g.position,c.position);a.MoveProxy(this.m_proxy,this.m_aabb,c)}};aa.b2FixtureDef=function(){this.filter=new N};aa.prototype.b2FixtureDef=function(){this.userData=this.shape=null;this.friction=0.2;this.density=this.restitution=0;this.filter.categoryBits=1;this.filter.maskBits=65535;this.filter.groupIndex=0;this.isSensor=false};Z.b2Island=function(){};Z.prototype.b2Island=function(){this.m_bodies=new Vector;this.m_contacts=new Vector;this.m_joints=new Vector}; +Z.prototype.Initialize=function(a,c,g,b,e,f){if(a===undefined)a=0;if(c===undefined)c=0;if(g===undefined)g=0;var m=0;this.m_bodyCapacity=a;this.m_contactCapacity=c;this.m_jointCapacity=g;this.m_jointCount=this.m_contactCount=this.m_bodyCount=0;this.m_allocator=b;this.m_listener=e;this.m_contactSolver=f;for(m=this.m_bodies.length;mA.b2_maxTranslationSquared){e.m_linearVelocity.Normalize();e.m_linearVelocity.x*=A.b2_maxTranslation*a.inv_dt;e.m_linearVelocity.y*=A.b2_maxTranslation*a.inv_dt}m=a.dt*e.m_angularVelocity;if(m*m>A.b2_maxRotationSquared)e.m_angularVelocity=e.m_angularVelocity<0?-A.b2_maxRotation*a.inv_dt:A.b2_maxRotation*a.inv_dt;e.m_sweep.c0.SetV(e.m_sweep.c);e.m_sweep.a0=e.m_sweep.a;e.m_sweep.c.x+=a.dt*e.m_linearVelocity.x;e.m_sweep.c.y+= +a.dt*e.m_linearVelocity.y;e.m_sweep.a+=a.dt*e.m_angularVelocity;e.SynchronizeTransform()}}for(b=0;bm||F.Dot(e.m_linearVelocity,e.m_linearVelocity)>c)g=e.m_sleepTime=0;else{e.m_sleepTime+=a.dt;g=F.Min(g,e.m_sleepTime)}}}if(g>=A.b2_timeToSleep)for(b=0;bA.b2_maxTranslationSquared){g.m_linearVelocity.Normalize();g.m_linearVelocity.x*=A.b2_maxTranslation* +a.inv_dt;g.m_linearVelocity.y*=A.b2_maxTranslation*a.inv_dt}e=a.dt*g.m_angularVelocity;if(e*e>A.b2_maxRotationSquared)g.m_angularVelocity=g.m_angularVelocity<0?-A.b2_maxRotation*a.inv_dt:A.b2_maxRotation*a.inv_dt;g.m_sweep.c0.SetV(g.m_sweep.c);g.m_sweep.a0=g.m_sweep.a;g.m_sweep.c.x+=a.dt*g.m_linearVelocity.x;g.m_sweep.c.y+=a.dt*g.m_linearVelocity.y;g.m_sweep.a+=a.dt*g.m_angularVelocity;g.SynchronizeTransform()}}for(c=0;c0?1/a:0;b.dtRatio=this.m_inv_dt0*a;b.warmStarting=h.m_warmStarting;this.m_contactManager.Collide();b.dt>0&&this.Solve(b);h.m_continuousPhysics&&b.dt>0&&this.SolveTOI(b);if(b.dt>0)this.m_inv_dt0=b.inv_dt;this.m_flags&=~h.e_locked};h.prototype.ClearForces=function(){for(var a=this.m_bodyList;a;a=a.m_next){a.m_force.SetZero();a.m_torque=0}};h.prototype.DrawDebugData= +function(){if(this.m_debugDraw!=null){this.m_debugDraw.m_sprite.graphics.clear();var a=this.m_debugDraw.GetFlags(),c,g,b;new y;new y;new y;var e;new U;new U;e=[new y,new y,new y,new y];var f=new w(0,0,0);if(a&E.e_shapeBit)for(c=this.m_bodyList;c;c=c.m_next){e=c.m_xf;for(g=c.GetFixtureList();g;g=g.m_next){b=g.GetShape();if(c.IsActive()==false)f.Set(0.5,0.5,0.3);else if(c.GetType()==k.b2_staticBody)f.Set(0.5,0.9,0.5);else if(c.GetType()==k.b2_kinematicBody)f.Set(0.5,0.5,0.9);else c.IsAwake()==false? +f.Set(0.6,0.6,0.6):f.Set(0.9,0.7,0.7);this.DrawShape(b,e,f)}}if(a&E.e_jointBit)for(c=this.m_jointList;c;c=c.m_next)this.DrawJoint(c);if(a&E.e_controllerBit)for(c=this.m_controllerList;c;c=c.m_next)c.Draw(this.m_debugDraw);if(a&E.e_pairBit){f.Set(0.3,0.9,0.9);for(c=this.m_contactManager.m_contactList;c;c=c.GetNext()){b=c.GetFixtureA();g=c.GetFixtureB();b=b.GetAABB().GetCenter();g=g.GetAABB().GetCenter();this.m_debugDraw.DrawSegment(b,g,f)}}if(a&E.e_aabbBit){b=this.m_contactManager.m_broadPhase;e=[new y, +new y,new y,new y];for(c=this.m_bodyList;c;c=c.GetNext())if(c.IsActive()!=false)for(g=c.GetFixtureList();g;g=g.GetNext()){var m=b.GetFatAABB(g.m_proxy);e[0].Set(m.lowerBound.x,m.lowerBound.y);e[1].Set(m.upperBound.x,m.lowerBound.y);e[2].Set(m.upperBound.x,m.upperBound.y);e[3].Set(m.lowerBound.x,m.upperBound.y);this.m_debugDraw.DrawPolygon(e,4,f)}}if(a&E.e_centerOfMassBit)for(c=this.m_bodyList;c;c=c.m_next){e=h.s_xf;e.R=c.m_xf.R;e.position=c.GetWorldCenter();this.m_debugDraw.DrawTransform(e)}}};h.prototype.QueryAABB= +function(a,c){var g=this.m_contactManager.m_broadPhase;g.Query(function(b){return a(g.GetUserData(b))},c)};h.prototype.QueryShape=function(a,c,g){if(g===undefined)g=null;if(g==null){g=new K;g.SetIdentity()}var b=this.m_contactManager.m_broadPhase,e=new U;c.ComputeAABB(e,g);b.Query(function(f){f=b.GetUserData(f)instanceof S?b.GetUserData(f):null;if(Y.TestOverlap(c,g,f.GetShape(),f.GetBody().GetTransform()))return a(f);return true},e)};h.prototype.QueryPoint=function(a,c){var g=this.m_contactManager.m_broadPhase, +b=new U;b.lowerBound.Set(c.x-A.b2_linearSlop,c.y-A.b2_linearSlop);b.upperBound.Set(c.x+A.b2_linearSlop,c.y+A.b2_linearSlop);g.Query(function(e){e=g.GetUserData(e)instanceof S?g.GetUserData(e):null;if(e.TestPoint(c))return a(e);return true},b)};h.prototype.RayCast=function(a,c,g){var b=this.m_contactManager.m_broadPhase,e=new V,f=new Q(c,g);b.RayCast(function(m,r){var s=b.GetUserData(r);s=s instanceof S?s:null;if(s.RayCast(e,m)){var v=e.fraction,t=new y((1-v)*c.x+v*g.x,(1-v)*c.y+v*g.y);return a(s, +t,e.normal,v)}return m.maxFraction},f)};h.prototype.RayCastOne=function(a,c){var g;this.RayCast(function(b,e,f,m){if(m===undefined)m=0;g=b;return m},a,c);return g};h.prototype.RayCastAll=function(a,c){var g=new Vector;this.RayCast(function(b){g[g.length]=b;return 1},a,c);return g};h.prototype.GetBodyList=function(){return this.m_bodyList};h.prototype.GetJointList=function(){return this.m_jointList};h.prototype.GetContactList=function(){return this.m_contactList};h.prototype.IsLocked=function(){return(this.m_flags& +h.e_locked)>0};h.prototype.Solve=function(a){for(var c,g=this.m_controllerList;g;g=g.m_next)g.Step(a);g=this.m_island;g.Initialize(this.m_bodyCount,this.m_contactCount,this.m_jointCount,null,this.m_contactManager.m_contactListener,this.m_contactSolver);for(c=this.m_bodyList;c;c=c.m_next)c.m_flags&=~k.e_islandFlag;for(var b=this.m_contactList;b;b=b.m_next)b.m_flags&=~l.e_islandFlag;for(b=this.m_jointList;b;b=b.m_next)b.m_islandFlag=false;parseInt(this.m_bodyCount);b=this.s_stack;for(var e=this.m_bodyList;e;e= +e.m_next)if(!(e.m_flags&k.e_islandFlag))if(!(e.IsAwake()==false||e.IsActive()==false))if(e.GetType()!=k.b2_staticBody){g.Clear();var f=0;b[f++]=e;for(e.m_flags|=k.e_islandFlag;f>0;){c=b[--f];g.AddBody(c);c.IsAwake()==false&&c.SetAwake(true);if(c.GetType()!=k.b2_staticBody){for(var m,r=c.m_contactList;r;r=r.next)if(!(r.contact.m_flags&l.e_islandFlag))if(!(r.contact.IsSensor()==true||r.contact.IsEnabled()==false||r.contact.IsTouching()==false)){g.AddContact(r.contact);r.contact.m_flags|=l.e_islandFlag; +m=r.other;if(!(m.m_flags&k.e_islandFlag)){b[f++]=m;m.m_flags|=k.e_islandFlag}}for(c=c.m_jointList;c;c=c.next)if(c.joint.m_islandFlag!=true){m=c.other;if(m.IsActive()!=false){g.AddJoint(c.joint);c.joint.m_islandFlag=true;if(!(m.m_flags&k.e_islandFlag)){b[f++]=m;m.m_flags|=k.e_islandFlag}}}}}g.Solve(a,this.m_gravity,this.m_allowSleep);for(f=0;f0&&c<1){c=(1-c)*s+c;if(c>1)c=1}b.m_toi=c;b.m_flags|=l.e_toiFlag}if(Number.MIN_VALUE0;){c=f[b++];--m;e.AddBody(c);c.IsAwake()==false&&c.SetAwake(true);if(c.GetType()==k.b2_dynamicBody){for(g=c.m_contactList;g;g=g.next){if(e.m_contactCount==e.m_contactCapacity)break;if(!(g.contact.m_flags&l.e_islandFlag))if(!(g.contact.IsSensor()==true||g.contact.IsEnabled()== +false||g.contact.IsTouching()==false)){e.AddContact(g.contact);g.contact.m_flags|=l.e_islandFlag;s=g.other;if(!(s.m_flags&k.e_islandFlag)){if(s.GetType()!=k.b2_staticBody){s.Advance(r);s.SetAwake(true)}f[b+m]=s;++m;s.m_flags|=k.e_islandFlag}}}for(c=c.m_jointList;c;c=c.next)if(e.m_jointCount!=e.m_jointCapacity)if(c.joint.m_islandFlag!=true){s=c.other;if(s.IsActive()!=false){e.AddJoint(c.joint);c.joint.m_islandFlag=true;if(!(s.m_flags&k.e_islandFlag)){if(s.GetType()!=k.b2_staticBody){s.Advance(r);s.SetAwake(true)}f[b+ +m]=s;++m;s.m_flags|=k.e_islandFlag}}}}}b=h.s_timestep;b.warmStarting=false;b.dt=(1-r)*a.dt;b.inv_dt=1/b.dt;b.dtRatio=0;b.velocityIterations=a.velocityIterations;b.positionIterations=a.positionIterations;e.SolveTOI(b);for(r=r=0;r0;for(c=0;c0){j.m_fixtureA.m_body.SetAwake(true);j.m_fixtureB.m_body.SetAwake(true)}var o=parseInt(j.m_fixtureA.GetType()), +q=parseInt(j.m_fixtureB.GetType());o=this.m_registers[o][q];o.poolCount++;j.m_next=o.pool;o.pool=j;o=o.destroyFcn;o(j,this.m_allocator)};V.b2ContactRegister=function(){};M.b2ContactResult=function(){this.position=new N;this.normal=new N;this.id=new aa};L.b2ContactSolver=function(){this.m_step=new H;this.m_constraints=new Vector};L.prototype.b2ContactSolver=function(){};L.prototype.Initialize=function(j,o,q,n){if(q===undefined)q=0;var a;this.m_step.Set(j);this.m_allocator=n;j=0;for(this.m_constraintCount= +q;this.m_constraints.length +0);L.s_worldManifold.Initialize(m,e.m_xf,g,f.m_xf,b);c=L.s_worldManifold.m_normal.x;a=L.s_worldManifold.m_normal.y;n=this.m_constraints[j];n.bodyA=e;n.bodyB=f;n.manifold=m;n.normal.x=c;n.normal.y=a;n.pointCount=m.m_pointCount;n.friction=r;n.restitution=s;n.localPlaneNormal.x=m.m_localPlaneNormal.x;n.localPlaneNormal.y=m.m_localPlaneNormal.y;n.localPoint.x=m.m_localPoint.x;n.localPoint.y=m.m_localPoint.y;n.radius=g+b;n.type=m.m_type;for(g=0;g0?n:0;q=n-o.normalImpulse;c=q*b;q=q*e;x.x-=J*c;x.y-=J*q;v-=T*(o.rA.x*q-o.rA.y*c);C.x+=P*c;C.y+=P*q;t+=X*(o.rB.x*q-o.rB.y*c);o.normalImpulse=n}else{o=a.points[0];j=a.points[1];q=o.normalImpulse;g=j.normalImpulse;var ba=(C.x-t*o.rB.y-x.x+v*o.rA.y)*b+(C.y+t*o.rB.x-x.y-v*o.rA.x)*e,ca=(C.x-t*j.rB.y-x.x+v*j.rA.y)*b+(C.y+ +t*j.rB.x-x.y-v*j.rA.x)*e;n=ba-o.velocityBias;c=ca-j.velocityBias;f=a.K;n-=f.col1.x*q+f.col2.x*g;for(c-=f.col1.y*q+f.col2.y*g;;){f=a.normalMass;$=-(f.col1.x*n+f.col2.x*c);f=-(f.col1.y*n+f.col2.y*c);if($>=0&&f>=0){q=$-q;g=f-g;a=q*b;q=q*e;b=g*b;e=g*e;x.x-=J*(a+b);x.y-=J*(q+e);v-=T*(o.rA.x*q-o.rA.y*a+j.rA.x*e-j.rA.y*b);C.x+=P*(a+b);C.y+=P*(q+e);t+=X*(o.rB.x*q-o.rB.y*a+j.rB.x*e-j.rB.y*b);o.normalImpulse=$;j.normalImpulse=f;break}$=-o.normalMass*n;f=0;ca=a.K.col1.y*$+c;if($>=0&&ca>=0){q=$-q;g=f-g;a=q*b; +q=q*e;b=g*b;e=g*e;x.x-=J*(a+b);x.y-=J*(q+e);v-=T*(o.rA.x*q-o.rA.y*a+j.rA.x*e-j.rA.y*b);C.x+=P*(a+b);C.y+=P*(q+e);t+=X*(o.rB.x*q-o.rB.y*a+j.rB.x*e-j.rB.y*b);o.normalImpulse=$;j.normalImpulse=f;break}$=0;f=-j.normalMass*c;ba=a.K.col2.x*f+n;if(f>=0&&ba>=0){q=$-q;g=f-g;a=q*b;q=q*e;b=g*b;e=g*e;x.x-=J*(a+b);x.y-=J*(q+e);v-=T*(o.rA.x*q-o.rA.y*a+j.rA.x*e-j.rA.y*b);C.x+=P*(a+b);C.y+=P*(q+e);t+=X*(o.rB.x*q-o.rB.y*a+j.rB.x*e-j.rB.y*b);o.normalImpulse=$;j.normalImpulse=f;break}f=$=0;ba=n;ca=c;if(ba>=0&&ca>=0){q= +$-q;g=f-g;a=q*b;q=q*e;b=g*b;e=g*e;x.x-=J*(a+b);x.y-=J*(q+e);v-=T*(o.rA.x*q-o.rA.y*a+j.rA.x*e-j.rA.y*b);C.x+=P*(a+b);C.y+=P*(q+e);t+=X*(o.rB.x*q-o.rB.y*a+j.rB.x*e-j.rB.y*b);o.normalImpulse=$;j.normalImpulse=f;break}break}}r.m_angularVelocity=v;s.m_angularVelocity=t}};L.prototype.FinalizeVelocityConstraints=function(){for(var j=0;j-1.5*O.b2_linearSlop};Box2D.postDefs.push(function(){Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold=new l;Box2D.Dynamics.Contacts.b2ContactSolver.s_psm=new u});Box2D.inherit(I,Box2D.Dynamics.Contacts.b2Contact); +I.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;I.b2EdgeAndCircleContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};I.Create=function(){return new I};I.Destroy=function(){};I.prototype.Reset=function(j,o){this.__super.Reset.call(this,j,o)};I.prototype.Evaluate=function(){var j=this.m_fixtureA.GetBody(),o=this.m_fixtureB.GetBody();this.b2CollideEdgeAndCircle(this.m_manifold,this.m_fixtureA.GetShape()instanceof G?this.m_fixtureA.GetShape():null,j.m_xf, +this.m_fixtureB.GetShape()instanceof F?this.m_fixtureB.GetShape():null,o.m_xf)};I.prototype.b2CollideEdgeAndCircle=function(){};Box2D.inherit(W,Box2D.Dynamics.Contacts.b2Contact);W.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;W.b2NullContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};W.prototype.b2NullContact=function(){this.__super.b2Contact.call(this)};W.prototype.Evaluate=function(){};Box2D.inherit(Y,Box2D.Dynamics.Contacts.b2Contact);Y.prototype.__super= +Box2D.Dynamics.Contacts.b2Contact.prototype;Y.b2PolyAndCircleContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};Y.Create=function(){return new Y};Y.Destroy=function(){};Y.prototype.Reset=function(j,o){this.__super.Reset.call(this,j,o);O.b2Assert(j.GetType()==y.e_polygonShape);O.b2Assert(o.GetType()==y.e_circleShape)};Y.prototype.Evaluate=function(){var j=this.m_fixtureA.m_body,o=this.m_fixtureB.m_body;S.CollidePolygonAndCircle(this.m_manifold,this.m_fixtureA.GetShape()instanceof +K?this.m_fixtureA.GetShape():null,j.m_xf,this.m_fixtureB.GetShape()instanceof F?this.m_fixtureB.GetShape():null,o.m_xf)};Box2D.inherit(k,Box2D.Dynamics.Contacts.b2Contact);k.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;k.b2PolyAndEdgeContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};k.Create=function(){return new k};k.Destroy=function(){};k.prototype.Reset=function(j,o){this.__super.Reset.call(this,j,o);O.b2Assert(j.GetType()==y.e_polygonShape); +O.b2Assert(o.GetType()==y.e_edgeShape)};k.prototype.Evaluate=function(){var j=this.m_fixtureA.GetBody(),o=this.m_fixtureB.GetBody();this.b2CollidePolyAndEdge(this.m_manifold,this.m_fixtureA.GetShape()instanceof K?this.m_fixtureA.GetShape():null,j.m_xf,this.m_fixtureB.GetShape()instanceof G?this.m_fixtureB.GetShape():null,o.m_xf)};k.prototype.b2CollidePolyAndEdge=function(){};Box2D.inherit(z,Box2D.Dynamics.Contacts.b2Contact);z.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;z.b2PolygonContact= +function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};z.Create=function(){return new z};z.Destroy=function(){};z.prototype.Reset=function(j,o){this.__super.Reset.call(this,j,o)};z.prototype.Evaluate=function(){var j=this.m_fixtureA.GetBody(),o=this.m_fixtureB.GetBody();S.CollidePolygons(this.m_manifold,this.m_fixtureA.GetShape()instanceof K?this.m_fixtureA.GetShape():null,j.m_xf,this.m_fixtureB.GetShape()instanceof K?this.m_fixtureB.GetShape():null,o.m_xf)};u.b2PositionSolverManifold= +function(){};u.prototype.b2PositionSolverManifold=function(){this.m_normal=new N;this.m_separations=new Vector_a2j_Number(O.b2_maxManifoldPoints);this.m_points=new Vector(O.b2_maxManifoldPoints);for(var j=0;j0);var o=0,q=0,n=0,a,c=0,g=0;switch(j.type){case Z.e_circles:a=j.bodyA.m_xf.R;n=j.localPoint;o=j.bodyA.m_xf.position.x+(a.col1.x*n.x+a.col2.x*n.y);q=j.bodyA.m_xf.position.y+(a.col1.y* +n.x+a.col2.y*n.y);a=j.bodyB.m_xf.R;n=j.points[0].localPoint;c=j.bodyB.m_xf.position.x+(a.col1.x*n.x+a.col2.x*n.y);a=j.bodyB.m_xf.position.y+(a.col1.y*n.x+a.col2.y*n.y);n=c-o;g=a-q;var b=n*n+g*g;if(b>Number.MIN_VALUE*Number.MIN_VALUE){b=Math.sqrt(b);this.m_normal.x=n/b;this.m_normal.y=g/b}else{this.m_normal.x=1;this.m_normal.y=0}this.m_points[0].x=0.5*(o+c);this.m_points[0].y=0.5*(q+a);this.m_separations[0]=n*this.m_normal.x+g*this.m_normal.y-j.radius;break;case Z.e_faceA:a=j.bodyA.m_xf.R;n=j.localPlaneNormal; +this.m_normal.x=a.col1.x*n.x+a.col2.x*n.y;this.m_normal.y=a.col1.y*n.x+a.col2.y*n.y;a=j.bodyA.m_xf.R;n=j.localPoint;c=j.bodyA.m_xf.position.x+(a.col1.x*n.x+a.col2.x*n.y);g=j.bodyA.m_xf.position.y+(a.col1.y*n.x+a.col2.y*n.y);a=j.bodyB.m_xf.R;for(o=0;o0||L>0?1/Math.max(M,L):0};V.prototype.Step=function(M){M=M.dt;if(!(M<=Number.MIN_VALUE)){if(M>this.maxTimestep&&this.maxTimestep>0)M=this.maxTimestep; +for(var L=this.m_bodyList;L;L=L.nextBody){var I=L.body;if(I.IsAwake()){var W=I.GetWorldVector(G.MulMV(this.T,I.GetLocalVector(I.GetLinearVelocity())));I.SetLinearVelocity(new K(I.GetLinearVelocity().x+W.x*M,I.GetLinearVelocity().y+W.y*M))}}}}})(); +(function(){var F=Box2D.Common.b2Settings,G=Box2D.Common.Math.b2Mat22,K=Box2D.Common.Math.b2Mat33,y=Box2D.Common.Math.b2Math,w=Box2D.Common.Math.b2Vec2,A=Box2D.Common.Math.b2Vec3,U=Box2D.Dynamics.Joints.b2DistanceJoint,p=Box2D.Dynamics.Joints.b2DistanceJointDef,B=Box2D.Dynamics.Joints.b2FrictionJoint,Q=Box2D.Dynamics.Joints.b2FrictionJointDef,V=Box2D.Dynamics.Joints.b2GearJoint,M=Box2D.Dynamics.Joints.b2GearJointDef,L=Box2D.Dynamics.Joints.b2Jacobian,I=Box2D.Dynamics.Joints.b2Joint,W=Box2D.Dynamics.Joints.b2JointDef, +Y=Box2D.Dynamics.Joints.b2JointEdge,k=Box2D.Dynamics.Joints.b2LineJoint,z=Box2D.Dynamics.Joints.b2LineJointDef,u=Box2D.Dynamics.Joints.b2MouseJoint,D=Box2D.Dynamics.Joints.b2MouseJointDef,H=Box2D.Dynamics.Joints.b2PrismaticJoint,O=Box2D.Dynamics.Joints.b2PrismaticJointDef,E=Box2D.Dynamics.Joints.b2PulleyJoint,R=Box2D.Dynamics.Joints.b2PulleyJointDef,N=Box2D.Dynamics.Joints.b2RevoluteJoint,S=Box2D.Dynamics.Joints.b2RevoluteJointDef,aa=Box2D.Dynamics.Joints.b2WeldJoint,Z=Box2D.Dynamics.Joints.b2WeldJointDef; +Box2D.inherit(U,Box2D.Dynamics.Joints.b2Joint);U.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;U.b2DistanceJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_localAnchor1=new w;this.m_localAnchor2=new w;this.m_u=new w};U.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};U.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};U.prototype.GetReactionForce=function(d){if(d===undefined)d= +0;return new w(d*this.m_impulse*this.m_u.x,d*this.m_impulse*this.m_u.y)};U.prototype.GetReactionTorque=function(){return 0};U.prototype.GetLength=function(){return this.m_length};U.prototype.SetLength=function(d){if(d===undefined)d=0;this.m_length=d};U.prototype.GetFrequency=function(){return this.m_frequencyHz};U.prototype.SetFrequency=function(d){if(d===undefined)d=0;this.m_frequencyHz=d};U.prototype.GetDampingRatio=function(){return this.m_dampingRatio};U.prototype.SetDampingRatio=function(d){if(d=== +undefined)d=0;this.m_dampingRatio=d};U.prototype.b2DistanceJoint=function(d){this.__super.b2Joint.call(this,d);this.m_localAnchor1.SetV(d.localAnchorA);this.m_localAnchor2.SetV(d.localAnchorB);this.m_length=d.length;this.m_frequencyHz=d.frequencyHz;this.m_dampingRatio=d.dampingRatio;this.m_bias=this.m_gamma=this.m_impulse=0};U.prototype.InitVelocityConstraints=function(d){var h,l=0,j=this.m_bodyA,o=this.m_bodyB;h=j.m_xf.R;var q=this.m_localAnchor1.x-j.m_sweep.localCenter.x,n=this.m_localAnchor1.y- +j.m_sweep.localCenter.y;l=h.col1.x*q+h.col2.x*n;n=h.col1.y*q+h.col2.y*n;q=l;h=o.m_xf.R;var a=this.m_localAnchor2.x-o.m_sweep.localCenter.x,c=this.m_localAnchor2.y-o.m_sweep.localCenter.y;l=h.col1.x*a+h.col2.x*c;c=h.col1.y*a+h.col2.y*c;a=l;this.m_u.x=o.m_sweep.c.x+a-j.m_sweep.c.x-q;this.m_u.y=o.m_sweep.c.y+c-j.m_sweep.c.y-n;l=Math.sqrt(this.m_u.x*this.m_u.x+this.m_u.y*this.m_u.y);l>F.b2_linearSlop?this.m_u.Multiply(1/l):this.m_u.SetZero();h=q*this.m_u.y-n*this.m_u.x;var g=a*this.m_u.y-c*this.m_u.x; +h=j.m_invMass+j.m_invI*h*h+o.m_invMass+o.m_invI*g*g;this.m_mass=h!=0?1/h:0;if(this.m_frequencyHz>0){l=l-this.m_length;g=2*Math.PI*this.m_frequencyHz;var b=this.m_mass*g*g;this.m_gamma=d.dt*(2*this.m_mass*this.m_dampingRatio*g+d.dt*b);this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0;this.m_bias=l*d.dt*b*this.m_gamma;this.m_mass=h+this.m_gamma;this.m_mass=this.m_mass!=0?1/this.m_mass:0}if(d.warmStarting){this.m_impulse*=d.dtRatio;d=this.m_impulse*this.m_u.x;h=this.m_impulse*this.m_u.y;j.m_linearVelocity.x-= +j.m_invMass*d;j.m_linearVelocity.y-=j.m_invMass*h;j.m_angularVelocity-=j.m_invI*(q*h-n*d);o.m_linearVelocity.x+=o.m_invMass*d;o.m_linearVelocity.y+=o.m_invMass*h;o.m_angularVelocity+=o.m_invI*(a*h-c*d)}else this.m_impulse=0};U.prototype.SolveVelocityConstraints=function(){var d,h=this.m_bodyA,l=this.m_bodyB;d=h.m_xf.R;var j=this.m_localAnchor1.x-h.m_sweep.localCenter.x,o=this.m_localAnchor1.y-h.m_sweep.localCenter.y,q=d.col1.x*j+d.col2.x*o;o=d.col1.y*j+d.col2.y*o;j=q;d=l.m_xf.R;var n=this.m_localAnchor2.x- +l.m_sweep.localCenter.x,a=this.m_localAnchor2.y-l.m_sweep.localCenter.y;q=d.col1.x*n+d.col2.x*a;a=d.col1.y*n+d.col2.y*a;n=q;q=-this.m_mass*(this.m_u.x*(l.m_linearVelocity.x+-l.m_angularVelocity*a-(h.m_linearVelocity.x+-h.m_angularVelocity*o))+this.m_u.y*(l.m_linearVelocity.y+l.m_angularVelocity*n-(h.m_linearVelocity.y+h.m_angularVelocity*j))+this.m_bias+this.m_gamma*this.m_impulse);this.m_impulse+=q;d=q*this.m_u.x;q=q*this.m_u.y;h.m_linearVelocity.x-=h.m_invMass*d;h.m_linearVelocity.y-=h.m_invMass* +q;h.m_angularVelocity-=h.m_invI*(j*q-o*d);l.m_linearVelocity.x+=l.m_invMass*d;l.m_linearVelocity.y+=l.m_invMass*q;l.m_angularVelocity+=l.m_invI*(n*q-a*d)};U.prototype.SolvePositionConstraints=function(){var d;if(this.m_frequencyHz>0)return true;var h=this.m_bodyA,l=this.m_bodyB;d=h.m_xf.R;var j=this.m_localAnchor1.x-h.m_sweep.localCenter.x,o=this.m_localAnchor1.y-h.m_sweep.localCenter.y,q=d.col1.x*j+d.col2.x*o;o=d.col1.y*j+d.col2.y*o;j=q;d=l.m_xf.R;var n=this.m_localAnchor2.x-l.m_sweep.localCenter.x, +a=this.m_localAnchor2.y-l.m_sweep.localCenter.y;q=d.col1.x*n+d.col2.x*a;a=d.col1.y*n+d.col2.y*a;n=q;q=l.m_sweep.c.x+n-h.m_sweep.c.x-j;var c=l.m_sweep.c.y+a-h.m_sweep.c.y-o;d=Math.sqrt(q*q+c*c);q/=d;c/=d;d=d-this.m_length;d=y.Clamp(d,-F.b2_maxLinearCorrection,F.b2_maxLinearCorrection);var g=-this.m_mass*d;this.m_u.Set(q,c);q=g*this.m_u.x;c=g*this.m_u.y;h.m_sweep.c.x-=h.m_invMass*q;h.m_sweep.c.y-=h.m_invMass*c;h.m_sweep.a-=h.m_invI*(j*c-o*q);l.m_sweep.c.x+=l.m_invMass*q;l.m_sweep.c.y+=l.m_invMass*c; +l.m_sweep.a+=l.m_invI*(n*c-a*q);h.SynchronizeTransform();l.SynchronizeTransform();return y.Abs(d)0)this.m_angularMass=1/this.m_angularMass;if(d.warmStarting){this.m_linearImpulse.x*=d.dtRatio;this.m_linearImpulse.y*=d.dtRatio;this.m_angularImpulse*=d.dtRatio;d=this.m_linearImpulse;j.m_linearVelocity.x-=h*d.x; +j.m_linearVelocity.y-=h*d.y;j.m_angularVelocity-=g*(q*d.y-n*d.x+this.m_angularImpulse);o.m_linearVelocity.x+=l*d.x;o.m_linearVelocity.y+=l*d.y;o.m_angularVelocity+=b*(a*d.y-c*d.x+this.m_angularImpulse)}else{this.m_linearImpulse.SetZero();this.m_angularImpulse=0}};B.prototype.SolveVelocityConstraints=function(d){var h,l=0,j=this.m_bodyA,o=this.m_bodyB,q=j.m_linearVelocity,n=j.m_angularVelocity,a=o.m_linearVelocity,c=o.m_angularVelocity,g=j.m_invMass,b=o.m_invMass,e=j.m_invI,f=o.m_invI;h=j.m_xf.R;var m= +this.m_localAnchorA.x-j.m_sweep.localCenter.x,r=this.m_localAnchorA.y-j.m_sweep.localCenter.y;l=h.col1.x*m+h.col2.x*r;r=h.col1.y*m+h.col2.y*r;m=l;h=o.m_xf.R;var s=this.m_localAnchorB.x-o.m_sweep.localCenter.x,v=this.m_localAnchorB.y-o.m_sweep.localCenter.y;l=h.col1.x*s+h.col2.x*v;v=h.col1.y*s+h.col2.y*v;s=l;h=0;l=-this.m_angularMass*(c-n);var t=this.m_angularImpulse;h=d.dt*this.m_maxTorque;this.m_angularImpulse=y.Clamp(this.m_angularImpulse+l,-h,h);l=this.m_angularImpulse-t;n-=e*l;c+=f*l;h=y.MulMV(this.m_linearMass, +new w(-(a.x-c*v-q.x+n*r),-(a.y+c*s-q.y-n*m)));l=this.m_linearImpulse.Copy();this.m_linearImpulse.Add(h);h=d.dt*this.m_maxForce;if(this.m_linearImpulse.LengthSquared()>h*h){this.m_linearImpulse.Normalize();this.m_linearImpulse.Multiply(h)}h=y.SubtractVV(this.m_linearImpulse,l);q.x-=g*h.x;q.y-=g*h.y;n-=e*(m*h.y-r*h.x);a.x+=b*h.x;a.y+=b*h.y;c+=f*(s*h.y-v*h.x);j.m_angularVelocity=n;o.m_angularVelocity=c};B.prototype.SolvePositionConstraints=function(){return true};Box2D.inherit(Q,Box2D.Dynamics.Joints.b2JointDef); +Q.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;Q.b2FrictionJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new w;this.localAnchorB=new w};Q.prototype.b2FrictionJointDef=function(){this.__super.b2JointDef.call(this);this.type=I.e_frictionJoint;this.maxTorque=this.maxForce=0};Q.prototype.Initialize=function(d,h,l){this.bodyA=d;this.bodyB=h;this.localAnchorA.SetV(this.bodyA.GetLocalPoint(l));this.localAnchorB.SetV(this.bodyB.GetLocalPoint(l))}; +Box2D.inherit(V,Box2D.Dynamics.Joints.b2Joint);V.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;V.b2GearJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_groundAnchor1=new w;this.m_groundAnchor2=new w;this.m_localAnchor1=new w;this.m_localAnchor2=new w;this.m_J=new L};V.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};V.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};V.prototype.GetReactionForce= +function(d){if(d===undefined)d=0;return new w(d*this.m_impulse*this.m_J.linearB.x,d*this.m_impulse*this.m_J.linearB.y)};V.prototype.GetReactionTorque=function(d){if(d===undefined)d=0;var h=this.m_bodyB.m_xf.R,l=this.m_localAnchor1.x-this.m_bodyB.m_sweep.localCenter.x,j=this.m_localAnchor1.y-this.m_bodyB.m_sweep.localCenter.y,o=h.col1.x*l+h.col2.x*j;j=h.col1.y*l+h.col2.y*j;l=o;return d*(this.m_impulse*this.m_J.angularB-l*this.m_impulse*this.m_J.linearB.y+j*this.m_impulse*this.m_J.linearB.x)};V.prototype.GetRatio= +function(){return this.m_ratio};V.prototype.SetRatio=function(d){if(d===undefined)d=0;this.m_ratio=d};V.prototype.b2GearJoint=function(d){this.__super.b2Joint.call(this,d);var h=parseInt(d.joint1.m_type),l=parseInt(d.joint2.m_type);this.m_prismatic2=this.m_revolute2=this.m_prismatic1=this.m_revolute1=null;var j=0,o=0;this.m_ground1=d.joint1.GetBodyA();this.m_bodyA=d.joint1.GetBodyB();if(h==I.e_revoluteJoint){this.m_revolute1=d.joint1 instanceof N?d.joint1:null;this.m_groundAnchor1.SetV(this.m_revolute1.m_localAnchor1); +this.m_localAnchor1.SetV(this.m_revolute1.m_localAnchor2);j=this.m_revolute1.GetJointAngle()}else{this.m_prismatic1=d.joint1 instanceof H?d.joint1:null;this.m_groundAnchor1.SetV(this.m_prismatic1.m_localAnchor1);this.m_localAnchor1.SetV(this.m_prismatic1.m_localAnchor2);j=this.m_prismatic1.GetJointTranslation()}this.m_ground2=d.joint2.GetBodyA();this.m_bodyB=d.joint2.GetBodyB();if(l==I.e_revoluteJoint){this.m_revolute2=d.joint2 instanceof N?d.joint2:null;this.m_groundAnchor2.SetV(this.m_revolute2.m_localAnchor1); +this.m_localAnchor2.SetV(this.m_revolute2.m_localAnchor2);o=this.m_revolute2.GetJointAngle()}else{this.m_prismatic2=d.joint2 instanceof H?d.joint2:null;this.m_groundAnchor2.SetV(this.m_prismatic2.m_localAnchor1);this.m_localAnchor2.SetV(this.m_prismatic2.m_localAnchor2);o=this.m_prismatic2.GetJointTranslation()}this.m_ratio=d.ratio;this.m_constant=j+this.m_ratio*o;this.m_impulse=0};V.prototype.InitVelocityConstraints=function(d){var h=this.m_ground1,l=this.m_ground2,j=this.m_bodyA,o=this.m_bodyB, +q=0,n=0,a=0,c=0,g=a=0,b=0;this.m_J.SetZero();if(this.m_revolute1){this.m_J.angularA=-1;b+=j.m_invI}else{h=h.m_xf.R;n=this.m_prismatic1.m_localXAxis1;q=h.col1.x*n.x+h.col2.x*n.y;n=h.col1.y*n.x+h.col2.y*n.y;h=j.m_xf.R;a=this.m_localAnchor1.x-j.m_sweep.localCenter.x;c=this.m_localAnchor1.y-j.m_sweep.localCenter.y;g=h.col1.x*a+h.col2.x*c;c=h.col1.y*a+h.col2.y*c;a=g;a=a*n-c*q;this.m_J.linearA.Set(-q,-n);this.m_J.angularA=-a;b+=j.m_invMass+j.m_invI*a*a}if(this.m_revolute2){this.m_J.angularB=-this.m_ratio; +b+=this.m_ratio*this.m_ratio*o.m_invI}else{h=l.m_xf.R;n=this.m_prismatic2.m_localXAxis1;q=h.col1.x*n.x+h.col2.x*n.y;n=h.col1.y*n.x+h.col2.y*n.y;h=o.m_xf.R;a=this.m_localAnchor2.x-o.m_sweep.localCenter.x;c=this.m_localAnchor2.y-o.m_sweep.localCenter.y;g=h.col1.x*a+h.col2.x*c;c=h.col1.y*a+h.col2.y*c;a=g;a=a*n-c*q;this.m_J.linearB.Set(-this.m_ratio*q,-this.m_ratio*n);this.m_J.angularB=-this.m_ratio*a;b+=this.m_ratio*this.m_ratio*(o.m_invMass+o.m_invI*a*a)}this.m_mass=b>0?1/b:0;if(d.warmStarting){j.m_linearVelocity.x+= +j.m_invMass*this.m_impulse*this.m_J.linearA.x;j.m_linearVelocity.y+=j.m_invMass*this.m_impulse*this.m_J.linearA.y;j.m_angularVelocity+=j.m_invI*this.m_impulse*this.m_J.angularA;o.m_linearVelocity.x+=o.m_invMass*this.m_impulse*this.m_J.linearB.x;o.m_linearVelocity.y+=o.m_invMass*this.m_impulse*this.m_J.linearB.y;o.m_angularVelocity+=o.m_invI*this.m_impulse*this.m_J.angularB}else this.m_impulse=0};V.prototype.SolveVelocityConstraints=function(){var d=this.m_bodyA,h=this.m_bodyB,l=-this.m_mass*this.m_J.Compute(d.m_linearVelocity, +d.m_angularVelocity,h.m_linearVelocity,h.m_angularVelocity);this.m_impulse+=l;d.m_linearVelocity.x+=d.m_invMass*l*this.m_J.linearA.x;d.m_linearVelocity.y+=d.m_invMass*l*this.m_J.linearA.y;d.m_angularVelocity+=d.m_invI*l*this.m_J.angularA;h.m_linearVelocity.x+=h.m_invMass*l*this.m_J.linearB.x;h.m_linearVelocity.y+=h.m_invMass*l*this.m_J.linearB.y;h.m_angularVelocity+=h.m_invI*l*this.m_J.angularB};V.prototype.SolvePositionConstraints=function(){var d=this.m_bodyA,h=this.m_bodyB,l=0,j=0;l=this.m_revolute1? +this.m_revolute1.GetJointAngle():this.m_prismatic1.GetJointTranslation();j=this.m_revolute2?this.m_revolute2.GetJointAngle():this.m_prismatic2.GetJointTranslation();l=-this.m_mass*(this.m_constant-(l+this.m_ratio*j));d.m_sweep.c.x+=d.m_invMass*l*this.m_J.linearA.x;d.m_sweep.c.y+=d.m_invMass*l*this.m_J.linearA.y;d.m_sweep.a+=d.m_invI*l*this.m_J.angularA;h.m_sweep.c.x+=h.m_invMass*l*this.m_J.linearB.x;h.m_sweep.c.y+=h.m_invMass*l*this.m_J.linearB.y;h.m_sweep.a+=h.m_invI*l*this.m_J.angularB;d.SynchronizeTransform(); +h.SynchronizeTransform();return 0Number.MIN_VALUE?1/this.m_motorMass:0;this.m_perp.SetV(y.MulMV(q.R,this.m_localYAxis1));this.m_s1=(j+n)*this.m_perp.y-(o+a)*this.m_perp.x;this.m_s2=c*this.m_perp.y- +g*this.m_perp.x;q=this.m_invMassA;n=this.m_invMassB;a=this.m_invIA;c=this.m_invIB;this.m_K.col1.x=q+n+a*this.m_s1*this.m_s1+c*this.m_s2*this.m_s2;this.m_K.col1.y=a*this.m_s1*this.m_a1+c*this.m_s2*this.m_a2;this.m_K.col2.x=this.m_K.col1.y;this.m_K.col2.y=q+n+a*this.m_a1*this.m_a1+c*this.m_a2*this.m_a2;if(this.m_enableLimit){j=this.m_axis.x*j+this.m_axis.y*o;if(y.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*F.b2_linearSlop)this.m_limitState=I.e_equalLimits;else if(j<=this.m_lowerTranslation){if(this.m_limitState!= +I.e_atLowerLimit){this.m_limitState=I.e_atLowerLimit;this.m_impulse.y=0}}else if(j>=this.m_upperTranslation){if(this.m_limitState!=I.e_atUpperLimit){this.m_limitState=I.e_atUpperLimit;this.m_impulse.y=0}}else{this.m_limitState=I.e_inactiveLimit;this.m_impulse.y=0}}else this.m_limitState=I.e_inactiveLimit;if(this.m_enableMotor==false)this.m_motorImpulse=0;if(d.warmStarting){this.m_impulse.x*=d.dtRatio;this.m_impulse.y*=d.dtRatio;this.m_motorImpulse*=d.dtRatio;d=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+ +this.m_impulse.y)*this.m_axis.x;j=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.y;o=this.m_impulse.x*this.m_s1+(this.m_motorImpulse+this.m_impulse.y)*this.m_a1;q=this.m_impulse.x*this.m_s2+(this.m_motorImpulse+this.m_impulse.y)*this.m_a2;h.m_linearVelocity.x-=this.m_invMassA*d;h.m_linearVelocity.y-=this.m_invMassA*j;h.m_angularVelocity-=this.m_invIA*o;l.m_linearVelocity.x+=this.m_invMassB*d;l.m_linearVelocity.y+=this.m_invMassB*j;l.m_angularVelocity+=this.m_invIB* +q}else{this.m_impulse.SetZero();this.m_motorImpulse=0}};k.prototype.SolveVelocityConstraints=function(d){var h=this.m_bodyA,l=this.m_bodyB,j=h.m_linearVelocity,o=h.m_angularVelocity,q=l.m_linearVelocity,n=l.m_angularVelocity,a=0,c=0,g=0,b=0;if(this.m_enableMotor&&this.m_limitState!=I.e_equalLimits){b=this.m_motorMass*(this.m_motorSpeed-(this.m_axis.x*(q.x-j.x)+this.m_axis.y*(q.y-j.y)+this.m_a2*n-this.m_a1*o));a=this.m_motorImpulse;c=d.dt*this.m_maxMotorForce;this.m_motorImpulse=y.Clamp(this.m_motorImpulse+ +b,-c,c);b=this.m_motorImpulse-a;a=b*this.m_axis.x;c=b*this.m_axis.y;g=b*this.m_a1;b=b*this.m_a2;j.x-=this.m_invMassA*a;j.y-=this.m_invMassA*c;o-=this.m_invIA*g;q.x+=this.m_invMassB*a;q.y+=this.m_invMassB*c;n+=this.m_invIB*b}c=this.m_perp.x*(q.x-j.x)+this.m_perp.y*(q.y-j.y)+this.m_s2*n-this.m_s1*o;if(this.m_enableLimit&&this.m_limitState!=I.e_inactiveLimit){g=this.m_axis.x*(q.x-j.x)+this.m_axis.y*(q.y-j.y)+this.m_a2*n-this.m_a1*o;a=this.m_impulse.Copy();d=this.m_K.Solve(new w,-c,-g);this.m_impulse.Add(d); +if(this.m_limitState==I.e_atLowerLimit)this.m_impulse.y=y.Max(this.m_impulse.y,0);else if(this.m_limitState==I.e_atUpperLimit)this.m_impulse.y=y.Min(this.m_impulse.y,0);c=-c-(this.m_impulse.y-a.y)*this.m_K.col2.x;g=0;g=this.m_K.col1.x!=0?c/this.m_K.col1.x+a.x:a.x;this.m_impulse.x=g;d.x=this.m_impulse.x-a.x;d.y=this.m_impulse.y-a.y;a=d.x*this.m_perp.x+d.y*this.m_axis.x;c=d.x*this.m_perp.y+d.y*this.m_axis.y;g=d.x*this.m_s1+d.y*this.m_a1;b=d.x*this.m_s2+d.y*this.m_a2}else{d=0;d=this.m_K.col1.x!=0?-c/ +this.m_K.col1.x:0;this.m_impulse.x+=d;a=d*this.m_perp.x;c=d*this.m_perp.y;g=d*this.m_s1;b=d*this.m_s2}j.x-=this.m_invMassA*a;j.y-=this.m_invMassA*c;o-=this.m_invIA*g;q.x+=this.m_invMassB*a;q.y+=this.m_invMassB*c;n+=this.m_invIB*b;h.m_linearVelocity.SetV(j);h.m_angularVelocity=o;l.m_linearVelocity.SetV(q);l.m_angularVelocity=n};k.prototype.SolvePositionConstraints=function(){var d=this.m_bodyA,h=this.m_bodyB,l=d.m_sweep.c,j=d.m_sweep.a,o=h.m_sweep.c,q=h.m_sweep.a,n,a=0,c=0,g=0,b=0,e=n=0,f=0;c=false; +var m=0,r=G.FromAngle(j);g=G.FromAngle(q);n=r;f=this.m_localAnchor1.x-this.m_localCenterA.x;var s=this.m_localAnchor1.y-this.m_localCenterA.y;a=n.col1.x*f+n.col2.x*s;s=n.col1.y*f+n.col2.y*s;f=a;n=g;g=this.m_localAnchor2.x-this.m_localCenterB.x;b=this.m_localAnchor2.y-this.m_localCenterB.y;a=n.col1.x*g+n.col2.x*b;b=n.col1.y*g+n.col2.y*b;g=a;n=o.x+g-l.x-f;a=o.y+b-l.y-s;if(this.m_enableLimit){this.m_axis=y.MulMV(r,this.m_localXAxis1);this.m_a1=(n+f)*this.m_axis.y-(a+s)*this.m_axis.x;this.m_a2=g*this.m_axis.y- +b*this.m_axis.x;var v=this.m_axis.x*n+this.m_axis.y*a;if(y.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*F.b2_linearSlop){m=y.Clamp(v,-F.b2_maxLinearCorrection,F.b2_maxLinearCorrection);e=y.Abs(v);c=true}else if(v<=this.m_lowerTranslation){m=y.Clamp(v-this.m_lowerTranslation+F.b2_linearSlop,-F.b2_maxLinearCorrection,0);e=this.m_lowerTranslation-v;c=true}else if(v>=this.m_upperTranslation){m=y.Clamp(v-this.m_upperTranslation+F.b2_linearSlop,0,F.b2_maxLinearCorrection);e=v-this.m_upperTranslation; +c=true}}this.m_perp=y.MulMV(r,this.m_localYAxis1);this.m_s1=(n+f)*this.m_perp.y-(a+s)*this.m_perp.x;this.m_s2=g*this.m_perp.y-b*this.m_perp.x;r=new w;s=this.m_perp.x*n+this.m_perp.y*a;e=y.Max(e,y.Abs(s));f=0;if(c){c=this.m_invMassA;g=this.m_invMassB;b=this.m_invIA;n=this.m_invIB;this.m_K.col1.x=c+g+b*this.m_s1*this.m_s1+n*this.m_s2*this.m_s2;this.m_K.col1.y=b*this.m_s1*this.m_a1+n*this.m_s2*this.m_a2;this.m_K.col2.x=this.m_K.col1.y;this.m_K.col2.y=c+g+b*this.m_a1*this.m_a1+n*this.m_a2*this.m_a2;this.m_K.Solve(r, +-s,-m)}else{c=this.m_invMassA;g=this.m_invMassB;b=this.m_invIA;n=this.m_invIB;m=c+g+b*this.m_s1*this.m_s1+n*this.m_s2*this.m_s2;c=0;c=m!=0?-s/m:0;r.x=c;r.y=0}m=r.x*this.m_perp.x+r.y*this.m_axis.x;c=r.x*this.m_perp.y+r.y*this.m_axis.y;s=r.x*this.m_s1+r.y*this.m_a1;r=r.x*this.m_s2+r.y*this.m_a2;l.x-=this.m_invMassA*m;l.y-=this.m_invMassA*c;j-=this.m_invIA*s;o.x+=this.m_invMassB*m;o.y+=this.m_invMassB*c;q+=this.m_invIB*r;d.m_sweep.a=j;h.m_sweep.a=q;d.SynchronizeTransform();h.SynchronizeTransform();return e<= +F.b2_linearSlop&&f<=F.b2_angularSlop};Box2D.inherit(z,Box2D.Dynamics.Joints.b2JointDef);z.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;z.b2LineJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new w;this.localAnchorB=new w;this.localAxisA=new w};z.prototype.b2LineJointDef=function(){this.__super.b2JointDef.call(this);this.type=I.e_lineJoint;this.localAxisA.Set(1,0);this.enableLimit=false;this.upperTranslation=this.lowerTranslation= +0;this.enableMotor=false;this.motorSpeed=this.maxMotorForce=0};z.prototype.Initialize=function(d,h,l,j){this.bodyA=d;this.bodyB=h;this.localAnchorA=this.bodyA.GetLocalPoint(l);this.localAnchorB=this.bodyB.GetLocalPoint(l);this.localAxisA=this.bodyA.GetLocalVector(j)};Box2D.inherit(u,Box2D.Dynamics.Joints.b2Joint);u.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;u.b2MouseJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.K=new G;this.K1=new G;this.K2=new G; +this.m_localAnchor=new w;this.m_target=new w;this.m_impulse=new w;this.m_mass=new G;this.m_C=new w};u.prototype.GetAnchorA=function(){return this.m_target};u.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor)};u.prototype.GetReactionForce=function(d){if(d===undefined)d=0;return new w(d*this.m_impulse.x,d*this.m_impulse.y)};u.prototype.GetReactionTorque=function(){return 0};u.prototype.GetTarget=function(){return this.m_target};u.prototype.SetTarget=function(d){this.m_bodyB.IsAwake()== +false&&this.m_bodyB.SetAwake(true);this.m_target=d};u.prototype.GetMaxForce=function(){return this.m_maxForce};u.prototype.SetMaxForce=function(d){if(d===undefined)d=0;this.m_maxForce=d};u.prototype.GetFrequency=function(){return this.m_frequencyHz};u.prototype.SetFrequency=function(d){if(d===undefined)d=0;this.m_frequencyHz=d};u.prototype.GetDampingRatio=function(){return this.m_dampingRatio};u.prototype.SetDampingRatio=function(d){if(d===undefined)d=0;this.m_dampingRatio=d};u.prototype.b2MouseJoint= +function(d){this.__super.b2Joint.call(this,d);this.m_target.SetV(d.target);var h=this.m_target.x-this.m_bodyB.m_xf.position.x,l=this.m_target.y-this.m_bodyB.m_xf.position.y,j=this.m_bodyB.m_xf.R;this.m_localAnchor.x=h*j.col1.x+l*j.col1.y;this.m_localAnchor.y=h*j.col2.x+l*j.col2.y;this.m_maxForce=d.maxForce;this.m_impulse.SetZero();this.m_frequencyHz=d.frequencyHz;this.m_dampingRatio=d.dampingRatio;this.m_gamma=this.m_beta=0};u.prototype.InitVelocityConstraints=function(d){var h=this.m_bodyB,l=h.GetMass(), +j=2*Math.PI*this.m_frequencyHz,o=l*j*j;this.m_gamma=d.dt*(2*l*this.m_dampingRatio*j+d.dt*o);this.m_gamma=this.m_gamma!=0?1/this.m_gamma:0;this.m_beta=d.dt*o*this.m_gamma;o=h.m_xf.R;l=this.m_localAnchor.x-h.m_sweep.localCenter.x;j=this.m_localAnchor.y-h.m_sweep.localCenter.y;var q=o.col1.x*l+o.col2.x*j;j=o.col1.y*l+o.col2.y*j;l=q;o=h.m_invMass;q=h.m_invI;this.K1.col1.x=o;this.K1.col2.x=0;this.K1.col1.y=0;this.K1.col2.y=o;this.K2.col1.x=q*j*j;this.K2.col2.x=-q*l*j;this.K2.col1.y=-q*l*j;this.K2.col2.y= +q*l*l;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=h.m_sweep.c.x+l-this.m_target.x;this.m_C.y=h.m_sweep.c.y+j-this.m_target.y;h.m_angularVelocity*=0.98;this.m_impulse.x*=d.dtRatio;this.m_impulse.y*=d.dtRatio;h.m_linearVelocity.x+=o*this.m_impulse.x;h.m_linearVelocity.y+=o*this.m_impulse.y;h.m_angularVelocity+=q*(l*this.m_impulse.y-j*this.m_impulse.x)};u.prototype.SolveVelocityConstraints=function(d){var h= +this.m_bodyB,l,j=0,o=0;l=h.m_xf.R;var q=this.m_localAnchor.x-h.m_sweep.localCenter.x,n=this.m_localAnchor.y-h.m_sweep.localCenter.y;j=l.col1.x*q+l.col2.x*n;n=l.col1.y*q+l.col2.y*n;q=j;j=h.m_linearVelocity.x+-h.m_angularVelocity*n;var a=h.m_linearVelocity.y+h.m_angularVelocity*q;l=this.m_mass;j=j+this.m_beta*this.m_C.x+this.m_gamma*this.m_impulse.x;o=a+this.m_beta*this.m_C.y+this.m_gamma*this.m_impulse.y;a=-(l.col1.x*j+l.col2.x*o);o=-(l.col1.y*j+l.col2.y*o);l=this.m_impulse.x;j=this.m_impulse.y;this.m_impulse.x+= +a;this.m_impulse.y+=o;d=d.dt*this.m_maxForce;this.m_impulse.LengthSquared()>d*d&&this.m_impulse.Multiply(d/this.m_impulse.Length());a=this.m_impulse.x-l;o=this.m_impulse.y-j;h.m_linearVelocity.x+=h.m_invMass*a;h.m_linearVelocity.y+=h.m_invMass*o;h.m_angularVelocity+=h.m_invI*(q*o-n*a)};u.prototype.SolvePositionConstraints=function(){return true};Box2D.inherit(D,Box2D.Dynamics.Joints.b2JointDef);D.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;D.b2MouseJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, +arguments);this.target=new w};D.prototype.b2MouseJointDef=function(){this.__super.b2JointDef.call(this);this.type=I.e_mouseJoint;this.maxForce=0;this.frequencyHz=5;this.dampingRatio=0.7};Box2D.inherit(H,Box2D.Dynamics.Joints.b2Joint);H.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;H.b2PrismaticJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_localAnchor1=new w;this.m_localAnchor2=new w;this.m_localXAxis1=new w;this.m_localYAxis1=new w;this.m_axis=new w; +this.m_perp=new w;this.m_K=new K;this.m_impulse=new A};H.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};H.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};H.prototype.GetReactionForce=function(d){if(d===undefined)d=0;return new w(d*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x),d*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y))};H.prototype.GetReactionTorque= +function(d){if(d===undefined)d=0;return d*this.m_impulse.y};H.prototype.GetJointTranslation=function(){var d=this.m_bodyA,h=this.m_bodyB,l=d.GetWorldPoint(this.m_localAnchor1),j=h.GetWorldPoint(this.m_localAnchor2);h=j.x-l.x;l=j.y-l.y;d=d.GetWorldVector(this.m_localXAxis1);return d.x*h+d.y*l};H.prototype.GetJointSpeed=function(){var d=this.m_bodyA,h=this.m_bodyB,l;l=d.m_xf.R;var j=this.m_localAnchor1.x-d.m_sweep.localCenter.x,o=this.m_localAnchor1.y-d.m_sweep.localCenter.y,q=l.col1.x*j+l.col2.x*o; +o=l.col1.y*j+l.col2.y*o;j=q;l=h.m_xf.R;var n=this.m_localAnchor2.x-h.m_sweep.localCenter.x,a=this.m_localAnchor2.y-h.m_sweep.localCenter.y;q=l.col1.x*n+l.col2.x*a;a=l.col1.y*n+l.col2.y*a;n=q;l=h.m_sweep.c.x+n-(d.m_sweep.c.x+j);q=h.m_sweep.c.y+a-(d.m_sweep.c.y+o);var c=d.GetWorldVector(this.m_localXAxis1),g=d.m_linearVelocity,b=h.m_linearVelocity;d=d.m_angularVelocity;h=h.m_angularVelocity;return l*-d*c.y+q*d*c.x+(c.x*(b.x+-h*a-g.x- -d*o)+c.y*(b.y+h*n-g.y-d*j))};H.prototype.IsLimitEnabled=function(){return this.m_enableLimit}; +H.prototype.EnableLimit=function(d){this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_enableLimit=d};H.prototype.GetLowerLimit=function(){return this.m_lowerTranslation};H.prototype.GetUpperLimit=function(){return this.m_upperTranslation};H.prototype.SetLimits=function(d,h){if(d===undefined)d=0;if(h===undefined)h=0;this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_lowerTranslation=d;this.m_upperTranslation=h};H.prototype.IsMotorEnabled=function(){return this.m_enableMotor}; +H.prototype.EnableMotor=function(d){this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_enableMotor=d};H.prototype.SetMotorSpeed=function(d){if(d===undefined)d=0;this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_motorSpeed=d};H.prototype.GetMotorSpeed=function(){return this.m_motorSpeed};H.prototype.SetMaxMotorForce=function(d){if(d===undefined)d=0;this.m_bodyA.SetAwake(true);this.m_bodyB.SetAwake(true);this.m_maxMotorForce=d};H.prototype.GetMotorForce=function(){return this.m_motorImpulse}; +H.prototype.b2PrismaticJoint=function(d){this.__super.b2Joint.call(this,d);this.m_localAnchor1.SetV(d.localAnchorA);this.m_localAnchor2.SetV(d.localAnchorB);this.m_localXAxis1.SetV(d.localAxisA);this.m_localYAxis1.x=-this.m_localXAxis1.y;this.m_localYAxis1.y=this.m_localXAxis1.x;this.m_refAngle=d.referenceAngle;this.m_impulse.SetZero();this.m_motorImpulse=this.m_motorMass=0;this.m_lowerTranslation=d.lowerTranslation;this.m_upperTranslation=d.upperTranslation;this.m_maxMotorForce=d.maxMotorForce;this.m_motorSpeed= +d.motorSpeed;this.m_enableLimit=d.enableLimit;this.m_enableMotor=d.enableMotor;this.m_limitState=I.e_inactiveLimit;this.m_axis.SetZero();this.m_perp.SetZero()};H.prototype.InitVelocityConstraints=function(d){var h=this.m_bodyA,l=this.m_bodyB,j,o=0;this.m_localCenterA.SetV(h.GetLocalCenter());this.m_localCenterB.SetV(l.GetLocalCenter());var q=h.GetTransform();l.GetTransform();j=h.m_xf.R;var n=this.m_localAnchor1.x-this.m_localCenterA.x,a=this.m_localAnchor1.y-this.m_localCenterA.y;o=j.col1.x*n+j.col2.x* +a;a=j.col1.y*n+j.col2.y*a;n=o;j=l.m_xf.R;var c=this.m_localAnchor2.x-this.m_localCenterB.x,g=this.m_localAnchor2.y-this.m_localCenterB.y;o=j.col1.x*c+j.col2.x*g;g=j.col1.y*c+j.col2.y*g;c=o;j=l.m_sweep.c.x+c-h.m_sweep.c.x-n;o=l.m_sweep.c.y+g-h.m_sweep.c.y-a;this.m_invMassA=h.m_invMass;this.m_invMassB=l.m_invMass;this.m_invIA=h.m_invI;this.m_invIB=l.m_invI;this.m_axis.SetV(y.MulMV(q.R,this.m_localXAxis1));this.m_a1=(j+n)*this.m_axis.y-(o+a)*this.m_axis.x;this.m_a2=c*this.m_axis.y-g*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/this.m_motorMass;this.m_perp.SetV(y.MulMV(q.R,this.m_localYAxis1));this.m_s1=(j+n)*this.m_perp.y-(o+a)*this.m_perp.x;this.m_s2=c*this.m_perp.y-g*this.m_perp.x;q=this.m_invMassA;n=this.m_invMassB;a=this.m_invIA;c=this.m_invIB;this.m_K.col1.x=q+n+a*this.m_s1*this.m_s1+c*this.m_s2*this.m_s2;this.m_K.col1.y=a*this.m_s1+c*this.m_s2;this.m_K.col1.z=a* +this.m_s1*this.m_a1+c*this.m_s2*this.m_a2;this.m_K.col2.x=this.m_K.col1.y;this.m_K.col2.y=a+c;this.m_K.col2.z=a*this.m_a1+c*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=q+n+a*this.m_a1*this.m_a1+c*this.m_a2*this.m_a2;if(this.m_enableLimit){j=this.m_axis.x*j+this.m_axis.y*o;if(y.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*F.b2_linearSlop)this.m_limitState=I.e_equalLimits;else if(j<=this.m_lowerTranslation){if(this.m_limitState!=I.e_atLowerLimit){this.m_limitState= +I.e_atLowerLimit;this.m_impulse.z=0}}else if(j>=this.m_upperTranslation){if(this.m_limitState!=I.e_atUpperLimit){this.m_limitState=I.e_atUpperLimit;this.m_impulse.z=0}}else{this.m_limitState=I.e_inactiveLimit;this.m_impulse.z=0}}else this.m_limitState=I.e_inactiveLimit;if(this.m_enableMotor==false)this.m_motorImpulse=0;if(d.warmStarting){this.m_impulse.x*=d.dtRatio;this.m_impulse.y*=d.dtRatio;this.m_motorImpulse*=d.dtRatio;d=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x; +j=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y;o=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1;q=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2;h.m_linearVelocity.x-=this.m_invMassA*d;h.m_linearVelocity.y-=this.m_invMassA*j;h.m_angularVelocity-=this.m_invIA*o;l.m_linearVelocity.x+=this.m_invMassB*d;l.m_linearVelocity.y+=this.m_invMassB*j;l.m_angularVelocity+=this.m_invIB* +q}else{this.m_impulse.SetZero();this.m_motorImpulse=0}};H.prototype.SolveVelocityConstraints=function(d){var h=this.m_bodyA,l=this.m_bodyB,j=h.m_linearVelocity,o=h.m_angularVelocity,q=l.m_linearVelocity,n=l.m_angularVelocity,a=0,c=0,g=0,b=0;if(this.m_enableMotor&&this.m_limitState!=I.e_equalLimits){b=this.m_motorMass*(this.m_motorSpeed-(this.m_axis.x*(q.x-j.x)+this.m_axis.y*(q.y-j.y)+this.m_a2*n-this.m_a1*o));a=this.m_motorImpulse;d=d.dt*this.m_maxMotorForce;this.m_motorImpulse=y.Clamp(this.m_motorImpulse+ +b,-d,d);b=this.m_motorImpulse-a;a=b*this.m_axis.x;c=b*this.m_axis.y;g=b*this.m_a1;b=b*this.m_a2;j.x-=this.m_invMassA*a;j.y-=this.m_invMassA*c;o-=this.m_invIA*g;q.x+=this.m_invMassB*a;q.y+=this.m_invMassB*c;n+=this.m_invIB*b}g=this.m_perp.x*(q.x-j.x)+this.m_perp.y*(q.y-j.y)+this.m_s2*n-this.m_s1*o;c=n-o;if(this.m_enableLimit&&this.m_limitState!=I.e_inactiveLimit){d=this.m_axis.x*(q.x-j.x)+this.m_axis.y*(q.y-j.y)+this.m_a2*n-this.m_a1*o;a=this.m_impulse.Copy();d=this.m_K.Solve33(new A,-g,-c,-d);this.m_impulse.Add(d); +if(this.m_limitState==I.e_atLowerLimit)this.m_impulse.z=y.Max(this.m_impulse.z,0);else if(this.m_limitState==I.e_atUpperLimit)this.m_impulse.z=y.Min(this.m_impulse.z,0);g=-g-(this.m_impulse.z-a.z)*this.m_K.col3.x;c=-c-(this.m_impulse.z-a.z)*this.m_K.col3.y;c=this.m_K.Solve22(new w,g,c);c.x+=a.x;c.y+=a.y;this.m_impulse.x=c.x;this.m_impulse.y=c.y;d.x=this.m_impulse.x-a.x;d.y=this.m_impulse.y-a.y;d.z=this.m_impulse.z-a.z;a=d.x*this.m_perp.x+d.z*this.m_axis.x;c=d.x*this.m_perp.y+d.z*this.m_axis.y;g=d.x* +this.m_s1+d.y+d.z*this.m_a1;b=d.x*this.m_s2+d.y+d.z*this.m_a2}else{d=this.m_K.Solve22(new w,-g,-c);this.m_impulse.x+=d.x;this.m_impulse.y+=d.y;a=d.x*this.m_perp.x;c=d.x*this.m_perp.y;g=d.x*this.m_s1+d.y;b=d.x*this.m_s2+d.y}j.x-=this.m_invMassA*a;j.y-=this.m_invMassA*c;o-=this.m_invIA*g;q.x+=this.m_invMassB*a;q.y+=this.m_invMassB*c;n+=this.m_invIB*b;h.m_linearVelocity.SetV(j);h.m_angularVelocity=o;l.m_linearVelocity.SetV(q);l.m_angularVelocity=n};H.prototype.SolvePositionConstraints=function(){var d= +this.m_bodyA,h=this.m_bodyB,l=d.m_sweep.c,j=d.m_sweep.a,o=h.m_sweep.c,q=h.m_sweep.a,n,a=0,c=0,g=0,b=a=n=0,e=0;c=false;var f=0,m=G.FromAngle(j),r=G.FromAngle(q);n=m;e=this.m_localAnchor1.x-this.m_localCenterA.x;var s=this.m_localAnchor1.y-this.m_localCenterA.y;a=n.col1.x*e+n.col2.x*s;s=n.col1.y*e+n.col2.y*s;e=a;n=r;r=this.m_localAnchor2.x-this.m_localCenterB.x;g=this.m_localAnchor2.y-this.m_localCenterB.y;a=n.col1.x*r+n.col2.x*g;g=n.col1.y*r+n.col2.y*g;r=a;n=o.x+r-l.x-e;a=o.y+g-l.y-s;if(this.m_enableLimit){this.m_axis= +y.MulMV(m,this.m_localXAxis1);this.m_a1=(n+e)*this.m_axis.y-(a+s)*this.m_axis.x;this.m_a2=r*this.m_axis.y-g*this.m_axis.x;var v=this.m_axis.x*n+this.m_axis.y*a;if(y.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*F.b2_linearSlop){f=y.Clamp(v,-F.b2_maxLinearCorrection,F.b2_maxLinearCorrection);b=y.Abs(v);c=true}else if(v<=this.m_lowerTranslation){f=y.Clamp(v-this.m_lowerTranslation+F.b2_linearSlop,-F.b2_maxLinearCorrection,0);b=this.m_lowerTranslation-v;c=true}else if(v>=this.m_upperTranslation){f= +y.Clamp(v-this.m_upperTranslation+F.b2_linearSlop,0,F.b2_maxLinearCorrection);b=v-this.m_upperTranslation;c=true}}this.m_perp=y.MulMV(m,this.m_localYAxis1);this.m_s1=(n+e)*this.m_perp.y-(a+s)*this.m_perp.x;this.m_s2=r*this.m_perp.y-g*this.m_perp.x;m=new A;s=this.m_perp.x*n+this.m_perp.y*a;r=q-j-this.m_refAngle;b=y.Max(b,y.Abs(s));e=y.Abs(r);if(c){c=this.m_invMassA;g=this.m_invMassB;n=this.m_invIA;a=this.m_invIB;this.m_K.col1.x=c+g+n*this.m_s1*this.m_s1+a*this.m_s2*this.m_s2;this.m_K.col1.y=n*this.m_s1+ +a*this.m_s2;this.m_K.col1.z=n*this.m_s1*this.m_a1+a*this.m_s2*this.m_a2;this.m_K.col2.x=this.m_K.col1.y;this.m_K.col2.y=n+a;this.m_K.col2.z=n*this.m_a1+a*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=c+g+n*this.m_a1*this.m_a1+a*this.m_a2*this.m_a2;this.m_K.Solve33(m,-s,-r,-f)}else{c=this.m_invMassA;g=this.m_invMassB;n=this.m_invIA;a=this.m_invIB;f=n*this.m_s1+a*this.m_s2;v=n+a;this.m_K.col1.Set(c+g+n*this.m_s1*this.m_s1+a*this.m_s2*this.m_s2,f,0);this.m_K.col2.Set(f, +v,0);f=this.m_K.Solve22(new w,-s,-r);m.x=f.x;m.y=f.y;m.z=0}f=m.x*this.m_perp.x+m.z*this.m_axis.x;c=m.x*this.m_perp.y+m.z*this.m_axis.y;s=m.x*this.m_s1+m.y+m.z*this.m_a1;m=m.x*this.m_s2+m.y+m.z*this.m_a2;l.x-=this.m_invMassA*f;l.y-=this.m_invMassA*c;j-=this.m_invIA*s;o.x+=this.m_invMassB*f;o.y+=this.m_invMassB*c;q+=this.m_invIB*m;d.m_sweep.a=j;h.m_sweep.a=q;d.SynchronizeTransform();h.SynchronizeTransform();return b<=F.b2_linearSlop&&e<=F.b2_angularSlop};Box2D.inherit(O,Box2D.Dynamics.Joints.b2JointDef); +O.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;O.b2PrismaticJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new w;this.localAnchorB=new w;this.localAxisA=new w};O.prototype.b2PrismaticJointDef=function(){this.__super.b2JointDef.call(this);this.type=I.e_prismaticJoint;this.localAxisA.Set(1,0);this.referenceAngle=0;this.enableLimit=false;this.upperTranslation=this.lowerTranslation=0;this.enableMotor=false;this.motorSpeed=this.maxMotorForce= +0};O.prototype.Initialize=function(d,h,l,j){this.bodyA=d;this.bodyB=h;this.localAnchorA=this.bodyA.GetLocalPoint(l);this.localAnchorB=this.bodyB.GetLocalPoint(l);this.localAxisA=this.bodyA.GetLocalVector(j);this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()};Box2D.inherit(E,Box2D.Dynamics.Joints.b2Joint);E.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;E.b2PulleyJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_groundAnchor1=new w;this.m_groundAnchor2= +new w;this.m_localAnchor1=new w;this.m_localAnchor2=new w;this.m_u1=new w;this.m_u2=new w};E.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};E.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};E.prototype.GetReactionForce=function(d){if(d===undefined)d=0;return new w(d*this.m_impulse*this.m_u2.x,d*this.m_impulse*this.m_u2.y)};E.prototype.GetReactionTorque=function(){return 0};E.prototype.GetGroundAnchorA=function(){var d= +this.m_ground.m_xf.position.Copy();d.Add(this.m_groundAnchor1);return d};E.prototype.GetGroundAnchorB=function(){var d=this.m_ground.m_xf.position.Copy();d.Add(this.m_groundAnchor2);return d};E.prototype.GetLength1=function(){var d=this.m_bodyA.GetWorldPoint(this.m_localAnchor1),h=d.x-(this.m_ground.m_xf.position.x+this.m_groundAnchor1.x);d=d.y-(this.m_ground.m_xf.position.y+this.m_groundAnchor1.y);return Math.sqrt(h*h+d*d)};E.prototype.GetLength2=function(){var d=this.m_bodyB.GetWorldPoint(this.m_localAnchor2), +h=d.x-(this.m_ground.m_xf.position.x+this.m_groundAnchor2.x);d=d.y-(this.m_ground.m_xf.position.y+this.m_groundAnchor2.y);return Math.sqrt(h*h+d*d)};E.prototype.GetRatio=function(){return this.m_ratio};E.prototype.b2PulleyJoint=function(d){this.__super.b2Joint.call(this,d);this.m_ground=this.m_bodyA.m_world.m_groundBody;this.m_groundAnchor1.x=d.groundAnchorA.x-this.m_ground.m_xf.position.x;this.m_groundAnchor1.y=d.groundAnchorA.y-this.m_ground.m_xf.position.y;this.m_groundAnchor2.x=d.groundAnchorB.x- +this.m_ground.m_xf.position.x;this.m_groundAnchor2.y=d.groundAnchorB.y-this.m_ground.m_xf.position.y;this.m_localAnchor1.SetV(d.localAnchorA);this.m_localAnchor2.SetV(d.localAnchorB);this.m_ratio=d.ratio;this.m_constant=d.lengthA+this.m_ratio*d.lengthB;this.m_maxLength1=y.Min(d.maxLengthA,this.m_constant-this.m_ratio*E.b2_minPulleyLength);this.m_maxLength2=y.Min(d.maxLengthB,(this.m_constant-E.b2_minPulleyLength)/this.m_ratio);this.m_limitImpulse2=this.m_limitImpulse1=this.m_impulse=0};E.prototype.InitVelocityConstraints= +function(d){var h=this.m_bodyA,l=this.m_bodyB,j;j=h.m_xf.R;var o=this.m_localAnchor1.x-h.m_sweep.localCenter.x,q=this.m_localAnchor1.y-h.m_sweep.localCenter.y,n=j.col1.x*o+j.col2.x*q;q=j.col1.y*o+j.col2.y*q;o=n;j=l.m_xf.R;var a=this.m_localAnchor2.x-l.m_sweep.localCenter.x,c=this.m_localAnchor2.y-l.m_sweep.localCenter.y;n=j.col1.x*a+j.col2.x*c;c=j.col1.y*a+j.col2.y*c;a=n;j=l.m_sweep.c.x+a;n=l.m_sweep.c.y+c;var g=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,b=this.m_ground.m_xf.position.y+ +this.m_groundAnchor2.y;this.m_u1.Set(h.m_sweep.c.x+o-(this.m_ground.m_xf.position.x+this.m_groundAnchor1.x),h.m_sweep.c.y+q-(this.m_ground.m_xf.position.y+this.m_groundAnchor1.y));this.m_u2.Set(j-g,n-b);j=this.m_u1.Length();n=this.m_u2.Length();j>F.b2_linearSlop?this.m_u1.Multiply(1/j):this.m_u1.SetZero();n>F.b2_linearSlop?this.m_u2.Multiply(1/n):this.m_u2.SetZero();if(this.m_constant-j-this.m_ratio*n>0){this.m_state=I.e_inactiveLimit;this.m_impulse=0}else this.m_state=I.e_atUpperLimit;if(jF.b2_linearSlop?this.m_u1.Multiply(1/ +l):this.m_u1.SetZero();e>F.b2_linearSlop?this.m_u2.Multiply(1/e):this.m_u2.SetZero();l=this.m_constant-l-this.m_ratio*e;r=y.Max(r,-l);l=y.Clamp(l+F.b2_linearSlop,-F.b2_maxLinearCorrection,0);m=-this.m_pulleyMass*l;l=-m*this.m_u1.x;e=-m*this.m_u1.y;f=-this.m_ratio*m*this.m_u2.x;m=-this.m_ratio*m*this.m_u2.y;d.m_sweep.c.x+=d.m_invMass*l;d.m_sweep.c.y+=d.m_invMass*e;d.m_sweep.a+=d.m_invI*(a*e-c*l);h.m_sweep.c.x+=h.m_invMass*f;h.m_sweep.c.y+=h.m_invMass*m;h.m_sweep.a+=h.m_invI*(g*m-b*f);d.SynchronizeTransform(); +h.SynchronizeTransform()}if(this.m_limitState1==I.e_atUpperLimit){l=d.m_xf.R;a=this.m_localAnchor1.x-d.m_sweep.localCenter.x;c=this.m_localAnchor1.y-d.m_sweep.localCenter.y;e=l.col1.x*a+l.col2.x*c;c=l.col1.y*a+l.col2.y*c;a=e;l=d.m_sweep.c.x+a;e=d.m_sweep.c.y+c;this.m_u1.Set(l-j,e-o);l=this.m_u1.Length();if(l>F.b2_linearSlop){this.m_u1.x*=1/l;this.m_u1.y*=1/l}else this.m_u1.SetZero();l=this.m_maxLength1-l;r=y.Max(r,-l);l=y.Clamp(l+F.b2_linearSlop,-F.b2_maxLinearCorrection,0);m=-this.m_limitMass1*l; +l=-m*this.m_u1.x;e=-m*this.m_u1.y;d.m_sweep.c.x+=d.m_invMass*l;d.m_sweep.c.y+=d.m_invMass*e;d.m_sweep.a+=d.m_invI*(a*e-c*l);d.SynchronizeTransform()}if(this.m_limitState2==I.e_atUpperLimit){l=h.m_xf.R;g=this.m_localAnchor2.x-h.m_sweep.localCenter.x;b=this.m_localAnchor2.y-h.m_sweep.localCenter.y;e=l.col1.x*g+l.col2.x*b;b=l.col1.y*g+l.col2.y*b;g=e;f=h.m_sweep.c.x+g;m=h.m_sweep.c.y+b;this.m_u2.Set(f-q,m-n);e=this.m_u2.Length();if(e>F.b2_linearSlop){this.m_u2.x*=1/e;this.m_u2.y*=1/e}else this.m_u2.SetZero(); +l=this.m_maxLength2-e;r=y.Max(r,-l);l=y.Clamp(l+F.b2_linearSlop,-F.b2_maxLinearCorrection,0);m=-this.m_limitMass2*l;f=-m*this.m_u2.x;m=-m*this.m_u2.y;h.m_sweep.c.x+=h.m_invMass*f;h.m_sweep.c.y+=h.m_invMass*m;h.m_sweep.a+=h.m_invI*(g*m-b*f);h.SynchronizeTransform()}return r=this.m_upperAngle){if(this.m_limitState!=I.e_atUpperLimit)this.m_impulse.z=0;this.m_limitState= +I.e_atUpperLimit}else{this.m_limitState=I.e_inactiveLimit;this.m_impulse.z=0}}else this.m_limitState=I.e_inactiveLimit;if(d.warmStarting){this.m_impulse.x*=d.dtRatio;this.m_impulse.y*=d.dtRatio;this.m_motorImpulse*=d.dtRatio;d=this.m_impulse.x;e=this.m_impulse.y;h.m_linearVelocity.x-=j*d;h.m_linearVelocity.y-=j*e;h.m_angularVelocity-=g*(q*e-n*d+this.m_motorImpulse+this.m_impulse.z);l.m_linearVelocity.x+=o*d;l.m_linearVelocity.y+=o*e;l.m_angularVelocity+=b*(a*e-c*d+this.m_motorImpulse+this.m_impulse.z)}else{this.m_impulse.SetZero(); +this.m_motorImpulse=0}};N.prototype.SolveVelocityConstraints=function(d){var h=this.m_bodyA,l=this.m_bodyB,j=0,o=j=0,q=0,n=0,a=0,c=h.m_linearVelocity,g=h.m_angularVelocity,b=l.m_linearVelocity,e=l.m_angularVelocity,f=h.m_invMass,m=l.m_invMass,r=h.m_invI,s=l.m_invI;if(this.m_enableMotor&&this.m_limitState!=I.e_equalLimits){o=this.m_motorMass*-(e-g-this.m_motorSpeed);q=this.m_motorImpulse;n=d.dt*this.m_maxMotorTorque;this.m_motorImpulse=y.Clamp(this.m_motorImpulse+o,-n,n);o=this.m_motorImpulse-q;g-= +r*o;e+=s*o}if(this.m_enableLimit&&this.m_limitState!=I.e_inactiveLimit){d=h.m_xf.R;o=this.m_localAnchor1.x-h.m_sweep.localCenter.x;q=this.m_localAnchor1.y-h.m_sweep.localCenter.y;j=d.col1.x*o+d.col2.x*q;q=d.col1.y*o+d.col2.y*q;o=j;d=l.m_xf.R;n=this.m_localAnchor2.x-l.m_sweep.localCenter.x;a=this.m_localAnchor2.y-l.m_sweep.localCenter.y;j=d.col1.x*n+d.col2.x*a;a=d.col1.y*n+d.col2.y*a;n=j;d=b.x+-e*a-c.x- -g*q;var v=b.y+e*n-c.y-g*o;this.m_mass.Solve33(this.impulse3,-d,-v,-(e-g));if(this.m_limitState== +I.e_equalLimits)this.m_impulse.Add(this.impulse3);else if(this.m_limitState==I.e_atLowerLimit){j=this.m_impulse.z+this.impulse3.z;if(j<0){this.m_mass.Solve22(this.reduced,-d,-v);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}}else if(this.m_limitState==I.e_atUpperLimit){j=this.m_impulse.z+this.impulse3.z;if(j>0){this.m_mass.Solve22(this.reduced,-d,-v);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}}c.x-=f*this.impulse3.x;c.y-=f*this.impulse3.y;g-=r*(o*this.impulse3.y-q*this.impulse3.x+this.impulse3.z);b.x+=m*this.impulse3.x;b.y+=m*this.impulse3.y;e+=s*(n*this.impulse3.y-a*this.impulse3.x+this.impulse3.z)}else{d=h.m_xf.R;o=this.m_localAnchor1.x-h.m_sweep.localCenter.x;q=this.m_localAnchor1.y-h.m_sweep.localCenter.y;j=d.col1.x*o+ +d.col2.x*q;q=d.col1.y*o+d.col2.y*q;o=j;d=l.m_xf.R;n=this.m_localAnchor2.x-l.m_sweep.localCenter.x;a=this.m_localAnchor2.y-l.m_sweep.localCenter.y;j=d.col1.x*n+d.col2.x*a;a=d.col1.y*n+d.col2.y*a;n=j;this.m_mass.Solve22(this.impulse2,-(b.x+-e*a-c.x- -g*q),-(b.y+e*n-c.y-g*o));this.m_impulse.x+=this.impulse2.x;this.m_impulse.y+=this.impulse2.y;c.x-=f*this.impulse2.x;c.y-=f*this.impulse2.y;g-=r*(o*this.impulse2.y-q*this.impulse2.x);b.x+=m*this.impulse2.x;b.y+=m*this.impulse2.y;e+=s*(n*this.impulse2.y- +a*this.impulse2.x)}h.m_linearVelocity.SetV(c);h.m_angularVelocity=g;l.m_linearVelocity.SetV(b);l.m_angularVelocity=e};N.prototype.SolvePositionConstraints=function(){var d=0,h,l=this.m_bodyA,j=this.m_bodyB,o=0,q=h=0,n=0,a=0;if(this.m_enableLimit&&this.m_limitState!=I.e_inactiveLimit){d=j.m_sweep.a-l.m_sweep.a-this.m_referenceAngle;var c=0;if(this.m_limitState==I.e_equalLimits){d=y.Clamp(d-this.m_lowerAngle,-F.b2_maxAngularCorrection,F.b2_maxAngularCorrection);c=-this.m_motorMass*d;o=y.Abs(d)}else if(this.m_limitState== +I.e_atLowerLimit){d=d-this.m_lowerAngle;o=-d;d=y.Clamp(d+F.b2_angularSlop,-F.b2_maxAngularCorrection,0);c=-this.m_motorMass*d}else if(this.m_limitState==I.e_atUpperLimit){o=d=d-this.m_upperAngle;d=y.Clamp(d-F.b2_angularSlop,0,F.b2_maxAngularCorrection);c=-this.m_motorMass*d}l.m_sweep.a-=l.m_invI*c;j.m_sweep.a+=j.m_invI*c;l.SynchronizeTransform();j.SynchronizeTransform()}h=l.m_xf.R;c=this.m_localAnchor1.x-l.m_sweep.localCenter.x;d=this.m_localAnchor1.y-l.m_sweep.localCenter.y;q=h.col1.x*c+h.col2.x* +d;d=h.col1.y*c+h.col2.y*d;c=q;h=j.m_xf.R;var g=this.m_localAnchor2.x-j.m_sweep.localCenter.x,b=this.m_localAnchor2.y-j.m_sweep.localCenter.y;q=h.col1.x*g+h.col2.x*b;b=h.col1.y*g+h.col2.y*b;g=q;n=j.m_sweep.c.x+g-l.m_sweep.c.x-c;a=j.m_sweep.c.y+b-l.m_sweep.c.y-d;var e=n*n+a*a;h=Math.sqrt(e);q=l.m_invMass;var f=j.m_invMass,m=l.m_invI,r=j.m_invI,s=10*F.b2_linearSlop;if(e>s*s){e=1/(q+f);n=e*-n;a=e*-a;l.m_sweep.c.x-=0.5*q*n;l.m_sweep.c.y-=0.5*q*a;j.m_sweep.c.x+=0.5*f*n;j.m_sweep.c.y+=0.5*f*a;n=j.m_sweep.c.x+ +g-l.m_sweep.c.x-c;a=j.m_sweep.c.y+b-l.m_sweep.c.y-d}this.K1.col1.x=q+f;this.K1.col2.x=0;this.K1.col1.y=0;this.K1.col2.y=q+f;this.K2.col1.x=m*d*d;this.K2.col2.x=-m*c*d;this.K2.col1.y=-m*c*d;this.K2.col2.y=m*c*c;this.K3.col1.x=r*b*b;this.K3.col2.x=-r*g*b;this.K3.col1.y=-r*g*b;this.K3.col2.y=r*g*g;this.K.SetM(this.K1);this.K.AddM(this.K2);this.K.AddM(this.K3);this.K.Solve(N.tImpulse,-n,-a);n=N.tImpulse.x;a=N.tImpulse.y;l.m_sweep.c.x-=l.m_invMass*n;l.m_sweep.c.y-=l.m_invMass*a;l.m_sweep.a-=l.m_invI*(c* +a-d*n);j.m_sweep.c.x+=j.m_invMass*n;j.m_sweep.c.y+=j.m_invMass*a;j.m_sweep.a+=j.m_invI*(g*a-b*n);l.SynchronizeTransform();j.SynchronizeTransform();return h<=F.b2_linearSlop&&o<=F.b2_angularSlop};Box2D.postDefs.push(function(){Box2D.Dynamics.Joints.b2RevoluteJoint.tImpulse=new w});Box2D.inherit(S,Box2D.Dynamics.Joints.b2JointDef);S.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;S.b2RevoluteJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA= +new w;this.localAnchorB=new w};S.prototype.b2RevoluteJointDef=function(){this.__super.b2JointDef.call(this);this.type=I.e_revoluteJoint;this.localAnchorA.Set(0,0);this.localAnchorB.Set(0,0);this.motorSpeed=this.maxMotorTorque=this.upperAngle=this.lowerAngle=this.referenceAngle=0;this.enableMotor=this.enableLimit=false};S.prototype.Initialize=function(d,h,l){this.bodyA=d;this.bodyB=h;this.localAnchorA=this.bodyA.GetLocalPoint(l);this.localAnchorB=this.bodyB.GetLocalPoint(l);this.referenceAngle=this.bodyB.GetAngle()- +this.bodyA.GetAngle()};Box2D.inherit(aa,Box2D.Dynamics.Joints.b2Joint);aa.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;aa.b2WeldJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_localAnchorA=new w;this.m_localAnchorB=new w;this.m_impulse=new A;this.m_mass=new K};aa.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)};aa.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)};aa.prototype.GetReactionForce= +function(d){if(d===undefined)d=0;return new w(d*this.m_impulse.x,d*this.m_impulse.y)};aa.prototype.GetReactionTorque=function(d){if(d===undefined)d=0;return d*this.m_impulse.z};aa.prototype.b2WeldJoint=function(d){this.__super.b2Joint.call(this,d);this.m_localAnchorA.SetV(d.localAnchorA);this.m_localAnchorB.SetV(d.localAnchorB);this.m_referenceAngle=d.referenceAngle;this.m_impulse.SetZero();this.m_mass=new K};aa.prototype.InitVelocityConstraints=function(d){var h,l=0,j=this.m_bodyA,o=this.m_bodyB; +h=j.m_xf.R;var q=this.m_localAnchorA.x-j.m_sweep.localCenter.x,n=this.m_localAnchorA.y-j.m_sweep.localCenter.y;l=h.col1.x*q+h.col2.x*n;n=h.col1.y*q+h.col2.y*n;q=l;h=o.m_xf.R;var a=this.m_localAnchorB.x-o.m_sweep.localCenter.x,c=this.m_localAnchorB.y-o.m_sweep.localCenter.y;l=h.col1.x*a+h.col2.x*c;c=h.col1.y*a+h.col2.y*c;a=l;h=j.m_invMass;l=o.m_invMass;var g=j.m_invI,b=o.m_invI;this.m_mass.col1.x=h+l+n*n*g+c*c*b;this.m_mass.col2.x=-n*q*g-c*a*b;this.m_mass.col3.x=-n*g-c*b;this.m_mass.col1.y=this.m_mass.col2.x; +this.m_mass.col2.y=h+l+q*q*g+a*a*b;this.m_mass.col3.y=q*g+a*b;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=g+b;if(d.warmStarting){this.m_impulse.x*=d.dtRatio;this.m_impulse.y*=d.dtRatio;this.m_impulse.z*=d.dtRatio;j.m_linearVelocity.x-=h*this.m_impulse.x;j.m_linearVelocity.y-=h*this.m_impulse.y;j.m_angularVelocity-=g*(q*this.m_impulse.y-n*this.m_impulse.x+this.m_impulse.z);o.m_linearVelocity.x+=l*this.m_impulse.x;o.m_linearVelocity.y+=l*this.m_impulse.y; +o.m_angularVelocity+=b*(a*this.m_impulse.y-c*this.m_impulse.x+this.m_impulse.z)}else this.m_impulse.SetZero()};aa.prototype.SolveVelocityConstraints=function(){var d,h=0,l=this.m_bodyA,j=this.m_bodyB,o=l.m_linearVelocity,q=l.m_angularVelocity,n=j.m_linearVelocity,a=j.m_angularVelocity,c=l.m_invMass,g=j.m_invMass,b=l.m_invI,e=j.m_invI;d=l.m_xf.R;var f=this.m_localAnchorA.x-l.m_sweep.localCenter.x,m=this.m_localAnchorA.y-l.m_sweep.localCenter.y;h=d.col1.x*f+d.col2.x*m;m=d.col1.y*f+d.col2.y*m;f=h;d= +j.m_xf.R;var r=this.m_localAnchorB.x-j.m_sweep.localCenter.x,s=this.m_localAnchorB.y-j.m_sweep.localCenter.y;h=d.col1.x*r+d.col2.x*s;s=d.col1.y*r+d.col2.y*s;r=h;d=n.x-a*s-o.x+q*m;h=n.y+a*r-o.y-q*f;var v=a-q,t=new A;this.m_mass.Solve33(t,-d,-h,-v);this.m_impulse.Add(t);o.x-=c*t.x;o.y-=c*t.y;q-=b*(f*t.y-m*t.x+t.z);n.x+=g*t.x;n.y+=g*t.y;a+=e*(r*t.y-s*t.x+t.z);l.m_angularVelocity=q;j.m_angularVelocity=a};aa.prototype.SolvePositionConstraints=function(){var d,h=0,l=this.m_bodyA,j=this.m_bodyB;d=l.m_xf.R; +var o=this.m_localAnchorA.x-l.m_sweep.localCenter.x,q=this.m_localAnchorA.y-l.m_sweep.localCenter.y;h=d.col1.x*o+d.col2.x*q;q=d.col1.y*o+d.col2.y*q;o=h;d=j.m_xf.R;var n=this.m_localAnchorB.x-j.m_sweep.localCenter.x,a=this.m_localAnchorB.y-j.m_sweep.localCenter.y;h=d.col1.x*n+d.col2.x*a;a=d.col1.y*n+d.col2.y*a;n=h;d=l.m_invMass;h=j.m_invMass;var c=l.m_invI,g=j.m_invI,b=j.m_sweep.c.x+n-l.m_sweep.c.x-o,e=j.m_sweep.c.y+a-l.m_sweep.c.y-q,f=j.m_sweep.a-l.m_sweep.a-this.m_referenceAngle,m=10*F.b2_linearSlop, +r=Math.sqrt(b*b+e*e),s=y.Abs(f);if(r>m){c*=1;g*=1}this.m_mass.col1.x=d+h+q*q*c+a*a*g;this.m_mass.col2.x=-q*o*c-a*n*g;this.m_mass.col3.x=-q*c-a*g;this.m_mass.col1.y=this.m_mass.col2.x;this.m_mass.col2.y=d+h+o*o*c+n*n*g;this.m_mass.col3.y=o*c+n*g;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=c+g;m=new A;this.m_mass.Solve33(m,-b,-e,-f);l.m_sweep.c.x-=d*m.x;l.m_sweep.c.y-=d*m.y;l.m_sweep.a-=c*(o*m.y-q*m.x+m.z);j.m_sweep.c.x+=h*m.x;j.m_sweep.c.y+=h*m.y; +j.m_sweep.a+=g*(n*m.y-a*m.x+m.z);l.SynchronizeTransform();j.SynchronizeTransform();return r<=F.b2_linearSlop&&s<=F.b2_angularSlop};Box2D.inherit(Z,Box2D.Dynamics.Joints.b2JointDef);Z.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;Z.b2WeldJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new w;this.localAnchorB=new w};Z.prototype.b2WeldJointDef=function(){this.__super.b2JointDef.call(this);this.type=I.e_weldJoint;this.referenceAngle= +0};Z.prototype.Initialize=function(d,h,l){this.bodyA=d;this.bodyB=h;this.localAnchorA.SetV(this.bodyA.GetLocalPoint(l));this.localAnchorB.SetV(this.bodyB.GetLocalPoint(l));this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()}})(); +(function(){var F=Box2D.Dynamics.b2DebugDraw;F.b2DebugDraw=function(){this.m_xformScale=this.m_fillAlpha=this.m_alpha=this.m_lineThickness=this.m_drawScale=1;var G=this;this.m_sprite={graphics:{clear:function(){G.m_ctx.clearRect(0,0,G.m_ctx.canvas.width,G.m_ctx.canvas.height)}}}};F.prototype._color=function(G,K){return"rgba("+((G&16711680)>>16)+","+((G&65280)>>8)+","+(G&255)+","+K+")"};F.prototype.b2DebugDraw=function(){this.m_drawFlags=0};F.prototype.SetFlags=function(G){if(G===undefined)G=0;this.m_drawFlags= +G};F.prototype.GetFlags=function(){return this.m_drawFlags};F.prototype.AppendFlags=function(G){if(G===undefined)G=0;this.m_drawFlags|=G};F.prototype.ClearFlags=function(G){if(G===undefined)G=0;this.m_drawFlags&=~G};F.prototype.SetSprite=function(G){this.m_ctx=G};F.prototype.GetSprite=function(){return this.m_ctx};F.prototype.SetDrawScale=function(G){if(G===undefined)G=0;this.m_drawScale=G};F.prototype.GetDrawScale=function(){return this.m_drawScale};F.prototype.SetLineThickness=function(G){if(G=== +undefined)G=0;this.m_lineThickness=G;this.m_ctx.strokeWidth=G};F.prototype.GetLineThickness=function(){return this.m_lineThickness};F.prototype.SetAlpha=function(G){if(G===undefined)G=0;this.m_alpha=G};F.prototype.GetAlpha=function(){return this.m_alpha};F.prototype.SetFillAlpha=function(G){if(G===undefined)G=0;this.m_fillAlpha=G};F.prototype.GetFillAlpha=function(){return this.m_fillAlpha};F.prototype.SetXFormScale=function(G){if(G===undefined)G=0;this.m_xformScale=G};F.prototype.GetXFormScale=function(){return this.m_xformScale}; +F.prototype.DrawPolygon=function(G,K,y){if(K){var w=this.m_ctx,A=this.m_drawScale;w.beginPath();w.strokeStyle=this._color(y.color,this.m_alpha);w.moveTo(G[0].x*A,G[0].y*A);for(y=1;yf;f++)if(e[f]==b){1==g?delete d[a]:e.splice(f,1);break}}},b.off=b.removeEventListener,b.removeAllEventListeners=function(a){a?(this._listeners&&delete this._listeners[a],this._captureListeners&&delete this._captureListeners[a]):this._listeners=this._captureListeners=null},b.dispatchEvent=function(a,b){if("string"==typeof a){var c=this._listeners;if(!c||!c[a])return!1;a=new createjs.Event(a)}if(a.target=b||this,a.bubbles&&this.parent){for(var d=this,e=[d];d.parent;)e.push(d=d.parent);var f,g=e.length;for(f=g-1;f>=0&&!a.propagationStopped;f--)e[f]._dispatchEvent(a,1+(0==f));for(f=1;g>f&&!a.propagationStopped;f++)e[f]._dispatchEvent(a,3)}else this._dispatchEvent(a,2);return a.defaultPrevented},b.hasEventListener=function(a){var b=this._listeners,c=this._captureListeners;return!!(b&&b[a]||c&&c[a])},b.willTrigger=function(a){for(var b=this;b;){if(b.hasEventListener(a))return!0;b=b.parent}return!1},b.toString=function(){return"[EventDispatcher]"},b._dispatchEvent=function(a,b){var c,d=1==b?this._captureListeners:this._listeners;if(a&&d){var e=d[a.type];if(!e||!(c=e.length))return;a.currentTarget=this,a.eventPhase=b,a.removed=!1,e=e.slice();for(var f=0;c>f&&!a.immediatePropagationStopped;f++){var g=e[f];g.handleEvent?g.handleEvent(a):g(a),a.removed&&(this.off(a.type,g,1==b),a.removed=!1)}}},createjs.EventDispatcher=a}(),this.createjs=this.createjs||{},function(){"use strict";createjs.indexOf=function(a,b){for(var c=0,d=a.length;d>c;c++)if(b===a[c])return c;return-1}}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(){throw"UID cannot be instantiated"};a._nextID=0,a.get=function(){return a._nextID++},createjs.UID=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(){throw"Ticker cannot be instantiated."};a.RAF_SYNCHED="synched",a.RAF="raf",a.TIMEOUT="timeout",a.useRAF=!1,a.timingMode=null,a.maxDelta=0,a.removeEventListener=null,a.removeAllEventListeners=null,a.dispatchEvent=null,a.hasEventListener=null,a._listeners=null,createjs.EventDispatcher.initialize(a),a._addEventListener=a.addEventListener,a.addEventListener=function(){return!a._inited&&a.init(),a._addEventListener.apply(a,arguments)},a._paused=!1,a._inited=!1,a._startTime=0,a._pausedTime=0,a._ticks=0,a._pausedTicks=0,a._interval=50,a._lastTime=0,a._times=null,a._tickTimes=null,a._timerId=null,a._raf=!0,a.init=function(){a._inited||(a._inited=!0,a._times=[],a._tickTimes=[],a._startTime=a._getTime(),a._times.push(a._lastTime=0),a.setInterval(a._interval))},a.reset=function(){if(a._raf){var b=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame;b&&b(a._timerId)}else clearTimeout(a._timerId);a.removeAllEventListeners("tick")},a.setInterval=function(b){a._interval=b,a._inited&&a._setupTick()},a.getInterval=function(){return a._interval},a.setFPS=function(b){a.setInterval(1e3/b)},a.getFPS=function(){return 1e3/a._interval},a.getMeasuredTickTime=function(b){var c=0,d=a._tickTimes;if(d.length<1)return-1;b=Math.min(d.length,b||0|a.getFPS());for(var e=0;b>e;e++)c+=d[e];return c/b},a.getMeasuredFPS=function(b){var c=a._times;return c.length<2?-1:(b=Math.min(c.length-1,b||0|a.getFPS()),1e3/((c[0]-c[b])/b))},a.setPaused=function(b){a._paused=b},a.getPaused=function(){return a._paused},a.getTime=function(b){return a._getTime()-a._startTime-(b?a._pausedTime:0)},a.getEventTime=function(b){return(a._lastTime||a._startTime)-(b?a._pausedTime:0)},a.getTicks=function(b){return a._ticks-(b?a._pausedTicks:0)},a._handleSynch=function(){var b=a._getTime()-a._startTime;a._timerId=null,a._setupTick(),b-a._lastTime>=.97*(a._interval-1)&&a._tick()},a._handleRAF=function(){a._timerId=null,a._setupTick(),a._tick()},a._handleTimeout=function(){a._timerId=null,a._setupTick(),a._tick()},a._setupTick=function(){if(null==a._timerId){var b=a.timingMode||a.useRAF&&a.RAF_SYNCHED;if(b==a.RAF_SYNCHED||b==a.RAF){var c=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(c)return a._timerId=c(b==a.RAF?a._handleRAF:a._handleSynch),a._raf=!0,void 0}a._raf=!1,a._timerId=setTimeout(a._handleTimeout,a._interval)}},a._tick=function(){var b=a._getTime()-a._startTime,c=b-a._lastTime,d=a._paused;if(a._ticks++,d&&(a._pausedTicks++,a._pausedTime+=c),a._lastTime=b,a.hasEventListener("tick")){var e=new createjs.Event("tick"),f=a.maxDelta;e.delta=f&&c>f?f:c,e.paused=d,e.time=b,e.runTime=b-a._pausedTime,a.dispatchEvent(e)}for(a._tickTimes.unshift(a._getTime()-b);a._tickTimes.length>100;)a._tickTimes.pop();for(a._times.unshift(b);a._times.length>100;)a._times.pop()};var b=window.performance&&(performance.now||performance.mozNow||performance.msNow||performance.oNow||performance.webkitNow);a._getTime=function(){return b&&b.call(performance)||(new Date).getTime()},createjs.Ticker=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b,c,d,e,f,g,h,i,j){this.initialize(a,b,c,d,e,f,g,h,i,j)},b=a.prototype=new createjs.Event;b.stageX=0,b.stageY=0,b.rawX=0,b.rawY=0,b.nativeEvent=null,b.pointerID=0,b.primary=!1,b.addEventListener=null,b.removeEventListener=null,b.removeAllEventListeners=null,b.dispatchEvent=null,b.hasEventListener=null,b._listeners=null,createjs.EventDispatcher.initialize(b),b._get_localX=function(){return this.currentTarget.globalToLocal(this.rawX,this.rawY).x},b._get_localY=function(){return this.currentTarget.globalToLocal(this.rawX,this.rawY).y};try{Object.defineProperties(b,{localX:{get:b._get_localX},localY:{get:b._get_localY}})}catch(c){}b.Event_initialize=b.initialize,b.initialize=function(a,b,c,d,e,f,g,h,i,j){this.Event_initialize(a,b,c),this.stageX=d,this.stageY=e,this.nativeEvent=f,this.pointerID=g,this.primary=h,this.rawX=null==i?d:i,this.rawY=null==j?e:j},b.clone=function(){return new a(this.type,this.bubbles,this.cancelable,this.stageX,this.stageY,this.target,this.nativeEvent,this.pointerID,this.primary,this.rawX,this.rawY)},b.toString=function(){return"[MouseEvent (type="+this.type+" stageX="+this.stageX+" stageY="+this.stageY+")]"},createjs.MouseEvent=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b,c,d,e,f){this.initialize(a,b,c,d,e,f)},b=a.prototype;a.identity=null,a.DEG_TO_RAD=Math.PI/180,b.a=1,b.b=0,b.c=0,b.d=1,b.tx=0,b.ty=0,b.alpha=1,b.shadow=null,b.compositeOperation=null,b.initialize=function(a,b,c,d,e,f){return this.a=null==a?1:a,this.b=b||0,this.c=c||0,this.d=null==d?1:d,this.tx=e||0,this.ty=f||0,this},b.prepend=function(a,b,c,d,e,f){var g=this.tx;if(1!=a||0!=b||0!=c||1!=d){var h=this.a,i=this.c;this.a=h*a+this.b*c,this.b=h*b+this.b*d,this.c=i*a+this.d*c,this.d=i*b+this.d*d}return this.tx=g*a+this.ty*c+e,this.ty=g*b+this.ty*d+f,this},b.append=function(a,b,c,d,e,f){var g=this.a,h=this.b,i=this.c,j=this.d;return this.a=a*g+b*i,this.b=a*h+b*j,this.c=c*g+d*i,this.d=c*h+d*j,this.tx=e*g+f*i+this.tx,this.ty=e*h+f*j+this.ty,this},b.prependMatrix=function(a){return this.prepend(a.a,a.b,a.c,a.d,a.tx,a.ty),this.prependProperties(a.alpha,a.shadow,a.compositeOperation),this},b.appendMatrix=function(a){return this.append(a.a,a.b,a.c,a.d,a.tx,a.ty),this.appendProperties(a.alpha,a.shadow,a.compositeOperation),this},b.prependTransform=function(b,c,d,e,f,g,h,i,j){if(f%360)var k=f*a.DEG_TO_RAD,l=Math.cos(k),m=Math.sin(k);else l=1,m=0;return(i||j)&&(this.tx-=i,this.ty-=j),g||h?(g*=a.DEG_TO_RAD,h*=a.DEG_TO_RAD,this.prepend(l*d,m*d,-m*e,l*e,0,0),this.prepend(Math.cos(h),Math.sin(h),-Math.sin(g),Math.cos(g),b,c)):this.prepend(l*d,m*d,-m*e,l*e,b,c),this},b.appendTransform=function(b,c,d,e,f,g,h,i,j){if(f%360)var k=f*a.DEG_TO_RAD,l=Math.cos(k),m=Math.sin(k);else l=1,m=0;return g||h?(g*=a.DEG_TO_RAD,h*=a.DEG_TO_RAD,this.append(Math.cos(h),Math.sin(h),-Math.sin(g),Math.cos(g),b,c),this.append(l*d,m*d,-m*e,l*e,0,0)):this.append(l*d,m*d,-m*e,l*e,b,c),(i||j)&&(this.tx-=i*this.a+j*this.c,this.ty-=i*this.b+j*this.d),this},b.rotate=function(a){var b=Math.cos(a),c=Math.sin(a),d=this.a,e=this.c,f=this.tx;return this.a=d*b-this.b*c,this.b=d*c+this.b*b,this.c=e*b-this.d*c,this.d=e*c+this.d*b,this.tx=f*b-this.ty*c,this.ty=f*c+this.ty*b,this},b.skew=function(b,c){return b*=a.DEG_TO_RAD,c*=a.DEG_TO_RAD,this.append(Math.cos(c),Math.sin(c),-Math.sin(b),Math.cos(b),0,0),this},b.scale=function(a,b){return this.a*=a,this.d*=b,this.c*=a,this.b*=b,this.tx*=a,this.ty*=b,this},b.translate=function(a,b){return this.tx+=a,this.ty+=b,this},b.identity=function(){return this.alpha=this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this.shadow=this.compositeOperation=null,this},b.invert=function(){var a=this.a,b=this.b,c=this.c,d=this.d,e=this.tx,f=a*d-b*c;return this.a=d/f,this.b=-b/f,this.c=-c/f,this.d=a/f,this.tx=(c*this.ty-d*e)/f,this.ty=-(a*this.ty-b*e)/f,this},b.isIdentity=function(){return 0==this.tx&&0==this.ty&&1==this.a&&0==this.b&&0==this.c&&1==this.d},b.transformPoint=function(a,b,c){return c=c||{},c.x=a*this.a+b*this.c+this.tx,c.y=a*this.b+b*this.d+this.ty,c},b.decompose=function(b){null==b&&(b={}),b.x=this.tx,b.y=this.ty,b.scaleX=Math.sqrt(this.a*this.a+this.b*this.b),b.scaleY=Math.sqrt(this.c*this.c+this.d*this.d);var c=Math.atan2(-this.c,this.d),d=Math.atan2(this.b,this.a);return c==d?(b.rotation=d/a.DEG_TO_RAD,this.a<0&&this.d>=0&&(b.rotation+=b.rotation<=0?180:-180),b.skewX=b.skewY=0):(b.skewX=c/a.DEG_TO_RAD,b.skewY=d/a.DEG_TO_RAD),b},b.reinitialize=function(a,b,c,d,e,f,g,h,i){return this.initialize(a,b,c,d,e,f),this.alpha=null==g?1:g,this.shadow=h,this.compositeOperation=i,this},b.copy=function(a){return this.reinitialize(a.a,a.b,a.c,a.d,a.tx,a.ty,a.alpha,a.shadow,a.compositeOperation)},b.appendProperties=function(a,b,c){return this.alpha*=a,this.shadow=b||this.shadow,this.compositeOperation=c||this.compositeOperation,this},b.prependProperties=function(a,b,c){return this.alpha*=a,this.shadow=this.shadow||b,this.compositeOperation=this.compositeOperation||c,this},b.clone=function(){return(new a).copy(this)},b.toString=function(){return"[Matrix2D (a="+this.a+" b="+this.b+" c="+this.c+" d="+this.d+" tx="+this.tx+" ty="+this.ty+")]"},a.identity=new a,createjs.Matrix2D=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b){this.initialize(a,b)},b=a.prototype;b.x=0,b.y=0,b.initialize=function(a,b){return this.x=null==a?0:a,this.y=null==b?0:b,this},b.copy=function(a){return this.initialize(a.x,a.y)},b.clone=function(){return new a(this.x,this.y)},b.toString=function(){return"[Point (x="+this.x+" y="+this.y+")]"},createjs.Point=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b,c,d){this.initialize(a,b,c,d)},b=a.prototype;b.x=0,b.y=0,b.width=0,b.height=0,b.initialize=function(a,b,c,d){return this.x=a||0,this.y=b||0,this.width=c||0,this.height=d||0,this},b.copy=function(a){return this.initialize(a.x,a.y,a.width,a.height)},b.clone=function(){return new a(this.x,this.y,this.width,this.height)},b.toString=function(){return"[Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")]"},createjs.Rectangle=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b,c,d,e,f,g){this.initialize(a,b,c,d,e,f,g)},b=a.prototype;b.target=null,b.overLabel=null,b.outLabel=null,b.downLabel=null,b.play=!1,b._isPressed=!1,b._isOver=!1,b.initialize=function(a,b,c,d,e,f,g){a.addEventListener&&(this.target=a,a.cursor="pointer",this.overLabel=null==c?"over":c,this.outLabel=null==b?"out":b,this.downLabel=null==d?"down":d,this.play=e,this.setEnabled(!0),this.handleEvent({}),f&&(g&&(f.actionsEnabled=!1,f.gotoAndStop&&f.gotoAndStop(g)),a.hitArea=f))},b.setEnabled=function(a){var b=this.target;a?(b.addEventListener("rollover",this),b.addEventListener("rollout",this),b.addEventListener("mousedown",this),b.addEventListener("pressup",this)):(b.removeEventListener("rollover",this),b.removeEventListener("rollout",this),b.removeEventListener("mousedown",this),b.removeEventListener("pressup",this))},b.toString=function(){return"[ButtonHelper]"},b.handleEvent=function(a){var b,c=this.target,d=a.type;"mousedown"==d?(this._isPressed=!0,b=this.downLabel):"pressup"==d?(this._isPressed=!1,b=this._isOver?this.overLabel:this.outLabel):"rollover"==d?(this._isOver=!0,b=this._isPressed?this.downLabel:this.overLabel):(this._isOver=!1,b=this._isPressed?this.overLabel:this.outLabel),this.play?c.gotoAndPlay&&c.gotoAndPlay(b):c.gotoAndStop&&c.gotoAndStop(b)},createjs.ButtonHelper=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b,c,d){this.initialize(a,b,c,d)},b=a.prototype;a.identity=null,b.color=null,b.offsetX=0,b.offsetY=0,b.blur=0,b.initialize=function(a,b,c,d){this.color=a,this.offsetX=b,this.offsetY=c,this.blur=d},b.toString=function(){return"[Shadow]"},b.clone=function(){return new a(this.color,this.offsetX,this.offsetY,this.blur)},a.identity=new a("transparent",0,0,0),createjs.Shadow=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a){this.initialize(a)},b=a.prototype=new createjs.EventDispatcher;b.complete=!0,b.framerate=0,b._animations=null,b._frames=null,b._images=null,b._data=null,b._loadCount=0,b._frameHeight=0,b._frameWidth=0,b._numFrames=0,b._regX=0,b._regY=0,b.initialize=function(a){var b,c,d,e;if(null!=a){if(this.framerate=a.framerate||0,a.images&&(c=a.images.length)>0)for(e=this._images=[],b=0;c>b;b++){var f=a.images[b];if("string"==typeof f){var g=f;f=document.createElement("img"),f.src=g}e.push(f),f.getContext||f.complete||(this._loadCount++,this.complete=!1,function(a){f.onload=function(){a._handleImageLoad()}}(this))}if(null==a.frames);else if(a.frames instanceof Array)for(this._frames=[],e=a.frames,b=0,c=e.length;c>b;b++){var h=e[b];this._frames.push({image:this._images[h[4]?h[4]:0],rect:new createjs.Rectangle(h[0],h[1],h[2],h[3]),regX:h[5]||0,regY:h[6]||0})}else d=a.frames,this._frameWidth=d.width,this._frameHeight=d.height,this._regX=d.regX||0,this._regY=d.regY||0,this._numFrames=d.count,0==this._loadCount&&this._calculateFrames();if(this._animations=[],null!=(d=a.animations)){this._data={};var i;for(i in d){var j={name:i},k=d[i];if("number"==typeof k)e=j.frames=[k];else if(k instanceof Array)if(1==k.length)j.frames=[k[0]];else for(j.speed=k[3],j.next=k[2],e=j.frames=[],b=k[0];b<=k[1];b++)e.push(b);else{j.speed=k.speed,j.next=k.next;var l=k.frames;e=j.frames="number"==typeof l?[l]:l.slice(0)}(j.next===!0||void 0===j.next)&&(j.next=i),(j.next===!1||e.length<2&&j.next==i)&&(j.next=null),j.speed||(j.speed=1),this._animations.push(i),this._data[i]=j}}}},b.getNumFrames=function(a){if(null==a)return this._frames?this._frames.length:this._numFrames;var b=this._data[a];return null==b?0:b.frames.length},b.getAnimations=function(){return this._animations.slice(0)},b.getAnimation=function(a){return this._data[a]},b.getFrame=function(a){var b;return this._frames&&(b=this._frames[a])?b:null},b.getFrameBounds=function(a,b){var c=this.getFrame(a);return c?(b||new createjs.Rectangle).initialize(-c.regX,-c.regY,c.rect.width,c.rect.height):null},b.toString=function(){return"[SpriteSheet]"},b.clone=function(){var b=new a;return b.complete=this.complete,b._animations=this._animations,b._frames=this._frames,b._images=this._images,b._data=this._data,b._frameHeight=this._frameHeight,b._frameWidth=this._frameWidth,b._numFrames=this._numFrames,b._loadCount=this._loadCount,b},b._handleImageLoad=function(){0==--this._loadCount&&(this._calculateFrames(),this.complete=!0,this.dispatchEvent("complete"))},b._calculateFrames=function(){if(!this._frames&&0!=this._frameWidth){this._frames=[];for(var a=0,b=this._frameWidth,c=this._frameHeight,d=0,e=this._images;d0?Math.min(this._numFrames-a,g*h):g*h,j=0;i>j;j++)this._frames.push({image:f,rect:new createjs.Rectangle(j%g*b,(0|j/g)*c,b,c),regX:this._regX,regY:this._regY});a+=i}this._numFrames=a}},createjs.SpriteSheet=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c){this.f=a,this.params=b,this.path=null==c?!0:c}a.prototype.exec=function(a){this.f.apply(a,this.params)};var b=function(){this.initialize()},c=b.prototype;b.getRGB=function(a,b,c,d){return null!=a&&null==c&&(d=b,c=255&a,b=255&a>>8,a=255&a>>16),null==d?"rgb("+a+","+b+","+c+")":"rgba("+a+","+b+","+c+","+d+")"},b.getHSL=function(a,b,c,d){return null==d?"hsl("+a%360+","+b+"%,"+c+"%)":"hsla("+a%360+","+b+"%,"+c+"%,"+d+")"},b.Command=a,b.BASE_64={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,a:26,b:27,c:28,d:29,e:30,f:31,g:32,h:33,i:34,j:35,k:36,l:37,m:38,n:39,o:40,p:41,q:42,r:43,s:44,t:45,u:46,v:47,w:48,x:49,y:50,z:51,0:52,1:53,2:54,3:55,4:56,5:57,6:58,7:59,8:60,9:61,"+":62,"/":63},b.STROKE_CAPS_MAP=["butt","round","square"],b.STROKE_JOINTS_MAP=["miter","round","bevel"];var d=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");if(d.getContext){var e=b._ctx=d.getContext("2d");b.beginCmd=new a(e.beginPath,[],!1),b.fillCmd=new a(e.fill,[],!1),b.strokeCmd=new a(e.stroke,[],!1),d.width=d.height=1}c._strokeInstructions=null,c._strokeStyleInstructions=null,c._strokeIgnoreScale=!1,c._fillInstructions=null,c._fillMatrix=null,c._instructions=null,c._oldInstructions=null,c._activeInstructions=null,c._active=!1,c._dirty=!1,c.initialize=function(){this.clear(),this._ctx=b._ctx},c.isEmpty=function(){return!(this._instructions.length||this._oldInstructions.length||this._activeInstructions.length)},c.draw=function(a){this._dirty&&this._updateInstructions();for(var b=this._instructions,c=0,d=b.length;d>c;c++)b[c].exec(a)},c.drawAsPath=function(a){this._dirty&&this._updateInstructions();for(var b,c=this._instructions,d=0,e=c.length;e>d;d++)((b=c[d]).path||0==d)&&b.exec(a)},c.moveTo=function(b,c){return this._activeInstructions.push(new a(this._ctx.moveTo,[b,c])),this},c.lineTo=function(b,c){return this._dirty=this._active=!0,this._activeInstructions.push(new a(this._ctx.lineTo,[b,c])),this},c.arcTo=function(b,c,d,e,f){return this._dirty=this._active=!0,this._activeInstructions.push(new a(this._ctx.arcTo,[b,c,d,e,f])),this},c.arc=function(b,c,d,e,f,g){return this._dirty=this._active=!0,null==g&&(g=!1),this._activeInstructions.push(new a(this._ctx.arc,[b,c,d,e,f,g])),this},c.quadraticCurveTo=function(b,c,d,e){return this._dirty=this._active=!0,this._activeInstructions.push(new a(this._ctx.quadraticCurveTo,[b,c,d,e])),this},c.bezierCurveTo=function(b,c,d,e,f,g){return this._dirty=this._active=!0,this._activeInstructions.push(new a(this._ctx.bezierCurveTo,[b,c,d,e,f,g])),this},c.rect=function(b,c,d,e){return this._dirty=this._active=!0,this._activeInstructions.push(new a(this._ctx.rect,[b,c,d,e])),this},c.closePath=function(){return this._active&&(this._dirty=!0,this._activeInstructions.push(new a(this._ctx.closePath,[]))),this},c.clear=function(){return this._instructions=[],this._oldInstructions=[],this._activeInstructions=[],this._strokeStyleInstructions=this._strokeInstructions=this._fillInstructions=this._fillMatrix=null,this._active=this._dirty=this._strokeIgnoreScale=!1,this},c.beginFill=function(b){return this._active&&this._newPath(),this._fillInstructions=b?[new a(this._setProp,["fillStyle",b],!1)]:null,this._fillMatrix=null,this},c.beginLinearGradientFill=function(b,c,d,e,f,g){this._active&&this._newPath();for(var h=this._ctx.createLinearGradient(d,e,f,g),i=0,j=b.length;j>i;i++)h.addColorStop(c[i],b[i]);return this._fillInstructions=[new a(this._setProp,["fillStyle",h],!1)],this._fillMatrix=null,this},c.beginRadialGradientFill=function(b,c,d,e,f,g,h,i){this._active&&this._newPath();for(var j=this._ctx.createRadialGradient(d,e,f,g,h,i),k=0,l=b.length;l>k;k++)j.addColorStop(c[k],b[k]);return this._fillInstructions=[new a(this._setProp,["fillStyle",j],!1)],this._fillMatrix=null,this},c.beginBitmapFill=function(b,c,d){this._active&&this._newPath(),c=c||"";var e=this._ctx.createPattern(b,c);return this._fillInstructions=[new a(this._setProp,["fillStyle",e],!1)],this._fillMatrix=d?[d.a,d.b,d.c,d.d,d.tx,d.ty]:null,this},c.endFill=function(){return this.beginFill()},c.setStrokeStyle=function(c,d,e,f,g){return this._active&&this._newPath(),this._strokeStyleInstructions=[new a(this._setProp,["lineWidth",null==c?"1":c],!1),new a(this._setProp,["lineCap",null==d?"butt":isNaN(d)?d:b.STROKE_CAPS_MAP[d]],!1),new a(this._setProp,["lineJoin",null==e?"miter":isNaN(e)?e:b.STROKE_JOINTS_MAP[e]],!1),new a(this._setProp,["miterLimit",null==f?"10":f],!1)],this._strokeIgnoreScale=g,this},c.beginStroke=function(b){return this._active&&this._newPath(),this._strokeInstructions=b?[new a(this._setProp,["strokeStyle",b],!1)]:null,this},c.beginLinearGradientStroke=function(b,c,d,e,f,g){this._active&&this._newPath();for(var h=this._ctx.createLinearGradient(d,e,f,g),i=0,j=b.length;j>i;i++)h.addColorStop(c[i],b[i]);return this._strokeInstructions=[new a(this._setProp,["strokeStyle",h],!1)],this},c.beginRadialGradientStroke=function(b,c,d,e,f,g,h,i){this._active&&this._newPath();for(var j=this._ctx.createRadialGradient(d,e,f,g,h,i),k=0,l=b.length;l>k;k++)j.addColorStop(c[k],b[k]);return this._strokeInstructions=[new a(this._setProp,["strokeStyle",j],!1)],this},c.beginBitmapStroke=function(b,c){this._active&&this._newPath(),c=c||"";var d=this._ctx.createPattern(b,c);return this._strokeInstructions=[new a(this._setProp,["strokeStyle",d],!1)],this},c.endStroke=function(){return this.beginStroke(),this},c.curveTo=c.quadraticCurveTo,c.drawRect=c.rect,c.drawRoundRect=function(a,b,c,d,e){return this.drawRoundRectComplex(a,b,c,d,e,e,e,e),this},c.drawRoundRectComplex=function(b,c,d,e,f,g,h,i){var j=(e>d?d:e)/2,k=0,l=0,m=0,n=0;0>f&&(f*=k=-1),f>j&&(f=j),0>g&&(g*=l=-1),g>j&&(g=j),0>h&&(h*=m=-1),h>j&&(h=j),0>i&&(i*=n=-1),i>j&&(i=j),this._dirty=this._active=!0;var o=this._ctx.arcTo,p=this._ctx.lineTo;return this._activeInstructions.push(new a(this._ctx.moveTo,[b+d-g,c]),new a(o,[b+d+g*l,c-g*l,b+d,c+g,g]),new a(p,[b+d,c+e-h]),new a(o,[b+d+h*m,c+e+h*m,b+d-h,c+e,h]),new a(p,[b+i,c+e]),new a(o,[b-i*n,c+e+i*n,b,c+e-i,i]),new a(p,[b,c+f]),new a(o,[b-f*k,c-f*k,b+f,c,f]),new a(this._ctx.closePath)),this},c.drawCircle=function(a,b,c){return this.arc(a,b,c,0,2*Math.PI),this},c.drawEllipse=function(b,c,d,e){this._dirty=this._active=!0;var f=.5522848,g=d/2*f,h=e/2*f,i=b+d,j=c+e,k=b+d/2,l=c+e/2;return this._activeInstructions.push(new a(this._ctx.moveTo,[b,l]),new a(this._ctx.bezierCurveTo,[b,l-h,k-g,c,k,c]),new a(this._ctx.bezierCurveTo,[k+g,c,i,l-h,i,l]),new a(this._ctx.bezierCurveTo,[i,l+h,k+g,j,k,j]),new a(this._ctx.bezierCurveTo,[k-g,j,b,l+h,b,l])),this},c.inject=function(b,c){return this._dirty=this._active=!0,this._activeInstructions.push(new a(b,[c])),this},c.drawPolyStar=function(b,c,d,e,f,g){this._dirty=this._active=!0,null==f&&(f=0),f=1-f,null==g?g=0:g/=180/Math.PI;var h=Math.PI/e;this._activeInstructions.push(new a(this._ctx.moveTo,[b+Math.cos(g)*d,c+Math.sin(g)*d]));for(var i=0;e>i;i++)g+=h,1!=f&&this._activeInstructions.push(new a(this._ctx.lineTo,[b+Math.cos(g)*d*f,c+Math.sin(g)*d*f])),g+=h,this._activeInstructions.push(new a(this._ctx.lineTo,[b+Math.cos(g)*d,c+Math.sin(g)*d]));return this},c.decodePath=function(a){for(var c=[this.moveTo,this.lineTo,this.quadraticCurveTo,this.bezierCurveTo,this.closePath],d=[2,2,4,6,0],e=0,f=a.length,g=[],h=0,i=0,j=b.BASE_64;f>e;){var k=a.charAt(e),l=j[k],m=l>>3,n=c[m];if(!n||3&l)throw"bad path data (@"+e+"): "+k;var o=d[m];m||(h=i=0),g.length=0,e++;for(var p=(1&l>>2)+2,q=0;o>q;q++){var r=j[a.charAt(e)],s=r>>5?-1:1;r=(31&r)<<6|j[a.charAt(e+1)],3==p&&(r=r<<6|j[a.charAt(e+2)]),r=s*r/10,q%2?h=r+=h:i=r+=i,g[q]=r,e+=p}n.apply(this,g)}return this},c.clone=function(){var a=new b;return a._instructions=this._instructions.slice(),a._activeInstructions=this._activeInstructions.slice(),a._oldInstructions=this._oldInstructions.slice(),this._fillInstructions&&(a._fillInstructions=this._fillInstructions.slice()),this._strokeInstructions&&(a._strokeInstructions=this._strokeInstructions.slice()),this._strokeStyleInstructions&&(a._strokeStyleInstructions=this._strokeStyleInstructions.slice()),a._active=this._active,a._dirty=this._dirty,a._fillMatrix=this._fillMatrix,a._strokeIgnoreScale=this._strokeIgnoreScale,a},c.toString=function(){return"[Graphics]"},c.mt=c.moveTo,c.lt=c.lineTo,c.at=c.arcTo,c.bt=c.bezierCurveTo,c.qt=c.quadraticCurveTo,c.a=c.arc,c.r=c.rect,c.cp=c.closePath,c.c=c.clear,c.f=c.beginFill,c.lf=c.beginLinearGradientFill,c.rf=c.beginRadialGradientFill,c.bf=c.beginBitmapFill,c.ef=c.endFill,c.ss=c.setStrokeStyle,c.s=c.beginStroke,c.ls=c.beginLinearGradientStroke,c.rs=c.beginRadialGradientStroke,c.bs=c.beginBitmapStroke,c.es=c.endStroke,c.dr=c.drawRect,c.rr=c.drawRoundRect,c.rc=c.drawRoundRectComplex,c.dc=c.drawCircle,c.de=c.drawEllipse,c.dp=c.drawPolyStar,c.p=c.decodePath,c._updateInstructions=function(){this._instructions=this._oldInstructions.slice(),this._instructions.push(b.beginCmd),this._appendInstructions(this._fillInstructions),this._appendInstructions(this._strokeInstructions),this._appendInstructions(this._strokeInstructions&&this._strokeStyleInstructions),this._appendInstructions(this._activeInstructions),this._fillInstructions&&this._appendDraw(b.fillCmd,this._fillMatrix),this._strokeInstructions&&this._appendDraw(b.strokeCmd,this._strokeIgnoreScale&&[1,0,0,1,0,0])},c._appendInstructions=function(a){a&&this._instructions.push.apply(this._instructions,a)},c._appendDraw=function(b,c){c?this._instructions.push(new a(this._ctx.save,[],!1),new a(this._ctx.transform,c,!1),b,new a(this._ctx.restore,[],!1)):this._instructions.push(b)},c._newPath=function(){this._dirty&&this._updateInstructions(),this._oldInstructions=this._instructions,this._activeInstructions=[],this._active=this._dirty=!1},c._setProp=function(a,b){this[a]=b},createjs.Graphics=b}(),this.createjs=this.createjs||{},function(){var a=function(){this.initialize()},b=a.prototype=new createjs.EventDispatcher;a._MOUSE_EVENTS=["click","dblclick","mousedown","mouseout","mouseover","pressmove","pressup","rollout","rollover"],a.suppressCrossDomainErrors=!1;var c=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");c.getContext&&(a._hitTestCanvas=c,a._hitTestContext=c.getContext("2d"),c.width=c.height=1),a._nextCacheID=1,b.alpha=1,b.cacheCanvas=null,b.id=-1,b.mouseEnabled=!0,b.tickEnabled=!0,b.name=null,b.parent=null,b.regX=0,b.regY=0,b.rotation=0,b.scaleX=1,b.scaleY=1,b.skewX=0,b.skewY=0,b.shadow=null,b.visible=!0,b.x=0,b.y=0,b.compositeOperation=null,b.snapToPixel=!1,b.filters=null,b.cacheID=0,b.mask=null,b.hitArea=null,b.cursor=null,b._cacheOffsetX=0,b._cacheOffsetY=0,b._cacheScale=1,b._cacheDataURLID=0,b._cacheDataURL=null,b._matrix=null,b._rectangle=null,b._bounds=null,b.initialize=function(){this.id=createjs.UID.get(),this._matrix=new createjs.Matrix2D,this._rectangle=new createjs.Rectangle},b.isVisible=function(){return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY)},b.draw=function(a,b){var c=this.cacheCanvas;if(b||!c)return!1;var d,e=this._cacheScale,f=this._cacheOffsetX,g=this._cacheOffsetY;return(d=this._applyFilterBounds(f,g,0,0))&&(f=d.x,g=d.y),a.drawImage(c,f,g,c.width/e,c.height/e),!0},b.updateContext=function(a){var b,c=this.mask,d=this;c&&c.graphics&&!c.graphics.isEmpty()&&(b=c.getMatrix(c._matrix),a.transform(b.a,b.b,b.c,b.d,b.tx,b.ty),c.graphics.drawAsPath(a),a.clip(),b.invert(),a.transform(b.a,b.b,b.c,b.d,b.tx,b.ty)),b=d._matrix.identity().appendTransform(d.x,d.y,d.scaleX,d.scaleY,d.rotation,d.skewX,d.skewY,d.regX,d.regY),createjs.Stage._snapToPixelEnabled&&d.snapToPixel?a.transform(b.a,b.b,b.c,b.d,0|b.tx+.5,0|b.ty+.5):a.transform(b.a,b.b,b.c,b.d,b.tx,b.ty),a.globalAlpha*=d.alpha,d.compositeOperation&&(a.globalCompositeOperation=d.compositeOperation),d.shadow&&this._applyShadow(a,d.shadow)},b.cache=function(a,b,c,d,e){e=e||1,this.cacheCanvas||(this.cacheCanvas=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas")),this._cacheWidth=c,this._cacheHeight=d,this._cacheOffsetX=a,this._cacheOffsetY=b,this._cacheScale=e,this.updateCache()},b.updateCache=function(b){var c,d=this.cacheCanvas,e=this._cacheScale,f=this._cacheOffsetX*e,g=this._cacheOffsetY*e,h=this._cacheWidth,i=this._cacheHeight;if(!d)throw"cache() must be called before updateCache()";var j=d.getContext("2d");(c=this._applyFilterBounds(f,g,h,i))&&(f=c.x,g=c.y,h=c.width,i=c.height),h=Math.ceil(h*e),i=Math.ceil(i*e),h!=d.width||i!=d.height?(d.width=h,d.height=i):b||j.clearRect(0,0,h+1,i+1),j.save(),j.globalCompositeOperation=b,j.setTransform(e,0,0,e,-f,-g),this.draw(j,!0),this._applyFilters(),j.restore(),this.cacheID=a._nextCacheID++},b.uncache=function(){this._cacheDataURL=this.cacheCanvas=null,this.cacheID=this._cacheOffsetX=this._cacheOffsetY=0,this._cacheScale=1},b.getCacheDataURL=function(){return this.cacheCanvas?(this.cacheID!=this._cacheDataURLID&&(this._cacheDataURL=this.cacheCanvas.toDataURL()),this._cacheDataURL):null},b.getStage=function(){for(var a=this;a.parent;)a=a.parent;return a instanceof createjs.Stage?a:null},b.localToGlobal=function(a,b){var c=this.getConcatenatedMatrix(this._matrix);return null==c?null:(c.append(1,0,0,1,a,b),new createjs.Point(c.tx,c.ty))},b.globalToLocal=function(a,b){var c=this.getConcatenatedMatrix(this._matrix);return null==c?null:(c.invert(),c.append(1,0,0,1,a,b),new createjs.Point(c.tx,c.ty))},b.localToLocal=function(a,b,c){var d=this.localToGlobal(a,b);return c.globalToLocal(d.x,d.y)},b.setTransform=function(a,b,c,d,e,f,g,h,i){return this.x=a||0,this.y=b||0,this.scaleX=null==c?1:c,this.scaleY=null==d?1:d,this.rotation=e||0,this.skewX=f||0,this.skewY=g||0,this.regX=h||0,this.regY=i||0,this},b.getMatrix=function(a){var b=this;return(a?a.identity():new createjs.Matrix2D).appendTransform(b.x,b.y,b.scaleX,b.scaleY,b.rotation,b.skewX,b.skewY,b.regX,b.regY).appendProperties(b.alpha,b.shadow,b.compositeOperation)},b.getConcatenatedMatrix=function(a){a?a.identity():a=new createjs.Matrix2D;for(var b=this;null!=b;)a.prependTransform(b.x,b.y,b.scaleX,b.scaleY,b.rotation,b.skewX,b.skewY,b.regX,b.regY).prependProperties(b.alpha,b.shadow,b.compositeOperation),b=b.parent;return a},b.hitTest=function(b,c){var d=a._hitTestContext;d.setTransform(1,0,0,1,-b,-c),this.draw(d); +var e=this._testHit(d);return d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,2,2),e},b.set=function(a){for(var b in a)this[b]=a[b];return this},b.getBounds=function(){if(this._bounds)return this._rectangle.copy(this._bounds);var a=this.cacheCanvas;if(a){var b=this._cacheScale;return this._rectangle.initialize(this._cacheOffsetX,this._cacheOffsetY,a.width/b,a.height/b)}return null},b.getTransformedBounds=function(){return this._getBounds()},b.setBounds=function(a,b,c,d){null==a&&(this._bounds=a),this._bounds=(this._bounds||new createjs.Rectangle).initialize(a,b,c,d)},b.clone=function(){var b=new a;return this.cloneProps(b),b},b.toString=function(){return"[DisplayObject (name="+this.name+")]"},b.cloneProps=function(a){a.alpha=this.alpha,a.name=this.name,a.regX=this.regX,a.regY=this.regY,a.rotation=this.rotation,a.scaleX=this.scaleX,a.scaleY=this.scaleY,a.shadow=this.shadow,a.skewX=this.skewX,a.skewY=this.skewY,a.visible=this.visible,a.x=this.x,a.y=this.y,a._bounds=this._bounds,a.mouseEnabled=this.mouseEnabled,a.compositeOperation=this.compositeOperation},b._applyShadow=function(a,b){b=b||Shadow.identity,a.shadowColor=b.color,a.shadowOffsetX=b.offsetX,a.shadowOffsetY=b.offsetY,a.shadowBlur=b.blur},b._tick=function(a){var b=this._listeners;if(b&&b.tick){var c=new createjs.Event("tick");c.params=a,this._dispatchEvent(c,this,2)}},b._testHit=function(b){try{var c=b.getImageData(0,0,1,1).data[3]>1}catch(d){if(!a.suppressCrossDomainErrors)throw"An error has occurred. This is most likely due to security restrictions on reading canvas pixel data with local or cross-domain images."}return c},b._applyFilters=function(){if(this.filters&&0!=this.filters.length&&this.cacheCanvas)for(var a=this.filters.length,b=this.cacheCanvas.getContext("2d"),c=this.cacheCanvas.width,d=this.cacheCanvas.height,e=0;a>e;e++)this.filters[e].applyFilter(b,0,0,c,d)},b._applyFilterBounds=function(a,b,c,d){var e,f,g=this.filters;if(!g||!(f=g.length))return null;for(var h=0;f>h;h++){var i=this.filters[h],j=i.getBounds&&i.getBounds();j&&(e||(e=this._rectangle.initialize(a,b,c,d)),e.x+=j.x,e.y+=j.y,e.width+=j.width,e.height+=j.height)}return e},b._getBounds=function(a,b){return this._transformBounds(this.getBounds(),a,b)},b._transformBounds=function(a,b,c){if(!a)return a;var d=a.x,e=a.y,f=a.width,g=a.height,h=c?this._matrix.identity():this.getMatrix(this._matrix);(d||e)&&h.appendTransform(0,0,1,1,0,0,0,-d,-e),b&&h.prependMatrix(b);var i=f*h.a,j=f*h.b,k=g*h.c,l=g*h.d,m=h.tx,n=h.ty,o=m,p=m,q=n,r=n;return(d=i+m)p&&(p=d),(d=i+k+m)p&&(p=d),(d=k+m)p&&(p=d),(e=j+n)r&&(r=e),(e=j+l+n)r&&(r=e),(e=l+n)r&&(r=e),a.initialize(o,q,p-o,r-q)},b._hasMouseEventListener=function(){for(var b=a._MOUSE_EVENTS,c=0,d=b.length;d>c;c++)if(this.hasEventListener(b[c]))return!0;return!!this.cursor},createjs.DisplayObject=a}(),this.createjs=this.createjs||{},function(){var a=function(){this.initialize()},b=a.prototype=new createjs.DisplayObject;b.children=null,b.mouseChildren=!0,b.tickChildren=!0,b.DisplayObject_initialize=b.initialize,b.initialize=function(){this.DisplayObject_initialize(),this.children=[]},b.isVisible=function(){var a=this.cacheCanvas||this.children.length;return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&a)},b.DisplayObject_draw=b.draw,b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return!0;for(var c=this.children.slice(0),d=0,e=c.length;e>d;d++){var f=c[d];f.isVisible()&&(a.save(),f.updateContext(a),f.draw(a),a.restore())}return!0},b.addChild=function(a){if(null==a)return a;var b=arguments.length;if(b>1){for(var c=0;b>c;c++)this.addChild(arguments[c]);return arguments[b-1]}return a.parent&&a.parent.removeChild(a),a.parent=this,this.children.push(a),a},b.addChildAt=function(a,b){var c=arguments.length,d=arguments[c-1];if(0>d||d>this.children.length)return arguments[c-2];if(c>2){for(var e=0;c-1>e;e++)this.addChildAt(arguments[e],d+e);return arguments[c-2]}return a.parent&&a.parent.removeChild(a),a.parent=this,this.children.splice(b,0,a),a},b.removeChild=function(a){var b=arguments.length;if(b>1){for(var c=!0,d=0;b>d;d++)c=c&&this.removeChild(arguments[d]);return c}return this.removeChildAt(createjs.indexOf(this.children,a))},b.removeChildAt=function(a){var b=arguments.length;if(b>1){for(var c=[],d=0;b>d;d++)c[d]=arguments[d];c.sort(function(a,b){return b-a});for(var e=!0,d=0;b>d;d++)e=e&&this.removeChildAt(c[d]);return e}if(0>a||a>this.children.length-1)return!1;var f=this.children[a];return f&&(f.parent=null),this.children.splice(a,1),!0},b.removeAllChildren=function(){for(var a=this.children;a.length;)a.pop().parent=null},b.getChildAt=function(a){return this.children[a]},b.getChildByName=function(a){for(var b=this.children,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null},b.sortChildren=function(a){this.children.sort(a)},b.getChildIndex=function(a){return createjs.indexOf(this.children,a)},b.getNumChildren=function(){return this.children.length},b.swapChildrenAt=function(a,b){var c=this.children,d=c[a],e=c[b];d&&e&&(c[a]=e,c[b]=d)},b.swapChildren=function(a,b){for(var c,d,e=this.children,f=0,g=e.length;g>f&&(e[f]==a&&(c=f),e[f]==b&&(d=f),null==c||null==d);f++);f!=g&&(e[c]=b,e[d]=a)},b.setChildIndex=function(a,b){var c=this.children,d=c.length;if(!(a.parent!=this||0>b||b>=d)){for(var e=0;d>e&&c[e]!=a;e++);e!=d&&e!=b&&(c.splice(e,1),c.splice(b,0,a))}},b.contains=function(a){for(;a;){if(a==this)return!0;a=a.parent}return!1},b.hitTest=function(a,b){return null!=this.getObjectUnderPoint(a,b)},b.getObjectsUnderPoint=function(a,b){var c=[],d=this.localToGlobal(a,b);return this._getObjectsUnderPoint(d.x,d.y,c),c},b.getObjectUnderPoint=function(a,b){var c=this.localToGlobal(a,b);return this._getObjectsUnderPoint(c.x,c.y)},b.DisplayObject_getBounds=b.getBounds,b.getBounds=function(){return this._getBounds(null,!0)},b.getTransformedBounds=function(){return this._getBounds()},b.clone=function(b){var c=new a;if(this.cloneProps(c),b)for(var d=c.children=[],e=0,f=this.children.length;f>e;e++){var g=this.children[e].clone(b);g.parent=c,d.push(g)}return c},b.toString=function(){return"[Container (name="+this.name+")]"},b.DisplayObject__tick=b._tick,b._tick=function(a){if(this.tickChildren)for(var b=this.children.length-1;b>=0;b--){var c=this.children[b];c.tickEnabled&&c._tick&&c._tick(a)}this.DisplayObject__tick(a)},b._getObjectsUnderPoint=function(b,c,d,e,f){var g=createjs.DisplayObject._hitTestContext,h=this._matrix;f=f||e&&this._hasMouseEventListener();for(var i=this.children,j=i.length,k=j-1;k>=0;k--){var l=i[k],m=l.hitArea;if(l.visible&&(m||l.isVisible())&&(!e||l.mouseEnabled))if(!m&&l instanceof a){var n=l._getObjectsUnderPoint(b,c,d,e,f);if(!d&&n)return e&&!this.mouseChildren?this:n}else{if(!f&&!l._hasMouseEventListener())continue;if(l.getConcatenatedMatrix(h),m&&(h.appendTransform(m.x,m.y,m.scaleX,m.scaleY,m.rotation,m.skewX,m.skewY,m.regX,m.regY),h.alpha=m.alpha),g.globalAlpha=h.alpha,g.setTransform(h.a,h.b,h.c,h.d,h.tx-b,h.ty-c),(m||l).draw(g),!this._testHit(g))continue;if(g.setTransform(1,0,0,1,0,0),g.clearRect(0,0,2,2),!d)return e&&!this.mouseChildren?this:l;d.push(l)}}return null},b._getBounds=function(a,b){var c=this.DisplayObject_getBounds();if(c)return this._transformBounds(c,a,b);var d,e,f,g,h=b?this._matrix.identity():this.getMatrix(this._matrix);a&&h.prependMatrix(a);for(var i=this.children.length,j=0;i>j;j++){var k=this.children[j];if(k.visible&&(c=k._getBounds(h))){var l=c.x,m=c.y,n=l+c.width,o=m+c.height;(d>l||null==d)&&(d=l),(n>e||null==e)&&(e=n),(f>m||null==f)&&(f=m),(o>g||null==g)&&(g=o)}}return null==e?null:this._rectangle.initialize(d,f,e-d,g-f)},createjs.Container=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a){this.initialize(a)},b=a.prototype=new createjs.Container;a._snapToPixelEnabled=!1,b.autoClear=!0,b.canvas=null,b.mouseX=0,b.mouseY=0,b.snapToPixelEnabled=!1,b.mouseInBounds=!1,b.tickOnUpdate=!0,b.mouseMoveOutside=!1,b.nextStage=null,b._pointerData=null,b._pointerCount=0,b._primaryPointerID=null,b._mouseOverIntervalID=null,b.Container_initialize=b.initialize,b.initialize=function(a){this.Container_initialize(),this.canvas="string"==typeof a?document.getElementById(a):a,this._pointerData={},this.enableDOMEvents(!0)},b.update=function(){if(this.canvas){this.tickOnUpdate&&(this.dispatchEvent("tickstart"),this.tickEnabled&&this._tick(arguments.length?arguments:null),this.dispatchEvent("tickend")),this.dispatchEvent("drawstart"),a._snapToPixelEnabled=this.snapToPixelEnabled,this.autoClear&&this.clear();var b=this.canvas.getContext("2d");b.save(),this.updateContext(b),this.draw(b,!1),b.restore(),this.dispatchEvent("drawend")}},b.handleEvent=function(a){"tick"==a.type&&this.update(a)},b.clear=function(){if(this.canvas){var a=this.canvas.getContext("2d");a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,this.canvas.width+1,this.canvas.height+1)}},b.toDataURL=function(a,b){b||(b="image/png");var c,d=this.canvas.getContext("2d"),e=this.canvas.width,f=this.canvas.height;if(a){c=d.getImageData(0,0,e,f);var g=d.globalCompositeOperation;d.globalCompositeOperation="destination-over",d.fillStyle=a,d.fillRect(0,0,e,f)}var h=this.canvas.toDataURL(b);return a&&(d.clearRect(0,0,e+1,f+1),d.putImageData(c,0,0),d.globalCompositeOperation=g),h},b.enableMouseOver=function(a){if(this._mouseOverIntervalID&&(clearInterval(this._mouseOverIntervalID),this._mouseOverIntervalID=null,0==a&&this._testMouseOver(!0)),null==a)a=20;else if(0>=a)return;var b=this;this._mouseOverIntervalID=setInterval(function(){b._testMouseOver()},1e3/Math.min(50,a))},b.enableDOMEvents=function(a){null==a&&(a=!0);var b,c,d=this._eventListeners;if(!a&&d){for(b in d)c=d[b],c.t.removeEventListener(b,c.f,!1);this._eventListeners=null}else if(a&&!d&&this.canvas){var e=window.addEventListener?window:document,f=this;d=this._eventListeners={},d.mouseup={t:e,f:function(a){f._handleMouseUp(a)}},d.mousemove={t:e,f:function(a){f._handleMouseMove(a)}},d.dblclick={t:this.canvas,f:function(a){f._handleDoubleClick(a)}},d.mousedown={t:this.canvas,f:function(a){f._handleMouseDown(a)}};for(b in d)c=d[b],c.t.addEventListener(b,c.f,!1)}},b.clone=function(){var b=new a(null);return this.cloneProps(b),b},b.toString=function(){return"[Stage (name="+this.name+")]"},b._getElementRect=function(a){var b;try{b=a.getBoundingClientRect()}catch(c){b={top:a.offsetTop,left:a.offsetLeft,width:a.offsetWidth,height:a.offsetHeight}}var d=(window.pageXOffset||document.scrollLeft||0)-(document.clientLeft||document.body.clientLeft||0),e=(window.pageYOffset||document.scrollTop||0)-(document.clientTop||document.body.clientTop||0),f=window.getComputedStyle?getComputedStyle(a):a.currentStyle,g=parseInt(f.paddingLeft)+parseInt(f.borderLeftWidth),h=parseInt(f.paddingTop)+parseInt(f.borderTopWidth),i=parseInt(f.paddingRight)+parseInt(f.borderRightWidth),j=parseInt(f.paddingBottom)+parseInt(f.borderBottomWidth);return{left:b.left+d+g,right:b.right+d-i,top:b.top+e+h,bottom:b.bottom+e-j}},b._getPointerData=function(a){var b=this._pointerData[a];return b||(b=this._pointerData[a]={x:0,y:0},null==this._primaryPointerID&&(this._primaryPointerID=a),(null==this._primaryPointerID||-1==this._primaryPointerID)&&(this._primaryPointerID=a)),b},b._handleMouseMove=function(a){a||(a=window.event),this._handlePointerMove(-1,a,a.pageX,a.pageY)},b._handlePointerMove=function(a,b,c,d){if(this.canvas){var e=this._getPointerData(a),f=e.inBounds;if(this._updatePointerPosition(a,b,c,d),f||e.inBounds||this.mouseMoveOutside){-1==a&&e.inBounds==!f&&this._dispatchMouseEvent(this,f?"mouseleave":"mouseenter",!1,a,e,b),this._dispatchMouseEvent(this,"stagemousemove",!1,a,e,b),this._dispatchMouseEvent(e.target,"pressmove",!0,a,e,b);var g=e.event;g&&g.hasEventListener("mousemove")&&g.dispatchEvent(new createjs.MouseEvent("mousemove",!1,!1,e.x,e.y,b,a,a==this._primaryPointerID,e.rawX,e.rawY),e.target),this.nextStage&&this.nextStage._handlePointerMove(a,b,c,d)}}},b._updatePointerPosition=function(a,b,c,d){var e=this._getElementRect(this.canvas);c-=e.left,d-=e.top;var f=this.canvas.width,g=this.canvas.height;c/=(e.right-e.left)/f,d/=(e.bottom-e.top)/g;var h=this._getPointerData(a);(h.inBounds=c>=0&&d>=0&&f-1>=c&&g-1>=d)?(h.x=c,h.y=d):this.mouseMoveOutside&&(h.x=0>c?0:c>f-1?f-1:c,h.y=0>d?0:d>g-1?g-1:d),h.posEvtObj=b,h.rawX=c,h.rawY=d,a==this._primaryPointerID&&(this.mouseX=h.x,this.mouseY=h.y,this.mouseInBounds=h.inBounds)},b._handleMouseUp=function(a){this._handlePointerUp(-1,a,!1)},b._handlePointerUp=function(a,b,c){var d=this._getPointerData(a);this._dispatchMouseEvent(this,"stagemouseup",!1,a,d,b);var e=d.target;e&&(this._getObjectsUnderPoint(d.x,d.y,null,!0)==e&&this._dispatchMouseEvent(e,"click",!0,a,d,b),this._dispatchMouseEvent(e,"pressup",!0,a,d,b));var f=d.event;f&&f.hasEventListener("mouseup")&&f.dispatchEvent(new createjs.MouseEvent("mouseup",!1,!1,d.x,d.y,b,a,a==this._primaryPointerID,d.rawX,d.rawY),e),c?(a==this._primaryPointerID&&(this._primaryPointerID=null),delete this._pointerData[a]):d.event=d.target=null,this.nextStage&&this.nextStage._handlePointerUp(a,b,c)},b._handleMouseDown=function(a){this._handlePointerDown(-1,a,a.pageX,a.pageY)},b._handlePointerDown=function(a,b,c,d){null!=d&&this._updatePointerPosition(a,b,c,d);var e=this._getPointerData(a);this._dispatchMouseEvent(this,"stagemousedown",!1,a,e,b),e.target=this._getObjectsUnderPoint(e.x,e.y,null,!0),e.event=this._dispatchMouseEvent(e.target,"mousedown",!0,a,e,b),this.nextStage&&this.nextStage._handlePointerDown(a,b,c,d)},b._testMouseOver=function(a){if(-1==this._primaryPointerID&&(a||this.mouseX!=this._mouseOverX||this.mouseY!=this._mouseOverY||!this.mouseInBounds)){var b,c,d,e,f=this._getPointerData(-1),g=f.posEvtObj,h=-1,i="";(a||this.mouseInBounds&&g&&g.target==this.canvas)&&(b=this._getObjectsUnderPoint(this.mouseX,this.mouseY,null,!0),this._mouseOverX=this.mouseX,this._mouseOverY=this.mouseY);var j=this._mouseOverTarget||[],k=j[j.length-1],l=this._mouseOverTarget=[];for(c=b;c;)l.unshift(c),null!=c.cursor&&(i=c.cursor),c=c.parent;for(this.canvas.style.cursor=i,d=0,e=l.length;e>d&&l[d]==j[d];d++)h=d;for(k!=b&&this._dispatchMouseEvent(k,"mouseout",!0,-1,f,g),d=j.length-1;d>h;d--)this._dispatchMouseEvent(j[d],"rollout",!1,-1,f,g);for(d=l.length-1;d>h;d--)this._dispatchMouseEvent(l[d],"rollover",!1,-1,f,g);k!=b&&this._dispatchMouseEvent(b,"mouseover",!0,-1,f,g)}},b._handleDoubleClick=function(a){var b=this._getPointerData(-1),c=this._getObjectsUnderPoint(b.x,b.y,null,!0);this._dispatchMouseEvent(c,"dblclick",!0,-1,b,a),this.nextStage&&this.nextStage._handleDoubleClick(a)},b._dispatchMouseEvent=function(a,b,c,d,e,f){if(a&&(c||a.hasEventListener(b))){var g=new createjs.MouseEvent(b,c,!1,e.x,e.y,f,d,d==this._primaryPointerID,e.rawX,e.rawY);return a.dispatchEvent(g),g}},createjs.Stage=a}(),this.createjs=this.createjs||{},function(){var a=function(a){this.initialize(a)},b=a.prototype=new createjs.DisplayObject;b.image=null,b.snapToPixel=!0,b.sourceRect=null,b.DisplayObject_initialize=b.initialize,b.initialize=function(a){this.DisplayObject_initialize(),"string"==typeof a?(this.image=document.createElement("img"),this.image.src=a):this.image=a},b.isVisible=function(){var a=this.cacheCanvas||this.image&&(this.image.complete||this.image.getContext||this.image.readyState>=2);return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&a)},b.DisplayObject_draw=b.draw,b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return!0;var c=this.sourceRect;return c?a.drawImage(this.image,c.x,c.y,c.width,c.height,0,0,c.width,c.height):a.drawImage(this.image,0,0),!0},b.DisplayObject_getBounds=b.getBounds,b.getBounds=function(){var a=this.DisplayObject_getBounds();if(a)return a;var b=this.sourceRect||this.image,c=this.image&&(this.image.complete||this.image.getContext||this.image.readyState>=2);return c?this._rectangle.initialize(0,0,b.width,b.height):null},b.clone=function(){var b=new a(this.image);return this.sourceRect&&(b.sourceRect=this.sourceRect.clone()),this.cloneProps(b),b},b.toString=function(){return"[Bitmap (name="+this.name+")]"},createjs.Bitmap=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b){this.initialize(a,b)},b=a.prototype=new createjs.DisplayObject;b.currentFrame=0,b.currentAnimation=null,b.paused=!0,b.spriteSheet=null,b.snapToPixel=!0,b.offset=0,b.currentAnimationFrame=0,b.framerate=0,b._advanceCount=0,b._animation=null,b._currentFrame=null,b.DisplayObject_initialize=b.initialize,b.initialize=function(a,b){this.DisplayObject_initialize(),this.spriteSheet=a,b&&this.gotoAndPlay(b)},b.isVisible=function(){var a=this.cacheCanvas||this.spriteSheet.complete;return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&a)},b.DisplayObject_draw=b.draw,b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return!0;this._normalizeFrame();var c=this.spriteSheet.getFrame(0|this._currentFrame);if(!c)return!1;var d=c.rect;return a.drawImage(c.image,d.x,d.y,d.width,d.height,-c.regX,-c.regY,d.width,d.height),!0},b.play=function(){this.paused=!1},b.stop=function(){this.paused=!0},b.gotoAndPlay=function(a){this.paused=!1,this._goto(a)},b.gotoAndStop=function(a){this.paused=!0,this._goto(a)},b.advance=function(a){var b=this._animation&&this._animation.speed||1,c=this.framerate||this.spriteSheet.framerate,d=c&&null!=a?a/(1e3/c):1;this._animation?this.currentAnimationFrame+=d*b:this._currentFrame+=d*b,this._normalizeFrame()},b.DisplayObject_getBounds=b.getBounds,b.getBounds=function(){return this.DisplayObject_getBounds()||this.spriteSheet.getFrameBounds(this.currentFrame,this._rectangle)},b.clone=function(){var b=new a(this.spriteSheet);return this.cloneProps(b),b},b.toString=function(){return"[Sprite (name="+this.name+")]"},b.DisplayObject__tick=b._tick,b._tick=function(a){this.paused||this.advance(a&&a[0]&&a[0].delta),this.DisplayObject__tick(a)},b._normalizeFrame=function(){var a,b=this._animation,c=this.paused,d=this._currentFrame,e=this.currentAnimationFrame;if(b)if(a=b.frames.length,(0|e)>=a){var f=b.next;if(this._dispatchAnimationEnd(b,d,c,f,a-1));else{if(f)return this._goto(f,e-a);this.paused=!0,e=this.currentAnimationFrame=b.frames.length-1,this._currentFrame=b.frames[e]}}else this._currentFrame=b.frames[0|e];else if(a=this.spriteSheet.getNumFrames(),d>=a&&!this._dispatchAnimationEnd(b,d,c,a-1)&&(this._currentFrame-=a)>=a)return this._normalizeFrame();this.currentFrame=0|this._currentFrame},b._dispatchAnimationEnd=function(a,b,c,d,e){var f=a?a.name:null;if(this.hasEventListener("animationend")){var g=new createjs.Event("animationend");g.name=f,g.next=d,this.dispatchEvent(g)}var h=this._animation!=a||this._currentFrame!=b;return h||c||!this.paused||(this.currentAnimationFrame=e,h=!0),h},b.DisplayObject_cloneProps=b.cloneProps,b.cloneProps=function(a){this.DisplayObject_cloneProps(a),a.currentFrame=this.currentFrame,a._currentFrame=this._currentFrame,a.currentAnimation=this.currentAnimation,a.paused=this.paused,a._animation=this._animation,a.currentAnimationFrame=this.currentAnimationFrame,a.framerate=this.framerate},b._goto=function(a,b){if(isNaN(a)){var c=this.spriteSheet.getAnimation(a);c&&(this.currentAnimationFrame=b||0,this._animation=c,this.currentAnimation=a,this._normalizeFrame())}else this.currentAnimationFrame=0,this.currentAnimation=this._animation=null,this._currentFrame=a,this._normalizeFrame()},createjs.Sprite=a}(),this.createjs=this.createjs||{},function(){"use strict";var a="BitmapAnimation is deprecated in favour of Sprite. See VERSIONS file for info on changes.";if(!createjs.Sprite)throw a;(createjs.BitmapAnimation=function(b){console.log(a),this.initialize(b)}).prototype=new createjs.Sprite}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a){this.initialize(a)},b=a.prototype=new createjs.DisplayObject;b.graphics=null,b.DisplayObject_initialize=b.initialize,b.initialize=function(a){this.DisplayObject_initialize(),this.graphics=a?a:new createjs.Graphics},b.isVisible=function(){var a=this.cacheCanvas||this.graphics&&!this.graphics.isEmpty();return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&a)},b.DisplayObject_draw=b.draw,b.draw=function(a,b){return this.DisplayObject_draw(a,b)?!0:(this.graphics.draw(a),!0)},b.clone=function(b){var c=new a(b&&this.graphics?this.graphics.clone():this.graphics);return this.cloneProps(c),c},b.toString=function(){return"[Shape (name="+this.name+")]"},createjs.Shape=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b,c){this.initialize(a,b,c)},b=a.prototype=new createjs.DisplayObject,c=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");c.getContext&&(a._workingContext=c.getContext("2d"),c.width=c.height=1),a.H_OFFSETS={start:0,left:0,center:-.5,end:-1,right:-1},a.V_OFFSETS={top:0,hanging:-.01,middle:-.4,alphabetic:-.8,ideographic:-.85,bottom:-1},b.text="",b.font=null,b.color=null,b.textAlign="left",b.textBaseline="top",b.maxWidth=null,b.outline=0,b.lineHeight=0,b.lineWidth=null,b.DisplayObject_initialize=b.initialize,b.initialize=function(a,b,c){this.DisplayObject_initialize(),this.text=a,this.font=b,this.color=c},b.isVisible=function(){var a=this.cacheCanvas||null!=this.text&&""!==this.text;return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&a)},b.DisplayObject_draw=b.draw,b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return!0;var c=this.color||"#000";return this.outline?(a.strokeStyle=c,a.lineWidth=1*this.outline):a.fillStyle=c,this._drawText(this._prepContext(a)),!0},b.getMeasuredWidth=function(){return this._prepContext(a._workingContext).measureText(this.text).width},b.getMeasuredLineHeight=function(){return 1.2*this._prepContext(a._workingContext).measureText("M").width},b.getMeasuredHeight=function(){return this._drawText(null,{}).height},b.DisplayObject_getBounds=b.getBounds,b.getBounds=function(){var b=this.DisplayObject_getBounds();if(b)return b;if(null==this.text||""==this.text)return null;var c=this._drawText(null,{}),d=this.maxWidth&&this.maxWidthi;i++){var k=h[i],l=null;if(null!=this.lineWidth&&(l=b.measureText(k).width)>this.lineWidth){var m=k.split(/(\s)/);k=m[0],l=b.measureText(k).width;for(var n=1,o=m.length;o>n;n+=2){var p=b.measureText(m[n]+m[n+1]).width;l+p>this.lineWidth?(d&&this._drawTextLine(b,k,g*e),l>f&&(f=l),k=m[n+1],l=b.measureText(k).width,g++):(k+=m[n]+m[n+1],l+=p)}}d&&this._drawTextLine(b,k,g*e),c&&null==l&&(l=b.measureText(k).width),l>f&&(f=l),g++}return c&&(c.count=g,c.width=f,c.height=g*e),c},b._drawTextLine=function(a,b,c){this.outline?a.strokeText(b,0,c,this.maxWidth||65535):a.fillText(b,0,c,this.maxWidth||65535)},createjs.Text=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b){this.initialize(a,b)}var b=a.prototype=new createjs.DisplayObject;b.text="",b.spriteSheet=null,b.lineHeight=0,b.letterSpacing=0,b.spaceWidth=0,b.DisplayObject_initialize=b.initialize,b.initialize=function(a,b){this.DisplayObject_initialize(),this.text=a,this.spriteSheet=b},b.DisplayObject_draw=b.draw,b.draw=function(a,b){return this.DisplayObject_draw(a,b)?!0:(this._drawText(a),void 0)},b.isVisible=function(){var a=this.cacheCanvas||this.spriteSheet&&this.spriteSheet.complete&&this.text;return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&a)},b.getBounds=function(){var a=this._rectangle;return this._drawText(null,a),a.width?a:null},b._getFrame=function(a,b){var c,d=b.getAnimation(a);return d||(a!=(c=a.toUpperCase())||a!=(c=a.toLowerCase())||(c=null),c&&(d=b.getAnimation(c))),d&&b.getFrame(d.frames[0])},b._getLineHeight=function(a){var b=this._getFrame("1",a)||this._getFrame("T",a)||this._getFrame("L",a)||a.getFrame(0);return b?b.rect.height:1},b._getSpaceWidth=function(a){var b=this._getFrame("1",a)||this._getFrame("l",a)||this._getFrame("e",a)||this._getFrame("a",a)||a.getFrame(0);return b?b.rect.width:1},b._drawText=function(a,b){var c,d,e,f=0,g=0,h=this.spaceWidth,i=this.lineHeight,j=this.spriteSheet,k=!!this._getFrame(" ",j);k||0!=h||(h=this._getSpaceWidth(j)),0==i&&(i=this._getLineHeight(j));for(var l=0,m=0,n=this.text.length;n>m;m++){var o=this.text.charAt(m);if(k||" "!=o)if("\n"!=o&&"\r"!=o){var p=this._getFrame(o,j);if(p){var q=p.rect;e=p.regX,c=q.width,a&&a.drawImage(p.image,q.x,q.y,c,d=q.height,f-e,g-p.regY,c,d),f+=c+this.letterSpacing}}else"\r"==o&&"\n"==this.text.charAt(m+1)&&m++,f-e>l&&(l=f-e),f=0,g+=i;else f+=h}f-e>l&&(l=f-e),b&&(b.width=l-this.letterSpacing,b.height=g+i)},createjs.BitmapText=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(){throw"SpriteSheetUtils cannot be instantiated"},b=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");b.getContext&&(a._workingCanvas=b,a._workingContext=b.getContext("2d"),b.width=b.height=1),a.addFlippedFrames=function(b,c,d,e){if(c||d||e){var f=0;c&&a._flip(b,++f,!0,!1),d&&a._flip(b,++f,!1,!0),e&&a._flip(b,++f,!0,!0)}},a.extractFrame=function(b,c){isNaN(c)&&(c=b.getAnimation(c).frames[0]);var d=b.getFrame(c);if(!d)return null;var e=d.rect,f=a._workingCanvas;f.width=e.width,f.height=e.height,a._workingContext.drawImage(d.image,e.x,e.y,e.width,e.height,0,0,e.width,e.height);var g=document.createElement("img");return g.src=f.toDataURL("image/png"),g},a.mergeAlpha=function(a,b,c){c||(c=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas")),c.width=Math.max(b.width,a.width),c.height=Math.max(b.height,a.height);var d=c.getContext("2d");return d.save(),d.drawImage(a,0,0),d.globalCompositeOperation="destination-in",d.drawImage(b,0,0),d.restore(),c},a._flip=function(b,c,d,e){for(var f=b._images,g=a._workingCanvas,h=a._workingContext,i=f.length/c,j=0;i>j;j++){var k=f[j];k.__tmp=j,h.setTransform(1,0,0,1,0,0),h.clearRect(0,0,g.width+1,g.height+1),g.width=k.width,g.height=k.height,h.setTransform(d?-1:1,0,0,e?-1:1,d?k.width:0,e?k.height:0),h.drawImage(k,0,0);var l=document.createElement("img");l.src=g.toDataURL("image/png"),l.width=k.width,l.height=k.height,f.push(l)}var m=b._frames,n=m.length/c;for(j=0;n>j;j++){k=m[j];var o=k.rect.clone();l=f[k.image.__tmp+i*c];var p={image:l,rect:o,regX:k.regX,regY:k.regY};d&&(o.x=l.width-o.x-o.width,p.regX=o.width-k.regX),e&&(o.y=l.height-o.y-o.height,p.regY=o.height-k.regY),m.push(p)}var q="_"+(d?"h":"")+(e?"v":""),r=b._animations,s=b._data,t=r.length/c;for(j=0;t>j;j++){var u=r[j];k=s[u];var v={name:u+q,speed:k.speed,next:k.next,frames:[]};k.next&&(v.next+=q),m=k.frames;for(var w=0,x=m.length;x>w;w++)v.frames.push(m[w]+n*c);s[v.name]=v,r.push(v.name)}},createjs.SpriteSheetUtils=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(){this.initialize()},b=a.prototype=new createjs.EventDispatcher;a.ERR_DIMENSIONS="frame dimensions exceed max spritesheet dimensions",a.ERR_RUNNING="a build is already running",b.maxWidth=2048,b.maxHeight=2048,b.spriteSheet=null,b.scale=1,b.padding=1,b.timeSlice=.3,b.progress=-1,b._frames=null,b._animations=null,b._data=null,b._nextFrameIndex=0,b._index=0,b._timerID=null,b._scale=1,b.initialize=function(){this._frames=[],this._animations={}},b.addFrame=function(b,c,d,e,f,g){if(this._data)throw a.ERR_RUNNING;var h=c||b.bounds||b.nominalBounds;return!h&&b.getBounds&&(h=b.getBounds()),h?(d=d||1,this._frames.push({source:b,sourceRect:h,scale:d,funct:e,params:f,scope:g,index:this._frames.length,height:h.height*d})-1):null},b.addAnimation=function(b,c,d,e){if(this._data)throw a.ERR_RUNNING;this._animations[b]={frames:c,next:d,frequency:e}},b.addMovieClip=function(b,c,d){if(this._data)throw a.ERR_RUNNING;var e=b.frameBounds,f=c||b.bounds||b.nominalBounds;if(!f&&b.getBounds&&(f=b.getBounds()),!f&&!e)return null;for(var g=this._frames.length,h=b.timeline.duration,i=0;h>i;i++){var j=e&&e[i]?e[i]:f;this.addFrame(b,j,d,function(a){var b=this.actionsEnabled;this.actionsEnabled=!1,this.gotoAndStop(a),this.actionsEnabled=b},[i],b)}var k=b.timeline._labels,l=[];for(var m in k)l.push({index:k[m],label:m});if(l.length){l.sort(function(a,b){return a.index-b.index});for(var i=0,n=l.length;n>i;i++){for(var o=l[i].label,p=g+l[i].index,q=g+(i==n-1?h:l[i+1].index),r=[],s=p;q>s;s++)r.push(s);this.addAnimation(o,r,!0)}}},b.build=function(){if(this._data)throw a.ERR_RUNNING;for(this._startBuild();this._drawNext(););return this._endBuild(),this.spriteSheet},b.buildAsync=function(b){if(this._data)throw a.ERR_RUNNING;this.timeSlice=b,this._startBuild();var c=this;this._timerID=setTimeout(function(){c._run()},50-50*Math.max(.01,Math.min(.99,this.timeSlice||.3)))},b.stopAsync=function(){clearTimeout(this._timerID),this._data=null},b.clone=function(){throw"SpriteSheetBuilder cannot be cloned."},b.toString=function(){return"[SpriteSheetBuilder]"},b._startBuild=function(){var b=this.padding||0;this.progress=0,this.spriteSheet=null,this._index=0,this._scale=this.scale;var c=[];this._data={images:[],frames:c,animations:this._animations};var d=this._frames.slice();if(d.sort(function(a,b){return a.height<=b.height?-1:1}),d[d.length-1].height+2*b>this.maxHeight)throw a.ERR_DIMENSIONS;for(var e=0,f=0,g=0;d.length;){var h=this._fillRow(d,e,g,c,b);if(h.w>f&&(f=h.w),e+=h.h,!h.h||!d.length){var i=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");i.width=this._getSize(f,this.maxWidth),i.height=this._getSize(e,this.maxHeight),this._data.images[g]=i,h.h||(f=e=0,g++)}}},b._getSize=function(a,b){for(var c=4;Math.pow(2,++c)=0;l--){var m=b[l],n=this._scale*m.scale,o=m.sourceRect,p=m.source,q=Math.floor(n*o.x-f),r=Math.floor(n*o.y-f),s=Math.ceil(n*o.height+2*f),t=Math.ceil(n*o.width+2*f);if(t>g)throw a.ERR_DIMENSIONS;s>i||j+t>g||(m.img=d,m.rect=new createjs.Rectangle(j,c,t,s),k=k||s,b.splice(l,1),e[m.index]=[j,c,t,s,d,Math.round(-q+n*p.regX-f),Math.round(-r+n*p.regY-f)],j+=t)}return{w:j,h:k}},b._endBuild=function(){this.spriteSheet=new createjs.SpriteSheet(this._data),this._data=null,this.progress=1,this.dispatchEvent("complete")},b._run=function(){for(var a=50*Math.max(.01,Math.min(.99,this.timeSlice||.3)),b=(new Date).getTime()+a,c=!1;b>(new Date).getTime();)if(!this._drawNext()){c=!0;break}if(c)this._endBuild();else{var d=this;this._timerID=setTimeout(function(){d._run()},50-a)}var e=this.progress=this._index/this._frames.length;if(this.hasEventListener("progress")){var f=new createjs.Event("progress");f.progress=e,this.dispatchEvent(f)}},b._drawNext=function(){var a=this._frames[this._index],b=a.scale*this._scale,c=a.rect,d=a.sourceRect,e=this._data.images[a.img],f=e.getContext("2d");return a.funct&&a.funct.apply(a.scope,a.params),f.save(),f.beginPath(),f.rect(c.x,c.y,c.width,c.height),f.clip(),f.translate(Math.ceil(c.x-d.x*b),Math.ceil(c.y-d.y*b)),f.scale(b,b),a.source.draw(f),f.restore(),++this._indexa)&&(a=0),this.blurX=0|a,(isNaN(b)||0>b)&&(b=0),this.blurY=0|b,(isNaN(c)||1>c)&&(c=1),this.quality=0|c},b.blurX=0,b.blurY=0,b.quality=1,b.mul_table=[1,171,205,293,57,373,79,137,241,27,391,357,41,19,283,265,497,469,443,421,25,191,365,349,335,161,155,149,9,278,269,261,505,245,475,231,449,437,213,415,405,395,193,377,369,361,353,345,169,331,325,319,313,307,301,37,145,285,281,69,271,267,263,259,509,501,493,243,479,118,465,459,113,446,55,435,429,423,209,413,51,403,199,393,97,3,379,375,371,367,363,359,355,351,347,43,85,337,333,165,327,323,5,317,157,311,77,305,303,75,297,294,73,289,287,71,141,279,277,275,68,135,67,133,33,262,260,129,511,507,503,499,495,491,61,121,481,477,237,235,467,232,115,457,227,451,7,445,221,439,218,433,215,427,425,211,419,417,207,411,409,203,202,401,399,396,197,49,389,387,385,383,95,189,47,187,93,185,23,183,91,181,45,179,89,177,11,175,87,173,345,343,341,339,337,21,167,83,331,329,327,163,81,323,321,319,159,79,315,313,39,155,309,307,153,305,303,151,75,299,149,37,295,147,73,291,145,289,287,143,285,71,141,281,35,279,139,69,275,137,273,17,271,135,269,267,133,265,33,263,131,261,130,259,129,257,1],b.shg_table=[0,9,10,11,9,12,10,11,12,9,13,13,10,9,13,13,14,14,14,14,10,13,14,14,14,13,13,13,9,14,14,14,15,14,15,14,15,15,14,15,15,15,14,15,15,15,15,15,14,15,15,15,15,15,15,12,14,15,15,13,15,15,15,15,16,16,16,15,16,14,16,16,14,16,13,16,16,16,15,16,13,16,15,16,14,9,16,16,16,16,16,16,16,16,16,13,14,16,16,15,16,16,10,16,15,16,14,16,16,14,16,16,14,16,16,14,15,16,16,16,14,15,14,15,13,16,16,15,17,17,17,17,17,17,14,15,17,17,16,16,17,16,15,17,16,17,11,17,16,17,16,17,16,17,17,16,17,17,16,17,17,16,16,17,17,17,16,14,17,17,17,17,15,16,14,16,15,16,13,16,15,16,14,16,15,16,12,16,15,16,17,17,17,17,17,13,16,15,17,17,17,16,15,17,17,17,16,15,17,17,14,16,17,17,16,17,17,16,15,17,16,14,17,16,15,17,16,17,17,16,17,15,16,17,14,17,16,15,17,16,17,13,17,16,17,17,16,17,14,17,16,17,16,17,16,17,9],b.getBounds=function(){var a=.5*Math.pow(this.quality,.6);return new createjs.Rectangle(-this.blurX*a,-this.blurY*a,2*this.blurX*a,2*this.blurY*a)},b.applyFilter=function(a,b,c,d,e,f,g,h){f=f||a,null==g&&(g=b),null==h&&(h=c);try{var i=a.getImageData(b,c,d,e)}catch(j){return!1}var k=this.blurX/2;if(isNaN(k)||0>k)return!1;k|=0;var l=this.blurY/2;if(isNaN(l)||0>l)return!1;if(l|=0,0==k&&0==l)return!1;var m=this.quality;(isNaN(m)||1>m)&&(m=1),m|=0,m>3&&(m=3),1>m&&(m=1);var b,c,n,o,p,q,r,s,t,u,v,w,x,y,z,A=i.data,B=k+k+1,C=l+l+1,D=d-1,E=e-1,F=k+1,G=l+1,H={r:0,b:0,g:0,a:0,next:null},I=H;for(n=1;B>n;n++)I=I.next={r:0,b:0,g:0,a:0,next:null};I.next=H;var J={r:0,b:0,g:0,a:0,next:null},K=J;for(n=1;C>n;n++)K=K.next={r:0,b:0,g:0,a:0,next:null};K.next=J;for(var L=null;m-->0;){r=q=0;var M=this.mul_table[k],N=this.shg_table[k];for(c=e;--c>-1;){for(s=F*(w=A[q]),t=F*(x=A[q+1]),u=F*(y=A[q+2]),v=F*(z=A[q+3]),I=H,n=F;--n>-1;)I.r=w,I.g=x,I.b=y,I.a=z,I=I.next;for(n=1;F>n;n++)o=q+((n>D?D:n)<<2),s+=I.r=A[o],t+=I.g=A[o+1],u+=I.b=A[o+2],v+=I.a=A[o+3],I=I.next;for(L=H,b=0;d>b;b++)A[q++]=s*M>>>N,A[q++]=t*M>>>N,A[q++]=u*M>>>N,A[q++]=v*M>>>N,o=r+((o=b+k+1)b;b++){for(q=b<<2,s=G*(w=A[q]),t=G*(x=A[q+1]),u=G*(y=A[q+2]),v=G*(z=A[q+3]),K=J,n=0;G>n;n++)K.r=w,K.g=x,K.b=y,K.a=z,K=K.next;for(p=d,n=1;l>=n;n++)q=p+b<<2,s+=K.r=A[q],t+=K.g=A[q+1],u+=K.b=A[q+2],v+=K.a=A[q+3],K=K.next,E>n&&(p+=d);if(q=b,L=J,m>0)for(c=0;e>c;c++)o=q<<2,A[o+3]=z=v*M>>>N,z>0?(A[o]=s*M>>>N,A[o+1]=t*M>>>N,A[o+2]=u*M>>>N):A[o]=A[o+1]=A[o+2]=0,o=b+((o=c+G)c;c++)o=q<<2,A[o+3]=z=v*M>>>N,z>0?(z=255/z,A[o]=(s*M>>>N)*z,A[o+1]=(t*M>>>N)*z,A[o+2]=(u*M>>>N)*z):A[o]=A[o+1]=A[o+2]=0,o=b+((o=c+G)n;n+=4)k[n+3]=l[n]||0;return f.putImageData(i,g,h),!0},b.clone=function(){return new a(this.alphaMap)},b.toString=function(){return"[AlphaMapFilter]"},b._prepAlphaMap=function(){if(!this.alphaMap)return!1;if(this.alphaMap==this._alphaMap&&this._mapData)return!0;this._mapData=null;var a,b=this._alphaMap=this.alphaMap,c=b;b instanceof HTMLCanvasElement?a=c.getContext("2d"):(c=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas"),c.width=b.width,c.height=b.height,a=c.getContext("2d"),a.drawImage(b,0,0));try{var d=a.getImageData(0,0,b.width,b.height)}catch(e){return!1}return this._mapData=d.data,!0},createjs.AlphaMapFilter=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a){this.initialize(a)},b=a.prototype=new createjs.Filter;b.initialize=function(a){this.mask=a},b.mask=null,b.applyFilter=function(a,b,c,d,e,f,g,h){return this.mask?(f=f||a,null==g&&(g=b),null==h&&(h=c),f.save(),f.globalCompositeOperation="destination-in",f.drawImage(this.mask,g,h),f.restore(),!0):!0},b.clone=function(){return new a(this.mask)},b.toString=function(){return"[AlphaMaskFilter]"},createjs.AlphaMaskFilter=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b,c,d,e,f,g,h){this.initialize(a,b,c,d,e,f,g,h)},b=a.prototype=new createjs.Filter;b.redMultiplier=1,b.greenMultiplier=1,b.blueMultiplier=1,b.alphaMultiplier=1,b.redOffset=0,b.greenOffset=0,b.blueOffset=0,b.alphaOffset=0,b.initialize=function(a,b,c,d,e,f,g,h){this.redMultiplier=null!=a?a:1,this.greenMultiplier=null!=b?b:1,this.blueMultiplier=null!=c?c:1,this.alphaMultiplier=null!=d?d:1,this.redOffset=e||0,this.greenOffset=f||0,this.blueOffset=g||0,this.alphaOffset=h||0},b.applyFilter=function(a,b,c,d,e,f,g,h){f=f||a,null==g&&(g=b),null==h&&(h=c);try{var i=a.getImageData(b,c,d,e)}catch(j){return!1}for(var k=i.data,l=k.length,m=0;l>m;m+=4)k[m]=k[m]*this.redMultiplier+this.redOffset,k[m+1]=k[m+1]*this.greenMultiplier+this.greenOffset,k[m+2]=k[m+2]*this.blueMultiplier+this.blueOffset,k[m+3]=k[m+3]*this.alphaMultiplier+this.alphaOffset;return f.putImageData(i,g,h),!0},b.toString=function(){return"[ColorFilter]"},b.clone=function(){return new a(this.redMultiplier,this.greenMultiplier,this.blueMultiplier,this.alphaMultiplier,this.redOffset,this.greenOffset,this.blueOffset,this.alphaOffset)},createjs.ColorFilter=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b,c,d){this.initialize(a,b,c,d)},b=a.prototype;a.DELTA_INDEX=[0,.01,.02,.04,.05,.06,.07,.08,.1,.11,.12,.14,.15,.16,.17,.18,.2,.21,.22,.24,.25,.27,.28,.3,.32,.34,.36,.38,.4,.42,.44,.46,.48,.5,.53,.56,.59,.62,.65,.68,.71,.74,.77,.8,.83,.86,.89,.92,.95,.98,1,1.06,1.12,1.18,1.24,1.3,1.36,1.42,1.48,1.54,1.6,1.66,1.72,1.78,1.84,1.9,1.96,2,2.12,2.25,2.37,2.5,2.62,2.75,2.87,3,3.2,3.4,3.6,3.8,4,4.3,4.7,4.9,5,5.5,6,6.5,6.8,7,7.3,7.5,7.8,8,8.4,8.7,9,9.4,9.6,9.8,10],a.IDENTITY_MATRIX=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1],a.LENGTH=a.IDENTITY_MATRIX.length,b.initialize=function(a,b,c,d){return this.reset(),this.adjustColor(a,b,c,d),this},b.reset=function(){return this.copyMatrix(a.IDENTITY_MATRIX)},b.adjustColor=function(a,b,c,d){return this.adjustHue(d),this.adjustContrast(b),this.adjustBrightness(a),this.adjustSaturation(c)},b.adjustBrightness=function(a){return 0==a||isNaN(a)?this:(a=this._cleanValue(a,255),this._multiplyMatrix([1,0,0,0,a,0,1,0,0,a,0,0,1,0,a,0,0,0,1,0,0,0,0,0,1]),this)},b.adjustContrast=function(b){if(0==b||isNaN(b))return this;b=this._cleanValue(b,100);var c;return 0>b?c=127+127*(b/100):(c=b%1,c=0==c?a.DELTA_INDEX[b]:a.DELTA_INDEX[b<<0]*(1-c)+a.DELTA_INDEX[(b<<0)+1]*c,c=127*c+127),this._multiplyMatrix([c/127,0,0,0,.5*(127-c),0,c/127,0,0,.5*(127-c),0,0,c/127,0,.5*(127-c),0,0,0,1,0,0,0,0,0,1]),this},b.adjustSaturation=function(a){if(0==a||isNaN(a))return this;a=this._cleanValue(a,100);var b=1+(a>0?3*a/100:a/100),c=.3086,d=.6094,e=.082;return this._multiplyMatrix([c*(1-b)+b,d*(1-b),e*(1-b),0,0,c*(1-b),d*(1-b)+b,e*(1-b),0,0,c*(1-b),d*(1-b),e*(1-b)+b,0,0,0,0,0,1,0,0,0,0,0,1]),this},b.adjustHue=function(a){if(0==a||isNaN(a))return this;a=this._cleanValue(a,180)/180*Math.PI;var b=Math.cos(a),c=Math.sin(a),d=.213,e=.715,f=.072;return this._multiplyMatrix([d+b*(1-d)+c*-d,e+b*-e+c*-e,f+b*-f+c*(1-f),0,0,d+b*-d+.143*c,e+b*(1-e)+.14*c,f+b*-f+c*-.283,0,0,d+b*-d+c*-(1-d),e+b*-e+c*e,f+b*(1-f)+c*f,0,0,0,0,0,1,0,0,0,0,0,1]),this},b.concat=function(b){return b=this._fixMatrix(b),b.length!=a.LENGTH?this:(this._multiplyMatrix(b),this)},b.clone=function(){return(new a).copyMatrix(this)},b.toArray=function(){for(var b=[],c=0,d=a.LENGTH;d>c;c++)b[c]=this[c];return b},b.copyMatrix=function(b){for(var c=a.LENGTH,d=0;c>d;d++)this[d]=b[d];return this},b.toString=function(){return"[ColorMatrix]"},b._multiplyMatrix=function(a){for(var b=[],c=0;5>c;c++){for(var d=0;5>d;d++)b[d]=this[d+5*c];for(var d=0;5>d;d++){for(var e=0,f=0;5>f;f++)e+=a[d+5*f]*b[f];this[d+5*c]=e}}},b._cleanValue=function(a,b){return Math.min(b,Math.max(-b,a))},b._fixMatrix=function(b){return b instanceof a&&(b=b.toArray()),b.lengtha.LENGTH&&(b=b.slice(0,a.LENGTH)),b},createjs.ColorMatrix=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a){this.initialize(a)},b=a.prototype=new createjs.Filter;b.matrix=null,b.initialize=function(a){this.matrix=a},b.applyFilter=function(a,b,c,d,e,f,g,h){f=f||a,null==g&&(g=b),null==h&&(h=c);try{var i=a.getImageData(b,c,d,e)}catch(j){return!1}for(var k,l,m,n,o=i.data,p=o.length,q=this.matrix,r=q[0],s=q[1],t=q[2],u=q[3],v=q[4],w=q[5],x=q[6],y=q[7],z=q[8],A=q[9],B=q[10],C=q[11],D=q[12],E=q[13],F=q[14],G=q[15],H=q[16],I=q[17],J=q[18],K=q[19],L=0;p>L;L+=4)k=o[L],l=o[L+1],m=o[L+2],n=o[L+3],o[L]=k*r+l*s+m*t+n*u+v,o[L+1]=k*w+l*x+m*y+n*z+A,o[L+2]=k*B+l*C+m*D+n*E+F,o[L+3]=k*G+l*H+m*I+n*J+K;return f.putImageData(i,g,h),!0},b.toString=function(){return"[ColorMatrixFilter]"},b.clone=function(){return new a(this.matrix)},createjs.ColorMatrixFilter=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(){throw"Touch cannot be instantiated"};a.isSupported=function(){return"ontouchstart"in window||window.navigator.msPointerEnabled&&window.navigator.msMaxTouchPoints>0||window.navigator.pointerEnabled&&window.navigator.maxTouchPoints>0},a.enable=function(b,c,d){return b&&b.canvas&&a.isSupported()?(b.__touch={pointers:{},multitouch:!c,preventDefault:!d,count:0},"ontouchstart"in window?a._IOS_enable(b):(window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&a._IE_enable(b),!0):!1},a.disable=function(b){b&&("ontouchstart"in window?a._IOS_disable(b):(window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&a._IE_disable(b))},a._IOS_enable=function(b){var c=b.canvas,d=b.__touch.f=function(c){a._IOS_handleEvent(b,c)};c.addEventListener("touchstart",d,!1),c.addEventListener("touchmove",d,!1),c.addEventListener("touchend",d,!1),c.addEventListener("touchcancel",d,!1)},a._IOS_disable=function(a){var b=a.canvas;if(b){var c=a.__touch.f;b.removeEventListener("touchstart",c,!1),b.removeEventListener("touchmove",c,!1),b.removeEventListener("touchend",c,!1),b.removeEventListener("touchcancel",c,!1)}},a._IOS_handleEvent=function(a,b){if(a){a.__touch.preventDefault&&b.preventDefault&&b.preventDefault();for(var c=b.changedTouches,d=b.type,e=0,f=c.length;f>e;e++){var g=c[e],h=g.identifier;g.target==a.canvas&&("touchstart"==d?this._handleStart(a,h,b,g.pageX,g.pageY):"touchmove"==d?this._handleMove(a,h,b,g.pageX,g.pageY):("touchend"==d||"touchcancel"==d)&&this._handleEnd(a,h,b))}}},a._IE_enable=function(b){var c=b.canvas,d=b.__touch.f=function(c){a._IE_handleEvent(b,c)};void 0===window.navigator.pointerEnabled?(c.addEventListener("MSPointerDown",d,!1),window.addEventListener("MSPointerMove",d,!1),window.addEventListener("MSPointerUp",d,!1),window.addEventListener("MSPointerCancel",d,!1),b.__touch.preventDefault&&(c.style.msTouchAction="none")):(c.addEventListener("pointerdown",d,!1),window.addEventListener("pointermove",d,!1),window.addEventListener("pointerup",d,!1),window.addEventListener("pointercancel",d,!1),b.__touch.preventDefault&&(c.style.touchAction="none")),b.__touch.activeIDs={}},a._IE_disable=function(a){var b=a.__touch.f;void 0===window.navigator.pointerEnabled?(window.removeEventListener("MSPointerMove",b,!1),window.removeEventListener("MSPointerUp",b,!1),window.removeEventListener("MSPointerCancel",b,!1),a.canvas&&a.canvas.removeEventListener("MSPointerDown",b,!1)):(window.removeEventListener("pointermove",b,!1),window.removeEventListener("pointerup",b,!1),window.removeEventListener("pointercancel",b,!1),a.canvas&&a.canvas.removeEventListener("pointerdown",b,!1))},a._IE_handleEvent=function(a,b){if(a){a.__touch.preventDefault&&b.preventDefault&&b.preventDefault();var c=b.type,d=b.pointerId,e=a.__touch.activeIDs;if("MSPointerDown"==c||"pointerdown"==c){if(b.srcElement!=a.canvas)return;e[d]=!0,this._handleStart(a,d,b,b.pageX,b.pageY)}else e[d]&&("MSPointerMove"==c||"pointermove"==c?this._handleMove(a,d,b,b.pageX,b.pageY):("MSPointerUp"==c||"MSPointerCancel"==c||"pointerup"==c||"pointercancel"==c)&&(delete e[d],this._handleEnd(a,d,b)))}},a._handleStart=function(a,b,c,d,e){var f=a.__touch;if(f.multitouch||!f.count){var g=f.pointers;g[b]||(g[b]=!0,f.count++,a._handlePointerDown(b,c,d,e))}},a._handleMove=function(a,b,c,d,e){a.__touch.pointers[b]&&a._handlePointerMove(b,c,d,e)},a._handleEnd=function(a,b,c){var d=a.__touch,e=d.pointers;e[b]&&(d.count--,a._handlePointerUp(b,c,!0),delete e[b])},createjs.Touch=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=createjs.EaselJS=createjs.EaselJS||{};a.version="0.7.1",a.buildDate="Thu, 12 Dec 2013 23:33:39 GMT"}(); \ No newline at end of file diff --git a/views/archive/j/ball-shooting/vendors/movieclip-0.7.1.min.js b/views/archive/j/ball-shooting/vendors/movieclip-0.7.1.min.js new file mode 100644 index 00000000..5bc00131 --- /dev/null +++ b/views/archive/j/ball-shooting/vendors/movieclip-0.7.1.min.js @@ -0,0 +1,12 @@ +/*! +* @license EaselJS +* Visit http://createjs.com/ for documentation, updates and examples. +* +* Copyright (c) 2011-2013 gskinner.com, inc. +* +* Distributed under the terms of the MIT license. +* http://www.opensource.org/licenses/mit-license.html +* +* This notice shall be included in all copies or substantial portions of the Software. +*/ +this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b,c,d){this.initialize(a,b,c,d)},b=a.prototype=new createjs.Container;a.INDEPENDENT="independent",a.SINGLE_FRAME="single",a.SYNCHED="synched",b.mode,b.startPosition=0,b.loop=!0,b.currentFrame=0,b.timeline=null,b.paused=!1,b.actionsEnabled=!0,b.autoReset=!0,b.frameBounds=null,b._synchOffset=0,b._prevPos=-1,b._prevPosition=0,b._managed,b.Container_initialize=b.initialize,b.initialize=function(b,c,d,e){this.mode=b||a.INDEPENDENT,this.startPosition=c||0,this.loop=d;var f={paused:!0,position:c,useTicks:!0};this.Container_initialize(),this.timeline=new createjs.Timeline(null,e,f),this._managed={}},b.isVisible=function(){return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY)},b.Container_draw=b.draw,b.draw=function(a,b){return this.DisplayObject_draw(a,b)?!0:(this._updateTimeline(),this.Container_draw(a,b),!0)},b.play=function(){this.paused=!1},b.stop=function(){this.paused=!0},b.gotoAndPlay=function(a){this.paused=!1,this._goto(a)},b.gotoAndStop=function(a){this.paused=!0,this._goto(a)},b.getLabels=function(){return this.timeline.getLabels()},b.getCurrentLabel=function(){return this._updateTimeline(),this.timeline.getCurrentLabel()},b.clone=function(){throw"MovieClip cannot be cloned."},b.toString=function(){return"[MovieClip (name="+this.name+")]"},b.Container__tick=b._tick,b._tick=function(b){this.paused||this.mode!=a.INDEPENDENT||(this._prevPosition=this._prevPos<0?0:this._prevPosition+1,this._updateTimeline()),this.Container__tick(b)},b._goto=function(a){var b=this.timeline.resolve(a);null!=b&&(-1==this._prevPos&&(this._prevPos=0/0),this._prevPosition=b,this._updateTimeline())},b._reset=function(){this._prevPos=-1,this.currentFrame=0},b._updateTimeline=function(){var b=this.timeline,c=this.mode!=a.INDEPENDENT;if(b.loop=null==this.loop?!0:this.loop,c?b.setPosition(this.startPosition+(this.mode==a.SINGLE_FRAME?0:this._synchOffset),createjs.Tween.NONE):b.setPosition(this._prevPos<0?0:this._prevPosition,this.actionsEnabled?null:createjs.Tween.NONE),this._prevPosition=b._prevPosition,this._prevPos!=b._prevPos){this.currentFrame=this._prevPos=b._prevPos;for(var d in this._managed)this._managed[d]=1;for(var e=b._tweens,f=0,g=e.length;g>f;f++){var h=e[f],i=h._target;if(i!=this&&!h.passive){var j=h._stepPosition;i instanceof createjs.DisplayObject?this._addManagedChild(i,j):this._setState(i.state,j)}}var k=this.children;for(f=k.length-1;f>=0;f--){var l=k[f].id;1==this._managed[l]&&(this.removeChildAt(f),delete this._managed[l])}}},b._setState=function(a,b){if(a)for(var c=a.length-1;c>=0;c--){var d=a[c],e=d.t,f=d.p;for(var g in f)e[g]=f[g];this._addManagedChild(e,b)}},b._addManagedChild=function(b,c){b._off||(this.addChildAt(b,0),b instanceof a&&(b._synchOffset=c,b.mode==a.INDEPENDENT&&b.autoReset&&!this._managed[b.id]&&b._reset()),this._managed[b.id]=2)},b.Container__getBounds=b._getBounds,b._getBounds=function(a,b){var c=this.DisplayObject_getBounds();return c||(this._updateTimeline(),this.frameBounds&&(c=this._rectangle.copy(this.frameBounds[this.currentFrame]))),c?this._transformBounds(c,a,b):this.Container__getBounds(a,b)},createjs.MovieClip=a;var c=function(){throw"MovieClipPlugin cannot be instantiated."};c.priority=100,c.install=function(){createjs.Tween.installPlugin(c,["startPosition"])},c.init=function(a,b,c){return c},c.step=function(){},c.tween=function(b,c,d,e,f,g){return b.target instanceof a?1==g?f[c]:e[c]:d},c.install()}(); \ No newline at end of file diff --git a/views/archive/j/ball-shooting/vendors/preloadjs-0.4.1.min.js b/views/archive/j/ball-shooting/vendors/preloadjs-0.4.1.min.js new file mode 100644 index 00000000..b61cea1c --- /dev/null +++ b/views/archive/j/ball-shooting/vendors/preloadjs-0.4.1.min.js @@ -0,0 +1,12 @@ +/*! +* @license PreloadJS +* Visit http://createjs.com/ for documentation, updates and examples. +* +* Copyright (c) 2011-2013 gskinner.com, inc. +* +* Distributed under the terms of the MIT license. +* http://www.opensource.org/licenses/mit-license.html +* +* This notice shall be included in all copies or substantial portions of the Software. +*/ +this.createjs=this.createjs||{},function(){"use strict";var a=createjs.PreloadJS=createjs.PreloadJS||{};a.version="0.4.1",a.buildDate="Thu, 12 Dec 2013 23:33:38 GMT"}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b,c){this.initialize(a,b,c)},b=a.prototype;b.type=null,b.target=null,b.currentTarget=null,b.eventPhase=0,b.bubbles=!1,b.cancelable=!1,b.timeStamp=0,b.defaultPrevented=!1,b.propagationStopped=!1,b.immediatePropagationStopped=!1,b.removed=!1,b.initialize=function(a,b,c){this.type=a,this.bubbles=b,this.cancelable=c,this.timeStamp=(new Date).getTime()},b.preventDefault=function(){this.defaultPrevented=!0},b.stopPropagation=function(){this.propagationStopped=!0},b.stopImmediatePropagation=function(){this.immediatePropagationStopped=this.propagationStopped=!0},b.remove=function(){this.removed=!0},b.clone=function(){return new a(this.type,this.bubbles,this.cancelable)},b.toString=function(){return"[Event (type="+this.type+")]"},createjs.Event=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(){},b=a.prototype;a.initialize=function(a){a.addEventListener=b.addEventListener,a.on=b.on,a.removeEventListener=a.off=b.removeEventListener,a.removeAllEventListeners=b.removeAllEventListeners,a.hasEventListener=b.hasEventListener,a.dispatchEvent=b.dispatchEvent,a._dispatchEvent=b._dispatchEvent,a.willTrigger=b.willTrigger},b._listeners=null,b._captureListeners=null,b.initialize=function(){},b.addEventListener=function(a,b,c){var d;d=c?this._captureListeners=this._captureListeners||{}:this._listeners=this._listeners||{};var e=d[a];return e&&this.removeEventListener(a,b,c),e=d[a],e?e.push(b):d[a]=[b],b},b.on=function(a,b,c,d,e,f){return b.handleEvent&&(c=c||b,b=b.handleEvent),c=c||this,this.addEventListener(a,function(a){b.call(c,a,e),d&&a.remove()},f)},b.removeEventListener=function(a,b,c){var d=c?this._captureListeners:this._listeners;if(d){var e=d[a];if(e)for(var f=0,g=e.length;g>f;f++)if(e[f]==b){1==g?delete d[a]:e.splice(f,1);break}}},b.off=b.removeEventListener,b.removeAllEventListeners=function(a){a?(this._listeners&&delete this._listeners[a],this._captureListeners&&delete this._captureListeners[a]):this._listeners=this._captureListeners=null},b.dispatchEvent=function(a,b){if("string"==typeof a){var c=this._listeners;if(!c||!c[a])return!1;a=new createjs.Event(a)}if(a.target=b||this,a.bubbles&&this.parent){for(var d=this,e=[d];d.parent;)e.push(d=d.parent);var f,g=e.length;for(f=g-1;f>=0&&!a.propagationStopped;f--)e[f]._dispatchEvent(a,1+(0==f));for(f=1;g>f&&!a.propagationStopped;f++)e[f]._dispatchEvent(a,3)}else this._dispatchEvent(a,2);return a.defaultPrevented},b.hasEventListener=function(a){var b=this._listeners,c=this._captureListeners;return!!(b&&b[a]||c&&c[a])},b.willTrigger=function(a){for(var b=this;b;){if(b.hasEventListener(a))return!0;b=b.parent}return!1},b.toString=function(){return"[EventDispatcher]"},b._dispatchEvent=function(a,b){var c,d=1==b?this._captureListeners:this._listeners;if(a&&d){var e=d[a.type];if(!e||!(c=e.length))return;a.currentTarget=this,a.eventPhase=b,a.removed=!1,e=e.slice();for(var f=0;c>f&&!a.immediatePropagationStopped;f++){var g=e[f];g.handleEvent?g.handleEvent(a):g(a),a.removed&&(this.off(a.type,g,1==b),a.removed=!1)}}},createjs.EventDispatcher=a}(),this.createjs=this.createjs||{},function(){"use strict";createjs.indexOf=function(a,b){for(var c=0,d=a.length;d>c;c++)if(b===a[c])return c;return-1}}(),this.createjs=this.createjs||{},function(){"use strict";createjs.proxy=function(a,b){var c=Array.prototype.slice.call(arguments,2);return function(){return a.apply(b,Array.prototype.slice.call(arguments,0).concat(c))}}}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(){this.init()};a.prototype=new createjs.EventDispatcher;var b=a.prototype,c=a;c.FILE_PATTERN=/^(?:(\w+:)\/{2}(\w+(?:\.\w+)*\/?)|(.{0,2}\/{1}))?([/.]*?(?:[^?]+)?\/)?((?:[^/?]+)\.(\w+))(?:\?(\S+)?)?$/,c.PATH_PATTERN=/^(?:(\w+:)\/{2})|(.{0,2}\/{1})?([/.]*?(?:[^?]+)?\/?)?$/,b.loaded=!1,b.canceled=!1,b.progress=0,b._item=null,b.getItem=function(){return this._item},b.init=function(){},b.load=function(){},b.close=function(){},b._sendLoadStart=function(){this._isCanceled()||this.dispatchEvent("loadstart")},b._sendProgress=function(a){if(!this._isCanceled()){var b=null;"number"==typeof a?(this.progress=a,b=new createjs.Event("progress"),b.loaded=this.progress,b.total=1):(b=a,this.progress=a.loaded/a.total,(isNaN(this.progress)||1/0==this.progress)&&(this.progress=0)),b.progress=this.progress,this.hasEventListener("progress")&&this.dispatchEvent(b)}},b._sendComplete=function(){this._isCanceled()||this.dispatchEvent("complete")},b._sendError=function(a){!this._isCanceled()&&this.hasEventListener("error")&&(null==a&&(a=new createjs.Event("error")),this.dispatchEvent(a))},b._isCanceled=function(){return null==window.createjs||this.canceled?!0:!1},b._parseURI=function(a){return a?a.match(c.FILE_PATTERN):null},b._parsePath=function(a){return a?a.match(c.PATH_PATTERN):null},b._formatQueryString=function(a,b){if(null==a)throw new Error("You must specify data.");var c=[];for(var d in a)c.push(d+"="+escape(a[d]));return b&&(c=c.concat(b)),c.join("&")},b.buildPath=function(a,b){if(null==b)return a;var c=[],d=a.indexOf("?");if(-1!=d){var e=a.slice(d+1);c=c.concat(e.split("&"))}return-1!=d?a.slice(0,d)+"?"+this._formatQueryString(b,c):a+"?"+this._formatQueryString(b,c)},b._isCrossDomain=function(a){var b=document.createElement("a");b.href=a.src;var c=document.createElement("a");c.href=location.href;var d=""!=b.hostname&&(b.port!=c.port||b.protocol!=c.protocol||b.hostname!=c.hostname);return d},b._isLocal=function(a){var b=document.createElement("a");return b.href=a.src,""==b.hostname&&"file:"==b.protocol},b.toString=function(){return"[PreloadJS AbstractLoader]"},createjs.AbstractLoader=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b,c){this.init(a,b,c)},b=a.prototype=new createjs.AbstractLoader,c=a;c.loadTimeout=8e3,c.LOAD_TIMEOUT=0,c.BINARY="binary",c.CSS="css",c.IMAGE="image",c.JAVASCRIPT="javascript",c.JSON="json",c.JSONP="jsonp",c.MANIFEST="manifest",c.SOUND="sound",c.SVG="svg",c.TEXT="text",c.XML="xml",c.POST="POST",c.GET="GET",b._basePath=null,b._crossOrigin="",b.useXHR=!0,b.stopOnError=!1,b.maintainScriptOrder=!0,b.next=null,b._typeCallbacks=null,b._extensionCallbacks=null,b._loadStartWasDispatched=!1,b._maxConnections=1,b._currentlyLoadingScript=null,b._currentLoads=null,b._loadQueue=null,b._loadQueueBackup=null,b._loadItemsById=null,b._loadItemsBySrc=null,b._loadedResults=null,b._loadedRawResults=null,b._numItems=0,b._numItemsLoaded=0,b._scriptOrder=null,b._loadedScripts=null,b.init=function(a,b,c){this._numItems=this._numItemsLoaded=0,this._paused=!1,this._loadStartWasDispatched=!1,this._currentLoads=[],this._loadQueue=[],this._loadQueueBackup=[],this._scriptOrder=[],this._loadedScripts=[],this._loadItemsById={},this._loadItemsBySrc={},this._loadedResults={},this._loadedRawResults={},this._typeCallbacks={},this._extensionCallbacks={},this._basePath=b,this.setUseXHR(a),this._crossOrigin=c===!0?"Anonymous":c===!1||null==c?"":c},b.setUseXHR=function(a){return this.useXHR=0!=a&&null!=window.XMLHttpRequest,this.useXHR},b.removeAll=function(){this.remove()},b.remove=function(a){var b=null;if(!a||a instanceof Array){if(a)b=a;else if(arguments.length>0)return}else b=[a];var c=!1;if(b){for(;b.length;){var d=b.pop(),e=this.getResult(d);for(f=this._loadQueue.length-1;f>=0;f--)if(g=this._loadQueue[f].getItem(),g.id==d||g.src==d){this._loadQueue.splice(f,1)[0].cancel();break}for(f=this._loadQueueBackup.length-1;f>=0;f--)if(g=this._loadQueueBackup[f].getItem(),g.id==d||g.src==d){this._loadQueueBackup.splice(f,1)[0].cancel();break}if(e)delete this._loadItemsById[e.id],delete this._loadItemsBySrc[e.src],this._disposeItem(e);else for(var f=this._currentLoads.length-1;f>=0;f--){var g=this._currentLoads[f].getItem();if(g.id==d||g.src==d){this._currentLoads.splice(f,1)[0].cancel(),c=!0;break}}}c&&this._loadNext()}else{this.close();for(var h in this._loadItemsById)this._disposeItem(this._loadItemsById[h]);this.init(this.useXHR)}},b.reset=function(){this.close();for(var a in this._loadItemsById)this._disposeItem(this._loadItemsById[a]);for(var b=[],c=0,d=this._loadQueueBackup.length;d>c;c++)b.push(this._loadQueueBackup[c].getItem());this.loadManifest(b,!1)},c.isBinary=function(a){switch(a){case createjs.LoadQueue.IMAGE:case createjs.LoadQueue.BINARY:return!0;default:return!1}},c.isText=function(a){switch(a){case createjs.LoadQueue.TEXT:case createjs.LoadQueue.JSON:case createjs.LoadQueue.MANIFEST:case createjs.LoadQueue.XML:case createjs.LoadQueue.HTML:case createjs.LoadQueue.CSS:case createjs.LoadQueue.SVG:case createjs.LoadQueue.JAVASCRIPT:return!0;default:return!1}},b.installPlugin=function(a){if(null!=a&&null!=a.getPreloadHandlers){var b=a.getPreloadHandlers();if(b.scope=a,null!=b.types)for(var c=0,d=b.types.length;d>c;c++)this._typeCallbacks[b.types[c]]=b;if(null!=b.extensions)for(c=0,d=b.extensions.length;d>c;c++)this._extensionCallbacks[b.extensions[c]]=b}},b.setMaxConnections=function(a){this._maxConnections=a,!this._paused&&this._loadQueue.length>0&&this._loadNext()},b.loadFile=function(a,b,c){if(null==a){var d=new createjs.Event("error");return d.text="PRELOAD_NO_FILE",this._sendError(d),void 0}this._addItem(a,null,c),b!==!1?this.setPaused(!1):this.setPaused(!0)},b.loadManifest=function(a,b,d){var e=null,f=null;if(a instanceof Array){if(0==a.length){var g=new createjs.Event("error");return g.text="PRELOAD_MANIFEST_EMPTY",this._sendError(g),void 0}e=a}else if("string"==typeof a)e=[{src:a,type:c.MANIFEST}];else{if("object"!=typeof a){var g=new createjs.Event("error");return g.text="PRELOAD_MANIFEST_NULL",this._sendError(g),void 0}if(void 0!==a.src){if(null==a.type)a.type=c.MANIFEST;else if(a.type!=c.MANIFEST){var g=new createjs.Event("error");g.text="PRELOAD_MANIFEST_ERROR",this._sendError(g)}e=[a]}else void 0!==a.manifest&&(e=a.manifest,f=a.path)}for(var h=0,i=e.length;i>h;h++)this._addItem(e[h],f,d);b!==!1?this.setPaused(!1):this.setPaused(!0)},b.load=function(){this.setPaused(!1)},b.getItem=function(a){return this._loadItemsById[a]||this._loadItemsBySrc[a]},b.getResult=function(a,b){var c=this._loadItemsById[a]||this._loadItemsBySrc[a];if(null==c)return null;var d=c.id;return b&&this._loadedRawResults[d]?this._loadedRawResults[d]:this._loadedResults[d]},b.setPaused=function(a){this._paused=a,this._paused||this._loadNext()},b.close=function(){for(;this._currentLoads.length;)this._currentLoads.pop().cancel();this._scriptOrder.length=0,this._loadedScripts.length=0,this.loadStartWasDispatched=!1},b._addItem=function(a,b,c){var d=this._createLoadItem(a,b,c);if(null!=d){var e=this._createLoader(d);null!=e&&(this._loadQueue.push(e),this._loadQueueBackup.push(e),this._numItems++,this._updateProgress(),this.maintainScriptOrder&&d.type==createjs.LoadQueue.JAVASCRIPT&&e instanceof createjs.XHRLoader&&(this._scriptOrder.push(d),this._loadedScripts.push(null)))}},b._createLoadItem=function(a,b,c){var d=null;switch(typeof a){case"string":d={src:a};break;case"object":d=window.HTMLAudioElement&&a instanceof window.HTMLAudioElement?{tag:a,src:d.tag.src,type:createjs.LoadQueue.SOUND}:a;break;default:return null}var e=this._parseURI(d.src);null!=e&&(d.ext=e[6]),null==d.type&&(d.type=this._getTypeByExtension(d.ext));var f="",g=c||this._basePath,h=d.src;if(e&&null==e[1]&&null==e[3])if(b){f=b;var i=this._parsePath(b);h=b+h,null!=g&&i&&null==i[1]&&null==i[2]&&(f=g+f)}else null!=g&&(f=g);if(d.src=f+d.src,d.path=f,(d.type==createjs.LoadQueue.JSON||d.type==createjs.LoadQueue.MANIFEST)&&(d._loadAsJSONP=null!=d.callback),d.type==createjs.LoadQueue.JSONP&&null==d.callback)throw new Error("callback is required for loading JSONP requests.");(void 0===d.tag||null===d.tag)&&(d.tag=this._createTag(d)),(void 0===d.id||null===d.id||""===d.id)&&(d.id=h);var j=this._typeCallbacks[d.type]||this._extensionCallbacks[d.ext];if(j){var k=j.callback.call(j.scope,d.src,d.type,d.id,d.data,f,this);if(k===!1)return null;k===!0||(null!=k.src&&(d.src=k.src),null!=k.id&&(d.id=k.id),null!=k.tag&&(d.tag=k.tag),null!=k.completeHandler&&(d.completeHandler=k.completeHandler),k.type&&(d.type=k.type),e=this._parseURI(d.src),null!=e&&null!=e[6]&&(d.ext=e[6].toLowerCase()))}return this._loadItemsById[d.id]=d,this._loadItemsBySrc[d.src]=d,d},b._createLoader=function(a){var b=this.useXHR;switch(a.type){case createjs.LoadQueue.JSON:case createjs.LoadQueue.MANIFEST:b=!a._loadAsJSONP;break;case createjs.LoadQueue.XML:case createjs.LoadQueue.TEXT:b=!0;break;case createjs.LoadQueue.SOUND:case createjs.LoadQueue.JSONP:b=!1;break;case null:return null}return b?new createjs.XHRLoader(a,this._crossOrigin):new createjs.TagLoader(a)},b._loadNext=function(){if(!this._paused){this._loadStartWasDispatched||(this._sendLoadStart(),this._loadStartWasDispatched=!0),this._numItems==this._numItemsLoaded?(this.loaded=!0,this._sendComplete(),this.next&&this.next.load&&this.next.load()):this.loaded=!1;for(var a=0;a=this._maxConnections);a++){var b=this._loadQueue[a];if(this.maintainScriptOrder&&b instanceof createjs.TagLoader&&b.getItem().type==createjs.LoadQueue.JAVASCRIPT){if(this._currentlyLoadingScript)continue;this._currentlyLoadingScript=!0}this._loadQueue.splice(a,1),a--,this._loadItem(b)}}},b._loadItem=function(a){a.on("progress",this._handleProgress,this),a.on("complete",this._handleFileComplete,this),a.on("error",this._handleFileError,this),this._currentLoads.push(a),this._sendFileStart(a.getItem()),a.load()},b._handleFileError=function(a){var b=a.target;this._numItemsLoaded++,this._updateProgress();var c=new createjs.Event("error");c.text="FILE_LOAD_ERROR",c.item=b.getItem(),this._sendError(c),this.stopOnError||(this._removeLoadItem(b),this._loadNext())},b._handleFileComplete=function(a){var b=a.target,c=b.getItem();if(this._loadedResults[c.id]=b.getResult(),b instanceof createjs.XHRLoader&&(this._loadedRawResults[c.id]=b.getResult(!0)),this._removeLoadItem(b),this.maintainScriptOrder&&c.type==createjs.LoadQueue.JAVASCRIPT){if(!(b instanceof createjs.TagLoader))return this._loadedScripts[createjs.indexOf(this._scriptOrder,c)]=c,this._checkScriptLoadOrder(b),void 0;this._currentlyLoadingScript=!1}if(delete c._loadAsJSONP,c.type==createjs.LoadQueue.MANIFEST){var d=b.getResult();null!=d&&void 0!==d.manifest&&this.loadManifest(d,!0)}this._processFinishedLoad(c,b)},b._processFinishedLoad=function(a,b){this._numItemsLoaded++,this._updateProgress(),this._sendFileComplete(a,b),this._loadNext()},b._checkScriptLoadOrder=function(){for(var a=this._loadedScripts.length,b=0;a>b;b++){var c=this._loadedScripts[b];if(null===c)break;if(c!==!0){var d=this._loadedResults[c.id];(document.body||document.getElementsByTagName("body")[0]).appendChild(d),this._processFinishedLoad(c),this._loadedScripts[b]=!0}}},b._removeLoadItem=function(a){for(var b=this._currentLoads.length,c=0;b>c;c++)if(this._currentLoads[c]==a){this._currentLoads.splice(c,1);break}},b._handleProgress=function(a){var b=a.target;this._sendFileProgress(b.getItem(),b.progress),this._updateProgress()},b._updateProgress=function(){var a=this._numItemsLoaded/this._numItems,b=this._numItems-this._numItemsLoaded;if(b>0){for(var c=0,d=0,e=this._currentLoads.length;e>d;d++)c+=this._currentLoads[d].progress;a+=c/b*(b/this._numItems)}this._sendProgress(a)},b._disposeItem=function(a){delete this._loadedResults[a.id],delete this._loadedRawResults[a.id],delete this._loadItemsById[a.id],delete this._loadItemsBySrc[a.src]},b._createTag=function(a){var b=null;switch(a.type){case createjs.LoadQueue.IMAGE:return b=document.createElement("img"),""==this._crossOrigin||this._isLocal(a)||(b.crossOrigin=this._crossOrigin),b;case createjs.LoadQueue.SOUND:return b=document.createElement("audio"),b.autoplay=!1,b;case createjs.LoadQueue.JSON:case createjs.LoadQueue.JSONP:case createjs.LoadQueue.JAVASCRIPT:case createjs.LoadQueue.MANIFEST:return b=document.createElement("script"),b.type="text/javascript",b;case createjs.LoadQueue.CSS:return b=this.useXHR?document.createElement("style"):document.createElement("link"),b.rel="stylesheet",b.type="text/css",b;case createjs.LoadQueue.SVG:return this.useXHR?b=document.createElement("svg"):(b=document.createElement("object"),b.type="image/svg+xml"),b}return null},b._getTypeByExtension=function(a){if(null==a)return createjs.LoadQueue.TEXT;switch(a.toLowerCase()){case"jpeg":case"jpg":case"gif":case"png":case"webp":case"bmp":return createjs.LoadQueue.IMAGE;case"ogg":case"mp3":case"wav":return createjs.LoadQueue.SOUND;case"json":return createjs.LoadQueue.JSON;case"xml":return createjs.LoadQueue.XML;case"css":return createjs.LoadQueue.CSS;case"js":return createjs.LoadQueue.JAVASCRIPT;case"svg":return createjs.LoadQueue.SVG;default:return createjs.LoadQueue.TEXT}},b._sendFileProgress=function(a,b){if(this._isCanceled())return this._cleanUp(),void 0;if(this.hasEventListener("fileprogress")){var c=new createjs.Event("fileprogress");c.progress=b,c.loaded=b,c.total=1,c.item=a,this.dispatchEvent(c)}},b._sendFileComplete=function(a,b){if(!this._isCanceled()){var c=new createjs.Event("fileload");c.loader=b,c.item=a,c.result=this._loadedResults[a.id],c.rawResult=this._loadedRawResults[a.id],a.completeHandler&&a.completeHandler(c),this.hasEventListener("fileload")&&this.dispatchEvent(c)}},b._sendFileStart=function(a){var b=new createjs.Event("filestart");b.item=a,this.hasEventListener("filestart")&&this.dispatchEvent(b)},b.toString=function(){return"[PreloadJS LoadQueue]"},createjs.LoadQueue=a;var d=function(){};d.init=function(){var a=navigator.userAgent;d.isFirefox=a.indexOf("Firefox")>-1,d.isOpera=null!=window.opera,d.isChrome=a.indexOf("Chrome")>-1,d.isIOS=a.indexOf("iPod")>-1||a.indexOf("iPhone")>-1||a.indexOf("iPad")>-1},d.init(),createjs.LoadQueue.BrowserDetect=d}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a){this.init(a)},b=a.prototype=new createjs.AbstractLoader;b._loadTimeout=null,b._tagCompleteProxy=null,b._isAudio=!1,b._tag=null,b._jsonResult=null,b.init=function(a){this._item=a,this._tag=a.tag,this._isAudio=window.HTMLAudioElement&&a.tag instanceof window.HTMLAudioElement,this._tagCompleteProxy=createjs.proxy(this._handleLoad,this)},b.getResult=function(){return this._item.type==createjs.LoadQueue.JSONP||this._item.type==createjs.LoadQueue.MANIFEST?this._jsonResult:this._tag},b.cancel=function(){this.canceled=!0,this._clean()},b.load=function(){var a=this._item,b=this._tag;clearTimeout(this._loadTimeout);var c=createjs.LoadQueue.LOAD_TIMEOUT;0==c&&(c=createjs.LoadQueue.loadTimeout),this._loadTimeout=setTimeout(createjs.proxy(this._handleTimeout,this),c),this._isAudio&&(b.src=null,b.preload="auto"),b.onerror=createjs.proxy(this._handleError,this),this._isAudio?(b.onstalled=createjs.proxy(this._handleStalled,this),b.addEventListener("canplaythrough",this._tagCompleteProxy,!1)):(b.onload=createjs.proxy(this._handleLoad,this),b.onreadystatechange=createjs.proxy(this._handleReadyStateChange,this));var d=this.buildPath(a.src,a.values);switch(a.type){case createjs.LoadQueue.CSS:b.href=d;break;case createjs.LoadQueue.SVG:b.data=d;break;default:b.src=d}if(a.type==createjs.LoadQueue.JSONP||a.type==createjs.LoadQueue.JSON||a.type==createjs.LoadQueue.MANIFEST){if(null==a.callback)throw new Error("callback is required for loading JSONP requests.");if(null!=window[a.callback])throw new Error('JSONP callback "'+a.callback+'" already exists on window. You need to specify a different callback. Or re-name the current one.');window[a.callback]=createjs.proxy(this._handleJSONPLoad,this)}(a.type==createjs.LoadQueue.SVG||a.type==createjs.LoadQueue.JSONP||a.type==createjs.LoadQueue.JSON||a.type==createjs.LoadQueue.MANIFEST||a.type==createjs.LoadQueue.JAVASCRIPT||a.type==createjs.LoadQueue.CSS)&&(this._startTagVisibility=b.style.visibility,b.style.visibility="hidden",(document.body||document.getElementsByTagName("body")[0]).appendChild(b)),null!=b.load&&b.load()},b._handleJSONPLoad=function(a){this._jsonResult=a},b._handleTimeout=function(){this._clean();var a=new createjs.Event("error");a.text="PRELOAD_TIMEOUT",this._sendError(a)},b._handleStalled=function(){},b._handleError=function(){this._clean();var a=new createjs.Event("error");this._sendError(a)},b._handleReadyStateChange=function(){clearTimeout(this._loadTimeout);var a=this.getItem().tag;("loaded"==a.readyState||"complete"==a.readyState)&&this._handleLoad()},b._handleLoad=function(){if(!this._isCanceled()){var a=this.getItem(),b=a.tag;if(!(this.loaded||this._isAudio&&4!==b.readyState)){switch(this.loaded=!0,a.type){case createjs.LoadQueue.SVG:case createjs.LoadQueue.JSON:case createjs.LoadQueue.JSONP:case createjs.LoadQueue.MANIFEST:case createjs.LoadQueue.CSS:b.style.visibility=this._startTagVisibility,(document.body||document.getElementsByTagName("body")[0]).removeChild(b)}this._clean(),this._sendComplete()}}},b._clean=function(){clearTimeout(this._loadTimeout);var a=this.getItem(),b=a.tag;null!=b&&(b.onload=null,b.removeEventListener&&b.removeEventListener("canplaythrough",this._tagCompleteProxy,!1),b.onstalled=null,b.onprogress=null,b.onerror=null,null!=b.parentNode&&a.type==createjs.LoadQueue.SVG&&a.type==createjs.LoadQueue.JSON&&a.type==createjs.LoadQueue.MANIFEST&&a.type==createjs.LoadQueue.CSS&&a.type==createjs.LoadQueue.JSONP&&b.parentNode.removeChild(b));var a=this.getItem();(a.type==createjs.LoadQueue.JSONP||a.type==createjs.LoadQueue.MANIFEST)&&(window[a.callback]=null)},b.toString=function(){return"[PreloadJS TagLoader]"},createjs.TagLoader=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b){this.init(a,b)},b=a.prototype=new createjs.AbstractLoader;b._request=null,b._loadTimeout=null,b._xhrLevel=1,b._response=null,b._rawResponse=null,b._crossOrigin="",b.init=function(a,b){this._item=a,this._crossOrigin=b,!this._createXHR(a)},b.getResult=function(a){return a&&this._rawResponse?this._rawResponse:this._response},b.cancel=function(){this.canceled=!0,this._clean(),this._request.abort()},b.load=function(){if(null==this._request)return this._handleError(),void 0;if(this._request.onloadstart=createjs.proxy(this._handleLoadStart,this),this._request.onprogress=createjs.proxy(this._handleProgress,this),this._request.onabort=createjs.proxy(this._handleAbort,this),this._request.onerror=createjs.proxy(this._handleError,this),this._request.ontimeout=createjs.proxy(this._handleTimeout,this),1==this._xhrLevel){var a=createjs.LoadQueue.LOAD_TIMEOUT;if(0==a)a=createjs.LoadQueue.loadTimeout;else try{console.warn("LoadQueue.LOAD_TIMEOUT has been deprecated in favor of LoadQueue.loadTimeout")}catch(b){}this._loadTimeout=setTimeout(createjs.proxy(this._handleTimeout,this),a)}this._request.onload=createjs.proxy(this._handleLoad,this),this._request.onreadystatechange=createjs.proxy(this._handleReadyStateChange,this);try{this._item.values&&this._item.method!=createjs.LoadQueue.GET?this._item.method==createjs.LoadQueue.POST&&this._request.send(this._formatQueryString(this._item.values)):this._request.send()}catch(c){var d=new createjs.Event("error");d.error=c,this._sendError(d)}},b.getAllResponseHeaders=function(){return this._request.getAllResponseHeaders instanceof Function?this._request.getAllResponseHeaders():null},b.getResponseHeader=function(a){return this._request.getResponseHeader instanceof Function?this._request.getResponseHeader(a):null},b._handleProgress=function(a){if(a&&!(a.loaded>0&&0==a.total)){var b=new createjs.Event("progress");b.loaded=a.loaded,b.total=a.total,this._sendProgress(b)}},b._handleLoadStart=function(){clearTimeout(this._loadTimeout),this._sendLoadStart()},b._handleAbort=function(){this._clean();var a=new createjs.Event("error");a.text="XHR_ABORTED",this._sendError(a)},b._handleError=function(){this._clean();var a=new createjs.Event("error");this._sendError(a)},b._handleReadyStateChange=function(){4==this._request.readyState&&this._handleLoad()},b._handleLoad=function(){if(!this.loaded){if(this.loaded=!0,!this._checkError())return this._handleError(),void 0;this._response=this._getResponse(),this._clean();var a=this._generateTag();a&&this._sendComplete()}},b._handleTimeout=function(a){this._clean();var b=new createjs.Event("error");b.text="PRELOAD_TIMEOUT",this._sendError(a)},b._checkError=function(){var a=parseInt(this._request.status);switch(a){case 404:case 0:return!1}return!0},b._getResponse=function(){if(null!=this._response)return this._response;if(null!=this._request.response)return this._request.response;try{if(null!=this._request.responseText)return this._request.responseText}catch(a){}try{if(null!=this._request.responseXML)return this._request.responseXML}catch(a){}return null},b._createXHR=function(a){var b=this._isCrossDomain(a),c=null;if(b&&window.XDomainRequest)c=new XDomainRequest;else if(window.XMLHttpRequest)c=new XMLHttpRequest;else try{c=new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(d){try{c=new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(d){try{c=new ActiveXObject("Msxml2.XMLHTTP")}catch(d){return!1}}}createjs.LoadQueue.isText(a.type)&&c.overrideMimeType&&c.overrideMimeType("text/plain; charset=utf-8"),this._xhrLevel="string"==typeof c.responseType?2:1;var e=null;return e=a.method==createjs.LoadQueue.GET?this.buildPath(a.src,a.values):a.src,c.open(a.method||createjs.LoadQueue.GET,e,!0),b&&c instanceof XMLHttpRequest&&1==this._xhrLevel&&c.setRequestHeader("Origin",location.origin),a.values&&a.method==createjs.LoadQueue.POST&&c.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),createjs.LoadQueue.isBinary(a.type)&&(c.responseType="arraybuffer"),this._request=c,!0},b._clean=function(){clearTimeout(this._loadTimeout);var a=this._request;a.onloadstart=null,a.onprogress=null,a.onabort=null,a.onerror=null,a.onload=null,a.ontimeout=null,a.onloadend=null,a.onreadystatechange=null},b._generateTag=function(){var a=this._item.type,b=this._item.tag;switch(a){case createjs.LoadQueue.IMAGE:return b.onload=createjs.proxy(this._handleTagReady,this),""!=this._crossOrigin&&(b.crossOrigin="Anonymous"),b.src=this.buildPath(this._item.src,this._item.values),this._rawResponse=this._response,this._response=b,!1;case createjs.LoadQueue.JAVASCRIPT:return b=document.createElement("script"),b.text=this._response,this._rawResponse=this._response,this._response=b,!0;case createjs.LoadQueue.CSS:var c=document.getElementsByTagName("head")[0];if(c.appendChild(b),b.styleSheet)b.styleSheet.cssText=this._response;else{var d=document.createTextNode(this._response);b.appendChild(d)}return this._rawResponse=this._response,this._response=b,!0;case createjs.LoadQueue.XML:var e=this._parseXML(this._response,"text/xml");return this._rawResponse=this._response,this._response=e,!0;case createjs.LoadQueue.SVG:var e=this._parseXML(this._response,"image/svg+xml");return this._rawResponse=this._response,null!=e.documentElement?(b.appendChild(e.documentElement),this._response=b):this._response=e,!0;case createjs.LoadQueue.JSON:case createjs.LoadQueue.MANIFEST:var f={};try{f=JSON.parse(this._response)}catch(g){f=g}return this._rawResponse=this._response,this._response=f,!0}return!0},b._parseXML=function(a,b){var c=null;try{if(window.DOMParser){var d=new DOMParser;c=d.parseFromString(a,b)}else c=new ActiveXObject("Microsoft.XMLDOM"),c.async=!1,c.loadXML(a)}catch(e){}return c},b._handleTagReady=function(){this._sendComplete()},b.toString=function(){return"[PreloadJS XHRLoader]"},createjs.XHRLoader=a}(),"object"!=typeof JSON&&(JSON={}),function(){"use strict";function f(a){return 10>a?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return"string"==typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g,h=gap,i=b[a];switch(i&&"object"==typeof i&&"function"==typeof i.toJSON&&(i=i.toJSON(a)),"function"==typeof rep&&(i=rep.call(b,a,i)),typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";if(gap+=indent,g=[],"[object Array]"===Object.prototype.toString.apply(i)){for(f=i.length,c=0;f>c;c+=1)g[c]=str(c,i)||"null";return e=0===g.length?"[]":gap?"[\n"+gap+g.join(",\n"+gap)+"\n"+h+"]":"["+g.join(",")+"]",gap=h,e}if(rep&&"object"==typeof rep)for(f=rep.length,c=0;f>c;c+=1)"string"==typeof rep[c]&&(d=rep[c],e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&g.push(quote(d)+(gap?": ":":")+e));return e=0===g.length?"{}":gap?"{\n"+gap+g.join(",\n"+gap)+"\n"+h+"}":"{"+g.join(",")+"}",gap=h,e}}"function"!=typeof Date.prototype.toJSON&&(Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;"function"!=typeof JSON.stringify&&(JSON.stringify=function(a,b,c){var d;if(gap="",indent="","number"==typeof c)for(d=0;c>d;d+=1)indent+=" ";else"string"==typeof c&&(indent=c);if(rep=b,b&&"function"!=typeof b&&("object"!=typeof b||"number"!=typeof b.length))throw new Error("JSON.stringify");return str("",{"":a})}),"function"!=typeof JSON.parse&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&"object"==typeof e)for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),void 0!==d?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;if(text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})),/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),"function"==typeof reviver?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}(); \ No newline at end of file diff --git a/views/archive/j/ball-shooting/vendors/tweenjs-0.5.1.min.js b/views/archive/j/ball-shooting/vendors/tweenjs-0.5.1.min.js new file mode 100644 index 00000000..911bbb45 --- /dev/null +++ b/views/archive/j/ball-shooting/vendors/tweenjs-0.5.1.min.js @@ -0,0 +1,17 @@ +/*! +* @license TweenJS +* Visit http://createjs.com/ for documentation, updates and examples. +* +* Copyright (c) 2011-2013 gskinner.com, inc. +* +* Distributed under the terms of the MIT license. +* http://www.opensource.org/licenses/mit-license.html +* +* This notice shall be included in all copies or substantial portions of the Software. +*/ + +/**! + * SoundJS FlashPlugin also includes swfobject (http://code.google.com/p/swfobject/) + */ + +this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b,c){this.initialize(a,b,c)},b=a.prototype;b.type=null,b.target=null,b.currentTarget=null,b.eventPhase=0,b.bubbles=!1,b.cancelable=!1,b.timeStamp=0,b.defaultPrevented=!1,b.propagationStopped=!1,b.immediatePropagationStopped=!1,b.removed=!1,b.initialize=function(a,b,c){this.type=a,this.bubbles=b,this.cancelable=c,this.timeStamp=(new Date).getTime()},b.preventDefault=function(){this.defaultPrevented=!0},b.stopPropagation=function(){this.propagationStopped=!0},b.stopImmediatePropagation=function(){this.immediatePropagationStopped=this.propagationStopped=!0},b.remove=function(){this.removed=!0},b.clone=function(){return new a(this.type,this.bubbles,this.cancelable)},b.toString=function(){return"[Event (type="+this.type+")]"},createjs.Event=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(){},b=a.prototype;a.initialize=function(a){a.addEventListener=b.addEventListener,a.on=b.on,a.removeEventListener=a.off=b.removeEventListener,a.removeAllEventListeners=b.removeAllEventListeners,a.hasEventListener=b.hasEventListener,a.dispatchEvent=b.dispatchEvent,a._dispatchEvent=b._dispatchEvent,a.willTrigger=b.willTrigger},b._listeners=null,b._captureListeners=null,b.initialize=function(){},b.addEventListener=function(a,b,c){var d;d=c?this._captureListeners=this._captureListeners||{}:this._listeners=this._listeners||{};var e=d[a];return e&&this.removeEventListener(a,b,c),e=d[a],e?e.push(b):d[a]=[b],b},b.on=function(a,b,c,d,e,f){return b.handleEvent&&(c=c||b,b=b.handleEvent),c=c||this,this.addEventListener(a,function(a){b.call(c,a,e),d&&a.remove()},f)},b.removeEventListener=function(a,b,c){var d=c?this._captureListeners:this._listeners;if(d){var e=d[a];if(e)for(var f=0,g=e.length;g>f;f++)if(e[f]==b){1==g?delete d[a]:e.splice(f,1);break}}},b.off=b.removeEventListener,b.removeAllEventListeners=function(a){a?(this._listeners&&delete this._listeners[a],this._captureListeners&&delete this._captureListeners[a]):this._listeners=this._captureListeners=null},b.dispatchEvent=function(a,b){if("string"==typeof a){var c=this._listeners;if(!c||!c[a])return!1;a=new createjs.Event(a)}if(a.target=b||this,a.bubbles&&this.parent){for(var d=this,e=[d];d.parent;)e.push(d=d.parent);var f,g=e.length;for(f=g-1;f>=0&&!a.propagationStopped;f--)e[f]._dispatchEvent(a,1+(0==f));for(f=1;g>f&&!a.propagationStopped;f++)e[f]._dispatchEvent(a,3)}else this._dispatchEvent(a,2);return a.defaultPrevented},b.hasEventListener=function(a){var b=this._listeners,c=this._captureListeners;return!!(b&&b[a]||c&&c[a])},b.willTrigger=function(a){for(var b=this;b;){if(b.hasEventListener(a))return!0;b=b.parent}return!1},b.toString=function(){return"[EventDispatcher]"},b._dispatchEvent=function(a,b){var c,d=1==b?this._captureListeners:this._listeners;if(a&&d){var e=d[a.type];if(!e||!(c=e.length))return;a.currentTarget=this,a.eventPhase=b,a.removed=!1,e=e.slice();for(var f=0;c>f&&!a.immediatePropagationStopped;f++){var g=e[f];g.handleEvent?g.handleEvent(a):g(a),a.removed&&(this.off(a.type,g,1==b),a.removed=!1)}}},createjs.EventDispatcher=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b,c){this.initialize(a,b,c)},b=a.prototype=new createjs.EventDispatcher;a.NONE=0,a.LOOP=1,a.REVERSE=2,a.IGNORE={},a._tweens=[],a._plugins={},a.get=function(b,c,d,e){return e&&a.removeTweens(b),new a(b,c,d)},a.tick=function(b,c){for(var d=a._tweens.slice(),e=d.length-1;e>=0;e--){var f=d[e];c&&!f.ignoreGlobalPause||f._paused||f.tick(f._useTicks?1:b)}},a.handleEvent=function(a){"tick"==a.type&&this.tick(a.delta,a.paused)},a.removeTweens=function(b){if(b.tweenjs_count){for(var c=a._tweens,d=c.length-1;d>=0;d--)c[d]._target==b&&(c[d]._paused=!0,c.splice(d,1));b.tweenjs_count=0}},a.removeAllTweens=function(){for(var b=a._tweens,c=0,d=b.length;d>c;c++){var e=b[c];e.paused=!0,e.target.tweenjs_count=0}b.length=0},a.hasActiveTweens=function(b){return b?b.tweenjs_count:a._tweens&&!!a._tweens.length},a.installPlugin=function(b,c){var d=b.priority;null==d&&(b.priority=d=0);for(var e=0,f=c.length,g=a._plugins;f>e;e++){var h=c[e];if(g[h]){for(var i=g[h],j=0,k=i.length;k>j&&!(d=a)return this;var c=this._cloneProps(this._curQueueProps);return this._addStep({d:a,p0:c,e:this._linearEase,p1:c,v:b})},b.to=function(a,b,c){return(isNaN(b)||0>b)&&(b=0),this._addStep({d:b||0,p0:this._cloneProps(this._curQueueProps),e:c,p1:this._cloneProps(this._appendQueueProps(a))})},b.call=function(a,b,c){return this._addAction({f:a,p:b?b:[this],o:c?c:this._target})},b.set=function(a,b){return this._addAction({f:this._set,o:this,p:[a,b?b:this._target]})},b.play=function(a){return a||(a=this),this.call(a.setPaused,[!1],a)},b.pause=function(a){return a||(a=this),this.call(a.setPaused,[!0],a)},b.setPosition=function(a,b){0>a&&(a=0),null==b&&(b=1);var c=a,d=!1;if(c>=this.duration&&(this.loop?c%=this.duration:(c=this.duration,d=!0)),c==this._prevPos)return d;var e=this._prevPos;if(this.position=this._prevPos=c,this._prevPosition=a,this._target)if(d)this._updateTargetProps(null,1);else if(this._steps.length>0){for(var f=0,g=this._steps.length;g>f&&!(this._steps[f].t>c);f++);var h=this._steps[f-1];this._updateTargetProps(h,(this._stepPosition=c-h.t)/h.d)}return 0!=b&&this._actions.length>0&&(this._useTicks?this._runActions(c,c):1==b&&e>c?(e!=this.duration&&this._runActions(e,this.duration),this._runActions(0,c,!0)):this._runActions(e,c)),d&&this.setPaused(!0),this.dispatchEvent("change"),d},b.tick=function(a){this._paused||this.setPosition(this._prevPosition+a)},b.setPaused=function(b){return this._paused=!!b,a._register(this,!b),this},b.w=b.wait,b.t=b.to,b.c=b.call,b.s=b.set,b.toString=function(){return"[Tween]"},b.clone=function(){throw"Tween can not be cloned."},b._updateTargetProps=function(b,c){var d,e,f,g,h,i;if(b||1!=c){if(this.passive=!!b.v,this.passive)return;b.e&&(c=b.e(c,0,1,1)),d=b.p0,e=b.p1}else this.passive=!1,d=e=this._curQueueProps;for(var j in this._initQueueProps){null==(g=d[j])&&(d[j]=g=this._initQueueProps[j]),null==(h=e[j])&&(e[j]=h=g),f=g==h||0==c||1==c||"number"!=typeof g?1==c?h:g:g+(h-g)*c;var k=!1;if(i=a._plugins[j])for(var l=0,m=i.length;m>l;l++){var n=i[l].tween(this,j,f,d,e,c,!!b&&d==e,!b);n==a.IGNORE?k=!0:f=n}k||(this._target[j]=f)}},b._runActions=function(a,b,c){var d=a,e=b,f=-1,g=this._actions.length,h=1;for(a>b&&(d=b,e=a,f=g,g=h=-1);(f+=h)!=g;){var i=this._actions[f],j=i.t;(j==e||j>d&&e>j||c&&j==a)&&i.f.apply(i.o,i.p)}},b._appendQueueProps=function(b){var c,d,e,f,g;for(var h in b)if(void 0===this._initQueueProps[h]){if(d=this._target[h],c=a._plugins[h])for(e=0,f=c.length;f>e;e++)d=c[e].init(this,h,d);this._initQueueProps[h]=this._curQueueProps[h]=void 0===d?null:d}else d=this._curQueueProps[h];for(var h in b){if(d=this._curQueueProps[h],c=a._plugins[h])for(g=g||{},e=0,f=c.length;f>e;e++)c[e].step&&c[e].step(this,h,d,b[h],g);this._curQueueProps[h]=b[h]}return g&&this._appendQueueProps(g),this._curQueueProps},b._cloneProps=function(a){var b={};for(var c in a)b[c]=a[c];return b},b._addStep=function(a){return a.d>0&&(this._steps.push(a),a.t=this.duration,this.duration+=a.d),this},b._addAction=function(a){return a.t=this.duration,this._actions.push(a),this},b._set=function(a,b){for(var c in a)b[c]=a[c]},createjs.Tween=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(a,b,c){this.initialize(a,b,c)},b=a.prototype=new createjs.EventDispatcher;b.ignoreGlobalPause=!1,b.duration=0,b.loop=!1,b.position=null,b._paused=!1,b._tweens=null,b._labels=null,b._labelList=null,b._prevPosition=0,b._prevPos=-1,b._useTicks=!1,b.initialize=function(a,b,c){this._tweens=[],c&&(this._useTicks=c.useTicks,this.loop=c.loop,this.ignoreGlobalPause=c.ignoreGlobalPause,c.onChange&&this.addEventListener("change",c.onChange)),a&&this.addTween.apply(this,a),this.setLabels(b),c&&c.paused?this._paused=!0:createjs.Tween._register(this,!0),c&&null!=c.position&&this.setPosition(c.position,createjs.Tween.NONE)},b.addTween=function(a){var b=arguments.length;if(b>1){for(var c=0;b>c;c++)this.addTween(arguments[c]);return arguments[0]}return 0==b?null:(this.removeTween(a),this._tweens.push(a),a.setPaused(!0),a._paused=!1,a._useTicks=this._useTicks,a.duration>this.duration&&(this.duration=a.duration),this._prevPos>=0&&a.setPosition(this._prevPos,createjs.Tween.NONE),a)},b.removeTween=function(a){var b=arguments.length;if(b>1){for(var c=!0,d=0;b>d;d++)c=c&&this.removeTween(arguments[d]);return c}if(0==b)return!1;for(var e=this._tweens,d=e.length;d--;)if(e[d]==a)return e.splice(d,1),a.duration>=this.duration&&this.updateDuration(),!0;return!1},b.addLabel=function(a,b){this._labels[a]=b;var c=this._labelList;if(c){for(var d=0,e=c.length;e>d&&!(bd&&!(ba&&(a=0);var c=this.loop?a%this.duration:a,d=!this.loop&&a>=this.duration;if(c==this._prevPos)return d;this._prevPosition=a,this.position=this._prevPos=c;for(var e=0,f=this._tweens.length;f>e;e++)if(this._tweens[e].setPosition(c,b),c!=this._prevPos)return!1;return d&&this.setPaused(!0),this.dispatchEvent("change"),d},b.setPaused=function(a){this._paused=!!a,createjs.Tween._register(this,!a)},b.updateDuration=function(){this.duration=0;for(var a=0,b=this._tweens.length;b>a;a++){var c=this._tweens[a];c.duration>this.duration&&(this.duration=c.duration)}},b.tick=function(a){this.setPosition(this._prevPosition+a)},b.resolve=function(a){var b=parseFloat(a);return isNaN(b)&&(b=this._labels[a]),b},b.toString=function(){return"[Timeline]"},b.clone=function(){throw"Timeline can not be cloned."},b._goto=function(a){var b=this.resolve(a);null!=b&&this.setPosition(b)},createjs.Timeline=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(){throw"Ease cannot be instantiated."};a.linear=function(a){return a},a.none=a.linear,a.get=function(a){return-1>a&&(a=-1),a>1&&(a=1),function(b){return 0==a?b:0>a?b*(b*-a+1+a):b*((2-b)*a+(1-a))}},a.getPowIn=function(a){return function(b){return Math.pow(b,a)}},a.getPowOut=function(a){return function(b){return 1-Math.pow(1-b,a)}},a.getPowInOut=function(a){return function(b){return(b*=2)<1?.5*Math.pow(b,a):1-.5*Math.abs(Math.pow(2-b,a))}},a.quadIn=a.getPowIn(2),a.quadOut=a.getPowOut(2),a.quadInOut=a.getPowInOut(2),a.cubicIn=a.getPowIn(3),a.cubicOut=a.getPowOut(3),a.cubicInOut=a.getPowInOut(3),a.quartIn=a.getPowIn(4),a.quartOut=a.getPowOut(4),a.quartInOut=a.getPowInOut(4),a.quintIn=a.getPowIn(5),a.quintOut=a.getPowOut(5),a.quintInOut=a.getPowInOut(5),a.sineIn=function(a){return 1-Math.cos(a*Math.PI/2)},a.sineOut=function(a){return Math.sin(a*Math.PI/2)},a.sineInOut=function(a){return-.5*(Math.cos(Math.PI*a)-1)},a.getBackIn=function(a){return function(b){return b*b*((a+1)*b-a)}},a.backIn=a.getBackIn(1.7),a.getBackOut=function(a){return function(b){return--b*b*((a+1)*b+a)+1}},a.backOut=a.getBackOut(1.7),a.getBackInOut=function(a){return a*=1.525,function(b){return(b*=2)<1?.5*b*b*((a+1)*b-a):.5*((b-=2)*b*((a+1)*b+a)+2)}},a.backInOut=a.getBackInOut(1.7),a.circIn=function(a){return-(Math.sqrt(1-a*a)-1)},a.circOut=function(a){return Math.sqrt(1- --a*a)},a.circInOut=function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)},a.bounceIn=function(b){return 1-a.bounceOut(1-b)},a.bounceOut=function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?7.5625*(a-=1.5/2.75)*a+.75:2.5/2.75>a?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},a.bounceInOut=function(b){return.5>b?.5*a.bounceIn(2*b):.5*a.bounceOut(2*b-1)+.5},a.getElasticIn=function(a,b){var c=2*Math.PI;return function(d){if(0==d||1==d)return d;var e=b/c*Math.asin(1/a);return-(a*Math.pow(2,10*(d-=1))*Math.sin((d-e)*c/b))}},a.elasticIn=a.getElasticIn(1,.3),a.getElasticOut=function(a,b){var c=2*Math.PI;return function(d){if(0==d||1==d)return d;var e=b/c*Math.asin(1/a);return a*Math.pow(2,-10*d)*Math.sin((d-e)*c/b)+1}},a.elasticOut=a.getElasticOut(1,.3),a.getElasticInOut=function(a,b){var c=2*Math.PI;return function(d){var e=b/c*Math.asin(1/a);return(d*=2)<1?-.5*a*Math.pow(2,10*(d-=1))*Math.sin((d-e)*c/b):.5*a*Math.pow(2,-10*(d-=1))*Math.sin((d-e)*c/b)+1}},a.elasticInOut=a.getElasticInOut(1,.3*1.5),createjs.Ease=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=function(){throw"MotionGuidePlugin cannot be instantiated."};a.priority=0,a._rotOffS,a._rotOffE,a._rotNormS,a._rotNormE,a.install=function(){return createjs.Tween.installPlugin(a,["guide","x","y","rotation"]),createjs.Tween.IGNORE},a.init=function(a,b,c){var d=a.target;return d.hasOwnProperty("x")||(d.x=0),d.hasOwnProperty("y")||(d.y=0),d.hasOwnProperty("rotation")||(d.rotation=0),"rotation"==b&&(a.__needsRot=!0),"guide"==b?null:c},a.step=function(b,c,d,e,f){if("rotation"==c&&(b.__rotGlobalS=d,b.__rotGlobalE=e,a.testRotData(b,f)),"guide"!=c)return e;var g,h=e;h.hasOwnProperty("path")||(h.path=[]);var i=h.path;if(h.hasOwnProperty("end")||(h.end=1),h.hasOwnProperty("start")||(h.start=d&&d.hasOwnProperty("end")&&d.path===i?d.end:0),h.hasOwnProperty("_segments")&&h._length)return e;var j=i.length,k=10;if(!(j>=6&&0==(j-2)%4))throw"invalid 'path' data, please see documentation for valid paths";h._segments=[],h._length=0;for(var l=2;j>l;l+=4){for(var m,n,o=i[l-2],p=i[l-1],q=i[l+0],r=i[l+1],s=i[l+2],t=i[l+3],u=o,v=p,w=0,x=[],y=1;k>=y;y++){var z=y/k,A=1-z;m=A*A*o+2*A*z*q+z*z*s,n=A*A*p+2*A*z*r+z*z*t,w+=x[x.push(Math.sqrt((g=m-u)*g+(g=n-v)*g))-1],u=m,v=n}h._segments.push(w),h._segments.push(x),h._length+=w}g=h.orient,h.orient=!0;var B={};return a.calc(h,h.start,B),b.__rotPathS=Number(B.rotation.toFixed(5)),a.calc(h,h.end,B),b.__rotPathE=Number(B.rotation.toFixed(5)),h.orient=!1,a.calc(h,h.end,f),h.orient=g,h.orient?(b.__guideData=h,a.testRotData(b,f),e):e},a.testRotData=function(a,b){if(void 0===a.__rotGlobalS||void 0===a.__rotGlobalE){if(a.__needsRot)return;a.__rotGlobalS=a.__rotGlobalE=void 0!==a._curQueueProps.rotation?a._curQueueProps.rotation:b.rotation=a.target.rotation||0}if(void 0!==a.__guideData){var c=a.__guideData,d=a.__rotGlobalE-a.__rotGlobalS,e=a.__rotPathE-a.__rotPathS,f=d-e;if("auto"==c.orient)f>180?f-=360:-180>f&&(f+=360);else if("cw"==c.orient){for(;0>f;)f+=360;0==f&&d>0&&180!=d&&(f+=360)}else if("ccw"==c.orient){for(f=d-(e>180?360-e:e);f>0;)f-=360;0==f&&0>d&&-180!=d&&(f-=360)}c.rotDelta=f,c.rotOffS=a.__rotGlobalS-a.__rotPathS,a.__rotGlobalS=a.__rotGlobalE=a.__guideData=a.__needsRot=void 0}},a.tween=function(b,c,d,e,f,g,h){var i=f.guide;if(void 0==i||i===e.guide)return d;if(i.lastRatio!=g){var j=(i.end-i.start)*(h?i.end:g)+i.start;switch(a.calc(i,j,b.target),i.orient){case"cw":case"ccw":case"auto":b.target.rotation+=i.rotOffS+i.rotDelta*g;break;case"fixed":default:b.target.rotation+=i.rotOffS}i.lastRatio=g}return"rotation"!=c||i.orient&&"false"!=i.orient?b.target[c]:d},a.calc=function(b,c,d){void 0==b._segments&&a.validate(b),void 0==d&&(d={x:0,y:0,rotation:0});for(var e=b._segments,f=b.path,g=b._length*c,h=e.length-2,i=0;g>e[i]&&h>i;)g-=e[i],i+=2;var j=e[i+1],k=0;for(h=j.length-1;g>j[k]&&h>k;)g-=j[k],k++;var l=k/++h+g/(h*j[k]);i=2*i+2;var m=1-l;return d.x=m*m*f[i-2]+2*m*l*f[i+0]+l*l*f[i+2],d.y=m*m*f[i-1]+2*m*l*f[i+1]+l*l*f[i+3],b.orient&&(d.rotation=57.2957795*Math.atan2((f[i+1]-f[i-1])*m+(f[i+3]-f[i+1])*l,(f[i+0]-f[i-2])*m+(f[i+2]-f[i+0])*l)),d},createjs.MotionGuidePlugin=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=createjs.TweenJS=createjs.TweenJS||{};a.version="0.5.1",a.buildDate="Thu, 12 Dec 2013 23:33:38 GMT"}(); \ No newline at end of file diff --git a/views/archive/j/box2d-car-game/css/cargame.css b/views/archive/j/box2d-car-game/css/cargame.css new file mode 100644 index 00000000..2eb364e8 --- /dev/null +++ b/views/archive/j/box2d-car-game/css/cargame.css @@ -0,0 +1,91 @@ +/*! + * Box2D Car Game Example + * http://42games.net/html5games/box2d-car-game/ + * + * This is an example game for the book HTML5 Games Development: A Beginning Guide. + * + * Copyright 2010, Thomas Seng Hin Mak + * makzan@42games.net + * + * All Right Reserved. + */ + +html, body{ + background: url(../images/website_background.jpg); + + font-family: 'Play', arial, serif; +} + +em { + margin: 0 6px; + color: #006600; +} + +.startscreen { + background: #eee url(../images/starting_screen.jpg); +} + +.gamebg_level0 { + background: #eee url(../images/bg.jpg); +} + +.gamebg_level1 { + background: #eee url(../images/bg2.jpg); +} + +.gamebg_level2 { + background: #eee url(../images/bg3.jpg); +} + +.gamebg_level3 { + background: #eee url(../images/bg4.jpg); +} + +.gamebg_level4 { + background: #eee url(../images/bg5.jpg); +} + +.gamebg_won { + background: #eee url(../images/game_completed_screen.jpg); +} + +#game { + width: 1300px; +} + +#asset { + position: absolute; + top: -99999px; +} + +#game-container { + position: relative; + width: 1300px; +} + +#level { + position: absolute; + top: 10px; + left: 10px; +} + +.progressbar { + position: absolute; + top: 10px; + right: 10px; + + width: 300px; + height:20px; + margin: 2px; + border: 1px solid #000; + + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#8C906F), color-stop(48%,#8C906F), color-stop(51%,#323721), color-stop(54%,#55624F), color-stop(100%,#55624F)); /* webkit */ + background: gradient(linear, left top, left bottom, color-stop(0%,#8C906F), color-stop(48%,#8C906F), color-stop(51%,#323721), color-stop(54%,#55624F), color-stop(100%,#55624F)); +} + +.progressbar .fuel-value { + height:20px; + + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#A8D751), color-stop(48%,#A8D751), color-stop(51%,#275606), color-stop(54%,#4A8A49), color-stop(100%,#4A8A49)); /* webkit */ + background: gradient(linear, left top, left bottom, color-stop(0%,#A8D751), color-stop(48%,#A8D751), color-stop(51%,#275606), color-stop(54%,#4A8A49), color-stop(100%,#4A8A49)); +} \ No newline at end of file diff --git a/views/archive/j/box2d-car-game/images/bg.jpg b/views/archive/j/box2d-car-game/images/bg.jpg new file mode 100644 index 00000000..36c5b363 Binary files /dev/null and b/views/archive/j/box2d-car-game/images/bg.jpg differ diff --git a/views/archive/j/box2d-car-game/images/bg2.jpg b/views/archive/j/box2d-car-game/images/bg2.jpg new file mode 100644 index 00000000..43948123 Binary files /dev/null and b/views/archive/j/box2d-car-game/images/bg2.jpg differ diff --git a/views/archive/j/box2d-car-game/images/bg3.jpg b/views/archive/j/box2d-car-game/images/bg3.jpg new file mode 100644 index 00000000..369d1f90 Binary files /dev/null and b/views/archive/j/box2d-car-game/images/bg3.jpg differ diff --git a/views/archive/j/box2d-car-game/images/bg4.jpg b/views/archive/j/box2d-car-game/images/bg4.jpg new file mode 100644 index 00000000..cf5df363 Binary files /dev/null and b/views/archive/j/box2d-car-game/images/bg4.jpg differ diff --git a/views/archive/j/box2d-car-game/images/bg5.jpg b/views/archive/j/box2d-car-game/images/bg5.jpg new file mode 100644 index 00000000..d53b797c Binary files /dev/null and b/views/archive/j/box2d-car-game/images/bg5.jpg differ diff --git a/views/archive/j/box2d-car-game/images/bus.png b/views/archive/j/box2d-car-game/images/bus.png new file mode 100644 index 00000000..4f4948db Binary files /dev/null and b/views/archive/j/box2d-car-game/images/bus.png differ diff --git a/views/archive/j/box2d-car-game/images/flag.png b/views/archive/j/box2d-car-game/images/flag.png new file mode 100644 index 00000000..a3e2c33d Binary files /dev/null and b/views/archive/j/box2d-car-game/images/flag.png differ diff --git a/views/archive/j/box2d-car-game/images/game_completed_screen.jpg b/views/archive/j/box2d-car-game/images/game_completed_screen.jpg new file mode 100644 index 00000000..d1345089 Binary files /dev/null and b/views/archive/j/box2d-car-game/images/game_completed_screen.jpg differ diff --git a/views/archive/j/box2d-car-game/images/starting_screen.jpg b/views/archive/j/box2d-car-game/images/starting_screen.jpg new file mode 100644 index 00000000..1e353725 Binary files /dev/null and b/views/archive/j/box2d-car-game/images/starting_screen.jpg differ diff --git a/views/archive/j/box2d-car-game/images/website_background.jpg b/views/archive/j/box2d-car-game/images/website_background.jpg new file mode 100644 index 00000000..a3ea5b9e Binary files /dev/null and b/views/archive/j/box2d-car-game/images/website_background.jpg differ diff --git a/views/archive/j/box2d-car-game/images/wheel.png b/views/archive/j/box2d-car-game/images/wheel.png new file mode 100644 index 00000000..1ed25b83 Binary files /dev/null and b/views/archive/j/box2d-car-game/images/wheel.png differ diff --git a/views/archive/j/box2d-car-game/index.htm b/views/archive/j/box2d-car-game/index.htm new file mode 100644 index 00000000..0f4b3e90 --- /dev/null +++ b/views/archive/j/box2d-car-game/index.htm @@ -0,0 +1,134 @@ + + + + + + + Box2D Car Game + + + + + + +
+

Box2DJS Car Game

+
+ + + +
+ + + +
+
+
+ +
+
+ +
+ + + +
+ +

Press X to move right. Z to move left. R to restart the game.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/views/archive/j/box2d-car-game/js/AUTHORS b/views/archive/j/box2d-car-game/js/AUTHORS new file mode 100644 index 00000000..f3348aae --- /dev/null +++ b/views/archive/j/box2d-car-game/js/AUTHORS @@ -0,0 +1,10 @@ +ExplorerCanvas + +Google Open Source: + + + +Developers: + Emil A Eklund + Erik Arvidsson + Glen Murphy \ No newline at end of file diff --git a/views/archive/j/box2d-car-game/js/COPYING b/views/archive/j/box2d-car-game/js/COPYING new file mode 100644 index 00000000..d6456956 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/COPYING @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/views/archive/j/box2d-car-game/js/README b/views/archive/j/box2d-car-game/js/README new file mode 100644 index 00000000..9e8268b9 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/README @@ -0,0 +1,22 @@ +ExplorerCanvas +Copyright 2006 Google Inc. + +------------------------------------------------------------------------------- +DESCRIPTION + +Firefox, Safari and Opera 9 support the canvas tag to allow 2D command-based +drawing operations. ExplorerCanvas brings the same functionality to Internet +Explorer; web developers only need to include a single script tag in their +existing canvas webpages to enable this support. + + +------------------------------------------------------------------------------- +INSTALLATION + +Include the ExplorerCanvas tag in the same directory as your HTML files, and +add the following code to your page, preferably in the tag. + + + +If you run into trouble, please look at the included example code to see how +to best implement this \ No newline at end of file diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/ClipVertex.js b/views/archive/j/box2d-car-game/js/box2d/collision/ClipVertex.js new file mode 100644 index 00000000..7c944dd5 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/ClipVertex.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var ClipVertex = Class.create(); +ClipVertex.prototype = +{ + v: new b2Vec2(), + id: new b2ContactID(), + initialize: function() { + // initialize instance variables for references + this.v = new b2Vec2(); + this.id = new b2ContactID(); + // +}}; + + diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/Features.js b/views/archive/j/box2d-car-game/js/box2d/collision/Features.js new file mode 100644 index 00000000..b0042a65 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/Features.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + +// We use contact ids to facilitate warm starting. +var Features = Class.create(); +Features.prototype = +{ + // + set_referenceFace: function(value){ + this._referenceFace = value; + this._m_id._key = (this._m_id._key & 0xffffff00) | (this._referenceFace & 0x000000ff) + }, + get_referenceFace: function(){ + return this._referenceFace; + }, + _referenceFace: 0, + // + set_incidentEdge: function(value){ + this._incidentEdge = value; + this._m_id._key = (this._m_id._key & 0xffff00ff) | ((this._incidentEdge << 8) & 0x0000ff00) + }, + get_incidentEdge: function(){ + return this._incidentEdge; + }, + _incidentEdge: 0, + // + set_incidentVertex: function(value){ + this._incidentVertex = value; + this._m_id._key = (this._m_id._key & 0xff00ffff) | ((this._incidentVertex << 16) & 0x00ff0000) + }, + get_incidentVertex: function(){ + return this._incidentVertex; + }, + _incidentVertex: 0, + // + set_flip: function(value){ + this._flip = value; + this._m_id._key = (this._m_id._key & 0x00ffffff) | ((this._flip << 24) & 0xff000000) + }, + get_flip: function(){ + return this._flip; + }, + _flip: 0, + _m_id: null, + initialize: function() {}}; diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2AABB.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2AABB.js new file mode 100644 index 00000000..c22ccc3b --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2AABB.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +// A manifold for two touching convex shapes. +var b2AABB = Class.create(); +b2AABB.prototype = +{ + IsValid: function(){ + //var d = b2Math.SubtractVV(this.maxVertex, this.minVertex); + var dX = this.maxVertex.x; + var dY = this.maxVertex.y; + dX = this.maxVertex.x; + dY = this.maxVertex.y; + dX -= this.minVertex.x; + dY -= this.minVertex.y; + var valid = dX >= 0.0 && dY >= 0.0; + valid = valid && this.minVertex.IsValid() && this.maxVertex.IsValid(); + return valid; + }, + + minVertex: new b2Vec2(), + maxVertex: new b2Vec2(), + initialize: function() { + // initialize instance variables for references + this.minVertex = new b2Vec2(); + this.maxVertex = new b2Vec2(); + // +}}; diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2Bound.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2Bound.js new file mode 100644 index 00000000..b203323c --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2Bound.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +var b2Bound = Class.create(); +b2Bound.prototype = { + IsLower: function(){ return (this.value & 1) == 0; }, + IsUpper: function(){ return (this.value & 1) == 1; }, + Swap: function(b){ + var tempValue = this.value; + var tempProxyId = this.proxyId; + var tempStabbingCount = this.stabbingCount; + + this.value = b.value; + this.proxyId = b.proxyId; + this.stabbingCount = b.stabbingCount; + + b.value = tempValue; + b.proxyId = tempProxyId; + b.stabbingCount = tempStabbingCount; + }, + + value: 0, + proxyId: 0, + stabbingCount: 0, + + initialize: function() {}} diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2BoundValues.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2BoundValues.js new file mode 100644 index 00000000..25294f23 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2BoundValues.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +var b2BoundValues = Class.create(); +b2BoundValues.prototype = { + lowerValues: [0,0], + upperValues: [0,0], + + initialize: function() { + // initialize instance variables for references + this.lowerValues = [0,0]; + this.upperValues = [0,0]; + // +}} diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2BroadPhase.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2BroadPhase.js new file mode 100644 index 00000000..f562329a --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2BroadPhase.js @@ -0,0 +1,898 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +/* +This broad phase uses the Sweep and Prune algorithm in: +Collision Detection in Interactive 3D Environments by Gino van den Bergen +Also, some ideas, such integral values for fast compares comes from +Bullet (http:/www.bulletphysics.com). +*/ + + +// Notes: +// - we use bound arrays instead of linked lists for cache coherence. +// - we use quantized integral values for fast compares. +// - we use short indices rather than pointers to save memory. +// - we use a stabbing count for fast overlap queries (less than order N). +// - we also use a time stamp on each proxy to speed up the registration of +// overlap query results. +// - where possible, we compare bound indices instead of values to reduce +// cache misses (TODO_ERIN). +// - no broadphase is perfect and neither is this one: it is not great for huge +// worlds (use a multi-SAP instead), it is not great for large objects. + +var b2BroadPhase = Class.create(); +b2BroadPhase.prototype = +{ +//public: + initialize: function(worldAABB, callback){ + // initialize instance variables for references + this.m_pairManager = new b2PairManager(); + this.m_proxyPool = new Array(b2Settings.b2_maxPairs); + this.m_bounds = new Array(2*b2Settings.b2_maxProxies); + this.m_queryResults = new Array(b2Settings.b2_maxProxies); + this.m_quantizationFactor = new b2Vec2(); + // + + //b2Settings.b2Assert(worldAABB.IsValid()); + var i = 0; + + this.m_pairManager.Initialize(this, callback); + + this.m_worldAABB = worldAABB; + + this.m_proxyCount = 0; + + // query results + for (i = 0; i < b2Settings.b2_maxProxies; i++){ + this.m_queryResults[i] = 0; + } + + // bounds array + this.m_bounds = new Array(2); + for (i = 0; i < 2; i++){ + this.m_bounds[i] = new Array(2*b2Settings.b2_maxProxies); + for (var j = 0; j < 2*b2Settings.b2_maxProxies; j++){ + this.m_bounds[i][j] = new b2Bound(); + } + } + + //var d = b2Math.SubtractVV(worldAABB.maxVertex, worldAABB.minVertex); + var dX = worldAABB.maxVertex.x; + var dY = worldAABB.maxVertex.y; + dX -= worldAABB.minVertex.x; + dY -= worldAABB.minVertex.y; + + this.m_quantizationFactor.x = b2Settings.USHRT_MAX / dX; + this.m_quantizationFactor.y = b2Settings.USHRT_MAX / dY; + + var tProxy; + for (i = 0; i < b2Settings.b2_maxProxies - 1; ++i) + { + tProxy = new b2Proxy(); + this.m_proxyPool[i] = tProxy; + tProxy.SetNext(i + 1); + tProxy.timeStamp = 0; + tProxy.overlapCount = b2BroadPhase.b2_invalid; + tProxy.userData = null; + } + tProxy = new b2Proxy(); + this.m_proxyPool[b2Settings.b2_maxProxies-1] = tProxy; + tProxy.SetNext(b2Pair.b2_nullProxy); + tProxy.timeStamp = 0; + tProxy.overlapCount = b2BroadPhase.b2_invalid; + tProxy.userData = null; + this.m_freeProxy = 0; + + this.m_timeStamp = 1; + this.m_queryResultCount = 0; + }, + //~b2BroadPhase(); + + // Use this to see if your proxy is in range. If it is not in range, + // it should be destroyed. Otherwise you may get O(m^2) pairs, where m + // is the number of proxies that are out of range. + InRange: function(aabb){ + //var d = b2Math.b2MaxV(b2Math.SubtractVV(aabb.minVertex, this.m_worldAABB.maxVertex), b2Math.SubtractVV(this.m_worldAABB.minVertex, aabb.maxVertex)); + var dX; + var dY; + var d2X; + var d2Y; + + dX = aabb.minVertex.x; + dY = aabb.minVertex.y; + dX -= this.m_worldAABB.maxVertex.x; + dY -= this.m_worldAABB.maxVertex.y; + + d2X = this.m_worldAABB.minVertex.x; + d2Y = this.m_worldAABB.minVertex.y; + d2X -= aabb.maxVertex.x; + d2Y -= aabb.maxVertex.y; + + dX = b2Math.b2Max(dX, d2X); + dY = b2Math.b2Max(dY, d2Y); + + return b2Math.b2Max(dX, dY) < 0.0; + }, + + // Get a single proxy. Returns NULL if the id is invalid. + GetProxy: function(proxyId){ + if (proxyId == b2Pair.b2_nullProxy || this.m_proxyPool[proxyId].IsValid() == false) + { + return null; + } + + return this.m_proxyPool[ proxyId ]; + }, + + // Create and destroy proxies. These call Flush first. + CreateProxy: function(aabb, userData){ + var index = 0; + var proxy; + + //b2Settings.b2Assert(this.m_proxyCount < b2_maxProxies); + //b2Settings.b2Assert(this.m_freeProxy != b2Pair.b2_nullProxy); + + var proxyId = this.m_freeProxy; + proxy = this.m_proxyPool[ proxyId ]; + this.m_freeProxy = proxy.GetNext(); + + proxy.overlapCount = 0; + proxy.userData = userData; + + var boundCount = 2 * this.m_proxyCount; + + var lowerValues = new Array(); + var upperValues = new Array(); + this.ComputeBounds(lowerValues, upperValues, aabb); + + for (var axis = 0; axis < 2; ++axis) + { + var bounds = this.m_bounds[axis]; + var lowerIndex = 0; + var upperIndex = 0; + var lowerIndexOut = [lowerIndex]; + var upperIndexOut = [upperIndex]; + this.Query(lowerIndexOut, upperIndexOut, lowerValues[axis], upperValues[axis], bounds, boundCount, axis); + lowerIndex = lowerIndexOut[0]; + upperIndex = upperIndexOut[0]; + + // Replace memmove calls + //memmove(bounds + upperIndex + 2, bounds + upperIndex, (edgeCount - upperIndex) * sizeof(b2Bound)); + var tArr = new Array(); + var j = 0; + var tEnd = boundCount - upperIndex + var tBound1; + var tBound2; + // make temp array + for (j = 0; j < tEnd; j++){ + tArr[j] = new b2Bound(); + tBound1 = tArr[j]; + tBound2 = bounds[upperIndex+j]; + tBound1.value = tBound2.value; + tBound1.proxyId = tBound2.proxyId; + tBound1.stabbingCount = tBound2.stabbingCount; + } + // move temp array back in to bounds + tEnd = tArr.length; + var tIndex = upperIndex+2; + for (j = 0; j < tEnd; j++){ + //bounds[tIndex+j] = tArr[j]; + tBound2 = tArr[j]; + tBound1 = bounds[tIndex+j] + tBound1.value = tBound2.value; + tBound1.proxyId = tBound2.proxyId; + tBound1.stabbingCount = tBound2.stabbingCount; + } + //memmove(bounds + lowerIndex + 1, bounds + lowerIndex, (upperIndex - lowerIndex) * sizeof(b2Bound)); + // make temp array + tArr = new Array(); + tEnd = upperIndex - lowerIndex; + for (j = 0; j < tEnd; j++){ + tArr[j] = new b2Bound(); + tBound1 = tArr[j]; + tBound2 = bounds[lowerIndex+j]; + tBound1.value = tBound2.value; + tBound1.proxyId = tBound2.proxyId; + tBound1.stabbingCount = tBound2.stabbingCount; + } + // move temp array back in to bounds + tEnd = tArr.length; + tIndex = lowerIndex+1; + for (j = 0; j < tEnd; j++){ + //bounds[tIndex+j] = tArr[j]; + tBound2 = tArr[j]; + tBound1 = bounds[tIndex+j] + tBound1.value = tBound2.value; + tBound1.proxyId = tBound2.proxyId; + tBound1.stabbingCount = tBound2.stabbingCount; + } + + // The upper index has increased because of the lower bound insertion. + ++upperIndex; + + // Copy in the new bounds. + bounds[lowerIndex].value = lowerValues[axis]; + bounds[lowerIndex].proxyId = proxyId; + bounds[upperIndex].value = upperValues[axis]; + bounds[upperIndex].proxyId = proxyId; + + bounds[lowerIndex].stabbingCount = lowerIndex == 0 ? 0 : bounds[lowerIndex-1].stabbingCount; + bounds[upperIndex].stabbingCount = bounds[upperIndex-1].stabbingCount; + + // Adjust the stabbing count between the new bounds. + for (index = lowerIndex; index < upperIndex; ++index) + { + bounds[index].stabbingCount++; + } + + // Adjust the all the affected bound indices. + for (index = lowerIndex; index < boundCount + 2; ++index) + { + var proxy2 = this.m_proxyPool[ bounds[index].proxyId ]; + if (bounds[index].IsLower()) + { + proxy2.lowerBounds[axis] = index; + } + else + { + proxy2.upperBounds[axis] = index; + } + } + } + + ++this.m_proxyCount; + + //b2Settings.b2Assert(this.m_queryResultCount < b2Settings.b2_maxProxies); + + for (var i = 0; i < this.m_queryResultCount; ++i) + { + //b2Settings.b2Assert(this.m_queryResults[i] < b2_maxProxies); + //b2Settings.b2Assert(this.m_proxyPool[this.m_queryResults[i]].IsValid()); + + this.m_pairManager.AddBufferedPair(proxyId, this.m_queryResults[i]); + } + + this.m_pairManager.Commit(); + + // Prepare for next query. + this.m_queryResultCount = 0; + this.IncrementTimeStamp(); + + return proxyId; + }, + + DestroyProxy: function(proxyId){ + + //b2Settings.b2Assert(0 < this.m_proxyCount && this.m_proxyCount <= b2_maxProxies); + + var proxy = this.m_proxyPool[ proxyId ]; + //b2Settings.b2Assert(proxy.IsValid()); + + var boundCount = 2 * this.m_proxyCount; + + for (var axis = 0; axis < 2; ++axis) + { + var bounds = this.m_bounds[axis]; + + var lowerIndex = proxy.lowerBounds[axis]; + var upperIndex = proxy.upperBounds[axis]; + var lowerValue = bounds[lowerIndex].value; + var upperValue = bounds[upperIndex].value; + + // replace memmove calls + //memmove(bounds + lowerIndex, bounds + lowerIndex + 1, (upperIndex - lowerIndex - 1) * sizeof(b2Bound)); + var tArr = new Array(); + var j = 0; + var tEnd = upperIndex - lowerIndex - 1; + var tBound1; + var tBound2; + // make temp array + for (j = 0; j < tEnd; j++){ + tArr[j] = new b2Bound(); + tBound1 = tArr[j]; + tBound2 = bounds[lowerIndex+1+j]; + tBound1.value = tBound2.value; + tBound1.proxyId = tBound2.proxyId; + tBound1.stabbingCount = tBound2.stabbingCount; + } + // move temp array back in to bounds + tEnd = tArr.length; + var tIndex = lowerIndex; + for (j = 0; j < tEnd; j++){ + //bounds[tIndex+j] = tArr[j]; + tBound2 = tArr[j]; + tBound1 = bounds[tIndex+j] + tBound1.value = tBound2.value; + tBound1.proxyId = tBound2.proxyId; + tBound1.stabbingCount = tBound2.stabbingCount; + } + //memmove(bounds + upperIndex-1, bounds + upperIndex + 1, (edgeCount - upperIndex - 1) * sizeof(b2Bound)); + // make temp array + tArr = new Array(); + tEnd = boundCount - upperIndex - 1; + for (j = 0; j < tEnd; j++){ + tArr[j] = new b2Bound(); + tBound1 = tArr[j]; + tBound2 = bounds[upperIndex+1+j]; + tBound1.value = tBound2.value; + tBound1.proxyId = tBound2.proxyId; + tBound1.stabbingCount = tBound2.stabbingCount; + } + // move temp array back in to bounds + tEnd = tArr.length; + tIndex = upperIndex-1; + for (j = 0; j < tEnd; j++){ + //bounds[tIndex+j] = tArr[j]; + tBound2 = tArr[j]; + tBound1 = bounds[tIndex+j] + tBound1.value = tBound2.value; + tBound1.proxyId = tBound2.proxyId; + tBound1.stabbingCount = tBound2.stabbingCount; + } + + // Fix bound indices. + tEnd = boundCount - 2; + for (var index = lowerIndex; index < tEnd; ++index) + { + var proxy2 = this.m_proxyPool[ bounds[index].proxyId ]; + if (bounds[index].IsLower()) + { + proxy2.lowerBounds[axis] = index; + } + else + { + proxy2.upperBounds[axis] = index; + } + } + + // Fix stabbing count. + tEnd = upperIndex - 1; + for (var index2 = lowerIndex; index2 < tEnd; ++index2) + { + bounds[index2].stabbingCount--; + } + + // this.Query for pairs to be removed. lowerIndex and upperIndex are not needed. + // make lowerIndex and upper output using an array and do this for others if compiler doesn't pick them up + this.Query([0], [0], lowerValue, upperValue, bounds, boundCount - 2, axis); + } + + //b2Settings.b2Assert(this.m_queryResultCount < b2Settings.b2_maxProxies); + + for (var i = 0; i < this.m_queryResultCount; ++i) + { + //b2Settings.b2Assert(this.m_proxyPool[this.m_queryResults[i]].IsValid()); + + this.m_pairManager.RemoveBufferedPair(proxyId, this.m_queryResults[i]); + } + + this.m_pairManager.Commit(); + + // Prepare for next query. + this.m_queryResultCount = 0; + this.IncrementTimeStamp(); + + // Return the proxy to the pool. + proxy.userData = null; + proxy.overlapCount = b2BroadPhase.b2_invalid; + proxy.lowerBounds[0] = b2BroadPhase.b2_invalid; + proxy.lowerBounds[1] = b2BroadPhase.b2_invalid; + proxy.upperBounds[0] = b2BroadPhase.b2_invalid; + proxy.upperBounds[1] = b2BroadPhase.b2_invalid; + + proxy.SetNext(this.m_freeProxy); + this.m_freeProxy = proxyId; + --this.m_proxyCount; + }, + + + // Call this.MoveProxy times like, then when you are done + // call this.Commit to finalized the proxy pairs (for your time step). + MoveProxy: function(proxyId, aabb){ + var axis = 0; + var index = 0; + var bound; + var prevBound + var nextBound + var nextProxyId = 0; + var nextProxy; + + if (proxyId == b2Pair.b2_nullProxy || b2Settings.b2_maxProxies <= proxyId) + { + //b2Settings.b2Assert(false); + return; + } + + if (aabb.IsValid() == false) + { + //b2Settings.b2Assert(false); + return; + } + + var boundCount = 2 * this.m_proxyCount; + + var proxy = this.m_proxyPool[ proxyId ]; + // Get new bound values + var newValues = new b2BoundValues(); + this.ComputeBounds(newValues.lowerValues, newValues.upperValues, aabb); + + // Get old bound values + var oldValues = new b2BoundValues(); + for (axis = 0; axis < 2; ++axis) + { + oldValues.lowerValues[axis] = this.m_bounds[axis][proxy.lowerBounds[axis]].value; + oldValues.upperValues[axis] = this.m_bounds[axis][proxy.upperBounds[axis]].value; + } + + for (axis = 0; axis < 2; ++axis) + { + var bounds = this.m_bounds[axis]; + + var lowerIndex = proxy.lowerBounds[axis]; + var upperIndex = proxy.upperBounds[axis]; + + var lowerValue = newValues.lowerValues[axis]; + var upperValue = newValues.upperValues[axis]; + + var deltaLower = lowerValue - bounds[lowerIndex].value; + var deltaUpper = upperValue - bounds[upperIndex].value; + + bounds[lowerIndex].value = lowerValue; + bounds[upperIndex].value = upperValue; + + // + // Expanding adds overlaps + // + + // Should we move the lower bound down? + if (deltaLower < 0) + { + index = lowerIndex; + while (index > 0 && lowerValue < bounds[index-1].value) + { + bound = bounds[index]; + prevBound = bounds[index - 1]; + + var prevProxyId = prevBound.proxyId; + var prevProxy = this.m_proxyPool[ prevBound.proxyId ]; + + prevBound.stabbingCount++; + + if (prevBound.IsUpper() == true) + { + if (this.TestOverlap(newValues, prevProxy)) + { + this.m_pairManager.AddBufferedPair(proxyId, prevProxyId); + } + + prevProxy.upperBounds[axis]++; + bound.stabbingCount++; + } + else + { + prevProxy.lowerBounds[axis]++; + bound.stabbingCount--; + } + + proxy.lowerBounds[axis]--; + + // swap + //var temp = bound; + //bound = prevEdge; + //prevEdge = temp; + bound.Swap(prevBound); + //b2Math.b2Swap(bound, prevEdge); + --index; + } + } + + // Should we move the upper bound up? + if (deltaUpper > 0) + { + index = upperIndex; + while (index < boundCount-1 && bounds[index+1].value <= upperValue) + { + bound = bounds[ index ]; + nextBound = bounds[ index + 1 ]; + nextProxyId = nextBound.proxyId; + nextProxy = this.m_proxyPool[ nextProxyId ]; + + nextBound.stabbingCount++; + + if (nextBound.IsLower() == true) + { + if (this.TestOverlap(newValues, nextProxy)) + { + this.m_pairManager.AddBufferedPair(proxyId, nextProxyId); + } + + nextProxy.lowerBounds[axis]--; + bound.stabbingCount++; + } + else + { + nextProxy.upperBounds[axis]--; + bound.stabbingCount--; + } + + proxy.upperBounds[axis]++; + // swap + //var temp = bound; + //bound = nextEdge; + //nextEdge = temp; + bound.Swap(nextBound); + //b2Math.b2Swap(bound, nextEdge); + index++; + } + } + + // + // Shrinking removes overlaps + // + + // Should we move the lower bound up? + if (deltaLower > 0) + { + index = lowerIndex; + while (index < boundCount-1 && bounds[index+1].value <= lowerValue) + { + bound = bounds[ index ]; + nextBound = bounds[ index + 1 ]; + + nextProxyId = nextBound.proxyId; + nextProxy = this.m_proxyPool[ nextProxyId ]; + + nextBound.stabbingCount--; + + if (nextBound.IsUpper()) + { + if (this.TestOverlap(oldValues, nextProxy)) + { + this.m_pairManager.RemoveBufferedPair(proxyId, nextProxyId); + } + + nextProxy.upperBounds[axis]--; + bound.stabbingCount--; + } + else + { + nextProxy.lowerBounds[axis]--; + bound.stabbingCount++; + } + + proxy.lowerBounds[axis]++; + // swap + //var temp = bound; + //bound = nextEdge; + //nextEdge = temp; + bound.Swap(nextBound); + //b2Math.b2Swap(bound, nextEdge); + index++; + } + } + + // Should we move the upper bound down? + if (deltaUpper < 0) + { + index = upperIndex; + while (index > 0 && upperValue < bounds[index-1].value) + { + bound = bounds[index]; + prevBound = bounds[index - 1]; + + prevProxyId = prevBound.proxyId; + prevProxy = this.m_proxyPool[ prevProxyId ]; + + prevBound.stabbingCount--; + + if (prevBound.IsLower() == true) + { + if (this.TestOverlap(oldValues, prevProxy)) + { + this.m_pairManager.RemoveBufferedPair(proxyId, prevProxyId); + } + + prevProxy.lowerBounds[axis]++; + bound.stabbingCount--; + } + else + { + prevProxy.upperBounds[axis]++; + bound.stabbingCount++; + } + + proxy.upperBounds[axis]--; + // swap + //var temp = bound; + //bound = prevEdge; + //prevEdge = temp; + bound.Swap(prevBound); + //b2Math.b2Swap(bound, prevEdge); + index--; + } + } + } + }, + + Commit: function(){ + this.m_pairManager.Commit(); + }, + + // this.Query an AABB for overlapping proxies, returns the user data and + // the count, up to the supplied maximum count. + QueryAABB: function(aabb, userData, maxCount){ + var lowerValues = new Array(); + var upperValues = new Array(); + this.ComputeBounds(lowerValues, upperValues, aabb); + + var lowerIndex = 0; + var upperIndex = 0; + var lowerIndexOut = [lowerIndex]; + var upperIndexOut = [upperIndex]; + this.Query(lowerIndexOut, upperIndexOut, lowerValues[0], upperValues[0], this.m_bounds[0], 2*this.m_proxyCount, 0); + this.Query(lowerIndexOut, upperIndexOut, lowerValues[1], upperValues[1], this.m_bounds[1], 2*this.m_proxyCount, 1); + + //b2Settings.b2Assert(this.m_queryResultCount < b2Settings.b2_maxProxies); + + var count = 0; + for (var i = 0; i < this.m_queryResultCount && count < maxCount; ++i, ++count) + { + //b2Settings.b2Assert(this.m_queryResults[i] < b2Settings.b2_maxProxies); + var proxy = this.m_proxyPool[ this.m_queryResults[i] ]; + //b2Settings.b2Assert(proxy.IsValid()); + userData[i] = proxy.userData; + } + + // Prepare for next query. + this.m_queryResultCount = 0; + this.IncrementTimeStamp(); + + return count; + }, + + Validate: function(){ + var pair; + var proxy1; + var proxy2; + var overlap; + + for (var axis = 0; axis < 2; ++axis) + { + var bounds = this.m_bounds[axis]; + + var boundCount = 2 * this.m_proxyCount; + var stabbingCount = 0; + + for (var i = 0; i < boundCount; ++i) + { + var bound = bounds[i]; + //b2Settings.b2Assert(i == 0 || bounds[i-1].value <= bound->value); + //b2Settings.b2Assert(bound->proxyId != b2_nullProxy); + //b2Settings.b2Assert(this.m_proxyPool[bound->proxyId].IsValid()); + + if (bound.IsLower() == true) + { + //b2Settings.b2Assert(this.m_proxyPool[bound.proxyId].lowerBounds[axis] == i); + stabbingCount++; + } + else + { + //b2Settings.b2Assert(this.m_proxyPool[bound.proxyId].upperBounds[axis] == i); + stabbingCount--; + } + + //b2Settings.b2Assert(bound.stabbingCount == stabbingCount); + } + } + + }, + +//private: + ComputeBounds: function(lowerValues, upperValues, aabb) + { + //b2Settings.b2Assert(aabb.maxVertex.x > aabb.minVertex.x); + //b2Settings.b2Assert(aabb.maxVertex.y > aabb.minVertex.y); + + //var minVertex = b2Math.b2ClampV(aabb.minVertex, this.m_worldAABB.minVertex, this.m_worldAABB.maxVertex); + var minVertexX = aabb.minVertex.x; + var minVertexY = aabb.minVertex.y; + minVertexX = b2Math.b2Min(minVertexX, this.m_worldAABB.maxVertex.x); + minVertexY = b2Math.b2Min(minVertexY, this.m_worldAABB.maxVertex.y); + minVertexX = b2Math.b2Max(minVertexX, this.m_worldAABB.minVertex.x); + minVertexY = b2Math.b2Max(minVertexY, this.m_worldAABB.minVertex.y); + + //var maxVertex = b2Math.b2ClampV(aabb.maxVertex, this.m_worldAABB.minVertex, this.m_worldAABB.maxVertex); + var maxVertexX = aabb.maxVertex.x; + var maxVertexY = aabb.maxVertex.y; + maxVertexX = b2Math.b2Min(maxVertexX, this.m_worldAABB.maxVertex.x); + maxVertexY = b2Math.b2Min(maxVertexY, this.m_worldAABB.maxVertex.y); + maxVertexX = b2Math.b2Max(maxVertexX, this.m_worldAABB.minVertex.x); + maxVertexY = b2Math.b2Max(maxVertexY, this.m_worldAABB.minVertex.y); + + // Bump lower bounds downs and upper bounds up. This ensures correct sorting of + // lower/upper bounds that would have equal values. + // TODO_ERIN implement fast float to uint16 conversion. + lowerValues[0] = /*uint*/(this.m_quantizationFactor.x * (minVertexX - this.m_worldAABB.minVertex.x)) & (b2Settings.USHRT_MAX - 1); + upperValues[0] = (/*uint*/(this.m_quantizationFactor.x * (maxVertexX - this.m_worldAABB.minVertex.x))& 0x0000ffff) | 1; + + lowerValues[1] = /*uint*/(this.m_quantizationFactor.y * (minVertexY - this.m_worldAABB.minVertex.y)) & (b2Settings.USHRT_MAX - 1); + upperValues[1] = (/*uint*/(this.m_quantizationFactor.y * (maxVertexY - this.m_worldAABB.minVertex.y))& 0x0000ffff) | 1; + }, + + // This one is only used for validation. + TestOverlapValidate: function(p1, p2){ + + for (var axis = 0; axis < 2; ++axis) + { + var bounds = this.m_bounds[axis]; + + //b2Settings.b2Assert(p1.lowerBounds[axis] < 2 * this.m_proxyCount); + //b2Settings.b2Assert(p1.upperBounds[axis] < 2 * this.m_proxyCount); + //b2Settings.b2Assert(p2.lowerBounds[axis] < 2 * this.m_proxyCount); + //b2Settings.b2Assert(p2.upperBounds[axis] < 2 * this.m_proxyCount); + + if (bounds[p1.lowerBounds[axis]].value > bounds[p2.upperBounds[axis]].value) + return false; + + if (bounds[p1.upperBounds[axis]].value < bounds[p2.lowerBounds[axis]].value) + return false; + } + + return true; + }, + + TestOverlap: function(b, p) + { + for (var axis = 0; axis < 2; ++axis) + { + var bounds = this.m_bounds[axis]; + + //b2Settings.b2Assert(p.lowerBounds[axis] < 2 * this.m_proxyCount); + //b2Settings.b2Assert(p.upperBounds[axis] < 2 * this.m_proxyCount); + + if (b.lowerValues[axis] > bounds[p.upperBounds[axis]].value) + return false; + + if (b.upperValues[axis] < bounds[p.lowerBounds[axis]].value) + return false; + } + + return true; + }, + + Query: function(lowerQueryOut, upperQueryOut, lowerValue, upperValue, bounds, boundCount, axis){ + + var lowerQuery = b2BroadPhase.BinarySearch(bounds, boundCount, lowerValue); + var upperQuery = b2BroadPhase.BinarySearch(bounds, boundCount, upperValue); + + // Easy case: lowerQuery <= lowerIndex(i) < upperQuery + // Solution: search query range for min bounds. + for (var j = lowerQuery; j < upperQuery; ++j) + { + if (bounds[j].IsLower()) + { + this.IncrementOverlapCount(bounds[j].proxyId); + } + } + + // Hard case: lowerIndex(i) < lowerQuery < upperIndex(i) + // Solution: use the stabbing count to search down the bound array. + if (lowerQuery > 0) + { + var i = lowerQuery - 1; + var s = bounds[i].stabbingCount; + + // Find the s overlaps. + while (s) + { + //b2Settings.b2Assert(i >= 0); + + if (bounds[i].IsLower()) + { + var proxy = this.m_proxyPool[ bounds[i].proxyId ]; + if (lowerQuery <= proxy.upperBounds[axis]) + { + this.IncrementOverlapCount(bounds[i].proxyId); + --s; + } + } + --i; + } + } + + lowerQueryOut[0] = lowerQuery; + upperQueryOut[0] = upperQuery; + }, + + + IncrementOverlapCount: function(proxyId){ + var proxy = this.m_proxyPool[ proxyId ]; + if (proxy.timeStamp < this.m_timeStamp) + { + proxy.timeStamp = this.m_timeStamp; + proxy.overlapCount = 1; + } + else + { + proxy.overlapCount = 2; + //b2Settings.b2Assert(this.m_queryResultCount < b2Settings.b2_maxProxies); + this.m_queryResults[this.m_queryResultCount] = proxyId; + ++this.m_queryResultCount; + } + }, + IncrementTimeStamp: function(){ + if (this.m_timeStamp == b2Settings.USHRT_MAX) + { + for (var i = 0; i < b2Settings.b2_maxProxies; ++i) + { + this.m_proxyPool[i].timeStamp = 0; + } + this.m_timeStamp = 1; + } + else + { + ++this.m_timeStamp; + } + }, + +//public: + m_pairManager: new b2PairManager(), + + m_proxyPool: new Array(b2Settings.b2_maxPairs), + m_freeProxy: 0, + + m_bounds: new Array(2*b2Settings.b2_maxProxies), + + m_queryResults: new Array(b2Settings.b2_maxProxies), + m_queryResultCount: 0, + + m_worldAABB: null, + m_quantizationFactor: new b2Vec2(), + m_proxyCount: 0, + m_timeStamp: 0}; +b2BroadPhase.s_validate = false; +b2BroadPhase.b2_invalid = b2Settings.USHRT_MAX; +b2BroadPhase.b2_nullEdge = b2Settings.USHRT_MAX; +b2BroadPhase.BinarySearch = function(bounds, count, value) + { + var low = 0; + var high = count - 1; + while (low <= high) + { + var mid = Math.floor((low + high) / 2); + if (bounds[mid].value > value) + { + high = mid - 1; + } + else if (bounds[mid].value < value) + { + low = mid + 1; + } + else + { + return /*uint*/(mid); + } + } + + return /*uint*/(low); + }; diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2BufferedPair.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2BufferedPair.js new file mode 100644 index 00000000..fe1419ef --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2BufferedPair.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +var b2BufferedPair = Class.create(); +b2BufferedPair.prototype = { + proxyId1: 0, + proxyId2: 0, + + initialize: function() {}} diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2Collision.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2Collision.js new file mode 100644 index 00000000..31719e32 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2Collision.js @@ -0,0 +1,738 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + +var b2Collision = Class.create(); +b2Collision.prototype = { + + // Null feature + + + + + // Find the separation between poly1 and poly2 for a give edge normal on poly1. + + + + + // Find the max separation between poly1 and poly2 using edge normals + // from poly1. + + + + + + + + // Find edge normal of max separation on A - return if separating axis is found + // Find edge normal of max separation on B - return if separation axis is found + // Choose reference edge(minA, minB) + // Find incident edge + // Clip + // The normal points from 1 to 2 + + + + + + + + + + + + + + + + initialize: function() {}} +b2Collision.b2_nullFeature = 0x000000ff; +b2Collision.ClipSegmentToLine = function(vOut, vIn, normal, offset) + { + // Start with no output points + var numOut = 0; + + var vIn0 = vIn[0].v; + var vIn1 = vIn[1].v; + + // Calculate the distance of end points to the line + var distance0 = b2Math.b2Dot(normal, vIn[0].v) - offset; + var distance1 = b2Math.b2Dot(normal, vIn[1].v) - offset; + + // If the points are behind the plane + if (distance0 <= 0.0) vOut[numOut++] = vIn[0]; + if (distance1 <= 0.0) vOut[numOut++] = vIn[1]; + + // If the points are on different sides of the plane + if (distance0 * distance1 < 0.0) + { + // Find intersection point of edge and plane + var interp = distance0 / (distance0 - distance1); + // expanded for performance + var tVec = vOut[numOut].v; + tVec.x = vIn0.x + interp * (vIn1.x - vIn0.x); + tVec.y = vIn0.y + interp * (vIn1.y - vIn0.y); + if (distance0 > 0.0) + { + vOut[numOut].id = vIn[0].id; + } + else + { + vOut[numOut].id = vIn[1].id; + } + ++numOut; + } + + return numOut; + }; +b2Collision.EdgeSeparation = function(poly1, edge1, poly2) + { + var vert1s = poly1.m_vertices; + var count2 = poly2.m_vertexCount; + var vert2s = poly2.m_vertices; + + // Convert normal from into poly2's frame. + //b2Settings.b2Assert(edge1 < poly1.m_vertexCount); + + //var normal = b2Math.b2MulMV(poly1.m_R, poly1->m_normals[edge1]); + var normalX = poly1.m_normals[edge1].x; + var normalY = poly1.m_normals[edge1].y; + var tX = normalX; + var tMat = poly1.m_R; + normalX = tMat.col1.x * tX + tMat.col2.x * normalY; + normalY = tMat.col1.y * tX + tMat.col2.y * normalY; + // ^^^^^^^ normal.MulM(poly1.m_R); + + //var normalLocal2 = b2Math.b2MulTMV(poly2.m_R, normal); + var normalLocal2X = normalX; + var normalLocal2Y = normalY; + tMat = poly2.m_R; + tX = normalLocal2X * tMat.col1.x + normalLocal2Y * tMat.col1.y; + normalLocal2Y = normalLocal2X * tMat.col2.x + normalLocal2Y * tMat.col2.y; + normalLocal2X = tX; + // ^^^^^ normalLocal2.MulTM(poly2.m_R); + + // Find support vertex on poly2 for -normal. + var vertexIndex2 = 0; + var minDot = Number.MAX_VALUE; + for (var i = 0; i < count2; ++i) + { + //var dot = b2Math.b2Dot(vert2s[i], normalLocal2); + var tVec = vert2s[i]; + var dot = tVec.x * normalLocal2X + tVec.y * normalLocal2Y; + if (dot < minDot) + { + minDot = dot; + vertexIndex2 = i; + } + } + + //b2Vec2 v1 = poly1->m_position + b2Mul(poly1->m_R, vert1s[edge1]); + tMat = poly1.m_R; + var v1X = poly1.m_position.x + (tMat.col1.x * vert1s[edge1].x + tMat.col2.x * vert1s[edge1].y) + var v1Y = poly1.m_position.y + (tMat.col1.y * vert1s[edge1].x + tMat.col2.y * vert1s[edge1].y) + + //b2Vec2 v2 = poly2->m_position + b2Mul(poly2->m_R, vert2s[vertexIndex2]); + tMat = poly2.m_R; + var v2X = poly2.m_position.x + (tMat.col1.x * vert2s[vertexIndex2].x + tMat.col2.x * vert2s[vertexIndex2].y) + var v2Y = poly2.m_position.y + (tMat.col1.y * vert2s[vertexIndex2].x + tMat.col2.y * vert2s[vertexIndex2].y) + + //var separation = b2Math.b2Dot( b2Math.SubtractVV( v2, v1 ) , normal); + v2X -= v1X; + v2Y -= v1Y; + //var separation = b2Math.b2Dot( v2 , normal); + var separation = v2X * normalX + v2Y * normalY; + return separation; + }; +b2Collision.FindMaxSeparation = function(edgeIndex /*int ptr*/, poly1, poly2, conservative) + { + var count1 = poly1.m_vertexCount; + + // Vector pointing from the origin of poly1 to the origin of poly2. + //var d = b2Math.SubtractVV( poly2.m_position, poly1.m_position ); + var dX = poly2.m_position.x - poly1.m_position.x; + var dY = poly2.m_position.y - poly1.m_position.y; + + //var dLocal1 = b2Math.b2MulTMV(poly1.m_R, d); + var dLocal1X = (dX * poly1.m_R.col1.x + dY * poly1.m_R.col1.y); + var dLocal1Y = (dX * poly1.m_R.col2.x + dY * poly1.m_R.col2.y); + + // Get support vertex hint for our search + var edge = 0; + var maxDot = -Number.MAX_VALUE; + for (var i = 0; i < count1; ++i) + { + //var dot = b2Math.b2Dot(poly.m_normals[i], dLocal1); + var dot = (poly1.m_normals[i].x * dLocal1X + poly1.m_normals[i].y * dLocal1Y); + if (dot > maxDot) + { + maxDot = dot; + edge = i; + } + } + + // Get the separation for the edge normal. + var s = b2Collision.EdgeSeparation(poly1, edge, poly2); + if (s > 0.0 && conservative == false) + { + return s; + } + + // Check the separation for the neighboring edges. + var prevEdge = edge - 1 >= 0 ? edge - 1 : count1 - 1; + var sPrev = b2Collision.EdgeSeparation(poly1, prevEdge, poly2); + if (sPrev > 0.0 && conservative == false) + { + return sPrev; + } + + var nextEdge = edge + 1 < count1 ? edge + 1 : 0; + var sNext = b2Collision.EdgeSeparation(poly1, nextEdge, poly2); + if (sNext > 0.0 && conservative == false) + { + return sNext; + } + + // Find the best edge and the search direction. + var bestEdge = 0; + var bestSeparation; + 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 + { + // pointer out + 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, edge, poly2); + if (s > 0.0 && conservative == false) + { + return s; + } + + if (s > bestSeparation) + { + bestEdge = edge; + bestSeparation = s; + } + else + { + break; + } + } + + // pointer out + edgeIndex[0] = bestEdge; + return bestSeparation; + }; +b2Collision.FindIncidentEdge = function(c, poly1, edge1, poly2) + { + var count1 = poly1.m_vertexCount; + var vert1s = poly1.m_vertices; + var count2 = poly2.m_vertexCount; + var vert2s = poly2.m_vertices; + + // Get the vertices associated with edge1. + var vertex11 = edge1; + var vertex12 = edge1 + 1 == count1 ? 0 : edge1 + 1; + + // Get the normal of edge1. + var tVec = vert1s[vertex12]; + //var normal1Local1 = b2Math.b2CrossVF( b2Math.SubtractVV( vert1s[vertex12], vert1s[vertex11] ), 1.0); + var normal1Local1X = tVec.x; + var normal1Local1Y = tVec.y; + tVec = vert1s[vertex11]; + normal1Local1X -= tVec.x; + normal1Local1Y -= tVec.y; + var tX = normal1Local1X; + normal1Local1X = normal1Local1Y; + normal1Local1Y = -tX; + // ^^^^ normal1Local1.CrossVF(1.0); + + var invLength = 1.0 / Math.sqrt(normal1Local1X*normal1Local1X + normal1Local1Y*normal1Local1Y); + normal1Local1X *= invLength; + normal1Local1Y *= invLength; + // ^^^^normal1Local1.Normalize(); + //var normal1 = b2Math.b2MulMV(poly1.m_R, normal1Local1); + var normal1X = normal1Local1X; + var normal1Y = normal1Local1Y; + + tX = normal1X; + var tMat = poly1.m_R; + normal1X = tMat.col1.x * tX + tMat.col2.x * normal1Y; + normal1Y = tMat.col1.y * tX + tMat.col2.y * normal1Y; + // ^^^^ normal1.MulM(poly1.m_R); + + //var normal1Local2 = b2Math.b2MulTMV(poly2.m_R, normal1); + var normal1Local2X = normal1X; + var normal1Local2Y = normal1Y; + tMat = poly2.m_R; + tX = normal1Local2X * tMat.col1.x + normal1Local2Y * tMat.col1.y; + normal1Local2Y = normal1Local2X * tMat.col2.x + normal1Local2Y * tMat.col2.y; + normal1Local2X = tX; + // ^^^^ normal1Local2.MulTM(poly2.m_R); + + // Find the incident edge on poly2. + var vertex21 = 0; + var vertex22 = 0; + var minDot = Number.MAX_VALUE; + for (var i = 0; i < count2; ++i) + { + var i1 = i; + var i2 = i + 1 < count2 ? i + 1 : 0; + + //var normal2Local2 = b2Math.b2CrossVF( b2Math.SubtractVV( vert2s[i2], vert2s[i1] ), 1.0); + tVec = vert2s[i2]; + var normal2Local2X = tVec.x; + var normal2Local2Y = tVec.y; + tVec = vert2s[i1]; + normal2Local2X -= tVec.x; + normal2Local2Y -= tVec.y; + tX = normal2Local2X; + normal2Local2X = normal2Local2Y; + normal2Local2Y = -tX; + // ^^^^ normal2Local2.CrossVF(1.0); + + invLength = 1.0 / Math.sqrt(normal2Local2X*normal2Local2X + normal2Local2Y*normal2Local2Y); + normal2Local2X *= invLength; + normal2Local2Y *= invLength; + // ^^^^ normal2Local2.Normalize(); + + //var dot = b2Math.b2Dot(normal2Local2, normal1Local2); + var dot = normal2Local2X * normal1Local2X + normal2Local2Y * normal1Local2Y; + if (dot < minDot) + { + minDot = dot; + vertex21 = i1; + vertex22 = i2; + } + } + + var tClip; + // Build the clip vertices for the incident edge. + tClip = c[0]; + //tClip.v = b2Math.AddVV(poly2.m_position, b2Math.b2MulMV(poly2.m_R, vert2s[vertex21])); + tVec = tClip.v; + tVec.SetV(vert2s[vertex21]); + tVec.MulM(poly2.m_R); + tVec.Add(poly2.m_position); + + tClip.id.features.referenceFace = edge1; + tClip.id.features.incidentEdge = vertex21; + tClip.id.features.incidentVertex = vertex21; + + tClip = c[1]; + //tClip.v = b2Math.AddVV(poly2.m_position, b2Math.b2MulMV(poly2.m_R, vert2s[vertex22])); + tVec = tClip.v; + tVec.SetV(vert2s[vertex22]); + tVec.MulM(poly2.m_R); + tVec.Add(poly2.m_position); + tClip.id.features.referenceFace = edge1; + tClip.id.features.incidentEdge = vertex21; + tClip.id.features.incidentVertex = vertex22; + }; +b2Collision.b2CollidePolyTempVec = new b2Vec2(); +b2Collision.b2CollidePoly = function(manifold, polyA, polyB, conservative) + { + manifold.pointCount = 0; + + var edgeA = 0; + var edgeAOut = [edgeA]; + var separationA = b2Collision.FindMaxSeparation(edgeAOut, polyA, polyB, conservative); + edgeA = edgeAOut[0]; + if (separationA > 0.0 && conservative == false) + return; + + var edgeB = 0; + var edgeBOut = [edgeB]; + var separationB = b2Collision.FindMaxSeparation(edgeBOut, polyB, polyA, conservative); + edgeB = edgeBOut[0]; + if (separationB > 0.0 && conservative == false) + return; + + var poly1; + var poly2; + var edge1 = 0; + var flip = 0; + var k_relativeTol = 0.98; + var k_absoluteTol = 0.001; + + // TODO_ERIN use "radius" of poly for absolute tolerance. + if (separationB > k_relativeTol * separationA + k_absoluteTol) + { + poly1 = polyB; + poly2 = polyA; + edge1 = edgeB; + flip = 1; + } + else + { + poly1 = polyA; + poly2 = polyB; + edge1 = edgeA; + flip = 0; + } + + var incidentEdge = [new ClipVertex(), new ClipVertex()]; + b2Collision.FindIncidentEdge(incidentEdge, poly1, edge1, poly2); + + var count1 = poly1.m_vertexCount; + var vert1s = poly1.m_vertices; + + var v11 = vert1s[edge1]; + var v12 = edge1 + 1 < count1 ? vert1s[edge1+1] : vert1s[0]; + + //var dv = b2Math.SubtractVV(v12, v11); + var dvX = v12.x - v11.x; + var dvY = v12.y - v11.y; + + //var sideNormal = b2Math.b2MulMV(poly1.m_R, b2Math.SubtractVV(v12, v11)); + var sideNormalX = v12.x - v11.x; + var sideNormalY = v12.y - v11.y; + + var tX = sideNormalX; + var tMat = poly1.m_R; + sideNormalX = tMat.col1.x * tX + tMat.col2.x * sideNormalY; + sideNormalY = tMat.col1.y * tX + tMat.col2.y * sideNormalY; + // ^^^^ sideNormal.MulM(poly1.m_R); + + var invLength = 1.0 / Math.sqrt(sideNormalX*sideNormalX + sideNormalY*sideNormalY); + sideNormalX *= invLength; + sideNormalY *= invLength; + // ^^^^ sideNormal.Normalize(); + + //var frontNormal = b2Math.b2CrossVF(sideNormal, 1.0); + var frontNormalX = sideNormalX; + var frontNormalY = sideNormalY; + tX = frontNormalX; + frontNormalX = frontNormalY; + frontNormalY = -tX; + // ^^^^ frontNormal.CrossVF(1.0); + + // Expanded for performance + //v11 = b2Math.AddVV(poly1.m_position, b2Math.b2MulMV(poly1.m_R, v11)); + var v11X = v11.x; + var v11Y = v11.y; + tX = v11X; + tMat = poly1.m_R; + v11X = tMat.col1.x * tX + tMat.col2.x * v11Y; + v11Y = tMat.col1.y * tX + tMat.col2.y * v11Y; + // ^^^^ v11.MulM(poly1.m_R); + v11X += poly1.m_position.x; + v11Y += poly1.m_position.y; + //v12 = b2Math.AddVV(poly1.m_position, b2Math.b2MulMV(poly1.m_R, v12)); + var v12X = v12.x; + var v12Y = v12.y; + tX = v12X; + tMat = poly1.m_R; + v12X = tMat.col1.x * tX + tMat.col2.x * v12Y; + v12Y = tMat.col1.y * tX + tMat.col2.y * v12Y; + // ^^^^ v12.MulM(poly1.m_R); + v12X += poly1.m_position.x; + v12Y += poly1.m_position.y; + + //var frontOffset = b2Math.b2Dot(frontNormal, v11); + var frontOffset = frontNormalX * v11X + frontNormalY * v11Y; + //var sideOffset1 = -b2Math.b2Dot(sideNormal, v11); + var sideOffset1 = -(sideNormalX * v11X + sideNormalY * v11Y); + //var sideOffset2 = b2Math.b2Dot(sideNormal, v12); + var sideOffset2 = sideNormalX * v12X + sideNormalY * v12Y; + + // Clip incident edge against extruded edge1 side edges. + var clipPoints1 = [new ClipVertex(), new ClipVertex()]; + var clipPoints2 = [new ClipVertex(), new ClipVertex()]; + + var np = 0; + + // Clip to box side 1 + b2Collision.b2CollidePolyTempVec.Set(-sideNormalX, -sideNormalY); + np = b2Collision.ClipSegmentToLine(clipPoints1, incidentEdge, b2Collision.b2CollidePolyTempVec, sideOffset1); + + if (np < 2) + return; + + // Clip to negative box side 1 + b2Collision.b2CollidePolyTempVec.Set(sideNormalX, sideNormalY); + np = b2Collision.ClipSegmentToLine(clipPoints2, clipPoints1, b2Collision.b2CollidePolyTempVec, sideOffset2); + + if (np < 2) + return; + + // Now clipPoints2 contains the clipped points. + if (flip){ + manifold.normal.Set(-frontNormalX, -frontNormalY); + } + else{ + manifold.normal.Set(frontNormalX, frontNormalY); + } + // ^^^^ manifold.normal = flip ? frontNormal.Negative() : frontNormal; + + var pointCount = 0; + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; ++i) + { + //var separation = b2Math.b2Dot(frontNormal, clipPoints2[i].v) - frontOffset; + var tVec = clipPoints2[i].v; + var separation = (frontNormalX * tVec.x + frontNormalY * tVec.y) - frontOffset; + + if (separation <= 0.0 || conservative == true) + { + var cp = manifold.points[ pointCount ]; + cp.separation = separation; + cp.position.SetV( clipPoints2[i].v ); + cp.id.Set( clipPoints2[i].id ); + cp.id.features.flip = flip; + ++pointCount; + } + } + + manifold.pointCount = pointCount; + }; +b2Collision.b2CollideCircle = function(manifold, circle1, circle2, conservative) + { + manifold.pointCount = 0; + + //var d = b2Math.SubtractVV(circle2.m_position, circle1.m_position); + var dX = circle2.m_position.x - circle1.m_position.x; + var dY = circle2.m_position.y - circle1.m_position.y; + //var distSqr = b2Math.b2Dot(d, d); + var distSqr = dX * dX + dY * dY; + var radiusSum = circle1.m_radius + circle2.m_radius; + if (distSqr > radiusSum * radiusSum && conservative == false) + { + return; + } + + var separation; + if (distSqr < Number.MIN_VALUE) + { + separation = -radiusSum; + manifold.normal.Set(0.0, 1.0); + } + else + { + var dist = Math.sqrt(distSqr); + separation = dist - radiusSum; + var a = 1.0 / dist; + manifold.normal.x = a * dX; + manifold.normal.y = a * dY; + } + + manifold.pointCount = 1; + var tPoint = manifold.points[0]; + tPoint.id.set_key(0); + tPoint.separation = separation; + //tPoint.position = b2Math.SubtractVV(circle2.m_position, b2Math.MulFV(circle2.m_radius, manifold.normal)); + tPoint.position.x = circle2.m_position.x - (circle2.m_radius * manifold.normal.x); + tPoint.position.y = circle2.m_position.y - (circle2.m_radius * manifold.normal.y); + }; +b2Collision.b2CollidePolyAndCircle = function(manifold, poly, circle, conservative) + { + manifold.pointCount = 0; + var tPoint; + + var dX; + var dY; + + // Compute circle position in the frame of the polygon. + //var xLocal = b2Math.b2MulTMV(poly.m_R, b2Math.SubtractVV(circle.m_position, poly.m_position)); + var xLocalX = circle.m_position.x - poly.m_position.x; + var xLocalY = circle.m_position.y - poly.m_position.y; + var tMat = poly.m_R; + var tX = xLocalX * tMat.col1.x + xLocalY * tMat.col1.y; + xLocalY = xLocalX * tMat.col2.x + xLocalY * tMat.col2.y; + xLocalX = tX; + + var dist; + + // Find the min separating edge. + var normalIndex = 0; + var separation = -Number.MAX_VALUE; + var radius = circle.m_radius; + for (var i = 0; i < poly.m_vertexCount; ++i) + { + //var s = b2Math.b2Dot(poly.m_normals[i], b2Math.SubtractVV(xLocal, poly.m_vertices[i])); + var s = poly.m_normals[i].x * (xLocalX-poly.m_vertices[i].x) + poly.m_normals[i].y * (xLocalY-poly.m_vertices[i].y); + if (s > radius) + { + // Early out. + return; + } + + if (s > separation) + { + separation = s; + normalIndex = i; + } + } + + // If the center is inside the polygon ... + if (separation < Number.MIN_VALUE) + { + manifold.pointCount = 1; + //manifold.normal = b2Math.b2MulMV(poly.m_R, poly.m_normals[normalIndex]); + var tVec = poly.m_normals[normalIndex]; + manifold.normal.x = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + manifold.normal.y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + + tPoint = manifold.points[0]; + tPoint.id.features.incidentEdge = normalIndex; + tPoint.id.features.incidentVertex = b2Collision.b2_nullFeature; + tPoint.id.features.referenceFace = b2Collision.b2_nullFeature; + tPoint.id.features.flip = 0; + tPoint.position.x = circle.m_position.x - radius * manifold.normal.x; + tPoint.position.y = circle.m_position.y - radius * manifold.normal.y; + //tPoint.position = b2Math.SubtractVV(circle.m_position , b2Math.MulFV(radius , manifold.normal)); + tPoint.separation = separation - radius; + return; + } + + // Project the circle center onto the edge segment. + var vertIndex1 = normalIndex; + var vertIndex2 = vertIndex1 + 1 < poly.m_vertexCount ? vertIndex1 + 1 : 0; + //var e = b2Math.SubtractVV(poly.m_vertices[vertIndex2] , poly.m_vertices[vertIndex1]); + var eX = poly.m_vertices[vertIndex2].x - poly.m_vertices[vertIndex1].x; + var eY = poly.m_vertices[vertIndex2].y - poly.m_vertices[vertIndex1].y; + //var length = e.Normalize(); + var length = Math.sqrt(eX*eX + eY*eY); + eX /= length; + eY /= length; + + // If the edge length is zero ... + if (length < Number.MIN_VALUE) + { + //d = b2Math.SubtractVV(xLocal , poly.m_vertices[vertIndex1]); + dX = xLocalX - poly.m_vertices[vertIndex1].x; + dY = xLocalY - poly.m_vertices[vertIndex1].y; + //dist = d.Normalize(); + dist = Math.sqrt(dX*dX + dY*dY); + dX /= dist; + dY /= dist; + if (dist > radius) + { + return; + } + + manifold.pointCount = 1; + //manifold.normal = b2Math.b2MulMV(poly.m_R, d); + manifold.normal.Set(tMat.col1.x * dX + tMat.col2.x * dY, tMat.col1.y * dX + tMat.col2.y * dY); + tPoint = manifold.points[0]; + tPoint.id.features.incidentEdge = b2Collision.b2_nullFeature; + tPoint.id.features.incidentVertex = vertIndex1; + tPoint.id.features.referenceFace = b2Collision.b2_nullFeature; + tPoint.id.features.flip = 0; + //tPoint.position = b2Math.SubtractVV(circle.m_position , b2Math.MulFV(radius , manifold.normal)); + tPoint.position.x = circle.m_position.x - radius * manifold.normal.x; + tPoint.position.y = circle.m_position.y - radius * manifold.normal.y; + tPoint.separation = dist - radius; + return; + } + + // Project the center onto the edge. + //var u = b2Math.b2Dot(b2Math.SubtractVV(xLocal , poly.m_vertices[vertIndex1]) , e); + var u = (xLocalX-poly.m_vertices[vertIndex1].x) * eX + (xLocalY-poly.m_vertices[vertIndex1].y) * eY; + + tPoint = manifold.points[0]; + tPoint.id.features.incidentEdge = b2Collision.b2_nullFeature; + tPoint.id.features.incidentVertex = b2Collision.b2_nullFeature; + tPoint.id.features.referenceFace = b2Collision.b2_nullFeature; + tPoint.id.features.flip = 0; + + var pX, pY; + if (u <= 0.0) + { + pX = poly.m_vertices[vertIndex1].x; + pY = poly.m_vertices[vertIndex1].y; + tPoint.id.features.incidentVertex = vertIndex1; + } + else if (u >= length) + { + pX = poly.m_vertices[vertIndex2].x; + pY = poly.m_vertices[vertIndex2].y; + tPoint.id.features.incidentVertex = vertIndex2; + } + else + { + //p = b2Math.AddVV(poly.m_vertices[vertIndex1] , b2Math.MulFV(u, e)); + pX = eX * u + poly.m_vertices[vertIndex1].x; + pY = eY * u + poly.m_vertices[vertIndex1].y; + tPoint.id.features.incidentEdge = vertIndex1; + } + + //d = b2Math.SubtractVV(xLocal , p); + dX = xLocalX - pX; + dY = xLocalY - pY; + //dist = d.Normalize(); + dist = Math.sqrt(dX*dX + dY*dY); + dX /= dist; + dY /= dist; + if (dist > radius) + { + return; + } + + manifold.pointCount = 1; + //manifold.normal = b2Math.b2MulMV(poly.m_R, d); + manifold.normal.Set(tMat.col1.x * dX + tMat.col2.x * dY, tMat.col1.y * dX + tMat.col2.y * dY); + //tPoint.position = b2Math.SubtractVV(circle.m_position , b2Math.MulFV(radius , manifold.normal)); + tPoint.position.x = circle.m_position.x - radius * manifold.normal.x; + tPoint.position.y = circle.m_position.y - radius * manifold.normal.y; + tPoint.separation = dist - radius; + }; +b2Collision.b2TestOverlap = function(a, b) + { + var t1 = b.minVertex; + var t2 = a.maxVertex; + //d1 = b2Math.SubtractVV(b.minVertex, a.maxVertex); + var d1X = t1.x - t2.x; + var d1Y = t1.y - t2.y; + //d2 = b2Math.SubtractVV(a.minVertex, b.maxVertex); + t1 = a.minVertex; + t2 = b.maxVertex; + 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; + }; diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2ContactID.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2ContactID.js new file mode 100644 index 00000000..f0962e9e --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2ContactID.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +// We use contact ids to facilitate warm starting. +var b2ContactID = Class.create(); +b2ContactID.prototype = +{ + initialize: function(){ + // initialize instance variables for references + this.features = new Features(); + // + + this.features._m_id = this; + + }, + Set: function(id){ + this.set_key(id._key); + }, + Copy: function(){ + var id = new b2ContactID(); + id.set_key(this._key); + return id; + }, + get_key: function(){ + return this._key; + }, + set_key: function(value) { + this._key = value; + this.features._referenceFace = 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; + }, + features: new Features(), + _key: 0}; diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2ContactPoint.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2ContactPoint.js new file mode 100644 index 00000000..2ba6359b --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2ContactPoint.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +// We use contact ids to facilitate warm starting. +var b2ContactPoint = Class.create(); +b2ContactPoint.prototype = +{ + position: new b2Vec2(), + separation: null, + normalImpulse: null, + tangentImpulse: null, + id: new b2ContactID(), + initialize: function() { + // initialize instance variables for references + this.position = new b2Vec2(); + this.id = new b2ContactID(); + // +}}; diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2Distance.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2Distance.js new file mode 100644 index 00000000..66bd84a2 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2Distance.js @@ -0,0 +1,333 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +var b2Distance = Class.create(); +b2Distance.prototype = +{ + + // GJK using Voronoi regions (Christer Ericson) and region selection + // optimizations (Casey Muratori). + + // The origin is either in the region of points[1] or in the edge region. The origin is + // not in region of points[0] because that is the old point. + + // Possible regions: + // - points[2] + // - edge points[0]-points[2] + // - edge points[1]-points[2] + // - inside the triangle + + + + + + + initialize: function() {}}; +b2Distance.ProcessTwo = function(p1Out, p2Out, p1s, p2s, points) + { + // If in point[1] region + //b2Vec2 r = -points[1]; + var rX = -points[1].x; + var rY = -points[1].y; + //b2Vec2 d = points[1] - points[0]; + var dX = points[0].x - points[1].x; + var dY = points[0].y - points[1].y; + //float32 length = d.Normalize(); + var length = Math.sqrt(dX*dX + dY*dY); + dX /= length; + dY /= length; + + //float32 lambda = b2Dot(r, d); + var lambda = rX * dX + rY * dY; + if (lambda <= 0.0 || length < Number.MIN_VALUE) + { + // The simplex is reduced to a point. + //*p1Out = p1s[1]; + p1Out.SetV(p1s[1]); + //*p2Out = p2s[1]; + p2Out.SetV(p2s[1]); + //p1s[0] = p1s[1]; + p1s[0].SetV(p1s[1]); + //p2s[0] = p2s[1]; + p2s[0].SetV(p2s[1]); + points[0].SetV(points[1]); + return 1; + } + + // Else in edge region + lambda /= length; + //*p1Out = p1s[1] + lambda * (p1s[0] - p1s[1]); + p1Out.x = p1s[1].x + lambda * (p1s[0].x - p1s[1].x); + p1Out.y = p1s[1].y + lambda * (p1s[0].y - p1s[1].y); + //*p2Out = p2s[1] + lambda * (p2s[0] - p2s[1]); + p2Out.x = p2s[1].x + lambda * (p2s[0].x - p2s[1].x); + p2Out.y = p2s[1].y + lambda * (p2s[0].y - p2s[1].y); + return 2; + }; +b2Distance.ProcessThree = function(p1Out, p2Out, p1s, p2s, points) + { + //b2Vec2 a = points[0]; + var aX = points[0].x; + var aY = points[0].y; + //b2Vec2 b = points[1]; + var bX = points[1].x; + var bY = points[1].y; + //b2Vec2 c = points[2]; + var cX = points[2].x; + var cY = points[2].y; + + //b2Vec2 ab = b - a; + var abX = bX - aX; + var abY = bY - aY; + //b2Vec2 ac = c - a; + var acX = cX - aX; + var acY = cY - aY; + //b2Vec2 bc = c - b; + var bcX = cX - bX; + var bcY = cY - bY; + + //float32 sn = -b2Dot(a, ab), sd = b2Dot(b, ab); + var sn = -(aX * abX + aY * abY); + var sd = (bX * abX + bY * abY); + //float32 tn = -b2Dot(a, ac), td = b2Dot(c, ac); + var tn = -(aX * acX + aY * acY); + var td = (cX * acX + cY * acY); + //float32 un = -b2Dot(b, bc), ud = b2Dot(c, bc); + var un = -(bX * bcX + bY * bcY); + var ud = (cX * bcX + cY * bcY); + + // In vertex c region? + if (td <= 0.0 && ud <= 0.0) + { + // Single point + //*p1Out = p1s[2]; + p1Out.SetV(p1s[2]); + //*p2Out = p2s[2]; + p2Out.SetV(p2s[2]); + //p1s[0] = p1s[2]; + p1s[0].SetV(p1s[2]); + //p2s[0] = p2s[2]; + p2s[0].SetV(p2s[2]); + points[0].SetV(points[2]); + return 1; + } + + // Should not be in vertex a or b region. + //b2Settings.b2Assert(sn > 0.0 || tn > 0.0); + //b2Settings.b2Assert(sd > 0.0 || un > 0.0); + + //float32 n = b2Cross(ab, ac); + var n = abX * acY - abY * acX; + + // Should not be in edge ab region. + //float32 vc = n * b2Cross(a, b); + var vc = n * (aX * bY - aY * bX); + //b2Settings.b2Assert(vc > 0.0 || sn > 0.0 || sd > 0.0); + + // In edge bc region? + //float32 va = n * b2Cross(b, c); + var va = n * (bX * cY - bY * cX); + if (va <= 0.0 && un >= 0.0 && ud >= 0.0) + { + //b2Settings.b2Assert(un + ud > 0.0); + + //float32 lambda = un / (un + ud); + var lambda = un / (un + ud); + //*p1Out = p1s[1] + lambda * (p1s[2] - p1s[1]); + p1Out.x = p1s[1].x + lambda * (p1s[2].x - p1s[1].x); + p1Out.y = p1s[1].y + lambda * (p1s[2].y - p1s[1].y); + //*p2Out = p2s[1] + lambda * (p2s[2] - p2s[1]); + p2Out.x = p2s[1].x + lambda * (p2s[2].x - p2s[1].x); + p2Out.y = p2s[1].y + lambda * (p2s[2].y - p2s[1].y); + //p1s[0] = p1s[2]; + p1s[0].SetV(p1s[2]); + //p2s[0] = p2s[2]; + p2s[0].SetV(p2s[2]); + //points[0] = points[2]; + points[0].SetV(points[2]); + return 2; + } + + // In edge ac region? + //float32 vb = n * b2Cross(c, a); + var vb = n * (cX * aY - cY * aX); + if (vb <= 0.0 && tn >= 0.0 && td >= 0.0) + { + //b2Settings.b2Assert(tn + td > 0.0); + + //float32 lambda = tn / (tn + td); + var lambda = tn / (tn + td); + //*p1Out = p1s[0] + lambda * (p1s[2] - p1s[0]); + p1Out.x = p1s[0].x + lambda * (p1s[2].x - p1s[0].x); + p1Out.y = p1s[0].y + lambda * (p1s[2].y - p1s[0].y); + //*p2Out = p2s[0] + lambda * (p2s[2] - p2s[0]); + p2Out.x = p2s[0].x + lambda * (p2s[2].x - p2s[0].x); + p2Out.y = p2s[0].y + lambda * (p2s[2].y - p2s[0].y); + //p1s[1] = p1s[2]; + p1s[1].SetV(p1s[2]); + //p2s[1] = p2s[2]; + p2s[1].SetV(p2s[2]); + //points[1] = points[2]; + points[1].SetV(points[2]); + return 2; + } + + // Inside the triangle, compute barycentric coordinates + //float32 denom = va + vb + vc; + var denom = va + vb + vc; + //b2Settings.b2Assert(denom > 0.0); + denom = 1.0 / denom; + //float32 u = va * denom; + var u = va * denom; + //float32 v = vb * denom; + var v = vb * denom; + //float32 w = 1.0f - u - v; + var w = 1.0 - u - v; + //*p1Out = u * p1s[0] + v * p1s[1] + w * p1s[2]; + p1Out.x = u * p1s[0].x + v * p1s[1].x + w * p1s[2].x; + p1Out.y = u * p1s[0].y + v * p1s[1].y + w * p1s[2].y; + //*p2Out = u * p2s[0] + v * p2s[1] + w * p2s[2]; + p2Out.x = u * p2s[0].x + v * p2s[1].x + w * p2s[2].x; + p2Out.y = u * p2s[0].y + v * p2s[1].y + w * p2s[2].y; + return 3; + }; +b2Distance.InPoinsts = function(w, points, pointCount) + { + for (var i = 0; i < pointCount; ++i) + { + if (w.x == points[i].x && w.y == points[i].y) + { + return true; + } + } + + return false; + }; +b2Distance.Distance = function(p1Out, p2Out, shape1, shape2) + { + //b2Vec2 p1s[3], p2s[3]; + var p1s = new Array(3); + var p2s = new Array(3); + //b2Vec2 points[3]; + var points = new Array(3); + //int32 pointCount = 0; + var pointCount = 0; + + //*p1Out = shape1->m_position; + p1Out.SetV(shape1.m_position); + //*p2Out = shape2->m_position; + p2Out.SetV(shape2.m_position); + + var vSqr = 0.0; + var maxIterations = 20; + for (var iter = 0; iter < maxIterations; ++iter) + { + //b2Vec2 v = *p2Out - *p1Out; + var vX = p2Out.x - p1Out.x; + var vY = p2Out.y - p1Out.y; + //b2Vec2 w1 = shape1->Support(v); + var w1 = shape1.Support(vX, vY); + //b2Vec2 w2 = shape2->Support(-v); + var w2 = shape2.Support(-vX, -vY); + //float32 vSqr = b2Dot(v, v); + vSqr = (vX*vX + vY*vY); + //b2Vec2 w = w2 - w1; + var wX = w2.x - w1.x; + var wY = w2.y - w1.y; + //float32 vw = b2Dot(v, w); + var vw = (vX*wX + vY*wY); + //if (vSqr - b2Dot(v, w) <= 0.01f * vSqr) + if (vSqr - b2Dot(vX * wX + vY * wY) <= 0.01 * vSqr) + { + if (pointCount == 0) + { + //*p1Out = w1; + p1Out.SetV(w1); + //*p2Out = w2; + p2Out.SetV(w2); + } + b2Distance.g_GJK_Iterations = iter; + return Math.sqrt(vSqr); + } + + switch (pointCount) + { + case 0: + //p1s[0] = w1; + p1s[0].SetV(w1); + //p2s[0] = w2; + p2s[0].SetV(w2); + points[0] = w; + //*p1Out = p1s[0]; + p1Out.SetV(p1s[0]); + //*p2Out = p2s[0]; + p2Out.SetV(p2s[0]); + ++pointCount; + break; + + case 1: + //p1s[1] = w1; + p1s[1].SetV(w1); + //p2s[1] = w2; + p2s[1].SetV(w2); + //points[1] = w; + points[1].x = wX; + points[1].y = wY; + pointCount = b2Distance.ProcessTwo(p1Out, p2Out, p1s, p2s, points); + break; + + case 2: + //p1s[2] = w1; + p1s[2].SetV(w1); + //p2s[2] = w2; + p2s[2].SetV(w2); + //points[2] = w; + points[2].x = wX; + points[2].y = wY; + pointCount = b2Distance.ProcessThree(p1Out, p2Out, p1s, p2s, points); + break; + } + + // If we have three points, then the origin is in the corresponding triangle. + if (pointCount == 3) + { + b2Distance.g_GJK_Iterations = iter; + return 0.0; + } + + //float32 maxSqr = -FLT_MAX; + var maxSqr = -Number.MAX_VALUE; + for (var i = 0; i < pointCount; ++i) + { + //maxSqr = b2Math.b2Max(maxSqr, b2Dot(points[i], points[i])); + maxSqr = b2Math.b2Max(maxSqr, (points[i].x*points[i].x + points[i].y*points[i].y)); + } + + if (pointCount == 3 || vSqr <= 100.0 * Number.MIN_VALUE * maxSqr) + { + b2Distance.g_GJK_Iterations = iter; + return Math.sqrt(vSqr); + } + } + + b2Distance.g_GJK_Iterations = maxIterations; + return Math.sqrt(vSqr); + }; +b2Distance.g_GJK_Iterations = 0; diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2Manifold.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2Manifold.js new file mode 100644 index 00000000..14b09794 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2Manifold.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +// A manifold for two touching convex shapes. +var b2Manifold = Class.create(); +b2Manifold.prototype = +{ + initialize: function(){ + this.points = new Array(b2Settings.b2_maxManifoldPoints); + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++){ + this.points[i] = new b2ContactPoint(); + } + this.normal = new b2Vec2(); + }, + points: null, + normal: null, + pointCount: 0}; diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2OBB.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2OBB.js new file mode 100644 index 00000000..0214be8e --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2OBB.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +// A manifold for two touching convex shapes. +var b2OBB = Class.create(); +b2OBB.prototype = +{ + R: new b2Mat22(), + center: new b2Vec2(), + extents: new b2Vec2(), + initialize: function() { + // initialize instance variables for references + this.R = new b2Mat22(); + this.center = new b2Vec2(); + this.extents = new b2Vec2(); + // +}}; diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2Pair.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2Pair.js new file mode 100644 index 00000000..56e615b8 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2Pair.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + +// The pair manager is used by the broad-phase to quickly add/remove/find pairs +// of overlapping proxies. It is based closely on code provided by Pierre Terdiman. +// http: + + + + + +var b2Pair = Class.create(); +b2Pair.prototype = +{ + + + SetBuffered: function() { this.status |= b2Pair.e_pairBuffered; }, + ClearBuffered: function() { this.status &= ~b2Pair.e_pairBuffered; }, + IsBuffered: function(){ return (this.status & b2Pair.e_pairBuffered) == b2Pair.e_pairBuffered; }, + + SetRemoved: function() { this.status |= b2Pair.e_pairRemoved; }, + ClearRemoved: function() { this.status &= ~b2Pair.e_pairRemoved; }, + IsRemoved: function(){ return (this.status & b2Pair.e_pairRemoved) == b2Pair.e_pairRemoved; }, + + SetFinal: function() { this.status |= b2Pair.e_pairFinal; }, + IsFinal: function(){ return (this.status & b2Pair.e_pairFinal) == b2Pair.e_pairFinal; }, + + userData: null, + proxyId1: 0, + proxyId2: 0, + next: 0, + status: 0, + + // STATIC + + // enum + + initialize: function() {}}; +b2Pair.b2_nullPair = b2Settings.USHRT_MAX; +b2Pair.b2_nullProxy = b2Settings.USHRT_MAX; +b2Pair.b2_tableCapacity = b2Settings.b2_maxPairs; +b2Pair.b2_tableMask = b2Pair.b2_tableCapacity - 1; +b2Pair.e_pairBuffered = 0x0001; +b2Pair.e_pairRemoved = 0x0002; +b2Pair.e_pairFinal = 0x0004; diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2PairCallback.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2PairCallback.js new file mode 100644 index 00000000..f68628c5 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2PairCallback.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +var b2PairCallback = Class.create(); +b2PairCallback.prototype = +{ + //virtual ~b2PairCallback() {} + + // This returns the new pair user data. + PairAdded: function(proxyUserData1, proxyUserData2){return null}, + + // This should free the pair's user data. In extreme circumstances, it is possible + // this will be called with null pairUserData because the pair never existed. + PairRemoved: function(proxyUserData1, proxyUserData2, pairUserData){}, + initialize: function() {}}; + + diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2PairManager.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2PairManager.js new file mode 100644 index 00000000..88d4c900 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2PairManager.js @@ -0,0 +1,386 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + +// The pair manager is used by the broad-phase to quickly add/remove/find pairs +// of overlapping proxies. It is based closely on code provided by Pierre Terdiman. +// http: + + + + + +var b2PairManager = Class.create(); +b2PairManager.prototype = +{ +//public: + initialize: function(){ + var i = 0; + //b2Settings.b2Assert(b2Math.b2IsPowerOfTwo(b2Pair.b2_tableCapacity) == true); + //b2Settings.b2Assert(b2Pair.b2_tableCapacity >= b2Settings.b2_maxPairs); + this.m_hashTable = new Array(b2Pair.b2_tableCapacity); + for (i = 0; i < b2Pair.b2_tableCapacity; ++i) + { + this.m_hashTable[i] = b2Pair.b2_nullPair; + } + this.m_pairs = new Array(b2Settings.b2_maxPairs); + for (i = 0; i < b2Settings.b2_maxPairs; ++i) + { + this.m_pairs[i] = new b2Pair(); + } + this.m_pairBuffer = new Array(b2Settings.b2_maxPairs); + for (i = 0; i < b2Settings.b2_maxPairs; ++i) + { + this.m_pairBuffer[i] = new b2BufferedPair(); + } + + for (i = 0; i < b2Settings.b2_maxPairs; ++i) + { + this.m_pairs[i].proxyId1 = b2Pair.b2_nullProxy; + this.m_pairs[i].proxyId2 = b2Pair.b2_nullProxy; + this.m_pairs[i].userData = null; + this.m_pairs[i].status = 0; + this.m_pairs[i].next = (i + 1); + } + this.m_pairs[b2Settings.b2_maxPairs-1].next = b2Pair.b2_nullPair; + this.m_pairCount = 0; + }, + //~b2PairManager(); + + Initialize: function(broadPhase, callback){ + this.m_broadPhase = broadPhase; + this.m_callback = callback; + }, + + /* + As proxies are created and moved, many pairs are created and destroyed. Even worse, the same + pair may be added and removed multiple times in a single time step of the physics engine. To reduce + traffic in the pair manager, we try to avoid destroying pairs in the pair manager until the + end of the physics step. This is done by buffering all the this.RemovePair requests. this.AddPair + requests are processed immediately because we need the hash table entry for quick lookup. + + All user user callbacks are delayed until the buffered pairs are confirmed in this.Commit. + This is very important because the user callbacks may be very expensive and client logic + may be harmed if pairs are added and removed within the same time step. + + Buffer a pair for addition. + We may add a pair that is not in the pair manager or pair buffer. + We may add a pair that is already in the pair manager and pair buffer. + If the added pair is not a new pair, then it must be in the pair buffer (because this.RemovePair was called). + */ + AddBufferedPair: function(proxyId1, proxyId2){ + //b2Settings.b2Assert(id1 != b2_nullProxy && id2 != b2_nullProxy); + //b2Settings.b2Assert(this.m_pairBufferCount < b2_maxPairs); + + var pair = this.AddPair(proxyId1, proxyId2); + + // If this pair is not in the pair buffer ... + if (pair.IsBuffered() == false) + { + // This must be a newly added pair. + //b2Settings.b2Assert(pair.IsFinal() == false); + + // Add it to the pair buffer. + pair.SetBuffered(); + this.m_pairBuffer[this.m_pairBufferCount].proxyId1 = pair.proxyId1; + this.m_pairBuffer[this.m_pairBufferCount].proxyId2 = pair.proxyId2; + ++this.m_pairBufferCount; + + //b2Settings.b2Assert(this.m_pairBufferCount <= this.m_pairCount); + } + + // Confirm this pair for the subsequent call to this.Commit. + pair.ClearRemoved(); + + if (b2BroadPhase.s_validate) + { + this.ValidateBuffer(); + } + }, + + // Buffer a pair for removal. + RemoveBufferedPair: function(proxyId1, proxyId2){ + //b2Settings.b2Assert(id1 != b2_nullProxy && id2 != b2_nullProxy); + //b2Settings.b2Assert(this.m_pairBufferCount < b2_maxPairs); + + var pair = this.Find(proxyId1, proxyId2); + + if (pair == null) + { + // The pair never existed. This is legal (due to collision filtering). + return; + } + + // If this pair is not in the pair buffer ... + if (pair.IsBuffered() == false) + { + // This must be an old pair. + //b2Settings.b2Assert(pair.IsFinal() == true); + + pair.SetBuffered(); + this.m_pairBuffer[this.m_pairBufferCount].proxyId1 = pair.proxyId1; + this.m_pairBuffer[this.m_pairBufferCount].proxyId2 = pair.proxyId2; + ++this.m_pairBufferCount; + + //b2Settings.b2Assert(this.m_pairBufferCount <= this.m_pairCount); + } + + pair.SetRemoved(); + + if (b2BroadPhase.s_validate) + { + this.ValidateBuffer(); + } + }, + + Commit: function(){ + var i = 0; + + var removeCount = 0; + + var proxies = this.m_broadPhase.m_proxyPool; + + for (i = 0; i < this.m_pairBufferCount; ++i) + { + var pair = this.Find(this.m_pairBuffer[i].proxyId1, this.m_pairBuffer[i].proxyId2); + //b2Settings.b2Assert(pair.IsBuffered()); + pair.ClearBuffered(); + + //b2Settings.b2Assert(pair.proxyId1 < b2Settings.b2_maxProxies && pair.proxyId2 < b2Settings.b2_maxProxies); + + var proxy1 = proxies[ pair.proxyId1 ]; + var proxy2 = proxies[ pair.proxyId2 ]; + + //b2Settings.b2Assert(proxy1.IsValid()); + //b2Settings.b2Assert(proxy2.IsValid()); + + if (pair.IsRemoved()) + { + // It is possible a pair was added then removed before a commit. Therefore, + // we should be careful not to tell the user the pair was removed when the + // the user didn't receive a matching add. + if (pair.IsFinal() == true) + { + this.m_callback.PairRemoved(proxy1.userData, proxy2.userData, pair.userData); + } + + // Store the ids so we can actually remove the pair below. + this.m_pairBuffer[removeCount].proxyId1 = pair.proxyId1; + this.m_pairBuffer[removeCount].proxyId2 = pair.proxyId2; + ++removeCount; + } + else + { + //b2Settings.b2Assert(this.m_broadPhase.TestOverlap(proxy1, proxy2) == true); + + if (pair.IsFinal() == false) + { + pair.userData = this.m_callback.PairAdded(proxy1.userData, proxy2.userData); + pair.SetFinal(); + } + } + } + + for (i = 0; i < removeCount; ++i) + { + this.RemovePair(this.m_pairBuffer[i].proxyId1, this.m_pairBuffer[i].proxyId2); + } + + this.m_pairBufferCount = 0; + + if (b2BroadPhase.s_validate) + { + this.ValidateTable(); + } + }, + +//private: + + // Add a pair and return the new pair. If the pair already exists, + // no new pair is created and the old one is returned. + AddPair: function(proxyId1, proxyId2){ + + if (proxyId1 > proxyId2){ + var temp = proxyId1; + proxyId1 = proxyId2; + proxyId2 = temp; + //b2Math.b2Swap(p1, p2); + } + + var hash = b2PairManager.Hash(proxyId1, proxyId2) & b2Pair.b2_tableMask; + + //var pairIndex = this.FindHash(proxyId1, proxyId2, hash); + var pair = pair = this.FindHash(proxyId1, proxyId2, hash); + + if (pair != null) + { + return pair; + } + + //b2Settings.b2Assert(this.m_pairCount < b2Settings.b2_maxPairs && this.m_freePair != b2_nullPair); + + var pIndex = this.m_freePair; + pair = this.m_pairs[pIndex]; + this.m_freePair = pair.next; + + pair.proxyId1 = proxyId1; + pair.proxyId2 = proxyId2; + pair.status = 0; + pair.userData = null; + pair.next = this.m_hashTable[hash]; + + this.m_hashTable[hash] = pIndex; + + ++this.m_pairCount; + + return pair; + }, + + // Remove a pair, return the pair's userData. + RemovePair: function(proxyId1, proxyId2){ + + //b2Settings.b2Assert(this.m_pairCount > 0); + + if (proxyId1 > proxyId2){ + var temp = proxyId1; + proxyId1 = proxyId2; + proxyId2 = temp; + //b2Math.b2Swap(proxyId1, proxyId2); + } + + var hash = b2PairManager.Hash(proxyId1, proxyId2) & b2Pair.b2_tableMask; + + var node = this.m_hashTable[hash]; + var pNode = null; + + while (node != b2Pair.b2_nullPair) + { + if (b2PairManager.Equals(this.m_pairs[node], proxyId1, proxyId2)) + { + var index = node; + + //*node = this.m_pairs[*node].next; + if (pNode){ + pNode.next = this.m_pairs[node].next; + } + else{ + this.m_hashTable[hash] = this.m_pairs[node].next; + } + + var pair = this.m_pairs[ index ]; + var userData = pair.userData; + + // Scrub + pair.next = this.m_freePair; + pair.proxyId1 = b2Pair.b2_nullProxy; + pair.proxyId2 = b2Pair.b2_nullProxy; + pair.userData = null; + pair.status = 0; + + this.m_freePair = index; + --this.m_pairCount; + return userData; + } + else + { + //node = &this.m_pairs[*node].next; + pNode = this.m_pairs[node]; + node = pNode.next; + } + } + + //b2Settings.b2Assert(false); + return null; + }, + + Find: function(proxyId1, proxyId2){ + + if (proxyId1 > proxyId2){ + var temp = proxyId1; + proxyId1 = proxyId2; + proxyId2 = temp; + //b2Math.b2Swap(proxyId1, proxyId2); + } + + var hash = b2PairManager.Hash(proxyId1, proxyId2) & b2Pair.b2_tableMask; + + return this.FindHash(proxyId1, proxyId2, hash); + }, + FindHash: function(proxyId1, proxyId2, hash){ + var index = this.m_hashTable[hash]; + + while( index != b2Pair.b2_nullPair && b2PairManager.Equals(this.m_pairs[index], proxyId1, proxyId2) == false) + { + index = this.m_pairs[index].next; + } + + if ( index == b2Pair.b2_nullPair ) + { + return null; + } + + //b2Settings.b2Assert(index < b2_maxPairs); + + return this.m_pairs[ index ]; + }, + + ValidateBuffer: function(){ + // DEBUG + }, + + ValidateTable: function(){ + // DEBUG + }, + +//public: + m_broadPhase: null, + m_callback: null, + m_pairs: null, + m_freePair: 0, + m_pairCount: 0, + + m_pairBuffer: null, + m_pairBufferCount: 0, + + m_hashTable: null + + +// static + // Thomas Wang's hash, see: http: + + + +}; +b2PairManager.Hash = function(proxyId1, proxyId2) + { + var key = ((proxyId2 << 16) & 0xffff0000) | proxyId1; + key = ~key + ((key << 15) & 0xFFFF8000); + key = key ^ ((key >> 12) & 0x000fffff); + key = key + ((key << 2) & 0xFFFFFFFC); + key = key ^ ((key >> 4) & 0x0fffffff); + key = key * 2057; + key = key ^ ((key >> 16) & 0x0000ffff); + return key; + }; +b2PairManager.Equals = function(pair, proxyId1, proxyId2) + { + return (pair.proxyId1 == proxyId1 && pair.proxyId2 == proxyId2); + }; +b2PairManager.EqualsPair = function(pair1, pair2) + { + return pair1.proxyId1 == pair2.proxyId1 && pair1.proxyId2 == pair2.proxyId2; + }; diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/b2Proxy.js b/views/archive/j/box2d-car-game/js/box2d/collision/b2Proxy.js new file mode 100644 index 00000000..60726d09 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/b2Proxy.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +var b2Proxy = Class.create(); +b2Proxy.prototype = { + GetNext: function(){ return this.lowerBounds[0]; }, + SetNext: function(next) { this.lowerBounds[0] = next /*& 0x0000ffff*/; }, + + IsValid: function(){ return this.overlapCount != b2BroadPhase.b2_invalid; }, + + lowerBounds: [/*uint*/(0), /*uint*/(0)], + upperBounds: [/*uint*/(0), /*uint*/(0)], + overlapCount: 0, + timeStamp: 0, + + userData: null, + + initialize: function() { + // initialize instance variables for references + this.lowerBounds = [/*uint*/(0), /*uint*/(0)]; + this.upperBounds = [/*uint*/(0), /*uint*/(0)]; + // +}} diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2BoxDef.js b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2BoxDef.js new file mode 100644 index 00000000..9cc24f79 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2BoxDef.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + + +var b2BoxDef = Class.create(); +Object.extend(b2BoxDef.prototype, b2ShapeDef.prototype); +Object.extend(b2BoxDef.prototype, +{ + initialize: function() + { + // The constructor for b2ShapeDef + this.type = b2Shape.e_unknownShape; + this.userData = null; + this.localPosition = new b2Vec2(0.0, 0.0); + this.localRotation = 0.0; + this.friction = 0.2; + this.restitution = 0.0; + this.density = 0.0; + this.categoryBits = 0x0001; + this.maskBits = 0xFFFF; + this.groupIndex = 0; + // + + this.type = b2Shape.e_boxShape; + this.extents = new b2Vec2(1.0, 1.0); + }, + + extents: null}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2CircleDef.js b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2CircleDef.js new file mode 100644 index 00000000..dd1c5826 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2CircleDef.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + + +var b2CircleDef = Class.create(); +Object.extend(b2CircleDef.prototype, b2ShapeDef.prototype); +Object.extend(b2CircleDef.prototype, +{ + initialize: function() + { + // The constructor for b2ShapeDef + this.type = b2Shape.e_unknownShape; + this.userData = null; + this.localPosition = new b2Vec2(0.0, 0.0); + this.localRotation = 0.0; + this.friction = 0.2; + this.restitution = 0.0; + this.density = 0.0; + this.categoryBits = 0x0001; + this.maskBits = 0xFFFF; + this.groupIndex = 0; + // + + this.type = b2Shape.e_circleShape; + this.radius = 1.0; + }, + + radius: null}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2CircleShape.js b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2CircleShape.js new file mode 100644 index 00000000..44561681 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2CircleShape.js @@ -0,0 +1,198 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + + +var b2CircleShape = Class.create(); +Object.extend(b2CircleShape.prototype, b2Shape.prototype); +Object.extend(b2CircleShape.prototype, +{ + TestPoint: function(p){ + //var d = b2Math.SubtractVV(p, this.m_position); + var d = new b2Vec2(); + d.SetV(p); + d.Subtract(this.m_position); + return b2Math.b2Dot(d, d) <= this.m_radius * this.m_radius; + }, + + //--------------- Internals Below ------------------- + + initialize: function(def, body, localCenter){ + // initialize instance variables for references + this.m_R = new b2Mat22(); + this.m_position = new b2Vec2(); + // + + // The constructor for b2Shape + this.m_userData = def.userData; + + this.m_friction = def.friction; + this.m_restitution = def.restitution; + this.m_body = body; + + this.m_proxyId = b2Pair.b2_nullProxy; + + this.m_maxRadius = 0.0; + + this.m_categoryBits = def.categoryBits; + this.m_maskBits = def.maskBits; + this.m_groupIndex = def.groupIndex; + // + + // initialize instance variables for references + this.m_localPosition = new b2Vec2(); + // + + //super(def, body); + + //b2Settings.b2Assert(def.type == b2Shape.e_circleShape); + var circle = def; + + //this.m_localPosition = def.localPosition - localCenter; + this.m_localPosition.Set(def.localPosition.x - localCenter.x, def.localPosition.y - localCenter.y); + this.m_type = b2Shape.e_circleShape; + this.m_radius = circle.radius; + + this.m_R.SetM(this.m_body.m_R); + //b2Vec2 r = b2Mul(this.m_body->this.m_R, this.m_localPosition); + var rX = this.m_R.col1.x * this.m_localPosition.x + this.m_R.col2.x * this.m_localPosition.y; + var rY = this.m_R.col1.y * this.m_localPosition.x + this.m_R.col2.y * this.m_localPosition.y; + //this.m_position = this.m_body->this.m_position + r; + this.m_position.x = this.m_body.m_position.x + rX; + this.m_position.y = this.m_body.m_position.y + rY; + //this.m_maxRadius = r.Length() + this.m_radius; + this.m_maxRadius = Math.sqrt(rX*rX+rY*rY) + this.m_radius; + + var aabb = new b2AABB(); + aabb.minVertex.Set(this.m_position.x - this.m_radius, this.m_position.y - this.m_radius); + aabb.maxVertex.Set(this.m_position.x + this.m_radius, this.m_position.y + this.m_radius); + + var broadPhase = this.m_body.m_world.m_broadPhase; + if (broadPhase.InRange(aabb)) + { + this.m_proxyId = broadPhase.CreateProxy(aabb, this); + } + else + { + this.m_proxyId = b2Pair.b2_nullProxy; + } + + if (this.m_proxyId == b2Pair.b2_nullProxy) + { + this.m_body.Freeze(); + } + }, + + Synchronize: function(position1, R1, position2, R2){ + this.m_R.SetM(R2); + //this.m_position = position2 + b2Mul(R2, this.m_localPosition); + this.m_position.x = (R2.col1.x * this.m_localPosition.x + R2.col2.x * this.m_localPosition.y) + position2.x; + this.m_position.y = (R2.col1.y * this.m_localPosition.x + R2.col2.y * this.m_localPosition.y) + position2.y; + + if (this.m_proxyId == b2Pair.b2_nullProxy) + { + return; + } + + // Compute an AABB that covers the swept shape (may miss some rotation effect). + //b2Vec2 p1 = position1 + b2Mul(R1, this.m_localPosition); + var p1X = position1.x + (R1.col1.x * this.m_localPosition.x + R1.col2.x * this.m_localPosition.y); + var p1Y = position1.y + (R1.col1.y * this.m_localPosition.x + R1.col2.y * this.m_localPosition.y); + //b2Vec2 lower = b2Min(p1, this.m_position); + var lowerX = Math.min(p1X, this.m_position.x); + var lowerY = Math.min(p1Y, this.m_position.y); + //b2Vec2 upper = b2Max(p1, this.m_position); + var upperX = Math.max(p1X, this.m_position.x); + var upperY = Math.max(p1Y, this.m_position.y); + + var aabb = new b2AABB(); + aabb.minVertex.Set(lowerX - this.m_radius, lowerY - this.m_radius); + aabb.maxVertex.Set(upperX + this.m_radius, upperY + this.m_radius); + + var broadPhase = this.m_body.m_world.m_broadPhase; + if (broadPhase.InRange(aabb)) + { + broadPhase.MoveProxy(this.m_proxyId, aabb); + } + else + { + this.m_body.Freeze(); + } + }, + + QuickSync: function(position, R){ + this.m_R.SetM(R); + //this.m_position = position + b2Mul(R, this.m_localPosition); + this.m_position.x = (R.col1.x * this.m_localPosition.x + R.col2.x * this.m_localPosition.y) + position.x; + this.m_position.y = (R.col1.y * this.m_localPosition.x + R.col2.y * this.m_localPosition.y) + position.y; + }, + + + ResetProxy: function(broadPhase) + { + if (this.m_proxyId == b2Pair.b2_nullProxy) + { + return; + } + + var proxy = broadPhase.GetProxy(this.m_proxyId); + + broadPhase.DestroyProxy(this.m_proxyId); + proxy = null; + + var aabb = new b2AABB(); + aabb.minVertex.Set(this.m_position.x - this.m_radius, this.m_position.y - this.m_radius); + aabb.maxVertex.Set(this.m_position.x + this.m_radius, this.m_position.y + this.m_radius); + + if (broadPhase.InRange(aabb)) + { + this.m_proxyId = broadPhase.CreateProxy(aabb, this); + } + else + { + this.m_proxyId = b2Pair.b2_nullProxy; + } + + if (this.m_proxyId == b2Pair.b2_nullProxy) + { + this.m_body.Freeze(); + } + }, + + + Support: function(dX, dY, out) + { + //b2Vec2 u = d; + //u.Normalize(); + var len = Math.sqrt(dX*dX + dY*dY); + dX /= len; + dY /= len; + //return this.m_position + this.m_radius * u; + out.Set( this.m_position.x + this.m_radius*dX, + this.m_position.y + this.m_radius*dY); + }, + + + // Local position in parent body + m_localPosition: new b2Vec2(), + m_radius: null}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2MassData.js b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2MassData.js new file mode 100644 index 00000000..2cd1af52 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2MassData.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + + +var b2MassData = Class.create(); +b2MassData.prototype = +{ + mass: 0.0, + center: new b2Vec2(0,0), + I: 0.0, + + initialize: function() { + // initialize instance variables for references + this.center = new b2Vec2(0,0); + // +}} diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2PolyDef.js b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2PolyDef.js new file mode 100644 index 00000000..6f13c284 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2PolyDef.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + + +var b2PolyDef = Class.create(); +Object.extend(b2PolyDef.prototype, b2ShapeDef.prototype); +Object.extend(b2PolyDef.prototype, +{ + initialize: function() + { + // The constructor for b2ShapeDef + this.type = b2Shape.e_unknownShape; + this.userData = null; + this.localPosition = new b2Vec2(0.0, 0.0); + this.localRotation = 0.0; + this.friction = 0.2; + this.restitution = 0.0; + this.density = 0.0; + this.categoryBits = 0x0001; + this.maskBits = 0xFFFF; + this.groupIndex = 0; + // + + // initialize instance variables for references + this.vertices = new Array(b2Settings.b2_maxPolyVertices); + // + + this.type = b2Shape.e_polyShape; + this.vertexCount = 0; + + for (var i = 0; i < b2Settings.b2_maxPolyVertices; i++){ + this.vertices[i] = new b2Vec2(); + } + }, + + vertices: new Array(b2Settings.b2_maxPolyVertices), + vertexCount: 0}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2PolyShape.js b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2PolyShape.js new file mode 100644 index 00000000..39ca4a62 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2PolyShape.js @@ -0,0 +1,492 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +// A convex polygon. The position of the polygon (m_position) is the +// position of the centroid. The vertices of the incoming polygon are pre-rotated +// according to the local rotation. The vertices are also shifted to be centered +// on the centroid. Since the local rotation is absorbed into the vertex +// coordinates, the polygon rotation is equal to the body rotation. However, +// the polygon position is centered on the polygon centroid. This simplifies +// some collision algorithms. + +var b2PolyShape = Class.create(); +Object.extend(b2PolyShape.prototype, b2Shape.prototype); +Object.extend(b2PolyShape.prototype, +{ + TestPoint: function(p){ + + //var pLocal = b2Math.b2MulTMV(this.m_R, b2Math.SubtractVV(p, this.m_position)); + var pLocal = new b2Vec2(); + pLocal.SetV(p); + pLocal.Subtract(this.m_position); + pLocal.MulTM(this.m_R); + + for (var i = 0; i < this.m_vertexCount; ++i) + { + //var dot = b2Math.b2Dot(this.m_normals[i], b2Math.SubtractVV(pLocal, this.m_vertices[i])); + var tVec = new b2Vec2(); + tVec.SetV(pLocal); + tVec.Subtract(this.m_vertices[i]); + + var dot = b2Math.b2Dot(this.m_normals[i], tVec); + if (dot > 0.0) + { + return false; + } + } + + return true; + }, + + //--------------- Internals Below ------------------- + // Temp vec for b2Shape.PolyCentroid + + initialize: function(def, body, newOrigin){ + // initialize instance variables for references + this.m_R = new b2Mat22(); + this.m_position = new b2Vec2(); + // + + // The constructor for b2Shape + this.m_userData = def.userData; + + this.m_friction = def.friction; + this.m_restitution = def.restitution; + this.m_body = body; + + this.m_proxyId = b2Pair.b2_nullProxy; + + this.m_maxRadius = 0.0; + + this.m_categoryBits = def.categoryBits; + this.m_maskBits = def.maskBits; + this.m_groupIndex = def.groupIndex; + // + + // initialize instance variables for references + this.syncAABB = new b2AABB(); + this.syncMat = new b2Mat22(); + this.m_localCentroid = new b2Vec2(); + this.m_localOBB = new b2OBB(); + // + + + //super(def, body); + + var i = 0; + + + var hX; + var hY; + + var tVec; + + var aabb = new b2AABB(); + + // Vertices + this.m_vertices = new Array(b2Settings.b2_maxPolyVertices); + this.m_coreVertices = new Array(b2Settings.b2_maxPolyVertices); + //for (i = 0; i < b2Settings.b2_maxPolyVertices; i++) + // this.m_vertices[i] = new b2Vec2(); + + // Normals + this.m_normals = new Array(b2Settings.b2_maxPolyVertices); + //for (i = 0; i < b2Settings.b2_maxPolyVertices; i++) + // this.m_normals[i] = new b2Vec2(); + + //b2Settings.b2Assert(def.type == b2Shape.e_boxShape || def.type == b2Shape.e_polyShape); + this.m_type = b2Shape.e_polyShape; + + var localR = new b2Mat22(def.localRotation); + + // Get the vertices transformed into the body frame. + if (def.type == b2Shape.e_boxShape) + { + //this.m_localCentroid = def.localPosition - newOrigin; + this.m_localCentroid.x = def.localPosition.x - newOrigin.x; + this.m_localCentroid.y = def.localPosition.y - newOrigin.y; + + var box = def; + this.m_vertexCount = 4; + hX = box.extents.x; + hY = box.extents.y; + + //hc.x = b2Max(0.0f, h.x - 2.0f * b2_linearSlop); + var hcX = Math.max(0.0, hX - 2.0 * b2Settings.b2_linearSlop); + //hc.y = b2Max(0.0f, h.y - 2.0f * b2_linearSlop); + var hcY = Math.max(0.0, hY - 2.0 * b2Settings.b2_linearSlop); + + //this.m_vertices[0] = b2Mul(localR, b2Vec2(h.x, h.y)); + tVec = this.m_vertices[0] = new b2Vec2(); + tVec.x = localR.col1.x * hX + localR.col2.x * hY; + tVec.y = localR.col1.y * hX + localR.col2.y * hY; + //this.m_vertices[1] = b2Mul(localR, b2Vec2(-h.x, h.y)); + tVec = this.m_vertices[1] = new b2Vec2(); + tVec.x = localR.col1.x * -hX + localR.col2.x * hY; + tVec.y = localR.col1.y * -hX + localR.col2.y * hY; + //this.m_vertices[2] = b2Mul(localR, b2Vec2(-h.x, -h.y)); + tVec = this.m_vertices[2] = new b2Vec2(); + tVec.x = localR.col1.x * -hX + localR.col2.x * -hY; + tVec.y = localR.col1.y * -hX + localR.col2.y * -hY; + //this.m_vertices[3] = b2Mul(localR, b2Vec2(h.x, -h.y)); + tVec = this.m_vertices[3] = new b2Vec2(); + tVec.x = localR.col1.x * hX + localR.col2.x * -hY; + tVec.y = localR.col1.y * hX + localR.col2.y * -hY; + + //this.m_coreVertices[0] = b2Mul(localR, b2Vec2(hc.x, hc.y)); + tVec = this.m_coreVertices[0] = new b2Vec2(); + tVec.x = localR.col1.x * hcX + localR.col2.x * hcY; + tVec.y = localR.col1.y * hcX + localR.col2.y * hcY; + //this.m_coreVertices[1] = b2Mul(localR, b2Vec2(-hc.x, hc.y)); + tVec = this.m_coreVertices[1] = new b2Vec2(); + tVec.x = localR.col1.x * -hcX + localR.col2.x * hcY; + tVec.y = localR.col1.y * -hcX + localR.col2.y * hcY; + //this.m_coreVertices[2] = b2Mul(localR, b2Vec2(-hc.x, -hc.y)); + tVec = this.m_coreVertices[2] = new b2Vec2(); + tVec.x = localR.col1.x * -hcX + localR.col2.x * -hcY; + tVec.y = localR.col1.y * -hcX + localR.col2.y * -hcY; + //this.m_coreVertices[3] = b2Mul(localR, b2Vec2(hc.x, -hc.y)); + tVec = this.m_coreVertices[3] = new b2Vec2(); + tVec.x = localR.col1.x * hcX + localR.col2.x * -hcY; + tVec.y = localR.col1.y * hcX + localR.col2.y * -hcY; + } + else + { + var poly = def; + + this.m_vertexCount = poly.vertexCount; + //b2Settings.b2Assert(3 <= this.m_vertexCount && this.m_vertexCount <= b2Settings.b2_maxPolyVertices); + //b2Vec2 centroid = b2Shape.PolyCentroid(poly->vertices, poly->vertexCount); + b2Shape.PolyCentroid(poly.vertices, poly.vertexCount, b2PolyShape.tempVec); + var centroidX = b2PolyShape.tempVec.x; + var centroidY = b2PolyShape.tempVec.y; + //this.m_localCentroid = def->localPosition + b2Mul(localR, centroid) - newOrigin; + this.m_localCentroid.x = def.localPosition.x + (localR.col1.x * centroidX + localR.col2.x * centroidY) - newOrigin.x; + this.m_localCentroid.y = def.localPosition.y + (localR.col1.y * centroidX + localR.col2.y * centroidY) - newOrigin.y; + + for (i = 0; i < this.m_vertexCount; ++i) + { + this.m_vertices[i] = new b2Vec2(); + this.m_coreVertices[i] = new b2Vec2(); + + //this.m_vertices[i] = b2Mul(localR, poly->vertices[i] - centroid); + hX = poly.vertices[i].x - centroidX; + hY = poly.vertices[i].y - centroidY; + this.m_vertices[i].x = localR.col1.x * hX + localR.col2.x * hY; + this.m_vertices[i].y = localR.col1.y * hX + localR.col2.y * hY; + + //b2Vec2 u = this.m_vertices[i]; + var uX = this.m_vertices[i].x; + var uY = this.m_vertices[i].y; + //float32 length = u.Length(); + var length = Math.sqrt(uX*uX + uY*uY); + if (length > Number.MIN_VALUE) + { + uX *= 1.0 / length; + uY *= 1.0 / length; + } + + //this.m_coreVertices[i] = this.m_vertices[i] - 2.0f * b2_linearSlop * u; + this.m_coreVertices[i].x = this.m_vertices[i].x - 2.0 * b2Settings.b2_linearSlop * uX; + this.m_coreVertices[i].y = this.m_vertices[i].y - 2.0 * b2Settings.b2_linearSlop * uY; + } + + } + + // Compute bounding box. TODO_ERIN optimize OBB + //var minVertex = new b2Vec2(Number.MAX_VALUE, Number.MAX_VALUE); + var minVertexX = Number.MAX_VALUE; + var minVertexY = Number.MAX_VALUE; + var maxVertexX = -Number.MAX_VALUE; + var maxVertexY = -Number.MAX_VALUE; + this.m_maxRadius = 0.0; + for (i = 0; i < this.m_vertexCount; ++i) + { + var v = this.m_vertices[i]; + //minVertex = b2Math.b2MinV(minVertex, this.m_vertices[i]); + minVertexX = Math.min(minVertexX, v.x); + minVertexY = Math.min(minVertexY, v.y); + //maxVertex = b2Math.b2MaxV(maxVertex, this.m_vertices[i]); + maxVertexX = Math.max(maxVertexX, v.x); + maxVertexY = Math.max(maxVertexY, v.y); + //this.m_maxRadius = b2Max(this.m_maxRadius, v.Length()); + this.m_maxRadius = Math.max(this.m_maxRadius, v.Length()); + } + + this.m_localOBB.R.SetIdentity(); + //this.m_localOBB.center = 0.5 * (minVertex + maxVertex); + this.m_localOBB.center.Set((minVertexX + maxVertexX) * 0.5, (minVertexY + maxVertexY) * 0.5); + //this.m_localOBB.extents = 0.5 * (maxVertex - minVertex); + this.m_localOBB.extents.Set((maxVertexX - minVertexX) * 0.5, (maxVertexY - minVertexY) * 0.5); + + // Compute the edge normals and next index map. + var i1 = 0; + var i2 = 0; + for (i = 0; i < this.m_vertexCount; ++i) + { + this.m_normals[i] = new b2Vec2(); + i1 = i; + i2 = i + 1 < this.m_vertexCount ? i + 1 : 0; + //b2Vec2 edge = this.m_vertices[i2] - this.m_vertices[i1]; + //var edgeX = this.m_vertices[i2].x - this.m_vertices[i1].x; + //var edgeY = this.m_vertices[i2].y - this.m_vertices[i1].y; + //this.m_normals[i] = b2Cross(edge, 1.0f); + this.m_normals[i].x = this.m_vertices[i2].y - this.m_vertices[i1].y; + this.m_normals[i].y = -(this.m_vertices[i2].x - this.m_vertices[i1].x); + this.m_normals[i].Normalize(); + } + + // Ensure the polygon in convex. TODO_ERIN compute convex hull. + for (i = 0; i < this.m_vertexCount; ++i) + { + i1 = i; + i2 = i + 1 < this.m_vertexCount ? i + 1 : 0; + + //b2Settings.b2Assert(b2Math.b2CrossVV(this.m_normals[i1], this.m_normals[i2]) > Number.MIN_VALUE); + } + + this.m_R.SetM(this.m_body.m_R); + //this.m_position.SetV( this.m_body.m_position + b2Mul(this.m_body->this.m_R, this.m_localCentroid) ); + this.m_position.x = this.m_body.m_position.x + (this.m_R.col1.x * this.m_localCentroid.x + this.m_R.col2.x * this.m_localCentroid.y); + this.m_position.y = this.m_body.m_position.y + (this.m_R.col1.y * this.m_localCentroid.x + this.m_R.col2.y * this.m_localCentroid.y); + + //var R = b2Math.b2MulMM(this.m_R, this.m_localOBB.R); + //R.col1 = b2MulMV(this.m_R, this.m_localOBB.R.col1); + b2PolyShape.tAbsR.col1.x = this.m_R.col1.x * this.m_localOBB.R.col1.x + this.m_R.col2.x * this.m_localOBB.R.col1.y; + b2PolyShape.tAbsR.col1.y = this.m_R.col1.y * this.m_localOBB.R.col1.x + this.m_R.col2.y * this.m_localOBB.R.col1.y; + //R.col2 = b2MulMV(this.m_R, this.m_localOBB.R.col2) + b2PolyShape.tAbsR.col2.x = this.m_R.col1.x * this.m_localOBB.R.col2.x + this.m_R.col2.x * this.m_localOBB.R.col2.y; + b2PolyShape.tAbsR.col2.y = this.m_R.col1.y * this.m_localOBB.R.col2.x + this.m_R.col2.y * this.m_localOBB.R.col2.y; + //var absR = b2Math.b2AbsM(R); + b2PolyShape.tAbsR.Abs() + + //h = b2Math.b2MulMV(b2PolyShape.tAbsR, this.m_localOBB.extents); + hX = b2PolyShape.tAbsR.col1.x * this.m_localOBB.extents.x + b2PolyShape.tAbsR.col2.x * this.m_localOBB.extents.y; + hY = b2PolyShape.tAbsR.col1.y * this.m_localOBB.extents.x + b2PolyShape.tAbsR.col2.y * this.m_localOBB.extents.y; + + //var position = this.m_position + b2Mul(this.m_R, this.m_localOBB.center); + var positionX = this.m_position.x + (this.m_R.col1.x * this.m_localOBB.center.x + this.m_R.col2.x * this.m_localOBB.center.y); + var positionY = this.m_position.y + (this.m_R.col1.y * this.m_localOBB.center.x + this.m_R.col2.y * this.m_localOBB.center.y); + + //aabb.minVertex = b2Math.SubtractVV(this.m_position, h); + aabb.minVertex.x = positionX - hX; + aabb.minVertex.y = positionY - hY; + //aabb.maxVertex = b2Math.AddVV(this.m_position, h); + aabb.maxVertex.x = positionX + hX; + aabb.maxVertex.y = positionY + hY; + + var broadPhase = this.m_body.m_world.m_broadPhase; + if (broadPhase.InRange(aabb)) + { + this.m_proxyId = broadPhase.CreateProxy(aabb, this); + } + else + { + this.m_proxyId = b2Pair.b2_nullProxy; + } + + if (this.m_proxyId == b2Pair.b2_nullProxy) + { + this.m_body.Freeze(); + } + }, + + // Temp AABB for Synch function + syncAABB: new b2AABB(), + syncMat: new b2Mat22(), + Synchronize: function(position1, R1, position2, R2){ + // The body transform is copied for convenience. + this.m_R.SetM(R2); + //this.m_position = this.m_body->this.m_position + b2Mul(this.m_body->this.m_R, this.m_localCentroid) + this.m_position.x = this.m_body.m_position.x + (R2.col1.x * this.m_localCentroid.x + R2.col2.x * this.m_localCentroid.y); + this.m_position.y = this.m_body.m_position.y + (R2.col1.y * this.m_localCentroid.x + R2.col2.y * this.m_localCentroid.y); + + if (this.m_proxyId == b2Pair.b2_nullProxy) + { + return; + } + + //b2AABB aabb1, aabb2; + var hX; + var hY; + + //b2Mat22 obbR = b2Mul(R1, this.m_localOBB.R); + var v1 = R1.col1; + var v2 = R1.col2; + var v3 = this.m_localOBB.R.col1; + var v4 = this.m_localOBB.R.col2; + //this.syncMat.col1 = b2MulMV(R1, this.m_localOBB.R.col1); + this.syncMat.col1.x = v1.x * v3.x + v2.x * v3.y; + this.syncMat.col1.y = v1.y * v3.x + v2.y * v3.y; + //this.syncMat.col2 = b2MulMV(R1, this.m_localOBB.R.col2); + this.syncMat.col2.x = v1.x * v4.x + v2.x * v4.y; + this.syncMat.col2.y = v1.y * v4.x + v2.y * v4.y; + //b2Mat22 absR = b2Abs(obbR); + this.syncMat.Abs(); + //b2Vec2 center = position1 + b2Mul(R1, this.m_localCentroid + this.m_localOBB.center); + hX = this.m_localCentroid.x + this.m_localOBB.center.x; + hY = this.m_localCentroid.y + this.m_localOBB.center.y; + var centerX = position1.x + (R1.col1.x * hX + R1.col2.x * hY); + var centerY = position1.y + (R1.col1.y * hX + R1.col2.y * hY); + //b2Vec2 h = b2Mul(this.syncMat, this.m_localOBB.extents); + hX = this.syncMat.col1.x * this.m_localOBB.extents.x + this.syncMat.col2.x * this.m_localOBB.extents.y; + hY = this.syncMat.col1.y * this.m_localOBB.extents.x + this.syncMat.col2.y * this.m_localOBB.extents.y; + //aabb1.minVertex = center - h; + this.syncAABB.minVertex.x = centerX - hX; + this.syncAABB.minVertex.y = centerY - hY; + //aabb1.maxVertex = center + h; + this.syncAABB.maxVertex.x = centerX + hX; + this.syncAABB.maxVertex.y = centerY + hY; + + //b2Mat22 obbR = b2Mul(R2, this.m_localOBB.R); + v1 = R2.col1; + v2 = R2.col2; + v3 = this.m_localOBB.R.col1; + v4 = this.m_localOBB.R.col2; + //this.syncMat.col1 = b2MulMV(R1, this.m_localOBB.R.col1); + this.syncMat.col1.x = v1.x * v3.x + v2.x * v3.y; + this.syncMat.col1.y = v1.y * v3.x + v2.y * v3.y; + //this.syncMat.col2 = b2MulMV(R1, this.m_localOBB.R.col2); + this.syncMat.col2.x = v1.x * v4.x + v2.x * v4.y; + this.syncMat.col2.y = v1.y * v4.x + v2.y * v4.y; + //b2Mat22 absR = b2Abs(obbR); + this.syncMat.Abs(); + //b2Vec2 center = position2 + b2Mul(R2, this.m_localCentroid + this.m_localOBB.center); + hX = this.m_localCentroid.x + this.m_localOBB.center.x; + hY = this.m_localCentroid.y + this.m_localOBB.center.y; + centerX = position2.x + (R2.col1.x * hX + R2.col2.x * hY); + centerY = position2.y + (R2.col1.y * hX + R2.col2.y * hY); + //b2Vec2 h = b2Mul(absR, this.m_localOBB.extents); + hX = this.syncMat.col1.x * this.m_localOBB.extents.x + this.syncMat.col2.x * this.m_localOBB.extents.y; + hY = this.syncMat.col1.y * this.m_localOBB.extents.x + this.syncMat.col2.y * this.m_localOBB.extents.y; + //aabb2.minVertex = center - h; + //aabb2.maxVertex = center + h; + + //aabb.minVertex = b2Min(aabb1.minVertex, aabb2.minVertex); + this.syncAABB.minVertex.x = Math.min(this.syncAABB.minVertex.x, centerX - hX); + this.syncAABB.minVertex.y = Math.min(this.syncAABB.minVertex.y, centerY - hY); + //aabb.maxVertex = b2Max(aabb1.maxVertex, aabb2.maxVertex); + this.syncAABB.maxVertex.x = Math.max(this.syncAABB.maxVertex.x, centerX + hX); + this.syncAABB.maxVertex.y = Math.max(this.syncAABB.maxVertex.y, centerY + hY); + + var broadPhase = this.m_body.m_world.m_broadPhase; + if (broadPhase.InRange(this.syncAABB)) + { + broadPhase.MoveProxy(this.m_proxyId, this.syncAABB); + } + else + { + this.m_body.Freeze(); + } + }, + + QuickSync: function(position, R){ + //this.m_R = R; + this.m_R.SetM(R); + //this.m_position = position + b2Mul(R, this.m_localCentroid); + this.m_position.x = position.x + (R.col1.x * this.m_localCentroid.x + R.col2.x * this.m_localCentroid.y); + this.m_position.y = position.y + (R.col1.y * this.m_localCentroid.x + R.col2.y * this.m_localCentroid.y); + }, + + ResetProxy: function(broadPhase){ + + if (this.m_proxyId == b2Pair.b2_nullProxy) + { + return; + } + + var proxy = broadPhase.GetProxy(this.m_proxyId); + + broadPhase.DestroyProxy(this.m_proxyId); + proxy = null; + + var R = b2Math.b2MulMM(this.m_R, this.m_localOBB.R); + var absR = b2Math.b2AbsM(R); + var h = b2Math.b2MulMV(absR, this.m_localOBB.extents); + //var position = this.m_position + b2Mul(this.m_R, this.m_localOBB.center); + var position = b2Math.b2MulMV(this.m_R, this.m_localOBB.center); + position.Add(this.m_position); + + var aabb = new b2AABB(); + //aabb.minVertex = position - h; + aabb.minVertex.SetV(position); + aabb.minVertex.Subtract(h); + //aabb.maxVertex = position + h; + aabb.maxVertex.SetV(position); + aabb.maxVertex.Add(h); + + if (broadPhase.InRange(aabb)) + { + this.m_proxyId = broadPhase.CreateProxy(aabb, this); + } + else + { + this.m_proxyId = b2Pair.b2_nullProxy; + } + + if (this.m_proxyId == b2Pair.b2_nullProxy) + { + this.m_body.Freeze(); + } + }, + + + Support: function(dX, dY, out) + { + //b2Vec2 dLocal = b2MulT(this.m_R, d); + var dLocalX = (dX*this.m_R.col1.x + dY*this.m_R.col1.y); + var dLocalY = (dX*this.m_R.col2.x + dY*this.m_R.col2.y); + + var bestIndex = 0; + //float32 bestValue = b2Dot(this.m_vertices[0], dLocal); + var bestValue = (this.m_coreVertices[0].x * dLocalX + this.m_coreVertices[0].y * dLocalY); + for (var i = 1; i < this.m_vertexCount; ++i) + { + //float32 value = b2Dot(this.m_vertices[i], dLocal); + var value = (this.m_coreVertices[i].x * dLocalX + this.m_coreVertices[i].y * dLocalY); + if (value > bestValue) + { + bestIndex = i; + bestValue = value; + } + } + + //return this.m_position + b2Mul(this.m_R, this.m_vertices[bestIndex]); + out.Set( this.m_position.x + (this.m_R.col1.x * this.m_coreVertices[bestIndex].x + this.m_R.col2.x * this.m_coreVertices[bestIndex].y), + this.m_position.y + (this.m_R.col1.y * this.m_coreVertices[bestIndex].x + this.m_R.col2.y * this.m_coreVertices[bestIndex].y)); + + }, + + + // Local position of the shape centroid in parent body frame. + m_localCentroid: new b2Vec2(), + + // Local position oriented bounding box. The OBB center is relative to + // shape centroid. + m_localOBB: new b2OBB(), + m_vertices: null, + m_coreVertices: null, + m_vertexCount: 0, + m_normals: null}); + +b2PolyShape.tempVec = new b2Vec2(); +b2PolyShape.tAbsR = new b2Mat22(); diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2Shape.js b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2Shape.js new file mode 100644 index 00000000..17ebf8f9 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2Shape.js @@ -0,0 +1,339 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + + + +// Shapes are created automatically when a body is created. +// Client code does not normally interact with shapes. +var b2Shape = Class.create(); +b2Shape.prototype = +{ + TestPoint: function(p){return false}, + + GetUserData: function(){return this.m_userData;}, + + GetType: function(){ + return this.m_type; + }, + + // Get the parent body of this shape. + GetBody: function(){ + return this.m_body; + }, + + GetPosition: function(){ + return this.m_position; + }, + GetRotationMatrix: function(){ + return this.m_R; + }, + + // Remove and then add proxy from the broad-phase. + // This is used to refresh the collision filters. + ResetProxy: function(broadPhase){}, + + // Get the next shape in the parent body's shape list. + GetNext: function(){ + return this.m_next; + }, + + //--------------- Internals Below ------------------- + + + + + initialize: function(def, body){ + // initialize instance variables for references + this.m_R = new b2Mat22(); + this.m_position = new b2Vec2(); + // + + this.m_userData = def.userData; + + this.m_friction = def.friction; + this.m_restitution = def.restitution; + this.m_body = body; + + this.m_proxyId = b2Pair.b2_nullProxy; + + this.m_maxRadius = 0.0; + + this.m_categoryBits = def.categoryBits; + this.m_maskBits = def.maskBits; + this.m_groupIndex = def.groupIndex; + }, + + // Internal use only. Do not call. + //b2Shape::~b2Shape() + //{ + // this.m_body->m_world->m_broadPhase->this.DestroyProxy(this.m_proxyId); + //} + + + DestroyProxy: function() + { + if (this.m_proxyId != b2Pair.b2_nullProxy) + { + this.m_body.m_world.m_broadPhase.DestroyProxy(this.m_proxyId); + this.m_proxyId = b2Pair.b2_nullProxy; + } + }, + + + // Internal use only. Do not call. + Synchronize: function(position1, R1, position2, R2){}, + QuickSync: function(position, R){}, + Support: function(dX, dY, out){}, + GetMaxRadius: function(){ + return this.m_maxRadius; + }, + + m_next: null, + + m_R: new b2Mat22(), + m_position: new b2Vec2(), + + m_type: 0, + + m_userData: null, + + m_body: null, + + m_friction: null, + m_restitution: null, + + m_maxRadius: null, + + m_proxyId: 0, + m_categoryBits: 0, + m_maskBits: 0, + m_groupIndex: 0 + + + + // b2ShapeType + + + + + + + + + + + + +}; + + +b2Shape.Create = function(def, body, center){ + switch (def.type) + { + case b2Shape.e_circleShape: + { + //void* mem = body->m_world->m_blockAllocator.Allocate(sizeof(b2CircleShape)); + return new b2CircleShape(def, body, center); + } + + case b2Shape.e_boxShape: + case b2Shape.e_polyShape: + { + //void* mem = body->m_world->m_blockAllocator.Allocate(sizeof(b2PolyShape)); + return new b2PolyShape(def, body, center); + } + } + + //b2Settings.b2Assert(false); + return null; + }; +b2Shape.Destroy = function(shape) + { + /*b2BlockAllocator& allocator = shape->m_body->m_world->m_blockAllocator; + + switch (shape.m_type) + { + case b2Shape.e_circleShape: + shape->~b2Shape(); + allocator.Free(shape, sizeof(b2CircleShape)); + break; + + case b2Shape.e_polyShape: + shape->~b2Shape(); + allocator.Free(shape, sizeof(b2PolyShape)); + break; + + default: + b2Assert(false); + } + + shape = NULL;*/ + + // FROM DESTRUCTOR + if (shape.m_proxyId != b2Pair.b2_nullProxy) + shape.m_body.m_world.m_broadPhase.DestroyProxy(shape.m_proxyId); + }; +b2Shape.e_unknownShape = -1; +b2Shape.e_circleShape = 0; +b2Shape.e_boxShape = 1; +b2Shape.e_polyShape = 2; +b2Shape.e_meshShape = 3; +b2Shape.e_shapeTypeCount = 4; +b2Shape.PolyMass = function(massData, vs, count, rho) + { + //b2Settings.b2Assert(count >= 3); + + //var center = new b2Vec2(0.0, 0.0); + var center = new b2Vec2(); + center.SetZero(); + + var area = 0.0; + var I = 0.0; + + // pRef is the reference point for forming triangles. + // It's location doesn't change the result (except for rounding error). + var pRef = new b2Vec2(0.0, 0.0); + + var inv3 = 1.0 / 3.0; + + for (var i = 0; i < count; ++i) + { + // Triangle vertices. + var p1 = pRef; + var p2 = vs[i]; + var p3 = i + 1 < count ? vs[i+1] : vs[0]; + + var e1 = b2Math.SubtractVV(p2, p1); + var e2 = b2Math.SubtractVV(p3, p1); + + var D = b2Math.b2CrossVV(e1, e2); + + var triangleArea = 0.5 * D; + area += triangleArea; + + // Area weighted centroid + // center += triangleArea * inv3 * (p1 + p2 + p3); + var tVec = new b2Vec2(); + tVec.SetV(p1); + tVec.Add(p2); + tVec.Add(p3); + tVec.Multiply(inv3*triangleArea); + center.Add(tVec); + + var px = p1.x; + var py = p1.y; + var ex1 = e1.x; + var ey1 = e1.y; + var ex2 = e2.x; + var ey2 = e2.y; + + var intx2 = inv3 * (0.25 * (ex1*ex1 + ex2*ex1 + ex2*ex2) + (px*ex1 + px*ex2)) + 0.5*px*px; + var inty2 = inv3 * (0.25 * (ey1*ey1 + ey2*ey1 + ey2*ey2) + (py*ey1 + py*ey2)) + 0.5*py*py; + + I += D * (intx2 + inty2); + } + + // Total mass + massData.mass = rho * area; + + // Center of mass + //b2Settings.b2Assert(area > Number.MIN_VALUE); + center.Multiply( 1.0 / area ); + massData.center = center; + + // Inertia tensor relative to the center. + I = rho * (I - area * b2Math.b2Dot(center, center)); + massData.I = I; + }; +b2Shape.PolyCentroid = function(vs, count, out) + { + //b2Settings.b2Assert(count >= 3); + + //b2Vec2 c; c.Set(0.0f, 0.0f); + var cX = 0.0; + var cY = 0.0; + //float32 area = 0.0f; + var area = 0.0; + + // pRef is the reference point for forming triangles. + // It's location doesn't change the result (except for rounding error). + //b2Vec2 pRef(0.0f, 0.0f); + var pRefX = 0.0; + var pRefY = 0.0; + /* + // This code would put the reference point inside the polygon. + for (var i = 0; i < count; ++i) + { + //pRef += vs[i]; + pRef.x += vs[i].x; + pRef.y += vs[i].y; + } + pRef.x *= 1.0 / count; + pRef.y *= 1.0 / count; + */ + + //const float32 inv3 = 1.0f / 3.0f; + var inv3 = 1.0 / 3.0; + + for (var i = 0; i < count; ++i) + { + // Triangle vertices. + //b2Vec2 p1 = pRef; + var p1X = pRefX; + var p1Y = pRefY; + //b2Vec2 p2 = vs[i]; + var p2X = vs[i].x; + var p2Y = vs[i].y; + //b2Vec2 p3 = i + 1 < count ? vs[i+1] : vs[0]; + var p3X = i + 1 < count ? vs[i+1].x : vs[0].x; + var p3Y = i + 1 < count ? vs[i+1].y : vs[0].y; + + //b2Vec2 e1 = p2 - p1; + var e1X = p2X - p1X; + var e1Y = p2Y - p1Y; + //b2Vec2 e2 = p3 - p1; + var e2X = p3X - p1X; + var e2Y = p3Y - p1Y; + + //float32 D = b2Cross(e1, e2); + var D = (e1X * e2Y - e1Y * e2X); + + //float32 triangleArea = 0.5f * D; + var triangleArea = 0.5 * D; + area += triangleArea; + + // Area weighted centroid + //c += triangleArea * inv3 * (p1 + p2 + p3); + cX += triangleArea * inv3 * (p1X + p2X + p3X); + cY += triangleArea * inv3 * (p1Y + p2Y + p3Y); + } + + // Centroid + //b2Settings.b2Assert(area > Number.MIN_VALUE); + cX *= 1.0 / area; + cY *= 1.0 / area; + + // Replace return with 'out' vector + //return c; + out.Set(cX, cY); + }; diff --git a/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2ShapeDef.js b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2ShapeDef.js new file mode 100644 index 00000000..8f48f07f --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/collision/shapes/b2ShapeDef.js @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + + +var b2ShapeDef = Class.create(); +b2ShapeDef.prototype = +{ + initialize: function() + { + this.type = b2Shape.e_unknownShape; + this.userData = null; + this.localPosition = new b2Vec2(0.0, 0.0); + this.localRotation = 0.0; + this.friction = 0.2; + this.restitution = 0.0; + this.density = 0.0; + this.categoryBits = 0x0001; + this.maskBits = 0xFFFF; + this.groupIndex = 0; + }, + + //virtual ~b2ShapeDef() {} + + ComputeMass: function(massData) + { + + massData.center = new b2Vec2(0.0, 0.0) + + if (this.density == 0.0) + { + massData.mass = 0.0; + massData.center.Set(0.0, 0.0); + massData.I = 0.0; + }; + + switch (this.type) + { + case b2Shape.e_circleShape: + { + var circle = this; + massData.mass = this.density * b2Settings.b2_pi * circle.radius * circle.radius; + massData.center.Set(0.0, 0.0); + massData.I = 0.5 * (massData.mass) * circle.radius * circle.radius; + } + break; + + case b2Shape.e_boxShape: + { + var box = this; + massData.mass = 4.0 * this.density * box.extents.x * box.extents.y; + massData.center.Set(0.0, 0.0); + massData.I = massData.mass / 3.0 * b2Math.b2Dot(box.extents, box.extents); + } + break; + + case b2Shape.e_polyShape: + { + var poly = this; + b2Shape.PolyMass(massData, poly.vertices, poly.vertexCount, this.density); + } + break; + + default: + massData.mass = 0.0; + massData.center.Set(0.0, 0.0); + massData.I = 0.0; + break; + } + }, + + type: 0, + userData: null, + localPosition: null, + localRotation: null, + friction: null, + restitution: null, + density: null, + + // The collision category bits. Normally you would just set one bit. + categoryBits: 0, + + // The collision mask bits. This states the categories that this + // shape would accept for collision. + maskBits: 0, + + // Collision groups allow a certain group of objects to never collide (negative) + // or always collide (positive). Zero means no collision group. Non-zero group + // filtering always wins against the mask bits. + groupIndex: 0}; diff --git a/views/archive/j/box2d-car-game/js/box2d/common/b2Settings.js b/views/archive/j/box2d-car-game/js/box2d/common/b2Settings.js new file mode 100644 index 00000000..890fde26 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/common/b2Settings.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2Settings = Class.create(); +b2Settings.prototype = { + + + + // Define your unit system here. The default system is + // meters-kilograms-seconds. For the tuning to work well, + // your dynamic objects should be bigger than a pebble and smaller + // than a house. + //static public const b2Settings.b2_lengthUnitsPerMeter = 1.0; + + // Use this for pixels: + + // Global tuning constants based on MKS units. + + // Collision + + // Dynamics + + // Sleep + + // assert + + initialize: function() {}} +b2Settings.USHRT_MAX = 0x0000ffff; +b2Settings.b2_pi = Math.PI; +b2Settings.b2_massUnitsPerKilogram = 1.0; +b2Settings.b2_timeUnitsPerSecond = 1.0; +b2Settings.b2_lengthUnitsPerMeter = 30.0; +b2Settings.b2_maxManifoldPoints = 2; +b2Settings.b2_maxShapesPerBody = 64; +b2Settings.b2_maxPolyVertices = 8; +b2Settings.b2_maxProxies = 1024; +b2Settings.b2_maxPairs = 8 * b2Settings.b2_maxProxies; +b2Settings.b2_linearSlop = 0.005 * b2Settings.b2_lengthUnitsPerMeter; +b2Settings.b2_angularSlop = 2.0 / 180.0 * b2Settings.b2_pi; +b2Settings.b2_velocityThreshold = 1.0 * b2Settings.b2_lengthUnitsPerMeter / b2Settings.b2_timeUnitsPerSecond; +b2Settings.b2_maxLinearCorrection = 0.2 * b2Settings.b2_lengthUnitsPerMeter; +b2Settings.b2_maxAngularCorrection = 8.0 / 180.0 * b2Settings.b2_pi; +b2Settings.b2_contactBaumgarte = 0.2; +b2Settings.b2_timeToSleep = 0.5 * b2Settings.b2_timeUnitsPerSecond; +b2Settings.b2_linearSleepTolerance = 0.01 * b2Settings.b2_lengthUnitsPerMeter / b2Settings.b2_timeUnitsPerSecond; +b2Settings.b2_angularSleepTolerance = 2.0 / 180.0 / b2Settings.b2_timeUnitsPerSecond; +b2Settings.b2Assert = function(a) + { + if (!a){ + var nullVec; + nullVec.x++; + } + }; diff --git a/views/archive/j/box2d-car-game/js/box2d/common/math/b2Mat22.js b/views/archive/j/box2d-car-game/js/box2d/common/math/b2Mat22.js new file mode 100644 index 00000000..d5fb1fce --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/common/math/b2Mat22.js @@ -0,0 +1,130 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2Mat22 = Class.create(); +b2Mat22.prototype = +{ + initialize: function(angle, c1, c2) + { + if (angle==null) angle = 0; + // initialize instance variables for references + this.col1 = new b2Vec2(); + this.col2 = new b2Vec2(); + // + + if (c1!=null && c2!=null){ + this.col1.SetV(c1); + this.col2.SetV(c2); + } + else{ + 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; + } + }, + + Set: function(angle) + { + 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; + }, + + SetVV: function(c1, c2) + { + this.col1.SetV(c1); + this.col2.SetV(c2); + }, + + Copy: function(){ + return new b2Mat22(0, this.col1, this.col2); + }, + + SetM: function(m) + { + this.col1.SetV(m.col1); + this.col2.SetV(m.col2); + }, + + 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; + }, + + SetIdentity: function() + { + this.col1.x = 1.0; this.col2.x = 0.0; + this.col1.y = 0.0; this.col2.y = 1.0; + }, + + SetZero: function() + { + this.col1.x = 0.0; this.col2.x = 0.0; + this.col1.y = 0.0; this.col2.y = 0.0; + }, + + Invert: function(out) + { + var a = this.col1.x; + var b = this.col2.x; + var c = this.col1.y; + var d = this.col2.y; + //var B = new b2Mat22(); + var det = a * d - b * c; + //b2Settings.b2Assert(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; + }, + + // this.Solve A * x = b + Solve: function(out, bX, bY) + { + //float32 a11 = this.col1.x, a12 = this.col2.x, a21 = this.col1.y, a22 = this.col2.y; + var a11 = this.col1.x; + var a12 = this.col2.x; + var a21 = this.col1.y; + var a22 = this.col2.y; + //float32 det = a11 * a22 - a12 * a21; + var det = a11 * a22 - a12 * a21; + //b2Settings.b2Assert(det != 0.0); + det = 1.0 / det; + out.x = det * (a22 * bX - a12 * bY); + out.y = det * (a11 * bY - a21 * bX); + + return out; + }, + + Abs: function() + { + this.col1.Abs(); + this.col2.Abs(); + }, + + col1: new b2Vec2(), + col2: new b2Vec2()}; diff --git a/views/archive/j/box2d-car-game/js/box2d/common/math/b2Math.js b/views/archive/j/box2d-car-game/js/box2d/common/math/b2Math.js new file mode 100644 index 00000000..85185bf4 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/common/math/b2Math.js @@ -0,0 +1,218 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +var b2Math = Class.create(); +b2Math.prototype = { + + + /*static public function b2InvSqrt(x) + { + float32 xhalf = 0.5f * x; + int32 i = *(int32*)&x; + i = 0x5f3759df - (i >> 1); + x = *(float32*)&i; + x = x * (1.5f - xhalf * x * x); + return x; + }*/ + + + + + + + + + + + + // A * B + + // A^T * B + + + + + + + + + + + + // b2Math.b2Random number in range [-1,1] + + /*inline float32 b2Math.b2Random(float32 lo, float32 hi) + { + float32 r = (float32)rand(); + r /= RAND_MAX; + r = (hi - lo) * r + lo; + return r; + }*/ + + // "Next Largest Power of 2 + // Given a binary integer value x, the next largest power of 2 can be computed by a SWAR algorithm + // that recursively "folds" the upper bits into the lower bits. This process yields a bit vector with + // the same most significant 1, but all 1's below it. Adding 1 to that value yields the next + // largest power of 2. For a 32-bit value:" + + + + // Temp vector functions to reduce calls to 'new' + /*static public var tempVec = new b2Vec2(); + + + static public var tempAABB = new b2AABB(); */ + + + + initialize: function() {}} +b2Math.b2IsValid = function(x) + { + return isFinite(x); + }; +b2Math.b2Dot = function(a, b) + { + return a.x * b.x + a.y * b.y; + }; +b2Math.b2CrossVV = function(a, b) + { + return a.x * b.y - a.y * b.x; + }; +b2Math.b2CrossVF = function(a, s) + { + var v = new b2Vec2(s * a.y, -s * a.x); + return v; + }; +b2Math.b2CrossFV = function(s, a) + { + var v = new b2Vec2(-s * a.y, s * a.x); + return v; + }; +b2Math.b2MulMV = 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.b2MulTMV = function(A, v) + { + var u = new b2Vec2(b2Math.b2Dot(v, A.col1), b2Math.b2Dot(v, A.col2)); + return u; + }; +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.MulFV = function(s, a) + { + var v = new b2Vec2(s * a.x, s * a.y); + return v; + }; +b2Math.AddMM = function(A, B) + { + var C = new b2Mat22(0, b2Math.AddVV(A.col1, B.col1), b2Math.AddVV(A.col2, B.col2)); + return C; + }; +b2Math.b2MulMM = function(A, B) + { + var C = new b2Mat22(0, b2Math.b2MulMV(A, B.col1), b2Math.b2MulMV(A, B.col2)); + return C; + }; +b2Math.b2MulTMM = function(A, B) + { + var c1 = new b2Vec2(b2Math.b2Dot(A.col1, B.col1), b2Math.b2Dot(A.col2, B.col1)); + var c2 = new b2Vec2(b2Math.b2Dot(A.col1, B.col2), b2Math.b2Dot(A.col2, B.col2)); + var C = new b2Mat22(0, c1, c2); + return C; + }; +b2Math.b2Abs = function(a) + { + return a > 0.0 ? a : -a; + }; +b2Math.b2AbsV = function(a) + { + var b = new b2Vec2(b2Math.b2Abs(a.x), b2Math.b2Abs(a.y)); + return b; + }; +b2Math.b2AbsM = function(A) + { + var B = new b2Mat22(0, b2Math.b2AbsV(A.col1), b2Math.b2AbsV(A.col2)); + return B; + }; +b2Math.b2Min = function(a, b) + { + return a < b ? a : b; + }; +b2Math.b2MinV = function(a, b) + { + var c = new b2Vec2(b2Math.b2Min(a.x, b.x), b2Math.b2Min(a.y, b.y)); + return c; + }; +b2Math.b2Max = function(a, b) + { + return a > b ? a : b; + }; +b2Math.b2MaxV = function(a, b) + { + var c = new b2Vec2(b2Math.b2Max(a.x, b.x), b2Math.b2Max(a.y, b.y)); + return c; + }; +b2Math.b2Clamp = function(a, low, high) + { + return b2Math.b2Max(low, b2Math.b2Min(a, high)); + }; +b2Math.b2ClampV = function(a, low, high) + { + return b2Math.b2MaxV(low, b2Math.b2MinV(a, high)); + }; +b2Math.b2Swap = function(a, b) + { + var tmp = a[0]; + a[0] = b[0]; + b[0] = tmp; + }; +b2Math.b2Random = function() + { + return Math.random() * 2 - 1; + }; +b2Math.b2NextPowerOfTwo = function(x) + { + x |= (x >> 1) & 0x7FFFFFFF; + x |= (x >> 2) & 0x3FFFFFFF; + x |= (x >> 4) & 0x0FFFFFFF; + x |= (x >> 8) & 0x00FFFFFF; + x |= (x >> 16)& 0x0000FFFF; + return x + 1; + }; +b2Math.b2IsPowerOfTwo = function(x) + { + var result = x > 0 && (x & (x - 1)) == 0; + return result; + }; +b2Math.tempVec2 = new b2Vec2(); +b2Math.tempVec3 = new b2Vec2(); +b2Math.tempVec4 = new b2Vec2(); +b2Math.tempVec5 = new b2Vec2(); +b2Math.tempMat = new b2Mat22(); diff --git a/views/archive/j/box2d-car-game/js/box2d/common/math/b2Vec2.js b/views/archive/j/box2d-car-game/js/box2d/common/math/b2Vec2.js new file mode 100644 index 00000000..24acd20d --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/common/math/b2Vec2.js @@ -0,0 +1,131 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +// b2Vec2 has no constructor so that it +// can be placed in a union. +var b2Vec2 = Class.create(); +b2Vec2.prototype = +{ + initialize: function(x_, y_) {this.x=x_; this.y=y_;}, + + SetZero: function() { this.x = 0.0; this.y = 0.0; }, + Set: function(x_, y_) {this.x=x_; this.y=y_;}, + SetV: function(v) {this.x=v.x; this.y=v.y;}, + + Negative: function(){ return new b2Vec2(-this.x, -this.y); }, + + + Copy: function(){ + return new b2Vec2(this.x,this.y); + }, + + Add: function(v) + { + this.x += v.x; this.y += v.y; + }, + + Subtract: function(v) + { + this.x -= v.x; this.y -= v.y; + }, + + Multiply: function(a) + { + this.x *= a; this.y *= a; + }, + + 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; + }, + + MulTM: function(A) + { + var tX = b2Math.b2Dot(this, A.col1); + this.y = b2Math.b2Dot(this, A.col2); + this.x = tX; + }, + + CrossVF: function(s) + { + var tX = this.x; + this.x = s * this.y; + this.y = -s * tX; + }, + + CrossFV: function(s) + { + var tX = this.x; + this.x = -s * this.y; + this.y = s * tX; + }, + + MinV: function(b) + { + this.x = this.x < b.x ? this.x : b.x; + this.y = this.y < b.y ? this.y : b.y; + }, + + MaxV: function(b) + { + this.x = this.x > b.x ? this.x : b.x; + this.y = this.y > b.y ? this.y : b.y; + }, + + Abs: function() + { + this.x = Math.abs(this.x); + this.y = Math.abs(this.y); + }, + + Length: function() + { + return Math.sqrt(this.x * this.x + this.y * this.y); + }, + + Normalize: function() + { + var length = this.Length(); + if (length < Number.MIN_VALUE) + { + return 0.0; + } + var invLength = 1.0 / length; + this.x *= invLength; + this.y *= invLength; + + return length; + }, + + IsValid: function() + { + return b2Math.b2IsValid(this.x) && b2Math.b2IsValid(this.y); + }, + + x: null, + y: null}; +b2Vec2.Make = function(x_, y_) + { + return new b2Vec2(x_, y_); + }; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/b2Body.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2Body.js new file mode 100644 index 00000000..6716d2fa --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2Body.js @@ -0,0 +1,469 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + +// A rigid body. Internal computation are done in terms +// of the center of mass position. The center of mass may +// be offset from the body's origin. +var b2Body = Class.create(); +b2Body.prototype = +{ + // Set the position of the body's origin and rotation (radians). + // This breaks any contacts and wakes the other bodies. + SetOriginPosition: function(position, rotation){ + if (this.IsFrozen()) + { + return; + } + + this.m_rotation = rotation; + this.m_R.Set(this.m_rotation); + this.m_position = b2Math.AddVV(position , b2Math.b2MulMV(this.m_R, this.m_center)); + + this.m_position0.SetV(this.m_position); + this.m_rotation0 = this.m_rotation; + + for (var s = this.m_shapeList; s != null; s = s.m_next) + { + s.Synchronize(this.m_position, this.m_R, this.m_position, this.m_R); + } + + this.m_world.m_broadPhase.Commit(); + }, + + // Get the position of the body's origin. The body's origin does not + // necessarily coincide with the center of mass. It depends on how the + // shapes are created. + GetOriginPosition: function(){ + return b2Math.SubtractVV(this.m_position, b2Math.b2MulMV(this.m_R, this.m_center)); + }, + + // Set the position of the body's center of mass and rotation (radians). + // This breaks any contacts and wakes the other bodies. + SetCenterPosition: function(position, rotation){ + if (this.IsFrozen()) + { + return; + } + + this.m_rotation = rotation; + this.m_R.Set(this.m_rotation); + this.m_position.SetV( position ); + + this.m_position0.SetV(this.m_position); + this.m_rotation0 = this.m_rotation; + + for (var s = this.m_shapeList; s != null; s = s.m_next) + { + s.Synchronize(this.m_position, this.m_R, this.m_position, this.m_R); + } + + this.m_world.m_broadPhase.Commit(); + }, + + // Get the position of the body's center of mass. The body's center of mass + // does not necessarily coincide with the body's origin. It depends on how the + // shapes are created. + GetCenterPosition: function(){ + return this.m_position; + }, + + // Get the rotation in radians. + GetRotation: function(){ + return this.m_rotation; + }, + + GetRotationMatrix: function(){ + return this.m_R; + }, + + // Set/Get the linear velocity of the center of mass. + SetLinearVelocity: function(v){ + this.m_linearVelocity.SetV(v); + }, + GetLinearVelocity: function(){ + return this.m_linearVelocity; + }, + + // Set/Get the angular velocity. + SetAngularVelocity: function(w){ + this.m_angularVelocity = w; + }, + GetAngularVelocity: function(){ + return this.m_angularVelocity; + }, + + // Apply a force at a world point. Additive. + ApplyForce: function(force, point) + { + if (this.IsSleeping() == false) + { + this.m_force.Add( force ); + this.m_torque += b2Math.b2CrossVV(b2Math.SubtractVV(point, this.m_position), force); + } + }, + + // Apply a torque. Additive. + ApplyTorque: function(torque) + { + if (this.IsSleeping() == false) + { + this.m_torque += torque; + } + }, + + // Apply an impulse at a point. This immediately modifies the velocity. + ApplyImpulse: function(impulse, point) + { + if (this.IsSleeping() == false) + { + this.m_linearVelocity.Add( b2Math.MulFV(this.m_invMass, impulse) ); + this.m_angularVelocity += ( this.m_invI * b2Math.b2CrossVV( b2Math.SubtractVV(point, this.m_position), impulse) ); + } + }, + + GetMass: function(){ + return this.m_mass; + }, + + GetInertia: function(){ + return this.m_I; + }, + + // Get the world coordinates of a point give the local coordinates + // relative to the body's center of mass. + GetWorldPoint: function(localPoint){ + return b2Math.AddVV(this.m_position , b2Math.b2MulMV(this.m_R, localPoint)); + }, + + // Get the world coordinates of a vector given the local coordinates. + GetWorldVector: function(localVector){ + return b2Math.b2MulMV(this.m_R, localVector); + }, + + // Returns a local point relative to the center of mass given a world point. + GetLocalPoint: function(worldPoint){ + return b2Math.b2MulTMV(this.m_R, b2Math.SubtractVV(worldPoint, this.m_position)); + }, + + // Returns a local vector given a world vector. + GetLocalVector: function(worldVector){ + return b2Math.b2MulTMV(this.m_R, worldVector); + }, + + // Is this body static (immovable)? + IsStatic: function(){ + return (this.m_flags & b2Body.e_staticFlag) == b2Body.e_staticFlag; + }, + + IsFrozen: function() + { + return (this.m_flags & b2Body.e_frozenFlag) == b2Body.e_frozenFlag; + }, + + // Is this body sleeping (not simulating). + IsSleeping: function(){ + return (this.m_flags & b2Body.e_sleepFlag) == b2Body.e_sleepFlag; + }, + + // You can disable sleeping on this particular body. + AllowSleeping: function(flag) + { + if (flag) + { + this.m_flags |= b2Body.e_allowSleepFlag; + } + else + { + this.m_flags &= ~b2Body.e_allowSleepFlag; + this.WakeUp(); + } + }, + + // Wake up this body so it will begin simulating. + WakeUp: function(){ + this.m_flags &= ~b2Body.e_sleepFlag; + this.m_sleepTime = 0.0; + }, + + // Get the list of all shapes attached to this body. + GetShapeList: function(){ + return this.m_shapeList; + }, + + GetContactList: function() + { + return this.m_contactList; + }, + + GetJointList: function() + { + return this.m_jointList; + }, + + // Get the next body in the world's body list. + GetNext: function(){ + return this.m_next; + }, + + GetUserData: function(){ + return this.m_userData; + }, + + //--------------- Internals Below ------------------- + + initialize: function(bd, world){ + // initialize instance variables for references + this.sMat0 = new b2Mat22(); + this.m_position = new b2Vec2(); + this.m_R = new b2Mat22(0); + this.m_position0 = new b2Vec2(); + // + + var i = 0; + var sd; + var massData; + + this.m_flags = 0; + this.m_position.SetV( bd.position ); + this.m_rotation = bd.rotation; + this.m_R.Set(this.m_rotation); + this.m_position0.SetV(this.m_position); + this.m_rotation0 = this.m_rotation; + this.m_world = world; + + this.m_linearDamping = b2Math.b2Clamp(1.0 - bd.linearDamping, 0.0, 1.0); + this.m_angularDamping = b2Math.b2Clamp(1.0 - bd.angularDamping, 0.0, 1.0); + + this.m_force = new b2Vec2(0.0, 0.0); + this.m_torque = 0.0; + + this.m_mass = 0.0; + + var massDatas = new Array(b2Settings.b2_maxShapesPerBody); + for (i = 0; i < b2Settings.b2_maxShapesPerBody; i++){ + massDatas[i] = new b2MassData(); + } + + // Compute the shape mass properties, the bodies total mass and COM. + this.m_shapeCount = 0; + this.m_center = new b2Vec2(0.0, 0.0); + for (i = 0; i < b2Settings.b2_maxShapesPerBody; ++i) + { + sd = bd.shapes[i]; + if (sd == null) break; + massData = massDatas[ i ]; + sd.ComputeMass(massData); + this.m_mass += massData.mass; + //this.m_center += massData->mass * (sd->localPosition + massData->center); + this.m_center.x += massData.mass * (sd.localPosition.x + massData.center.x); + this.m_center.y += massData.mass * (sd.localPosition.y + massData.center.y); + ++this.m_shapeCount; + } + + // Compute center of mass, and shift the origin to the COM. + if (this.m_mass > 0.0) + { + this.m_center.Multiply( 1.0 / this.m_mass ); + this.m_position.Add( b2Math.b2MulMV(this.m_R, this.m_center) ); + } + else + { + this.m_flags |= b2Body.e_staticFlag; + } + + // Compute the moment of inertia. + this.m_I = 0.0; + for (i = 0; i < this.m_shapeCount; ++i) + { + sd = bd.shapes[i]; + massData = massDatas[ i ]; + this.m_I += massData.I; + var r = b2Math.SubtractVV( b2Math.AddVV(sd.localPosition, massData.center), this.m_center ); + this.m_I += massData.mass * b2Math.b2Dot(r, r); + } + + if (this.m_mass > 0.0) + { + this.m_invMass = 1.0 / this.m_mass; + } + else + { + this.m_invMass = 0.0; + } + + if (this.m_I > 0.0 && bd.preventRotation == false) + { + this.m_invI = 1.0 / this.m_I; + } + else + { + this.m_I = 0.0; + this.m_invI = 0.0; + } + + // Compute the center of mass velocity. + this.m_linearVelocity = b2Math.AddVV(bd.linearVelocity, b2Math.b2CrossFV(bd.angularVelocity, this.m_center)); + this.m_angularVelocity = bd.angularVelocity; + + this.m_jointList = null; + this.m_contactList = null; + this.m_prev = null; + this.m_next = null; + + // Create the shapes. + this.m_shapeList = null; + for (i = 0; i < this.m_shapeCount; ++i) + { + sd = bd.shapes[i]; + var shape = b2Shape.Create(sd, this, this.m_center); + shape.m_next = this.m_shapeList; + this.m_shapeList = shape; + } + + this.m_sleepTime = 0.0; + if (bd.allowSleep) + { + this.m_flags |= b2Body.e_allowSleepFlag; + } + if (bd.isSleeping) + { + this.m_flags |= b2Body.e_sleepFlag; + } + + if ((this.m_flags & b2Body.e_sleepFlag) || this.m_invMass == 0.0) + { + this.m_linearVelocity.Set(0.0, 0.0); + this.m_angularVelocity = 0.0; + } + + this.m_userData = bd.userData; + }, + // does not support destructors + /*~b2Body(){ + b2Shape* s = this.m_shapeList; + while (s) + { + b2Shape* s0 = s; + s = s->this.m_next; + + b2Shape::this.Destroy(s0); + } + }*/ + + Destroy: function(){ + var s = this.m_shapeList; + while (s) + { + var s0 = s; + s = s.m_next; + + b2Shape.Destroy(s0); + } + }, + + // Temp mat + sMat0: new b2Mat22(), + SynchronizeShapes: function(){ + //b2Mat22 R0(this.m_rotation0); + this.sMat0.Set(this.m_rotation0); + for (var s = this.m_shapeList; s != null; s = s.m_next) + { + s.Synchronize(this.m_position0, this.sMat0, this.m_position, this.m_R); + } + }, + + QuickSyncShapes: function(){ + for (var s = this.m_shapeList; s != null; s = s.m_next) + { + s.QuickSync(this.m_position, this.m_R); + } + }, + + // This is used to prevent connected bodies from colliding. + // It may lie, depending on the collideConnected flag. + IsConnected: function(other){ + for (var jn = this.m_jointList; jn != null; jn = jn.next) + { + if (jn.other == other) + return jn.joint.m_collideConnected == false; + } + + return false; + }, + + Freeze: function(){ + this.m_flags |= b2Body.e_frozenFlag; + this.m_linearVelocity.SetZero(); + this.m_angularVelocity = 0.0; + + for (var s = this.m_shapeList; s != null; s = s.m_next) + { + s.DestroyProxy(); + } + }, + + m_flags: 0, + + m_position: new b2Vec2(), + m_rotation: null, + m_R: new b2Mat22(0), + + // Conservative advancement data. + m_position0: new b2Vec2(), + m_rotation0: null, + + m_linearVelocity: null, + m_angularVelocity: null, + + m_force: null, + m_torque: null, + + m_center: null, + + m_world: null, + m_prev: null, + m_next: null, + + m_shapeList: null, + m_shapeCount: 0, + + m_jointList: null, + m_contactList: null, + + m_mass: null, + m_invMass: null, + m_I: null, + m_invI: null, + + m_linearDamping: null, + m_angularDamping: null, + + m_sleepTime: null, + + m_userData: null}; +b2Body.e_staticFlag = 0x0001; +b2Body.e_frozenFlag = 0x0002; +b2Body.e_islandFlag = 0x0004; +b2Body.e_sleepFlag = 0x0008; +b2Body.e_allowSleepFlag = 0x0010; +b2Body.e_destroyFlag = 0x0020; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/b2BodyDef.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2BodyDef.js new file mode 100644 index 00000000..c586b379 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2BodyDef.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2BodyDef = Class.create(); +b2BodyDef.prototype = +{ + initialize: function() + { + // initialize instance variables for references + this.shapes = new Array(); + // + + this.userData = null; + for (var i = 0; i < b2Settings.b2_maxShapesPerBody; i++){ + this.shapes[i] = null; + } + this.position = new b2Vec2(0.0, 0.0); + this.rotation = 0.0; + this.linearVelocity = new b2Vec2(0.0, 0.0); + this.angularVelocity = 0.0; + this.linearDamping = 0.0; + this.angularDamping = 0.0; + this.allowSleep = true; + this.isSleeping = false; + this.preventRotation = false; + }, + + userData: null, + shapes: new Array(), + position: null, + rotation: null, + linearVelocity: null, + angularVelocity: null, + linearDamping: null, + angularDamping: null, + allowSleep: null, + isSleeping: null, + preventRotation: null, + + AddShape: function(shape) + { + for (var i = 0; i < b2Settings.b2_maxShapesPerBody; ++i) + { + if (this.shapes[i] == null) + { + this.shapes[i] = shape; + break; + } + } + }}; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/b2CollisionFilter.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2CollisionFilter.js new file mode 100644 index 00000000..6724f257 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2CollisionFilter.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + + +var b2CollisionFilter = Class.create(); +b2CollisionFilter.prototype = +{ + + // Return true if contact calculations should be performed between these two shapes. + ShouldCollide: function(shape1, shape2){ + if (shape1.m_groupIndex == shape2.m_groupIndex && shape1.m_groupIndex != 0) + { + return shape1.m_groupIndex > 0; + } + + var collide = (shape1.m_maskBits & shape2.m_categoryBits) != 0 && (shape1.m_categoryBits & shape2.m_maskBits) != 0; + return collide; + }, + + + initialize: function() {}}; +b2CollisionFilter.b2_defaultFilter = new b2CollisionFilter; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/b2ContactManager.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2ContactManager.js new file mode 100644 index 00000000..cfb2df79 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2ContactManager.js @@ -0,0 +1,337 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2ContactManager = Class.create(); +Object.extend(b2ContactManager.prototype, b2PairCallback.prototype); +Object.extend(b2ContactManager.prototype, +{ + initialize: function(){ + // The constructor for b2PairCallback + // + + // initialize instance variables for references + this.m_nullContact = new b2NullContact(); + // + + this.m_world = null; + this.m_destroyImmediate = false; + }, + + // This is a callback from the broadphase when two AABB proxies begin + // to overlap. We create a b2Contact to manage the narrow phase. + PairAdded: function(proxyUserData1, proxyUserData2){ + var shape1 = proxyUserData1; + var shape2 = proxyUserData2; + + var body1 = shape1.m_body; + var body2 = shape2.m_body; + + if (body1.IsStatic() && body2.IsStatic()) + { + return this.m_nullContact; + } + + if (shape1.m_body == shape2.m_body) + { + return this.m_nullContact; + } + + if (body2.IsConnected(body1)) + { + return this.m_nullContact; + } + + if (this.m_world.m_filter != null && this.m_world.m_filter.ShouldCollide(shape1, shape2) == false) + { + return this.m_nullContact; + } + + // Ensure that body2 is dynamic (body1 is static or dynamic). + if (body2.m_invMass == 0.0) + { + var tempShape = shape1; + shape1 = shape2; + shape2 = tempShape; + //b2Math.b2Swap(shape1, shape2); + var tempBody = body1; + body1 = body2; + body2 = tempBody; + //b2Math.b2Swap(body1, body2); + } + + // Call the factory. + var contact = b2Contact.Create(shape1, shape2, this.m_world.m_blockAllocator); + + if (contact == null) + { + return this.m_nullContact; + } + else + { + // Insert into the world. + contact.m_prev = null; + contact.m_next = this.m_world.m_contactList; + if (this.m_world.m_contactList != null) + { + this.m_world.m_contactList.m_prev = contact; + } + this.m_world.m_contactList = contact; + this.m_world.m_contactCount++; + } + + return contact; + }, + + // This is a callback from the broadphase when two AABB proxies cease + // to overlap. We destroy the b2Contact. + PairRemoved: function(proxyUserData1, proxyUserData2, pairUserData){ + + if (pairUserData == null) + { + return; + } + + var c = pairUserData; + if (c != this.m_nullContact) + { + //b2Settings.b2Assert(this.m_world.m_contactCount > 0); + if (this.m_destroyImmediate == true) + { + this.DestroyContact(c); + c = null; + } + else + { + c.m_flags |= b2Contact.e_destroyFlag; + } + } + }, + + DestroyContact: function(c) + { + + //b2Settings.b2Assert(this.m_world.m_contactCount > 0); + + // Remove from the world. + 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 there are contact points, then disconnect from the island graph. + if (c.GetManifoldCount() > 0) + { + var body1 = c.m_shape1.m_body; + var body2 = c.m_shape2.m_body; + var node1 = c.m_node1; + var node2 = c.m_node2; + + // Wake up touching bodies. + body1.WakeUp(); + body2.WakeUp(); + + // Remove from body 1 + if (node1.prev) + { + node1.prev.next = node1.next; + } + + if (node1.next) + { + node1.next.prev = node1.prev; + } + + if (node1 == body1.m_contactList) + { + body1.m_contactList = node1.next; + } + + node1.prev = null; + node1.next = null; + + // Remove from body 2 + if (node2.prev) + { + node2.prev.next = node2.next; + } + + if (node2.next) + { + node2.next.prev = node2.prev; + } + + if (node2 == body2.m_contactList) + { + body2.m_contactList = node2.next; + } + + node2.prev = null; + node2.next = null; + } + + // Call the factory. + b2Contact.Destroy(c, this.m_world.m_blockAllocator); + --this.m_world.m_contactCount; + }, + + + // Destroy any contacts marked for deferred destruction. + CleanContactList: function() + { + var c = this.m_world.m_contactList; + while (c != null) + { + var c0 = c; + c = c.m_next; + + if (c0.m_flags & b2Contact.e_destroyFlag) + { + this.DestroyContact(c0); + c0 = null; + } + } + }, + + + // This is the top level collision call for the time step. Here + // all the narrow phase collision is processed for the world + // contact list. + Collide: function() + { + var body1; + var body2; + var node1; + var node2; + + for (var c = this.m_world.m_contactList; c != null; c = c.m_next) + { + if (c.m_shape1.m_body.IsSleeping() && + c.m_shape2.m_body.IsSleeping()) + { + continue; + } + + var oldCount = c.GetManifoldCount(); + c.Evaluate(); + + var newCount = c.GetManifoldCount(); + + if (oldCount == 0 && newCount > 0) + { + //b2Settings.b2Assert(c.GetManifolds().pointCount > 0); + + // Connect to island graph. + body1 = c.m_shape1.m_body; + body2 = c.m_shape2.m_body; + node1 = c.m_node1; + node2 = c.m_node2; + + // Connect to body 1 + node1.contact = c; + node1.other = body2; + + node1.prev = null; + node1.next = body1.m_contactList; + if (node1.next != null) + { + node1.next.prev = c.m_node1; + } + body1.m_contactList = c.m_node1; + + // Connect to body 2 + node2.contact = c; + node2.other = body1; + + node2.prev = null; + node2.next = body2.m_contactList; + if (node2.next != null) + { + node2.next.prev = node2; + } + body2.m_contactList = node2; + } + else if (oldCount > 0 && newCount == 0) + { + // Disconnect from island graph. + body1 = c.m_shape1.m_body; + body2 = c.m_shape2.m_body; + node1 = c.m_node1; + node2 = c.m_node2; + + // Remove from body 1 + if (node1.prev) + { + node1.prev.next = node1.next; + } + + if (node1.next) + { + node1.next.prev = node1.prev; + } + + if (node1 == body1.m_contactList) + { + body1.m_contactList = node1.next; + } + + node1.prev = null; + node1.next = null; + + // Remove from body 2 + if (node2.prev) + { + node2.prev.next = node2.next; + } + + if (node2.next) + { + node2.next.prev = node2.prev; + } + + if (node2 == body2.m_contactList) + { + body2.m_contactList = node2.next; + } + + node2.prev = null; + node2.next = null; + } + } + }, + + m_world: null, + + // This lets us provide broadphase proxy pair user data for + // contacts that shouldn't exist. + m_nullContact: new b2NullContact(), + m_destroyImmediate: null}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/b2Island.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2Island.js new file mode 100644 index 00000000..ee15d716 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2Island.js @@ -0,0 +1,331 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +/* +Position Correction Notes +========================= +I tried the several algorithms for position correction of the 2D revolute joint. +I looked at these systems: +- simple pendulum (1m diameter sphere on massless 5m stick) with initial angular velocity of 100 rad/s. +- suspension bridge with 30 1m long planks of length 1m. +- multi-link chain with 30 1m long links. + +Here are the algorithms: + +Baumgarte - A fraction of the position error is added to the velocity error. There is no +separate position solver. + +Pseudo Velocities - After the velocity solver and position integration, +the position error, Jacobian, and effective mass are recomputed. Then +the velocity constraints are solved with pseudo velocities and a fraction +of the position error is added to the pseudo velocity error. The pseudo +velocities are initialized to zero and there is no warm-starting. After +the position solver, the pseudo velocities are added to the positions. +This is also called the First Order World method or the Position LCP method. + +Modified Nonlinear Gauss-Seidel (NGS) - Like Pseudo Velocities except the +position error is re-computed for each constraint and the positions are updated +after the constraint is solved. The radius vectors (aka Jacobians) are +re-computed too (otherwise the algorithm has horrible instability). The pseudo +velocity states are not needed because they are effectively zero at the beginning +of each iteration. Since we have the current position error, we allow the +iterations to terminate early if the error becomes smaller than b2_linearSlop. + +Full NGS or just NGS - Like Modified NGS except the effective mass are re-computed +each time a constraint is solved. + +Here are the results: +Baumgarte - this is the cheapest algorithm but it has some stability problems, +especially with the bridge. The chain links separate easily close to the root +and they jitter struggle to pull together. This is one of the most common +methods in the field. The big drawback is that the position correction artificially +affects the momentum, thus leading to instabilities and false bounce. I used a +bias factor of 0.2. A larger bias factor makes the bridge less stable, a smaller +factor makes joints and contacts more spongy. + +Pseudo Velocities - the is more stable than the Baumgarte method. The bridge is +stable. However, joints still separate with large angular velocities. Drag the +simple pendulum in a circle quickly and the joint will separate. The chain separates +easily and does not recover. I used a bias factor of 0.2. A larger value lead to +the bridge collapsing when a heavy cube drops on it. + +Modified NGS - this algorithm is better in some ways than Baumgarte and Pseudo +Velocities, but in other ways it is worse. The bridge and chain are much more +stable, but the simple pendulum goes unstable at high angular velocities. + +Full NGS - stable in all tests. The joints display good stiffness. The bridge +still sags, but this is better than infinite forces. + +Recommendations +Pseudo Velocities are not really worthwhile because the bridge and chain cannot +recover from joint separation. In other cases the benefit over Baumgarte is small. + +Modified NGS is not a robust method for the revolute joint due to the violent +instability seen in the simple pendulum. Perhaps it is viable with other constraint +types, especially scalar constraints where the effective mass is a scalar. + +This leaves Baumgarte and Full NGS. Baumgarte has small, but manageable instabilities +and is very fast. I don't think we can escape Baumgarte, especially in highly +demanding cases where high constraint fidelity is not needed. + +Full NGS is robust and easy on the eyes. I recommend this option for +higher fidelity simulation and certainly for suspension bridges and long chains. +Full NGS might be a good choice for ragdolls, especially motorized ragdolls where +joint separation can be problematic. The number of NGS iterations can be reduced +for better performance without harming robustness much. + +Each joint in a can be handled differently in the position solver. So I recommend +a system where the user can select the algorithm on a per joint basis. I would +probably default to the slower Full NGS and let the user select the faster +Baumgarte method in performance critical scenarios. +*/ + + +var b2Island = Class.create(); +b2Island.prototype = +{ + initialize: function(bodyCapacity, contactCapacity, jointCapacity, allocator) + { + 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_bodies = (b2Body**)allocator->Allocate(bodyCapacity * sizeof(b2Body*)); + this.m_bodies = new Array(bodyCapacity); + for (i = 0; i < bodyCapacity; i++) + this.m_bodies[i] = null; + + //this.m_contacts = (b2Contact**)allocator->Allocate(contactCapacity * sizeof(b2Contact*)); + this.m_contacts = new Array(contactCapacity); + for (i = 0; i < contactCapacity; i++) + this.m_contacts[i] = null; + + //this.m_joints = (b2Joint**)allocator->Allocate(jointCapacity * sizeof(b2Joint*)); + this.m_joints = new Array(jointCapacity); + for (i = 0; i < jointCapacity; i++) + this.m_joints[i] = null; + + this.m_allocator = allocator; + }, + //~b2Island(); + + Clear: function() + { + this.m_bodyCount = 0; + this.m_contactCount = 0; + this.m_jointCount = 0; + }, + + Solve: function(step, gravity) + { + var i = 0; + var b; + + for (i = 0; i < this.m_bodyCount; ++i) + { + b = this.m_bodies[i]; + + if (b.m_invMass == 0.0) + continue; + + b.m_linearVelocity.Add( b2Math.MulFV (step.dt, b2Math.AddVV(gravity, b2Math.MulFV( b.m_invMass, b.m_force ) ) ) ); + b.m_angularVelocity += step.dt * b.m_invI * b.m_torque; + + //b.m_linearVelocity *= b.m_linearDamping; + b.m_linearVelocity.Multiply(b.m_linearDamping); + b.m_angularVelocity *= b.m_angularDamping; + + // Store positions for conservative advancement. + b.m_position0.SetV(b.m_position); + b.m_rotation0 = b.m_rotation; + } + + var contactSolver = new b2ContactSolver(this.m_contacts, this.m_contactCount, this.m_allocator); + + // Pre-solve + contactSolver.PreSolve(); + + for (i = 0; i < this.m_jointCount; ++i) + { + this.m_joints[i].PrepareVelocitySolver(); + } + + // this.Solve velocity constraints. + for (i = 0; i < step.iterations; ++i) + { + contactSolver.SolveVelocityConstraints(); + + for (var j = 0; j < this.m_jointCount; ++j) + { + this.m_joints[j].SolveVelocityConstraints(step); + } + } + + // Integrate positions. + for (i = 0; i < this.m_bodyCount; ++i) + { + b = this.m_bodies[i]; + + if (b.m_invMass == 0.0) + continue; + + //b.m_position.Add( b2Math.MulFV (step.dt, b.m_linearVelocity) ); + b.m_position.x += step.dt * b.m_linearVelocity.x; + b.m_position.y += step.dt * b.m_linearVelocity.y; + b.m_rotation += step.dt * b.m_angularVelocity; + + b.m_R.Set(b.m_rotation); + } + + for (i = 0; i < this.m_jointCount; ++i) + { + this.m_joints[i].PreparePositionSolver(); + } + + // this.Solve position constraints. + if (b2World.s_enablePositionCorrection) + { + for (b2Island.m_positionIterationCount = 0; b2Island.m_positionIterationCount < step.iterations; ++b2Island.m_positionIterationCount) + { + var contactsOkay = contactSolver.SolvePositionConstraints(b2Settings.b2_contactBaumgarte); + + var jointsOkay = true; + for (i = 0; i < this.m_jointCount; ++i) + { + var jointOkay = this.m_joints[i].SolvePositionConstraints(); + jointsOkay = jointsOkay && jointOkay; + } + + if (contactsOkay && jointsOkay) + { + break; + } + } + } + + // Post-solve. + contactSolver.PostSolve(); + + // Synchronize shapes and reset forces. + for (i = 0; i < this.m_bodyCount; ++i) + { + b = this.m_bodies[i]; + + if (b.m_invMass == 0.0) + continue; + + b.m_R.Set(b.m_rotation); + + b.SynchronizeShapes(); + b.m_force.Set(0.0, 0.0); + b.m_torque = 0.0; + } + }, + + UpdateSleep: function(dt) + { + var i = 0; + var b; + + 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.m_invMass == 0.0) + { + 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.b2Dot(b.m_linearVelocity, b.m_linearVelocity) > linTolSqr) + { + b.m_sleepTime = 0.0; + minSleepTime = 0.0; + } + else + { + b.m_sleepTime += dt; + minSleepTime = b2Math.b2Min(minSleepTime, b.m_sleepTime); + } + } + + if (minSleepTime >= b2Settings.b2_timeToSleep) + { + for (i = 0; i < this.m_bodyCount; ++i) + { + b = this.m_bodies[i]; + b.m_flags |= b2Body.e_sleepFlag; + } + } + }, + + AddBody: function(body) + { + //b2Settings.b2Assert(this.m_bodyCount < this.m_bodyCapacity); + this.m_bodies[this.m_bodyCount++] = body; + }, + + AddContact: function(contact) + { + //b2Settings.b2Assert(this.m_contactCount < this.m_contactCapacity); + this.m_contacts[this.m_contactCount++] = contact; + }, + + AddJoint: function(joint) + { + //b2Settings.b2Assert(this.m_jointCount < this.m_jointCapacity); + this.m_joints[this.m_jointCount++] = joint; + }, + + m_allocator: null, + + m_bodies: null, + m_contacts: null, + m_joints: null, + + m_bodyCount: 0, + m_jointCount: 0, + m_contactCount: 0, + + m_bodyCapacity: 0, + m_contactCapacity: 0, + m_jointCapacity: 0, + + m_positionError: null}; +b2Island.m_positionIterationCount = 0; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/b2TimeStep.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2TimeStep.js new file mode 100644 index 00000000..599390ed --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2TimeStep.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +var b2TimeStep = Class.create(); +b2TimeStep.prototype = +{ + dt: null, + inv_dt: null, + iterations: 0, + initialize: function() {}}; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/b2World.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2World.js new file mode 100644 index 00000000..b90ae436 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2World.js @@ -0,0 +1,522 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + +var b2World = Class.create(); +b2World.prototype = +{ + initialize: function(worldAABB, gravity, doSleep){ + // initialize instance variables for references + this.step = new b2TimeStep(); + this.m_contactManager = new b2ContactManager(); + // + + + this.m_listener = null; + this.m_filter = b2CollisionFilter.b2_defaultFilter; + + this.m_bodyList = null; + this.m_contactList = null; + this.m_jointList = null; + + this.m_bodyCount = 0; + this.m_contactCount = 0; + this.m_jointCount = 0; + + this.m_bodyDestroyList = null; + + this.m_allowSleep = doSleep; + + this.m_gravity = gravity; + + this.m_contactManager.m_world = this; + this.m_broadPhase = new b2BroadPhase(worldAABB, this.m_contactManager); + + var bd = new b2BodyDef(); + this.m_groundBody = this.CreateBody(bd); + }, + //~b2World(){ + // this.DestroyBody(this.m_groundBody); + // delete this.m_broadPhase; + //} + + // Set a callback to notify you when a joint is implicitly destroyed + // when an attached body is destroyed. + SetListener: function(listener){ + this.m_listener = listener; + }, + + // Register a collision filter to provide specific control over collision. + // Otherwise the default filter is used (b2CollisionFilter). + SetFilter: function(filter){ + this.m_filter = filter; + }, + + // Create and destroy rigid bodies. Destruction is deferred until the + // the next call to this.Step. This is done so that bodies may be destroyed + // while you iterate through the contact list. + CreateBody: function(def){ + //void* mem = this.m_blockAllocator.Allocate(sizeof(b2Body)); + 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; + }, + // Body destruction is deferred to make contact processing more robust. + DestroyBody: function(b) + { + + if (b.m_flags & b2Body.e_destroyFlag) + { + return; + } + + // Remove from normal body list. + 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; + } + + b.m_flags |= b2Body.e_destroyFlag; + //b2Settings.b2Assert(this.m_bodyCount > 0); + --this.m_bodyCount; + + //b->~b2Body(); + //b.Destroy(); + // Add to the deferred destruction list. + b.m_prev = null; + b.m_next = this.m_bodyDestroyList; + this.m_bodyDestroyList = b; + }, + + CleanBodyList: function() + { + this.m_contactManager.m_destroyImmediate = true; + + var b = this.m_bodyDestroyList; + while (b) + { + //b2Settings.b2Assert((b.m_flags & b2Body.e_destroyFlag) != 0); + + // Preserve the next pointer. + var b0 = b; + b = b.m_next; + + // Delete the attached joints + var jn = b0.m_jointList; + while (jn) + { + var jn0 = jn; + jn = jn.next; + + if (this.m_listener) + { + this.m_listener.NotifyJointDestroyed(jn0.joint); + } + + this.DestroyJoint(jn0.joint); + } + + b0.Destroy(); + //this.m_blockAllocator.Free(b0, sizeof(b2Body)); + } + + // Reset the list. + this.m_bodyDestroyList = null; + + this.m_contactManager.m_destroyImmediate = false; + }, + + CreateJoint: function(def){ + var j = b2Joint.Create(def, this.m_blockAllocator); + + // Connect to the world list. + 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; + + // Connect to the bodies + j.m_node1.joint = j; + j.m_node1.other = j.m_body2; + j.m_node1.prev = null; + j.m_node1.next = j.m_body1.m_jointList; + if (j.m_body1.m_jointList) j.m_body1.m_jointList.prev = j.m_node1; + j.m_body1.m_jointList = j.m_node1; + + j.m_node2.joint = j; + j.m_node2.other = j.m_body1; + j.m_node2.prev = null; + j.m_node2.next = j.m_body2.m_jointList; + if (j.m_body2.m_jointList) j.m_body2.m_jointList.prev = j.m_node2; + j.m_body2.m_jointList = j.m_node2; + + // If the joint prevents collisions, then reset collision filtering. + if (def.collideConnected == false) + { + // Reset the proxies on the body with the minimum number of shapes. + var b = def.body1.m_shapeCount < def.body2.m_shapeCount ? def.body1 : def.body2; + for (var s = b.m_shapeList; s; s = s.m_next) + { + s.ResetProxy(this.m_broadPhase); + } + } + + return j; + }, + DestroyJoint: function(j) + { + + var collideConnected = j.m_collideConnected; + + // Remove from the world. + 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; + } + + // Disconnect from island graph. + var body1 = j.m_body1; + var body2 = j.m_body2; + + // Wake up touching bodies. + body1.WakeUp(); + body2.WakeUp(); + + // Remove from body 1 + if (j.m_node1.prev) + { + j.m_node1.prev.next = j.m_node1.next; + } + + if (j.m_node1.next) + { + j.m_node1.next.prev = j.m_node1.prev; + } + + if (j.m_node1 == body1.m_jointList) + { + body1.m_jointList = j.m_node1.next; + } + + j.m_node1.prev = null; + j.m_node1.next = null; + + // Remove from body 2 + if (j.m_node2.prev) + { + j.m_node2.prev.next = j.m_node2.next; + } + + if (j.m_node2.next) + { + j.m_node2.next.prev = j.m_node2.prev; + } + + if (j.m_node2 == body2.m_jointList) + { + body2.m_jointList = j.m_node2.next; + } + + j.m_node2.prev = null; + j.m_node2.next = null; + + b2Joint.Destroy(j, this.m_blockAllocator); + + //b2Settings.b2Assert(this.m_jointCount > 0); + --this.m_jointCount; + + // If the joint prevents collisions, then reset collision filtering. + if (collideConnected == false) + { + // Reset the proxies on the body with the minimum number of shapes. + var b = body1.m_shapeCount < body2.m_shapeCount ? body1 : body2; + for (var s = b.m_shapeList; s; s = s.m_next) + { + s.ResetProxy(this.m_broadPhase); + } + } + }, + + // The world provides a single ground body with no collision shapes. You + // can use this to simplify the creation of joints. + GetGroundBody: function(){ + return this.m_groundBody; + }, + + + step: new b2TimeStep(), + // this.Step + Step: function(dt, iterations){ + + var b; + var other; + + + this.step.dt = dt; + this.step.iterations = iterations; + if (dt > 0.0) + { + this.step.inv_dt = 1.0 / dt; + } + else + { + this.step.inv_dt = 0.0; + } + + this.m_positionIterationCount = 0; + + // Handle deferred contact destruction. + this.m_contactManager.CleanContactList(); + + // Handle deferred body destruction. + this.CleanBodyList(); + + // Update contacts. + this.m_contactManager.Collide(); + + // Size the island for the worst case. + var island = new b2Island(this.m_bodyCount, this.m_contactCount, this.m_jointCount, this.m_stackAllocator); + + // Clear all the island flags. + for (b = this.m_bodyList; b != null; b = b.m_next) + { + b.m_flags &= ~b2Body.e_islandFlag; + } + for (var c = this.m_contactList; c != null; c = c.m_next) + { + c.m_flags &= ~b2Contact.e_islandFlag; + } + for (var j = this.m_jointList; j != null; j = j.m_next) + { + j.m_islandFlag = false; + } + + // Build and simulate all awake islands. + var stackSize = this.m_bodyCount; + //var stack = (b2Body**)this.m_stackAllocator.Allocate(stackSize * sizeof(b2Body*)); + var stack = new Array(this.m_bodyCount); + for (var k = 0; k < this.m_bodyCount; k++) + stack[k] = null; + + for (var seed = this.m_bodyList; seed != null; seed = seed.m_next) + { + if (seed.m_flags & (b2Body.e_staticFlag | b2Body.e_islandFlag | b2Body.e_sleepFlag | b2Body.e_frozenFlag)) + { + continue; + } + + // Reset island and stack. + island.Clear(); + var stackCount = 0; + stack[stackCount++] = seed; + seed.m_flags |= b2Body.e_islandFlag;; + + // Perform a depth first search (DFS) on the constraint graph. + while (stackCount > 0) + { + // Grab the next body off the stack and add it to the island. + b = stack[--stackCount]; + island.AddBody(b); + + // Make sure the body is awake. + b.m_flags &= ~b2Body.e_sleepFlag; + + // To keep islands, we don't + // propagate islands across static bodies. + if (b.m_flags & b2Body.e_staticFlag) + { + continue; + } + + // Search all contacts connected to this body. + for (var cn = b.m_contactList; cn != null; cn = cn.next) + { + if (cn.contact.m_flags & b2Contact.e_islandFlag) + { + continue; + } + + island.AddContact(cn.contact); + cn.contact.m_flags |= b2Contact.e_islandFlag; + + other = cn.other; + if (other.m_flags & b2Body.e_islandFlag) + { + continue; + } + + //b2Settings.b2Assert(stackCount < stackSize); + stack[stackCount++] = other; + other.m_flags |= b2Body.e_islandFlag; + } + + // Search all joints connect to this body. + for (var jn = b.m_jointList; jn != null; jn = jn.next) + { + if (jn.joint.m_islandFlag == true) + { + continue; + } + + island.AddJoint(jn.joint); + jn.joint.m_islandFlag = true; + + other = jn.other; + if (other.m_flags & b2Body.e_islandFlag) + { + continue; + } + + //b2Settings.b2Assert(stackCount < stackSize); + stack[stackCount++] = other; + other.m_flags |= b2Body.e_islandFlag; + } + } + + island.Solve(this.step, this.m_gravity); + + this.m_positionIterationCount = b2Math.b2Max(this.m_positionIterationCount, b2Island.m_positionIterationCount); + + if (this.m_allowSleep) + { + island.UpdateSleep(dt); + } + + // Post solve cleanup. + for (var i = 0; i < island.m_bodyCount; ++i) + { + // Allow static bodies to participate in other islands. + b = island.m_bodies[i]; + if (b.m_flags & b2Body.e_staticFlag) + { + b.m_flags &= ~b2Body.e_islandFlag; + } + + // Handle newly frozen bodies. + if (b.IsFrozen() && this.m_listener) + { + var response = this.m_listener.NotifyBoundaryViolated(b); + if (response == b2WorldListener.b2_destroyBody) + { + this.DestroyBody(b); + b = null; + island.m_bodies[i] = null; + } + } + } + } + + this.m_broadPhase.Commit(); + + //this.m_stackAllocator.Free(stack); + }, + + // this.Query the world for all shapes that potentially overlap the + // provided AABB. You provide a shape pointer buffer of specified + // size. The number of shapes found is returned. + Query: function(aabb, shapes, maxCount){ + + //void** results = (void**)this.m_stackAllocator.Allocate(maxCount * sizeof(void*)); + var results = new Array(); + var count = this.m_broadPhase.QueryAABB(aabb, results, maxCount); + + for (var i = 0; i < count; ++i) + { + shapes[i] = results[i]; + } + + //this.m_stackAllocator.Free(results); + return count; + }, + + // You can use these to iterate over all the bodies, joints, and contacts. + GetBodyList: function(){ + return this.m_bodyList; + }, + GetJointList: function(){ + return this.m_jointList; + }, + GetContactList: function(){ + return this.m_contactList; + }, + + //--------------- Internals Below ------------------- + + m_blockAllocator: null, + m_stackAllocator: null, + + m_broadPhase: null, + m_contactManager: new b2ContactManager(), + + m_bodyList: null, + m_contactList: null, + m_jointList: null, + + m_bodyCount: 0, + m_contactCount: 0, + m_jointCount: 0, + + // These bodies will be destroyed at the next time this.step. + m_bodyDestroyList: null, + + m_gravity: null, + m_allowSleep: null, + + m_groundBody: null, + + m_listener: null, + m_filter: null, + + m_positionIterationCount: 0}; +b2World.s_enablePositionCorrection = 1; +b2World.s_enableWarmStarting = 1; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/b2WorldListener.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2WorldListener.js new file mode 100644 index 00000000..9167570e --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/b2WorldListener.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + + +var b2WorldListener = Class.create(); +b2WorldListener.prototype = +{ + + // If a body is destroyed, then any joints attached to it are also destroyed. + // This prevents memory leaks, but you may unexpectedly be left with an + // orphaned joint pointer. + // Box2D will notify you when a joint is implicitly destroyed. + // It is NOT called if you directly destroy a joint. + // Implement this abstract class and provide it to b2World via + // b2World::SetListener(). + // DO NOT modify the Box2D world inside this callback. + NotifyJointDestroyed: function(joint){}, + + // This is called when a body's shape passes outside of the world boundary. If you + // override this and pass back e_destroyBody, you must nullify your copies of the + // body pointer. + NotifyBoundaryViolated: function(body) + { + //NOT_USED(body); + return b2WorldListener.b2_freezeBody; + }, + + + + initialize: function() {}}; +b2WorldListener.b2_freezeBody = 0; +b2WorldListener.b2_destroyBody = 1; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2CircleContact.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2CircleContact.js new file mode 100644 index 00000000..dc8df84e --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2CircleContact.js @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + +var b2CircleContact = Class.create(); +Object.extend(b2CircleContact.prototype, b2Contact.prototype); +Object.extend(b2CircleContact.prototype, +{ + + initialize: function(s1, s2) { + // The constructor for b2Contact + // initialize instance variables for references + this.m_node1 = new b2ContactNode(); + this.m_node2 = new b2ContactNode(); + // + this.m_flags = 0; + + if (!s1 || !s2){ + this.m_shape1 = null; + this.m_shape2 = null; + return; + } + + this.m_shape1 = s1; + this.m_shape2 = s2; + + this.m_manifoldCount = 0; + + this.m_friction = Math.sqrt(this.m_shape1.m_friction * this.m_shape2.m_friction); + this.m_restitution = b2Math.b2Max(this.m_shape1.m_restitution, this.m_shape2.m_restitution); + + this.m_prev = null; + this.m_next = null; + + this.m_node1.contact = null; + this.m_node1.prev = null; + this.m_node1.next = null; + this.m_node1.other = null; + + this.m_node2.contact = null; + this.m_node2.prev = null; + this.m_node2.next = null; + this.m_node2.other = null; + // + + // initialize instance variables for references + this.m_manifold = [new b2Manifold()]; + // + + //super(shape1, shape2); + + //b2Settings.b2Assert(this.m_shape1.m_type == b2Shape.e_circleShape); + //b2Settings.b2Assert(this.m_shape2.m_type == b2Shape.e_circleShape); + this.m_manifold[0].pointCount = 0; + this.m_manifold[0].points[0].normalImpulse = 0.0; + this.m_manifold[0].points[0].tangentImpulse = 0.0; + }, + //~b2CircleContact() {} + + Evaluate: function(){ + b2Collision.b2CollideCircle(this.m_manifold[0], this.m_shape1, this.m_shape2, false); + + if (this.m_manifold[0].pointCount > 0) + { + this.m_manifoldCount = 1; + } + else + { + this.m_manifoldCount = 0; + } + }, + + GetManifolds: function() + { + return this.m_manifold; + }, + + m_manifold: [new b2Manifold()]}); + +b2CircleContact.Create = function(shape1, shape2, allocator){ + return new b2CircleContact(shape1, shape2); + }; +b2CircleContact.Destroy = function(contact, allocator){ + // + }; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2Conservative.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2Conservative.js new file mode 100644 index 00000000..fe1cd4b9 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2Conservative.js @@ -0,0 +1,228 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2Conservative = Class.create(); +b2Conservative.prototype = { + + // Temp vars + + + + initialize: function() {}} +b2Conservative.R1 = new b2Mat22(); +b2Conservative.R2 = new b2Mat22(); +b2Conservative.x1 = new b2Vec2(); +b2Conservative.x2 = new b2Vec2(); +b2Conservative.Conservative = function(shape1, shape2){ + var body1 = shape1.GetBody(); + var body2 = shape2.GetBody(); + + //b2Vec2 v1 = body1->m_position - body1->m_position0; + var v1X = body1.m_position.x - body1.m_position0.x; + var v1Y = body1.m_position.y - body1.m_position0.y; + //float32 omega1 = body1->m_rotation - body1->m_rotation0; + var omega1 = body1.m_rotation - body1.m_rotation0; + //b2Vec2 v2 = body2->m_position - body2->m_position0; + var v2X = body2.m_position.x - body2.m_position0.x; + var v2Y = body2.m_position.y - body2.m_position0.y; + //float32 omega2 = body2->m_rotation - body2->m_rotation0; + var omega2 = body2.m_rotation - body2.m_rotation0; + + //float32 r1 = shape1->GetMaxRadius(); + var r1 = shape1.GetMaxRadius(); + //float32 r2 = shape2->GetMaxRadius(); + var r2 = shape2.GetMaxRadius(); + + //b2Vec2 p1Start = body1->m_position0; + var p1StartX = body1.m_position0.x; + var p1StartY = body1.m_position0.y; + //float32 a1Start = body1->m_rotation0; + var a1Start = body1.m_rotation0; + + //b2Vec2 p2Start = body2->m_position0; + var p2StartX = body2.m_position0.x; + var p2StartY = body2.m_position0.y; + //float32 a2Start = body2->m_rotation0; + var a2Start = body2.m_rotation0; + + //b2Vec2 p1 = p1Start; + var p1X = p1StartX; + var p1Y = p1StartY; + //float32 a1 = a1Start; + var a1 = a1Start; + //b2Vec2 p2 = p2Start; + var p2X = p2StartX; + var p2Y = p2StartY; + //float32 a2 = a2Start; + var a2 = a2Start; + + //b2Mat22 b2Conservative.R1(a1), b2Conservative.R2(a2); + b2Conservative.R1.Set(a1); + b2Conservative.R2.Set(a2); + + //shape1->QuickSync(p1, b2Conservative.R1); + shape1.QuickSync(p1, b2Conservative.R1); + //shape2->QuickSync(p2, b2Conservative.R2); + shape2.QuickSync(p2, b2Conservative.R2); + + //float32 s1 = 0.0f; + var s1 = 0.0; + //const int32 maxIterations = 10; + var maxIterations = 10; + //b2Vec2 d; + var dX; + var dY; + //float32 invRelativeVelocity = 0.0f; + var invRelativeVelocity = 0.0; + //bool hit = true; + var hit = true; + //b2Vec2 b2Conservative.x1, b2Conservative.x2; moved to static var + for (var iter = 0; iter < maxIterations; ++iter) + { + // Get the accurate distance between shapes. + //float32 distance = b2Distance.Distance(&b2Conservative.x1, &b2Conservative.x2, shape1, shape2); + var distance = b2Distance.Distance(b2Conservative.x1, b2Conservative.x2, shape1, shape2); + if (distance < b2Settings.b2_linearSlop) + { + if (iter == 0) + { + hit = false; + } + else + { + hit = true; + } + break; + } + + if (iter == 0) + { + //b2Vec2 d = b2Conservative.x2 - b2Conservative.x1; + dX = b2Conservative.x2.x - b2Conservative.x1.x; + dY = b2Conservative.x2.y - b2Conservative.x1.y; + //d.Normalize(); + var dLen = Math.sqrt(dX*dX + dY*dY); + //float32 relativeVelocity = b2Dot(d, v1 - v2) + b2Abs(omega1) * r1 + b2Abs(omega2) * r2; + var relativeVelocity = (dX*(v1X-v2X) + dY*(v1Y - v2Y)) + Math.abs(omega1) * r1 + Math.abs(omega2) * r2; + if (Math.abs(relativeVelocity) < Number.MIN_VALUE) + { + hit = false; + break; + } + + invRelativeVelocity = 1.0 / relativeVelocity; + } + + // Get the conservative movement. + //float32 ds = distance * invRelativeVelocity; + var ds = distance * invRelativeVelocity; + //float32 s2 = s1 + ds; + var s2 = s1 + ds; + + if (s2 < 0.0 || 1.0 < s2) + { + hit = false; + break; + } + + if (s2 < (1.0 + 100.0 * Number.MIN_VALUE) * s1) + { + hit = true; + break; + } + + s1 = s2; + + // Move forward conservatively. + //p1 = p1Start + s1 * v1; + p1X = p1StartX + s1 * v1.x; + p1Y = p1StartY + s1 * v1.y; + //a1 = a1Start + s1 * omega1; + a1 = a1Start + s1 * omega1; + //p2 = p2Start + s1 * v2; + p2X = p2StartX + s1 * v2.x; + p2Y = p2StartY + s1 * v2.y; + //a2 = a2Start + s1 * omega2; + a2 = a2Start + s1 * omega2; + + b2Conservative.R1.Set(a1); + b2Conservative.R2.Set(a2); + shape1.QuickSync(p1, b2Conservative.R1); + shape2.QuickSync(p2, b2Conservative.R2); + } + + if (hit) + { + // Hit, move bodies to safe position and re-sync shapes. + //b2Vec2 d = b2Conservative.x2 - b2Conservative.x1; + dX = b2Conservative.x2.x - b2Conservative.x1.x; + dY = b2Conservative.x2.y - b2Conservative.x1.y; + //float32 length = d.Length(); + var length = Math.sqrt(dX*dX + dY*dY); + if (length > FLT_EPSILON) + { + d *= b2_linearSlop / length; + } + + if (body1.IsStatic()) + { + //body1.m_position = p1; + body1.m_position.x = p1X; + body1.m_position.y = p1Y; + } + else + { + //body1.m_position = p1 - d; + body1.m_position.x = p1X - dX; + body1.m_position.y = p1Y - dY; + } + body1.m_rotation = a1; + body1.m_R.Set(a1); + body1.QuickSyncShapes(); + + if (body2.IsStatic()) + { + //body2->m_position = p2; + body2.m_position.x = p2X; + body2.m_position.y = p2Y; + } + else + { + //body2->m_position = p2 + d; + body2.m_position.x = p2X + dX; + body2.m_position.y = p2Y + dY; + } + //body2.m_position = p2 + d; + body2.m_position.x = p2X + dX; + body2.m_position.y = p2Y + dY; + body2.m_rotation = a2; + body2.m_R.Set(a2); + body2.QuickSyncShapes(); + + return true; + } + + // No hit, restore shapes. + shape1.QuickSync(body1.m_position, body1.m_R); + shape2.QuickSync(body2.m_position, body2.m_R); + return false; + }; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2Contact.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2Contact.js new file mode 100644 index 00000000..283feafa --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2Contact.js @@ -0,0 +1,201 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +//typedef b2Contact* b2ContactCreateFcn(b2Shape* shape1, b2Shape* shape2, b2BlockAllocator* allocator); +//typedef void b2ContactDestroyFcn(b2Contact* contact, b2BlockAllocator* allocator); + + + +var b2Contact = Class.create(); +b2Contact.prototype = +{ + GetManifolds: function(){return null}, + GetManifoldCount: function() + { + return this.m_manifoldCount; + }, + + GetNext: function(){ + return this.m_next; + }, + + GetShape1: function(){ + return this.m_shape1; + }, + + GetShape2: function(){ + return this.m_shape2; + }, + + //--------------- Internals Below ------------------- + + // this.m_flags + // enum + + + initialize: function(s1, s2) + { + // initialize instance variables for references + this.m_node1 = new b2ContactNode(); + this.m_node2 = new b2ContactNode(); + // + + this.m_flags = 0; + + if (!s1 || !s2){ + this.m_shape1 = null; + this.m_shape2 = null; + return; + } + + this.m_shape1 = s1; + this.m_shape2 = s2; + + this.m_manifoldCount = 0; + + this.m_friction = Math.sqrt(this.m_shape1.m_friction * this.m_shape2.m_friction); + this.m_restitution = b2Math.b2Max(this.m_shape1.m_restitution, this.m_shape2.m_restitution); + + this.m_prev = null; + this.m_next = null; + + this.m_node1.contact = null; + this.m_node1.prev = null; + this.m_node1.next = null; + this.m_node1.other = null; + + this.m_node2.contact = null; + this.m_node2.prev = null; + this.m_node2.next = null; + this.m_node2.other = null; + }, + + //virtual ~b2Contact() {} + + Evaluate: function(){}, + + m_flags: 0, + + // World pool and list pointers. + m_prev: null, + m_next: null, + + // Nodes for connecting bodies. + m_node1: new b2ContactNode(), + m_node2: new b2ContactNode(), + + m_shape1: null, + m_shape2: null, + + m_manifoldCount: 0, + + // Combined friction + m_friction: null, + m_restitution: null}; +b2Contact.e_islandFlag = 0x0001; +b2Contact.e_destroyFlag = 0x0002; +b2Contact.AddType = function(createFcn, destroyFcn, type1, type2) + { + //b2Settings.b2Assert(b2Shape.e_unknownShape < type1 && type1 < b2Shape.e_shapeTypeCount); + //b2Settings.b2Assert(b2Shape.e_unknownShape < type2 && type2 < b2Shape.e_shapeTypeCount); + + b2Contact.s_registers[type1][type2].createFcn = createFcn; + b2Contact.s_registers[type1][type2].destroyFcn = destroyFcn; + b2Contact.s_registers[type1][type2].primary = true; + + if (type1 != type2) + { + b2Contact.s_registers[type2][type1].createFcn = createFcn; + b2Contact.s_registers[type2][type1].destroyFcn = destroyFcn; + b2Contact.s_registers[type2][type1].primary = false; + } + }; +b2Contact.InitializeRegisters = function(){ + b2Contact.s_registers = new Array(b2Shape.e_shapeTypeCount); + for (var i = 0; i < b2Shape.e_shapeTypeCount; i++){ + b2Contact.s_registers[i] = new Array(b2Shape.e_shapeTypeCount); + for (var j = 0; j < b2Shape.e_shapeTypeCount; j++){ + b2Contact.s_registers[i][j] = new b2ContactRegister(); + } + } + + b2Contact.AddType(b2CircleContact.Create, b2CircleContact.Destroy, b2Shape.e_circleShape, b2Shape.e_circleShape); + b2Contact.AddType(b2PolyAndCircleContact.Create, b2PolyAndCircleContact.Destroy, b2Shape.e_polyShape, b2Shape.e_circleShape); + b2Contact.AddType(b2PolyContact.Create, b2PolyContact.Destroy, b2Shape.e_polyShape, b2Shape.e_polyShape); + + }; +b2Contact.Create = function(shape1, shape2, allocator){ + if (b2Contact.s_initialized == false) + { + b2Contact.InitializeRegisters(); + b2Contact.s_initialized = true; + } + + var type1 = shape1.m_type; + var type2 = shape2.m_type; + + //b2Settings.b2Assert(b2Shape.e_unknownShape < type1 && type1 < b2Shape.e_shapeTypeCount); + //b2Settings.b2Assert(b2Shape.e_unknownShape < type2 && type2 < b2Shape.e_shapeTypeCount); + + var createFcn = b2Contact.s_registers[type1][type2].createFcn; + if (createFcn) + { + if (b2Contact.s_registers[type1][type2].primary) + { + return createFcn(shape1, shape2, allocator); + } + else + { + var c = createFcn(shape2, shape1, allocator); + for (var i = 0; i < c.GetManifoldCount(); ++i) + { + var m = c.GetManifolds()[ i ]; + m.normal = m.normal.Negative(); + } + return c; + } + } + else + { + return null; + } + }; +b2Contact.Destroy = function(contact, allocator){ + //b2Settings.b2Assert(b2Contact.s_initialized == true); + + if (contact.GetManifoldCount() > 0) + { + contact.m_shape1.m_body.WakeUp(); + contact.m_shape2.m_body.WakeUp(); + } + + var type1 = contact.m_shape1.m_type; + var type2 = contact.m_shape2.m_type; + + //b2Settings.b2Assert(b2Shape.e_unknownShape < type1 && type1 < b2Shape.e_shapeTypeCount); + //b2Settings.b2Assert(b2Shape.e_unknownShape < type2 && type2 < b2Shape.e_shapeTypeCount); + + var destroyFcn = b2Contact.s_registers[type1][type2].destroyFcn; + destroyFcn(contact, allocator); + }; +b2Contact.s_registers = null; +b2Contact.s_initialized = false; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactConstraint.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactConstraint.js new file mode 100644 index 00000000..79b82e1f --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactConstraint.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2ContactConstraint = Class.create(); +b2ContactConstraint.prototype = +{ + initialize: function(){ + // initialize instance variables for references + this.normal = new b2Vec2(); + // + + this.points = new Array(b2Settings.b2_maxManifoldPoints); + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++){ + this.points[i] = new b2ContactConstraintPoint(); + } + + + }, + points: null, + normal: new b2Vec2(), + manifold: null, + body1: null, + body2: null, + friction: null, + restitution: null, + pointCount: 0}; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactConstraintPoint.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactConstraintPoint.js new file mode 100644 index 00000000..bc3dca6e --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactConstraintPoint.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2ContactConstraintPoint = Class.create(); +b2ContactConstraintPoint.prototype = +{ + localAnchor1: new b2Vec2(), + localAnchor2: new b2Vec2(), + normalImpulse: null, + tangentImpulse: null, + positionImpulse: null, + normalMass: null, + tangentMass: null, + separation: null, + velocityBias: null, + initialize: function() { + // initialize instance variables for references + this.localAnchor1 = new b2Vec2(); + this.localAnchor2 = new b2Vec2(); + // +}}; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactNode.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactNode.js new file mode 100644 index 00000000..c10e4826 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactNode.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2ContactNode = Class.create(); +b2ContactNode.prototype = +{ + other: null, + contact: null, + prev: null, + next: null, + initialize: function() {}}; + + + diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactRegister.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactRegister.js new file mode 100644 index 00000000..524c352b --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactRegister.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +var b2ContactRegister = Class.create(); +b2ContactRegister.prototype = +{ + createFcn: null, + destroyFcn: null, + primary: null, + initialize: function() {}}; + + + diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactSolver.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactSolver.js new file mode 100644 index 00000000..0b0d3f44 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2ContactSolver.js @@ -0,0 +1,537 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2ContactSolver = Class.create(); +b2ContactSolver.prototype = +{ + initialize: function(contacts, contactCount, allocator){ + // initialize instance variables for references + this.m_constraints = new Array(); + // + + this.m_allocator = allocator; + + var i = 0; + var tVec; + var tMat; + + this.m_constraintCount = 0; + for (i = 0; i < contactCount; ++i) + { + this.m_constraintCount += contacts[i].GetManifoldCount(); + } + + // fill array + for (i = 0; i < this.m_constraintCount; i++){ + this.m_constraints[i] = new b2ContactConstraint(); + } + + var count = 0; + for (i = 0; i < contactCount; ++i) + { + var contact = contacts[i]; + var b1 = contact.m_shape1.m_body; + var b2 = contact.m_shape2.m_body; + var manifoldCount = contact.GetManifoldCount(); + var manifolds = contact.GetManifolds(); + var friction = contact.m_friction; + var restitution = contact.m_restitution; + + //var v1 = b1.m_linearVelocity.Copy(); + var v1X = b1.m_linearVelocity.x; + var v1Y = b1.m_linearVelocity.y; + //var v2 = b2.m_linearVelocity.Copy(); + var v2X = b2.m_linearVelocity.x; + var v2Y = b2.m_linearVelocity.y; + var w1 = b1.m_angularVelocity; + var w2 = b2.m_angularVelocity; + + for (var j = 0; j < manifoldCount; ++j) + { + var manifold = manifolds[ j ]; + + //b2Settings.b2Assert(manifold.pointCount > 0); + + //var normal = manifold.normal.Copy(); + var normalX = manifold.normal.x; + var normalY = manifold.normal.y; + + //b2Settings.b2Assert(count < this.m_constraintCount); + var c = this.m_constraints[ count ]; + c.body1 = b1; + c.body2 = b2; + c.manifold = manifold; + //c.normal = normal; + c.normal.x = normalX; + c.normal.y = normalY; + c.pointCount = manifold.pointCount; + c.friction = friction; + c.restitution = restitution; + + for (var k = 0; k < c.pointCount; ++k) + { + var cp = manifold.points[ k ]; + var ccp = c.points[ k ]; + + ccp.normalImpulse = cp.normalImpulse; + ccp.tangentImpulse = cp.tangentImpulse; + ccp.separation = cp.separation; + + //var r1 = b2Math.SubtractVV( cp.position, b1.m_position ); + var r1X = cp.position.x - b1.m_position.x; + var r1Y = cp.position.y - b1.m_position.y; + //var r2 = b2Math.SubtractVV( cp.position, b2.m_position ); + var r2X = cp.position.x - b2.m_position.x; + var r2Y = cp.position.y - b2.m_position.y; + + //ccp.localAnchor1 = b2Math.b2MulTMV(b1.m_R, r1); + tVec = ccp.localAnchor1; + tMat = b1.m_R; + tVec.x = r1X * tMat.col1.x + r1Y * tMat.col1.y; + tVec.y = r1X * tMat.col2.x + r1Y * tMat.col2.y; + + //ccp.localAnchor2 = b2Math.b2MulTMV(b2.m_R, r2); + tVec = ccp.localAnchor2; + tMat = b2.m_R; + tVec.x = r2X * tMat.col1.x + r2Y * tMat.col1.y; + tVec.y = r2X * tMat.col2.x + r2Y * tMat.col2.y; + + var r1Sqr = r1X * r1X + r1Y * r1Y; + var r2Sqr = r2X * r2X + r2Y * r2Y; + + //var rn1 = b2Math.b2Dot(r1, normal); + var rn1 = r1X*normalX + r1Y*normalY; + //var rn2 = b2Math.b2Dot(r2, normal); + var rn2 = r2X*normalX + r2Y*normalY; + var kNormal = b1.m_invMass + b2.m_invMass; + kNormal += b1.m_invI * (r1Sqr - rn1 * rn1) + b2.m_invI * (r2Sqr - rn2 * rn2); + //b2Settings.b2Assert(kNormal > Number.MIN_VALUE); + ccp.normalMass = 1.0 / kNormal; + + //var tangent = b2Math.b2CrossVF(normal, 1.0); + var tangentX = normalY + var tangentY = -normalX; + + //var rt1 = b2Math.b2Dot(r1, tangent); + var rt1 = r1X*tangentX + r1Y*tangentY; + //var rt2 = b2Math.b2Dot(r2, tangent); + var rt2 = r2X*tangentX + r2Y*tangentY; + var kTangent = b1.m_invMass + b2.m_invMass; + kTangent += b1.m_invI * (r1Sqr - rt1 * rt1) + b2.m_invI * (r2Sqr - rt2 * rt2); + //b2Settings.b2Assert(kTangent > Number.MIN_VALUE); + ccp.tangentMass = 1.0 / kTangent; + + // Setup a velocity bias for restitution. + ccp.velocityBias = 0.0; + if (ccp.separation > 0.0) + { + ccp.velocityBias = -60.0 * ccp.separation; + } + //var vRel = b2Math.b2Dot(c.normal, b2Math.SubtractVV( b2Math.SubtractVV( b2Math.AddVV( v2, b2Math.b2CrossFV(w2, r2)), v1 ), b2Math.b2CrossFV(w1, r1))); + var tX = v2X + (-w2*r2Y) - v1X - (-w1*r1Y); + var tY = v2Y + (w2*r2X) - v1Y - (w1*r1X); + //var vRel = b2Dot(c.normal, tX/Y); + var vRel = c.normal.x*tX + c.normal.y*tY; + if (vRel < -b2Settings.b2_velocityThreshold) + { + ccp.velocityBias += -c.restitution * vRel; + } + } + + ++count; + } + } + + //b2Settings.b2Assert(count == this.m_constraintCount); + }, + //~b2ContactSolver(); + + PreSolve: function(){ + var tVec; + var tVec2; + var tMat; + + // Warm start. + for (var i = 0; i < this.m_constraintCount; ++i) + { + var c = this.m_constraints[ i ]; + + var b1 = c.body1; + var b2 = c.body2; + var invMass1 = b1.m_invMass; + var invI1 = b1.m_invI; + var invMass2 = b2.m_invMass; + var invI2 = b2.m_invI; + //var normal = new b2Vec2(c.normal.x, c.normal.y); + var normalX = c.normal.x; + var normalY = c.normal.y; + //var tangent = b2Math.b2CrossVF(normal, 1.0); + var tangentX = normalY; + var tangentY = -normalX; + + var j = 0; + var tCount = 0; + if (b2World.s_enableWarmStarting) + { + tCount = c.pointCount; + for (j = 0; j < tCount; ++j) + { + var ccp = c.points[ j ]; + //var P = b2Math.AddVV( b2Math.MulFV(ccp.normalImpulse, normal), b2Math.MulFV(ccp.tangentImpulse, tangent)); + var PX = ccp.normalImpulse*normalX + ccp.tangentImpulse*tangentX; + var PY = ccp.normalImpulse*normalY + ccp.tangentImpulse*tangentY; + + //var r1 = b2Math.b2MulMV(b1.m_R, ccp.localAnchor1); + tMat = b1.m_R; + tVec = ccp.localAnchor1; + var r1X = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + var r1Y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + + //var r2 = b2Math.b2MulMV(b2.m_R, ccp.localAnchor2); + tMat = b2.m_R; + tVec = ccp.localAnchor2; + var r2X = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + var r2Y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + + //b1.m_angularVelocity -= invI1 * b2Math.b2CrossVV(r1, P); + b1.m_angularVelocity -= invI1 * (r1X * PY - r1Y * PX); + //b1.m_linearVelocity.Subtract( b2Math.MulFV(invMass1, P) ); + b1.m_linearVelocity.x -= invMass1 * PX; + b1.m_linearVelocity.y -= invMass1 * PY; + //b2.m_angularVelocity += invI2 * b2Math.b2CrossVV(r2, P); + b2.m_angularVelocity += invI2 * (r2X * PY - r2Y * PX); + //b2.m_linearVelocity.Add( b2Math.MulFV(invMass2, P) ); + b2.m_linearVelocity.x += invMass2 * PX; + b2.m_linearVelocity.y += invMass2 * PY; + + ccp.positionImpulse = 0.0; + } + } + else{ + tCount = c.pointCount; + for (j = 0; j < tCount; ++j) + { + var ccp2 = c.points[ j ]; + ccp2.normalImpulse = 0.0; + ccp2.tangentImpulse = 0.0; + + ccp2.positionImpulse = 0.0; + } + } + } + }, + SolveVelocityConstraints: function(){ + var j = 0; + var ccp; + var r1X; + var r1Y; + var r2X; + var r2Y; + var dvX; + var dvY; + var lambda; + var newImpulse; + var PX; + var PY; + + var tMat; + var tVec; + + for (var i = 0; i < this.m_constraintCount; ++i) + { + var c = this.m_constraints[ i ]; + var b1 = c.body1; + var b2 = c.body2; + var b1_angularVelocity = b1.m_angularVelocity; + var b1_linearVelocity = b1.m_linearVelocity; + var b2_angularVelocity = b2.m_angularVelocity; + var b2_linearVelocity = b2.m_linearVelocity; + + var invMass1 = b1.m_invMass; + var invI1 = b1.m_invI; + var invMass2 = b2.m_invMass; + var invI2 = b2.m_invI; + //var normal = new b2Vec2(c.normal.x, c.normal.y); + var normalX = c.normal.x; + var normalY = c.normal.y; + //var tangent = b2Math.b2CrossVF(normal, 1.0); + var tangentX = normalY; + var tangentY = -normalX; + + // Solver normal constraints + var tCount = c.pointCount; + for (j = 0; j < tCount; ++j) + { + ccp = c.points[ j ]; + + //r1 = b2Math.b2MulMV(b1.m_R, ccp.localAnchor1); + tMat = b1.m_R; + tVec = ccp.localAnchor1; + r1X = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y + r1Y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y + //r2 = b2Math.b2MulMV(b2.m_R, ccp.localAnchor2); + tMat = b2.m_R; + tVec = ccp.localAnchor2; + r2X = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y + r2Y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y + + // Relative velocity at contact + //var dv = b2Math.SubtractVV( b2Math.AddVV( b2.m_linearVelocity, b2Math.b2CrossFV(b2.m_angularVelocity, r2)), b2Math.SubtractVV(b1.m_linearVelocity, b2Math.b2CrossFV(b1.m_angularVelocity, r1))); + //dv = b2Math.SubtractVV(b2Math.SubtractVV( b2Math.AddVV( b2.m_linearVelocity, b2Math.b2CrossFV(b2.m_angularVelocity, r2)), b1.m_linearVelocity), b2Math.b2CrossFV(b1.m_angularVelocity, r1)); + dvX = b2_linearVelocity.x + (-b2_angularVelocity * r2Y) - b1_linearVelocity.x - (-b1_angularVelocity * r1Y); + dvY = b2_linearVelocity.y + (b2_angularVelocity * r2X) - b1_linearVelocity.y - (b1_angularVelocity * r1X); + + // Compute normal impulse + //var vn = b2Math.b2Dot(dv, normal); + var vn = dvX * normalX + dvY * normalY; + lambda = -ccp.normalMass * (vn - ccp.velocityBias); + + // b2Clamp the accumulated impulse + newImpulse = b2Math.b2Max(ccp.normalImpulse + lambda, 0.0); + lambda = newImpulse - ccp.normalImpulse; + + // Apply contact impulse + //P = b2Math.MulFV(lambda, normal); + PX = lambda * normalX; + PY = lambda * normalY; + + //b1.m_linearVelocity.Subtract( b2Math.MulFV( invMass1, P ) ); + b1_linearVelocity.x -= invMass1 * PX; + b1_linearVelocity.y -= invMass1 * PY; + b1_angularVelocity -= invI1 * (r1X * PY - r1Y * PX); + + //b2.m_linearVelocity.Add( b2Math.MulFV( invMass2, P ) ); + b2_linearVelocity.x += invMass2 * PX; + b2_linearVelocity.y += invMass2 * PY; + b2_angularVelocity += invI2 * (r2X * PY - r2Y * PX); + + ccp.normalImpulse = newImpulse; + + + + // MOVED FROM BELOW + // Relative velocity at contact + //var dv = b2.m_linearVelocity + b2Cross(b2.m_angularVelocity, r2) - b1.m_linearVelocity - b2Cross(b1.m_angularVelocity, r1); + //dv = b2Math.SubtractVV(b2Math.SubtractVV(b2Math.AddVV(b2.m_linearVelocity, b2Math.b2CrossFV(b2.m_angularVelocity, r2)), b1.m_linearVelocity), b2Math.b2CrossFV(b1.m_angularVelocity, r1)); + dvX = b2_linearVelocity.x + (-b2_angularVelocity * r2Y) - b1_linearVelocity.x - (-b1_angularVelocity * r1Y); + dvY = b2_linearVelocity.y + (b2_angularVelocity * r2X) - b1_linearVelocity.y - (b1_angularVelocity * r1X); + + // Compute tangent impulse + var vt = dvX*tangentX + dvY*tangentY; + lambda = ccp.tangentMass * (-vt); + + // b2Clamp the accumulated impulse + var maxFriction = c.friction * ccp.normalImpulse; + newImpulse = b2Math.b2Clamp(ccp.tangentImpulse + lambda, -maxFriction, maxFriction); + lambda = newImpulse - ccp.tangentImpulse; + + // Apply contact impulse + //P = b2Math.MulFV(lambda, tangent); + PX = lambda * tangentX; + PY = lambda * tangentY; + + //b1.m_linearVelocity.Subtract( b2Math.MulFV( invMass1, P ) ); + b1_linearVelocity.x -= invMass1 * PX; + b1_linearVelocity.y -= invMass1 * PY; + b1_angularVelocity -= invI1 * (r1X * PY - r1Y * PX); + + //b2.m_linearVelocity.Add( b2Math.MulFV( invMass2, P ) ); + b2_linearVelocity.x += invMass2 * PX; + b2_linearVelocity.y += invMass2 * PY; + b2_angularVelocity += invI2 * (r2X * PY - r2Y * PX); + + ccp.tangentImpulse = newImpulse; + } + + + + // Solver tangent constraints + // MOVED ABOVE FOR EFFICIENCY + /*for (j = 0; j < tCount; ++j) + { + ccp = c.points[ j ]; + + //r1 = b2Math.b2MulMV(b1.m_R, ccp.localAnchor1); + tMat = b1.m_R; + tVec = ccp.localAnchor1; + r1X = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y + r1Y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y + //r2 = b2Math.b2MulMV(b2.m_R, ccp.localAnchor2); + tMat = b2.m_R; + tVec = ccp.localAnchor2; + r2X = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y + r2Y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y + + // Relative velocity at contact + //var dv = b2.m_linearVelocity + b2Cross(b2.m_angularVelocity, r2) - b1.m_linearVelocity - b2Cross(b1.m_angularVelocity, r1); + //dv = b2Math.SubtractVV(b2Math.SubtractVV(b2Math.AddVV(b2.m_linearVelocity, b2Math.b2CrossFV(b2.m_angularVelocity, r2)), b1.m_linearVelocity), b2Math.b2CrossFV(b1.m_angularVelocity, r1)); + dvX = b2_linearVelocity.x + (-b2_angularVelocity * r2Y) - b1_linearVelocity.x - (-b1_angularVelocity * r1Y); + dvY = b2_linearVelocity.y + (b2_angularVelocity * r2X) - b1_linearVelocity.y - (b1_angularVelocity * r1X); + + // Compute tangent impulse + var vt = dvX*tangentX + dvY*tangentY; + lambda = ccp.tangentMass * (-vt); + + // b2Clamp the accumulated impulse + var maxFriction = c.friction * ccp.normalImpulse; + newImpulse = b2Math.b2Clamp(ccp.tangentImpulse + lambda, -maxFriction, maxFriction); + lambda = newImpulse - ccp.tangentImpulse; + + // Apply contact impulse + //P = b2Math.MulFV(lambda, tangent); + PX = lambda * tangentX; + PY = lambda * tangentY; + + //b1.m_linearVelocity.Subtract( b2Math.MulFV( invMass1, P ) ); + b1_linearVelocity.x -= invMass1 * PX; + b1_linearVelocity.y -= invMass1 * PY; + b1_angularVelocity -= invI1 * (r1X * PY - r1Y * PX); + + //b2.m_linearVelocity.Add( b2Math.MulFV( invMass2, P ) ); + b2_linearVelocity.x += invMass2 * PX; + b2_linearVelocity.y += invMass2 * PY; + b2_angularVelocity += invI2 * (r2X * PY - r2Y * PX); + + ccp.tangentImpulse = newImpulse; + }*/ + + // Update angular velocity + b1.m_angularVelocity = b1_angularVelocity; + b2.m_angularVelocity = b2_angularVelocity; + } + }, + SolvePositionConstraints: function(beta){ + var minSeparation = 0.0; + + var tMat; + var tVec; + + for (var i = 0; i < this.m_constraintCount; ++i) + { + var c = this.m_constraints[ i ]; + var b1 = c.body1; + var b2 = c.body2; + var b1_position = b1.m_position; + var b1_rotation = b1.m_rotation; + var b2_position = b2.m_position; + var b2_rotation = b2.m_rotation; + + var invMass1 = b1.m_invMass; + var invI1 = b1.m_invI; + var invMass2 = b2.m_invMass; + var invI2 = b2.m_invI; + //var normal = new b2Vec2(c.normal.x, c.normal.y); + var normalX = c.normal.x; + var normalY = c.normal.y; + //var tangent = b2Math.b2CrossVF(normal, 1.0); + var tangentX = normalY; + var tangentY = -normalX; + + // Solver normal constraints + var tCount = c.pointCount; + for (var j = 0; j < tCount; ++j) + { + var ccp = c.points[ j ]; + + //r1 = b2Math.b2MulMV(b1.m_R, ccp.localAnchor1); + tMat = b1.m_R; + tVec = ccp.localAnchor1; + var r1X = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y + var r1Y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y + //r2 = b2Math.b2MulMV(b2.m_R, ccp.localAnchor2); + tMat = b2.m_R; + tVec = ccp.localAnchor2; + var r2X = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y + var r2Y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y + + //var p1 = b2Math.AddVV(b1.m_position, r1); + var p1X = b1_position.x + r1X; + var p1Y = b1_position.y + r1Y; + + //var p2 = b2Math.AddVV(b2.m_position, r2); + var p2X = b2_position.x + r2X; + var p2Y = b2_position.y + r2Y; + + //var dp = b2Math.SubtractVV(p2, p1); + var dpX = p2X - p1X; + var dpY = p2Y - p1Y; + + // Approximate the current separation. + //var separation = b2Math.b2Dot(dp, normal) + ccp.separation; + var separation = (dpX*normalX + dpY*normalY) + ccp.separation; + + // Track max constraint error. + minSeparation = b2Math.b2Min(minSeparation, separation); + + // Prevent large corrections and allow slop. + var C = beta * b2Math.b2Clamp(separation + b2Settings.b2_linearSlop, -b2Settings.b2_maxLinearCorrection, 0.0); + + // Compute normal impulse + var dImpulse = -ccp.normalMass * C; + + // b2Clamp the accumulated impulse + var impulse0 = ccp.positionImpulse; + ccp.positionImpulse = b2Math.b2Max(impulse0 + dImpulse, 0.0); + dImpulse = ccp.positionImpulse - impulse0; + + //var impulse = b2Math.MulFV( dImpulse, normal ); + var impulseX = dImpulse * normalX; + var impulseY = dImpulse * normalY; + + //b1.m_position.Subtract( b2Math.MulFV( invMass1, impulse ) ); + b1_position.x -= invMass1 * impulseX; + b1_position.y -= invMass1 * impulseY; + b1_rotation -= invI1 * (r1X * impulseY - r1Y * impulseX); + b1.m_R.Set(b1_rotation); + + //b2.m_position.Add( b2Math.MulFV( invMass2, impulse ) ); + b2_position.x += invMass2 * impulseX; + b2_position.y += invMass2 * impulseY; + b2_rotation += invI2 * (r2X * impulseY - r2Y * impulseX); + b2.m_R.Set(b2_rotation); + } + // Update body rotations + b1.m_rotation = b1_rotation; + b2.m_rotation = b2_rotation; + } + + return minSeparation >= -b2Settings.b2_linearSlop; + }, + PostSolve: 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 mPoint = m.points[j]; + var cPoint = c.points[j]; + mPoint.normalImpulse = cPoint.normalImpulse; + mPoint.tangentImpulse = cPoint.tangentImpulse; + } + } + }, + + m_allocator: null, + m_constraints: new Array(), + m_constraintCount: 0}; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2NullContact.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2NullContact.js new file mode 100644 index 00000000..faa2bb40 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2NullContact.js @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2NullContact = Class.create(); +Object.extend(b2NullContact.prototype, b2Contact.prototype); +Object.extend(b2NullContact.prototype, +{ + initialize: function(s1, s2) { + // The constructor for b2Contact + // initialize instance variables for references + this.m_node1 = new b2ContactNode(); + this.m_node2 = new b2ContactNode(); + // + this.m_flags = 0; + + if (!s1 || !s2){ + this.m_shape1 = null; + this.m_shape2 = null; + return; + } + + this.m_shape1 = s1; + this.m_shape2 = s2; + + this.m_manifoldCount = 0; + + this.m_friction = Math.sqrt(this.m_shape1.m_friction * this.m_shape2.m_friction); + this.m_restitution = b2Math.b2Max(this.m_shape1.m_restitution, this.m_shape2.m_restitution); + + this.m_prev = null; + this.m_next = null; + + this.m_node1.contact = null; + this.m_node1.prev = null; + this.m_node1.next = null; + this.m_node1.other = null; + + this.m_node2.contact = null; + this.m_node2.prev = null; + this.m_node2.next = null; + this.m_node2.other = null; + // +}, + Evaluate: function() {}, + GetManifolds: function(){ return null; }}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2PolyAndCircleContact.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2PolyAndCircleContact.js new file mode 100644 index 00000000..1f0a7e32 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2PolyAndCircleContact.js @@ -0,0 +1,103 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2PolyAndCircleContact = Class.create(); +Object.extend(b2PolyAndCircleContact.prototype, b2Contact.prototype); +Object.extend(b2PolyAndCircleContact.prototype, { + + + initialize: function(s1, s2) { + // The constructor for b2Contact + // initialize instance variables for references + this.m_node1 = new b2ContactNode(); + this.m_node2 = new b2ContactNode(); + // + this.m_flags = 0; + + if (!s1 || !s2){ + this.m_shape1 = null; + this.m_shape2 = null; + return; + } + + this.m_shape1 = s1; + this.m_shape2 = s2; + + this.m_manifoldCount = 0; + + this.m_friction = Math.sqrt(this.m_shape1.m_friction * this.m_shape2.m_friction); + this.m_restitution = b2Math.b2Max(this.m_shape1.m_restitution, this.m_shape2.m_restitution); + + this.m_prev = null; + this.m_next = null; + + this.m_node1.contact = null; + this.m_node1.prev = null; + this.m_node1.next = null; + this.m_node1.other = null; + + this.m_node2.contact = null; + this.m_node2.prev = null; + this.m_node2.next = null; + this.m_node2.other = null; + // + + // initialize instance variables for references + this.m_manifold = [new b2Manifold()]; + // + + //super(shape1, shape2); + + b2Settings.b2Assert(this.m_shape1.m_type == b2Shape.e_polyShape); + b2Settings.b2Assert(this.m_shape2.m_type == b2Shape.e_circleShape); + this.m_manifold[0].pointCount = 0; + this.m_manifold[0].points[0].normalImpulse = 0.0; + this.m_manifold[0].points[0].tangentImpulse = 0.0; + }, + //~b2PolyAndCircleContact() {} + + Evaluate: function(){ + b2Collision.b2CollidePolyAndCircle(this.m_manifold[0], this.m_shape1, this.m_shape2, false); + + if (this.m_manifold[0].pointCount > 0) + { + this.m_manifoldCount = 1; + } + else + { + this.m_manifoldCount = 0; + } + }, + + GetManifolds: function() + { + return this.m_manifold; + }, + + m_manifold: [new b2Manifold()]}) + +b2PolyAndCircleContact.Create = function(shape1, shape2, allocator){ + return new b2PolyAndCircleContact(shape1, shape2); + }; +b2PolyAndCircleContact.Destroy = function(contact, allocator){ + // + }; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2PolyContact.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2PolyContact.js new file mode 100644 index 00000000..e11bf402 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/contacts/b2PolyContact.js @@ -0,0 +1,163 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2PolyContact = Class.create(); +Object.extend(b2PolyContact.prototype, b2Contact.prototype); +Object.extend(b2PolyContact.prototype, +{ + + initialize: function(s1, s2) { + // The constructor for b2Contact + // initialize instance variables for references + this.m_node1 = new b2ContactNode(); + this.m_node2 = new b2ContactNode(); + // + this.m_flags = 0; + + if (!s1 || !s2){ + this.m_shape1 = null; + this.m_shape2 = null; + return; + } + + this.m_shape1 = s1; + this.m_shape2 = s2; + + this.m_manifoldCount = 0; + + this.m_friction = Math.sqrt(this.m_shape1.m_friction * this.m_shape2.m_friction); + this.m_restitution = b2Math.b2Max(this.m_shape1.m_restitution, this.m_shape2.m_restitution); + + this.m_prev = null; + this.m_next = null; + + this.m_node1.contact = null; + this.m_node1.prev = null; + this.m_node1.next = null; + this.m_node1.other = null; + + this.m_node2.contact = null; + this.m_node2.prev = null; + this.m_node2.next = null; + this.m_node2.other = null; + // + + // initialize instance variables for references + this.m0 = new b2Manifold(); + this.m_manifold = [new b2Manifold()]; + // + + //super(shape1, shape2); + //b2Settings.b2Assert(this.m_shape1.m_type == b2Shape.e_polyShape); + //b2Settings.b2Assert(this.m_shape2.m_type == b2Shape.e_polyShape); + this.m_manifold[0].pointCount = 0; + }, + //~b2PolyContact() {} + + // store temp manifold to reduce calls to new + m0: new b2Manifold(), + + Evaluate: function(){ + var tMani = this.m_manifold[0]; + // replace memcpy + // memcpy(&this.m0, &this.m_manifold, sizeof(b2Manifold)); + //this.m0.points = new Array(tMani.pointCount); + var tPoints = this.m0.points; + + for (var k = 0; k < tMani.pointCount; k++){ + var tPoint = tPoints[k]; + var tPoint0 = tMani.points[k]; + //tPoint.separation = tPoint0.separation; + tPoint.normalImpulse = tPoint0.normalImpulse; + tPoint.tangentImpulse = tPoint0.tangentImpulse; + //tPoint.position.SetV( tPoint0.position ); + + tPoint.id = tPoint0.id.Copy(); + + /*this.m0.points[k].id.features = new Features(); + this.m0.points[k].id.features.referenceFace = this.m_manifold[0].points[k].id.features.referenceFace; + this.m0.points[k].id.features.incidentEdge = this.m_manifold[0].points[k].id.features.incidentEdge; + this.m0.points[k].id.features.incidentVertex = this.m_manifold[0].points[k].id.features.incidentVertex; + this.m0.points[k].id.features.flip = this.m_manifold[0].points[k].id.features.flip;*/ + } + //this.m0.normal.SetV( tMani.normal ); + this.m0.pointCount = tMani.pointCount; + + b2Collision.b2CollidePoly(tMani, this.m_shape1, this.m_shape2, false); + + // Match contact ids to facilitate warm starting. + if (tMani.pointCount > 0) + { + var match = [false, false]; + + // Match old contact ids to new contact ids and copy the + // stored impulses to warm start the solver. + for (var i = 0; i < tMani.pointCount; ++i) + { + var cp = tMani.points[ i ]; + + cp.normalImpulse = 0.0; + cp.tangentImpulse = 0.0; + var idKey = cp.id.key; + + for (var j = 0; j < this.m0.pointCount; ++j) + { + + if (match[j] == true) + continue; + + var cp0 = this.m0.points[j]; + var id0 = cp0.id; + + if (id0.key == idKey) + { + match[j] = true; + cp.normalImpulse = cp0.normalImpulse; + cp.tangentImpulse = cp0.tangentImpulse; + break; + } + } + } + + this.m_manifoldCount = 1; + } + else + { + this.m_manifoldCount = 0; + } + }, + + GetManifolds: function() + { + return this.m_manifold; + }, + + m_manifold: [new b2Manifold()]}); + +b2PolyContact.Create = function(shape1, shape2, allocator){ + //void* mem = allocator->Allocate(sizeof(b2PolyContact)); + return new b2PolyContact(shape1, shape2); + }; +b2PolyContact.Destroy = function(contact, allocator){ + //((b2PolyContact*)contact)->~b2PolyContact(); + //allocator->Free(contact, sizeof(b2PolyContact)); + }; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2DistanceJoint.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2DistanceJoint.js new file mode 100644 index 00000000..b91e4779 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2DistanceJoint.js @@ -0,0 +1,264 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + +// C = norm(p2 - p1) - L +// u = (p2 - p1) / norm(p2 - p1) +// Cdot = dot(u, v2 + cross(w2, r2) - v1 - cross(w1, r1)) +// J = [-u -cross(r1, u) u cross(r2, u)] +// K = J * invM * JT +// = invMass1 + invI1 * cross(r1, u)^2 + invMass2 + invI2 * cross(r2, u)^2 + +var b2DistanceJoint = Class.create(); +Object.extend(b2DistanceJoint.prototype, b2Joint.prototype); +Object.extend(b2DistanceJoint.prototype, +{ + //--------------- Internals Below ------------------- + + initialize: function(def){ + // The constructor for b2Joint + // initialize instance variables for references + this.m_node1 = new b2JointNode(); + this.m_node2 = new b2JointNode(); + // + this.m_type = def.type; + this.m_prev = null; + this.m_next = null; + this.m_body1 = def.body1; + this.m_body2 = def.body2; + this.m_collideConnected = def.collideConnected; + this.m_islandFlag = false; + this.m_userData = def.userData; + // + + // initialize instance variables for references + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_u = new b2Vec2(); + // + + //super(def); + + var tMat; + var tX; + var tY; + //this.m_localAnchor1 = b2MulT(this.m_body1->m_R, def->anchorPoint1 - this.m_body1->m_position); + tMat = this.m_body1.m_R; + tX = def.anchorPoint1.x - this.m_body1.m_position.x; + tY = def.anchorPoint1.y - this.m_body1.m_position.y; + this.m_localAnchor1.x = tX*tMat.col1.x + tY*tMat.col1.y; + this.m_localAnchor1.y = tX*tMat.col2.x + tY*tMat.col2.y; + //this.m_localAnchor2 = b2MulT(this.m_body2->m_R, def->anchorPoint2 - this.m_body2->m_position); + tMat = this.m_body2.m_R; + tX = def.anchorPoint2.x - this.m_body2.m_position.x; + tY = def.anchorPoint2.y - this.m_body2.m_position.y; + this.m_localAnchor2.x = tX*tMat.col1.x + tY*tMat.col1.y; + this.m_localAnchor2.y = tX*tMat.col2.x + tY*tMat.col2.y; + + //b2Vec2 d = def->anchorPoint2 - def->anchorPoint1; + tX = def.anchorPoint2.x - def.anchorPoint1.x; + tY = def.anchorPoint2.y - def.anchorPoint1.y; + //this.m_length = d.Length(); + this.m_length = Math.sqrt(tX*tX + tY*tY); + this.m_impulse = 0.0; + }, + + PrepareVelocitySolver: function(){ + + var tMat; + + // Compute the effective mass matrix. + //b2Vec2 r1 = b2Mul(this.m_body1->m_R, this.m_localAnchor1); + tMat = this.m_body1.m_R; + var r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + var r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //b2Vec2 r2 = b2Mul(this.m_body2->m_R, this.m_localAnchor2); + tMat = this.m_body2.m_R; + var r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + var r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + //this.m_u = this.m_body2->m_position + r2 - this.m_body1->m_position - r1; + this.m_u.x = this.m_body2.m_position.x + r2X - this.m_body1.m_position.x - r1X; + this.m_u.y = this.m_body2.m_position.y + r2Y - this.m_body1.m_position.y - r1Y; + + // Handle singularity. + //float32 length = this.m_u.Length(); + 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 *= 1.0 / length; + this.m_u.Multiply( 1.0 / length ); + } + else + { + this.m_u.SetZero(); + } + + //float32 cr1u = b2Cross(r1, this.m_u); + var cr1u = (r1X * this.m_u.y - r1Y * this.m_u.x); + //float32 cr2u = b2Cross(r2, this.m_u); + var cr2u = (r2X * this.m_u.y - r2Y * this.m_u.x); + //this.m_mass = this.m_body1->m_invMass + this.m_body1->m_invI * cr1u * cr1u + this.m_body2->m_invMass + this.m_body2->m_invI * cr2u * cr2u; + this.m_mass = this.m_body1.m_invMass + this.m_body1.m_invI * cr1u * cr1u + this.m_body2.m_invMass + this.m_body2.m_invI * cr2u * cr2u; + //b2Settings.b2Assert(this.m_mass > Number.MIN_VALUE); + this.m_mass = 1.0 / this.m_mass; + + if (b2World.s_enableWarmStarting) + { + //b2Vec2 P = this.m_impulse * this.m_u; + var PX = this.m_impulse * this.m_u.x; + var PY = this.m_impulse * this.m_u.y; + //this.m_body1.m_linearVelocity -= this.m_body1.m_invMass * P; + this.m_body1.m_linearVelocity.x -= this.m_body1.m_invMass * PX; + this.m_body1.m_linearVelocity.y -= this.m_body1.m_invMass * PY; + //this.m_body1.m_angularVelocity -= this.m_body1.m_invI * b2Cross(r1, P); + this.m_body1.m_angularVelocity -= this.m_body1.m_invI * (r1X * PY - r1Y * PX); + //this.m_body2.m_linearVelocity += this.m_body2.m_invMass * P; + this.m_body2.m_linearVelocity.x += this.m_body2.m_invMass * PX; + this.m_body2.m_linearVelocity.y += this.m_body2.m_invMass * PY; + //this.m_body2.m_angularVelocity += this.m_body2.m_invI * b2Cross(r2, P); + this.m_body2.m_angularVelocity += this.m_body2.m_invI * (r2X * PY - r2Y * PX); + } + else + { + this.m_impulse = 0.0; + } + + }, + + + + SolveVelocityConstraints: function(step){ + + var tMat; + + //b2Vec2 r1 = b2Mul(this.m_body1->m_R, this.m_localAnchor1); + tMat = this.m_body1.m_R; + var r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + var r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //b2Vec2 r2 = b2Mul(this.m_body2->m_R, this.m_localAnchor2); + tMat = this.m_body2.m_R; + var r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + var r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + + // Cdot = dot(u, v + cross(w, r)) + //b2Vec2 v1 = this.m_body1->m_linearVelocity + b2Cross(this.m_body1->m_angularVelocity, r1); + var v1X = this.m_body1.m_linearVelocity.x + (-this.m_body1.m_angularVelocity * r1Y); + var v1Y = this.m_body1.m_linearVelocity.y + (this.m_body1.m_angularVelocity * r1X); + //b2Vec2 v2 = this.m_body2->m_linearVelocity + b2Cross(this.m_body2->m_angularVelocity, r2); + var v2X = this.m_body2.m_linearVelocity.x + (-this.m_body2.m_angularVelocity * r2Y); + var v2Y = this.m_body2.m_linearVelocity.y + (this.m_body2.m_angularVelocity * r2X); + //float32 Cdot = b2Dot(this.m_u, v2 - v1); + var Cdot = (this.m_u.x * (v2X - v1X) + this.m_u.y * (v2Y - v1Y)); + //float32 impulse = -this.m_mass * Cdot; + var impulse = -this.m_mass * Cdot; + this.m_impulse += impulse; + + //b2Vec2 P = impulse * this.m_u; + var PX = impulse * this.m_u.x; + var PY = impulse * this.m_u.y; + //this.m_body1->m_linearVelocity -= this.m_body1->m_invMass * P; + this.m_body1.m_linearVelocity.x -= this.m_body1.m_invMass * PX; + this.m_body1.m_linearVelocity.y -= this.m_body1.m_invMass * PY; + //this.m_body1->m_angularVelocity -= this.m_body1->m_invI * b2Cross(r1, P); + this.m_body1.m_angularVelocity -= this.m_body1.m_invI * (r1X * PY - r1Y * PX); + //this.m_body2->m_linearVelocity += this.m_body2->m_invMass * P; + this.m_body2.m_linearVelocity.x += this.m_body2.m_invMass * PX; + this.m_body2.m_linearVelocity.y += this.m_body2.m_invMass * PY; + //this.m_body2->m_angularVelocity += this.m_body2->m_invI * b2Cross(r2, P); + this.m_body2.m_angularVelocity += this.m_body2.m_invI * (r2X * PY - r2Y * PX); + }, + + SolvePositionConstraints: function(){ + + var tMat; + + //b2Vec2 r1 = b2Mul(this.m_body1->m_R, this.m_localAnchor1); + tMat = this.m_body1.m_R; + var r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + var r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //b2Vec2 r2 = b2Mul(this.m_body2->m_R, this.m_localAnchor2); + tMat = this.m_body2.m_R; + var r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + var r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + //b2Vec2 d = this.m_body2->m_position + r2 - this.m_body1->m_position - r1; + var dX = this.m_body2.m_position.x + r2X - this.m_body1.m_position.x - r1X; + var dY = this.m_body2.m_position.y + r2Y - this.m_body1.m_position.y - r1Y; + + //float32 length = d.Normalize(); + var length = Math.sqrt(dX*dX + dY*dY); + dX /= length; + dY /= length; + //float32 C = length - this.m_length; + var C = length - this.m_length; + C = b2Math.b2Clamp(C, -b2Settings.b2_maxLinearCorrection, b2Settings.b2_maxLinearCorrection); + + var impulse = -this.m_mass * C; + //this.m_u = d; + this.m_u.Set(dX, dY); + //b2Vec2 P = impulse * this.m_u; + var PX = impulse * this.m_u.x; + var PY = impulse * this.m_u.y; + + //this.m_body1->m_position -= this.m_body1->m_invMass * P; + this.m_body1.m_position.x -= this.m_body1.m_invMass * PX; + this.m_body1.m_position.y -= this.m_body1.m_invMass * PY; + //this.m_body1->m_rotation -= this.m_body1->m_invI * b2Cross(r1, P); + this.m_body1.m_rotation -= this.m_body1.m_invI * (r1X * PY - r1Y * PX); + //this.m_body2->m_position += this.m_body2->m_invMass * P; + this.m_body2.m_position.x += this.m_body2.m_invMass * PX; + this.m_body2.m_position.y += this.m_body2.m_invMass * PY; + //this.m_body2->m_rotation -= this.m_body2->m_invI * b2Cross(r2, P); + this.m_body2.m_rotation += this.m_body2.m_invI * (r2X * PY - r2Y * PX); + + this.m_body1.m_R.Set(this.m_body1.m_rotation); + this.m_body2.m_R.Set(this.m_body2.m_rotation); + + return b2Math.b2Abs(C) < b2Settings.b2_linearSlop; + + }, + + GetAnchor1: function(){ + return b2Math.AddVV(this.m_body1.m_position , b2Math.b2MulMV(this.m_body1.m_R, this.m_localAnchor1)); + }, + GetAnchor2: function(){ + return b2Math.AddVV(this.m_body2.m_position , b2Math.b2MulMV(this.m_body2.m_R, this.m_localAnchor2)); + }, + + GetReactionForce: function(invTimeStep) + { + //var F = (this.m_impulse * invTimeStep) * this.m_u; + var F = new b2Vec2(); + F.SetV(this.m_u); + F.Multiply(this.m_impulse * invTimeStep); + return F; + }, + + GetReactionTorque: function(invTimeStep) + { + //NOT_USED(invTimeStep); + return 0.0; + }, + + m_localAnchor1: new b2Vec2(), + m_localAnchor2: new b2Vec2(), + m_u: new b2Vec2(), + m_impulse: null, + m_mass: null, + m_length: null}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2DistanceJointDef.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2DistanceJointDef.js new file mode 100644 index 00000000..0c89b7a2 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2DistanceJointDef.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2DistanceJointDef = Class.create(); +Object.extend(b2DistanceJointDef.prototype, b2JointDef.prototype); +Object.extend(b2DistanceJointDef.prototype, +{ + initialize: function() + { + // The constructor for b2JointDef + this.type = b2Joint.e_unknownJoint; + this.userData = null; + this.body1 = null; + this.body2 = null; + this.collideConnected = false; + // + + // initialize instance variables for references + this.anchorPoint1 = new b2Vec2(); + this.anchorPoint2 = new b2Vec2(); + // + + this.type = b2Joint.e_distanceJoint; + //this.anchorPoint1.Set(0.0, 0.0); + //this.anchorPoint2.Set(0.0, 0.0); + }, + + anchorPoint1: new b2Vec2(), + anchorPoint2: new b2Vec2()}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2GearJoint.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2GearJoint.js new file mode 100644 index 00000000..daace0b7 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2GearJoint.js @@ -0,0 +1,307 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + +var b2GearJoint = Class.create(); +Object.extend(b2GearJoint.prototype, b2Joint.prototype); +Object.extend(b2GearJoint.prototype, +{ + GetAnchor1: function(){ + //return this.m_body1.m_position + b2MulMV(this.m_body1.m_R, this.m_localAnchor1); + var tMat = this.m_body1.m_R; + return new b2Vec2( this.m_body1.m_position.x + (tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y), + this.m_body1.m_position.y + (tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y)); + }, + GetAnchor2: function(){ + //return this.m_body2->m_position + b2Mul(this.m_body2->m_R, this.m_localAnchor2); + var tMat = this.m_body2.m_R; + return new b2Vec2( this.m_body2.m_position.x + (tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y), + this.m_body2.m_position.y + (tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y)); + }, + + GetReactionForce: function(invTimeStep){ + //b2Vec2 F(0.0f, 0.0f); + return new b2Vec2(); + }, + GetReactionTorque: function(invTimeStep){ + return 0.0; + }, + + GetRatio: function(){ + return this.m_ratio; + }, + + //--------------- Internals Below ------------------- + + initialize: function(def){ + // The constructor for b2Joint + // initialize instance variables for references + this.m_node1 = new b2JointNode(); + this.m_node2 = new b2JointNode(); + // + this.m_type = def.type; + this.m_prev = null; + this.m_next = null; + this.m_body1 = def.body1; + this.m_body2 = def.body2; + this.m_collideConnected = def.collideConnected; + this.m_islandFlag = false; + this.m_userData = def.userData; + // + + // initialize instance variables for references + 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(); + // + + // parent constructor + //super(def); + + //b2Settings.b2Assert(def.joint1.m_type == b2Joint.e_revoluteJoint || def.joint1.m_type == b2Joint.e_prismaticJoint); + //b2Settings.b2Assert(def.joint2.m_type == b2Joint.e_revoluteJoint || def.joint2.m_type == b2Joint.e_prismaticJoint); + //b2Settings.b2Assert(def.joint1.m_body1.IsStatic()); + //b2Settings.b2Assert(def.joint2.m_body1.IsStatic()); + + this.m_revolute1 = null; + this.m_prismatic1 = null; + this.m_revolute2 = null; + this.m_prismatic2 = null; + + var coordinate1; + var coordinate2; + + this.m_ground1 = def.joint1.m_body1; + this.m_body1 = def.joint1.m_body2; + if (def.joint1.m_type == b2Joint.e_revoluteJoint) + { + this.m_revolute1 = def.joint1; + 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; + 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.m_body1; + this.m_body2 = def.joint2.m_body2; + if (def.joint2.m_type == b2Joint.e_revoluteJoint) + { + this.m_revolute2 = def.joint2; + 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; + 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; + + }, + + PrepareVelocitySolver: function(){ + var g1 = this.m_ground1; + var g2 = this.m_ground2; + var b1 = this.m_body1; + var b2 = this.m_body2; + + // temp vars + var ugX; + var ugY; + var rX; + var rY; + var tMat; + var tVec; + var crug; + + var K = 0.0; + this.m_J.SetZero(); + + if (this.m_revolute1) + { + this.m_J.angular1 = -1.0; + K += b1.m_invI; + } + else + { + //b2Vec2 ug = b2MulMV(g1->m_R, this.m_prismatic1->m_localXAxis1); + tMat = g1.m_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; + //b2Vec2 r = b2MulMV(b1->m_R, this.m_localAnchor1); + tMat = b1.m_R; + rX = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + rY = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + + //var crug = b2Cross(r, ug); + crug = rX * ugY - rY * ugX; + //this.m_J.linear1 = -ug; + this.m_J.linear1.Set(-ugX, -ugY); + this.m_J.angular1 = -crug; + K += b1.m_invMass + b1.m_invI * crug * crug; + } + + if (this.m_revolute2) + { + this.m_J.angular2 = -this.m_ratio; + K += this.m_ratio * this.m_ratio * b2.m_invI; + } + else + { + //b2Vec2 ug = b2Mul(g2->m_R, this.m_prismatic2->m_localXAxis1); + tMat = g2.m_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; + //b2Vec2 r = b2Mul(b2->m_R, this.m_localAnchor2); + tMat = b2.m_R; + rX = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + rY = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + //float32 crug = b2Cross(r, ug); + crug = rX * ugY - rY * ugX; + //this.m_J.linear2 = -this.m_ratio * ug; + this.m_J.linear2.Set(-this.m_ratio*ugX, -this.m_ratio*ugY); + this.m_J.angular2 = -this.m_ratio * crug; + K += this.m_ratio * this.m_ratio * (b2.m_invMass + b2.m_invI * crug * crug); + } + + // Compute effective mass. + //b2Settings.b2Assert(K > 0.0); + this.m_mass = 1.0 / K; + + // Warm starting. + //b1.m_linearVelocity += b1.m_invMass * this.m_impulse * this.m_J.linear1; + b1.m_linearVelocity.x += b1.m_invMass * this.m_impulse * this.m_J.linear1.x; + b1.m_linearVelocity.y += b1.m_invMass * this.m_impulse * this.m_J.linear1.y; + b1.m_angularVelocity += b1.m_invI * this.m_impulse * this.m_J.angular1; + //b2.m_linearVelocity += b2.m_invMass * this.m_impulse * this.m_J.linear2; + b2.m_linearVelocity.x += b2.m_invMass * this.m_impulse * this.m_J.linear2.x; + b2.m_linearVelocity.y += b2.m_invMass * this.m_impulse * this.m_J.linear2.y; + b2.m_angularVelocity += b2.m_invI * this.m_impulse * this.m_J.angular2; + }, + + + SolveVelocityConstraints: function(step){ + var b1 = this.m_body1; + var b2 = this.m_body2; + + var Cdot = this.m_J.Compute( b1.m_linearVelocity, b1.m_angularVelocity, + b2.m_linearVelocity, b2.m_angularVelocity); + + var impulse = -this.m_mass * Cdot; + this.m_impulse += impulse; + + b1.m_linearVelocity.x += b1.m_invMass * impulse * this.m_J.linear1.x; + b1.m_linearVelocity.y += b1.m_invMass * impulse * this.m_J.linear1.y; + b1.m_angularVelocity += b1.m_invI * impulse * this.m_J.angular1; + b2.m_linearVelocity.x += b2.m_invMass * impulse * this.m_J.linear2.x; + b2.m_linearVelocity.y += b2.m_invMass * impulse * this.m_J.linear2.y; + b2.m_angularVelocity += b2.m_invI * impulse * this.m_J.angular2; + }, + + SolvePositionConstraints: function(){ + var linearError = 0.0; + + var b1 = this.m_body1; + var b2 = this.m_body2; + + var coordinate1; + var coordinate2; + 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; + + b1.m_position.x += b1.m_invMass * impulse * this.m_J.linear1.x; + b1.m_position.y += b1.m_invMass * impulse * this.m_J.linear1.y; + b1.m_rotation += b1.m_invI * impulse * this.m_J.angular1; + b2.m_position.x += b2.m_invMass * impulse * this.m_J.linear2.x; + b2.m_position.y += b2.m_invMass * impulse * this.m_J.linear2.y; + b2.m_rotation += b2.m_invI * impulse * this.m_J.angular2; + b1.m_R.Set(b1.m_rotation); + b2.m_R.Set(b2.m_rotation); + + return linearError < b2Settings.b2_linearSlop; + }, + + m_ground1: null, + m_ground2: null, + + // One of these is NULL. + m_revolute1: null, + m_prismatic1: null, + + // One of these is NULL. + m_revolute2: null, + m_prismatic2: null, + + m_groundAnchor1: new b2Vec2(), + m_groundAnchor2: new b2Vec2(), + + m_localAnchor1: new b2Vec2(), + m_localAnchor2: new b2Vec2(), + + m_J: new b2Jacobian(), + + m_constant: null, + m_ratio: null, + + // Effective mass + m_mass: null, + + // Impulse for accumulation/warm starting. + m_impulse: null}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2GearJointDef.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2GearJointDef.js new file mode 100644 index 00000000..aaf30a37 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2GearJointDef.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + +// A gear joint is used to connect two joints together. Either joint +// can be a revolute or prismatic joint. You specify a gear ratio +// to bind the motions together: +// coordinate1 + ratio * coordinate2 = constant +// The ratio can be negative or positive. If one joint is a revolute joint +// and the other joint is a prismatic joint, then the ratio will have units +// of length or units of 1/length. +// +// RESTRICITON: The revolute and prismatic joints must be attached to +// a fixed body (which must be body1 on those joints). + +var b2GearJointDef = Class.create(); +Object.extend(b2GearJointDef.prototype, b2JointDef.prototype); +Object.extend(b2GearJointDef.prototype, +{ + initialize: function() + { + this.type = b2Joint.e_gearJoint; + this.joint1 = null; + this.joint2 = null; + this.ratio = 1.0; + }, + + joint1: null, + joint2: null, + ratio: null}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2Jacobian.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2Jacobian.js new file mode 100644 index 00000000..f67a22a5 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2Jacobian.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2Jacobian = Class.create(); +b2Jacobian.prototype = +{ + linear1: new b2Vec2(), + angular1: null, + linear2: new b2Vec2(), + angular2: null, + + SetZero: function(){ + this.linear1.SetZero(); this.angular1 = 0.0; + this.linear2.SetZero(); this.angular2 = 0.0; + }, + Set: function(x1, a1, x2, a2){ + this.linear1.SetV(x1); this.angular1 = a1; + this.linear2.SetV(x2); this.angular2 = a2; + }, + Compute: function(x1, a1, x2, a2){ + + //return b2Math.b2Dot(this.linear1, x1) + this.angular1 * a1 + b2Math.b2Dot(this.linear2, x2) + this.angular2 * a2; + return (this.linear1.x*x1.x + this.linear1.y*x1.y) + this.angular1 * a1 + (this.linear2.x*x2.x + this.linear2.y*x2.y) + this.angular2 * a2; + }, + initialize: function() { + // initialize instance variables for references + this.linear1 = new b2Vec2(); + this.linear2 = new b2Vec2(); + // +}}; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2Joint.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2Joint.js new file mode 100644 index 00000000..88a57669 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2Joint.js @@ -0,0 +1,200 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2Joint = Class.create(); +b2Joint.prototype = +{ + GetType: function(){ + return this.m_type; + }, + + GetAnchor1: function(){return null}, + GetAnchor2: function(){return null}, + + GetReactionForce: function(invTimeStep){return null}, + GetReactionTorque: function(invTimeStep){return 0.0}, + + GetBody1: function() + { + return this.m_body1; + }, + + GetBody2: function() + { + return this.m_body2; + }, + + GetNext: function(){ + return this.m_next; + }, + + GetUserData: function(){ + return this.m_userData; + }, + + //--------------- Internals Below ------------------- + + + + initialize: function(def){ + // initialize instance variables for references + this.m_node1 = new b2JointNode(); + this.m_node2 = new b2JointNode(); + // + + this.m_type = def.type; + this.m_prev = null; + this.m_next = null; + this.m_body1 = def.body1; + this.m_body2 = def.body2; + this.m_collideConnected = def.collideConnected; + this.m_islandFlag = false; + this.m_userData = def.userData; + }, + //virtual ~b2Joint() {} + + PrepareVelocitySolver: function(){}, + SolveVelocityConstraints: function(step){}, + + // This returns true if the position errors are within tolerance. + PreparePositionSolver: function(){}, + SolvePositionConstraints: function(){return false}, + + m_type: 0, + m_prev: null, + m_next: null, + m_node1: new b2JointNode(), + m_node2: new b2JointNode(), + m_body1: null, + m_body2: null, + + m_islandFlag: null, + m_collideConnected: null, + + m_userData: null + + + // ENUMS + + // enum b2JointType + + // enum b2LimitState + +}; +b2Joint.Create = function(def, allocator){ + var joint = null; + + switch (def.type) + { + case b2Joint.e_distanceJoint: + { + //void* mem = allocator->Allocate(sizeof(b2DistanceJoint)); + joint = new b2DistanceJoint(def); + } + break; + + case b2Joint.e_mouseJoint: + { + //void* mem = allocator->Allocate(sizeof(b2MouseJoint)); + joint = new b2MouseJoint(def); + } + break; + + case b2Joint.e_prismaticJoint: + { + //void* mem = allocator->Allocate(sizeof(b2PrismaticJoint)); + joint = new b2PrismaticJoint(def); + } + break; + + case b2Joint.e_revoluteJoint: + { + //void* mem = allocator->Allocate(sizeof(b2RevoluteJoint)); + joint = new b2RevoluteJoint(def); + } + break; + + case b2Joint.e_pulleyJoint: + { + //void* mem = allocator->Allocate(sizeof(b2PulleyJoint)); + joint = new b2PulleyJoint(def); + } + break; + + case b2Joint.e_gearJoint: + { + //void* mem = allocator->Allocate(sizeof(b2GearJoint)); + joint = new b2GearJoint(def); + } + break; + + default: + //b2Settings.b2Assert(false); + break; + } + + return joint; + }; +b2Joint.Destroy = function(joint, allocator){ + /*joint->~b2Joint(); + switch (joint.m_type) + { + case b2Joint.e_distanceJoint: + allocator->Free(joint, sizeof(b2DistanceJoint)); + break; + + case b2Joint.e_mouseJoint: + allocator->Free(joint, sizeof(b2MouseJoint)); + break; + + case b2Joint.e_prismaticJoint: + allocator->Free(joint, sizeof(b2PrismaticJoint)); + break; + + case b2Joint.e_revoluteJoint: + allocator->Free(joint, sizeof(b2RevoluteJoint)); + break; + + case b2Joint.e_pulleyJoint: + allocator->Free(joint, sizeof(b2PulleyJoint)); + break; + + case b2Joint.e_gearJoint: + allocator->Free(joint, sizeof(b2GearJoint)); + break; + + default: + b2Assert(false); + break; + }*/ + }; +b2Joint.e_unknownJoint = 0; +b2Joint.e_revoluteJoint = 1; +b2Joint.e_prismaticJoint = 2; +b2Joint.e_distanceJoint = 3; +b2Joint.e_pulleyJoint = 4; +b2Joint.e_mouseJoint = 5; +b2Joint.e_gearJoint = 6; +b2Joint.e_inactiveLimit = 0; +b2Joint.e_atLowerLimit = 1; +b2Joint.e_atUpperLimit = 2; +b2Joint.e_equalLimits = 3; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2JointDef.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2JointDef.js new file mode 100644 index 00000000..6b949e60 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2JointDef.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2JointDef = Class.create(); +b2JointDef.prototype = +{ + + initialize: function() + { + this.type = b2Joint.e_unknownJoint; + this.userData = null; + this.body1 = null; + this.body2 = null; + this.collideConnected = false; + }, + + type: 0, + userData: null, + body1: null, + body2: null, + collideConnected: null} diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2JointNode.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2JointNode.js new file mode 100644 index 00000000..b1c837b3 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2JointNode.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2JointNode = Class.create(); +b2JointNode.prototype = +{ + + other: null, + joint: null, + prev: null, + next: null, + + + initialize: function() {}} diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2MouseJoint.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2MouseJoint.js new file mode 100644 index 00000000..cf933a98 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2MouseJoint.js @@ -0,0 +1,234 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +// p = attached point, m = mouse point +// C = p - m +// Cdot = v +// = v + cross(w, r) +// J = [I r_skew] +// Identity used: +// w k % (rx i + ry j) = w * (-ry i + rx j) + +var b2MouseJoint = Class.create(); +Object.extend(b2MouseJoint.prototype, b2Joint.prototype); +Object.extend(b2MouseJoint.prototype, +{ + GetAnchor1: function(){ + return this.m_target; + }, + GetAnchor2: function(){ + var tVec = b2Math.b2MulMV(this.m_body2.m_R, this.m_localAnchor); + tVec.Add(this.m_body2.m_position); + return tVec; + }, + + GetReactionForce: function(invTimeStep) + { + //b2Vec2 F = invTimeStep * this.m_impulse; + var F = new b2Vec2(); + F.SetV(this.m_impulse); + F.Multiply(invTimeStep); + return F; + }, + + GetReactionTorque: function(invTimeStep) + { + //NOT_USED(invTimeStep); + return 0.0; + }, + + SetTarget: function(target){ + this.m_body2.WakeUp(); + this.m_target = target; + }, + + //--------------- Internals Below ------------------- + + initialize: function(def){ + // The constructor for b2Joint + // initialize instance variables for references + this.m_node1 = new b2JointNode(); + this.m_node2 = new b2JointNode(); + // + this.m_type = def.type; + this.m_prev = null; + this.m_next = null; + this.m_body1 = def.body1; + this.m_body2 = def.body2; + this.m_collideConnected = def.collideConnected; + this.m_islandFlag = false; + this.m_userData = def.userData; + // + + // initialize instance variables for references + 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_ptpMass = new b2Mat22(); + this.m_C = new b2Vec2(); + // + + //super(def); + + this.m_target.SetV(def.target); + //this.m_localAnchor = b2Math.b2MulTMV(this.m_body2.m_R, b2Math.SubtractVV( this.m_target, this.m_body2.m_position ) ); + var tX = this.m_target.x - this.m_body2.m_position.x; + var tY = this.m_target.y - this.m_body2.m_position.y; + this.m_localAnchor.x = (tX * this.m_body2.m_R.col1.x + tY * this.m_body2.m_R.col1.y); + this.m_localAnchor.y = (tX * this.m_body2.m_R.col2.x + tY * this.m_body2.m_R.col2.y); + + this.m_maxForce = def.maxForce; + this.m_impulse.SetZero(); + + var mass = this.m_body2.m_mass; + + // Frequency + var omega = 2.0 * b2Settings.b2_pi * def.frequencyHz; + + // Damping coefficient + var d = 2.0 * mass * def.dampingRatio * omega; + + // Spring stiffness + var k = mass * omega * omega; + + // magic formulas + this.m_gamma = 1.0 / (d + def.timeStep * k); + this.m_beta = def.timeStep * k / (d + def.timeStep * k); + }, + + // Presolve vars + K: new b2Mat22(), + K1: new b2Mat22(), + K2: new b2Mat22(), + PrepareVelocitySolver: function(){ + var b = this.m_body2; + + var tMat; + + // Compute the effective mass matrix. + //b2Vec2 r = b2Mul(b.m_R, this.m_localAnchor); + tMat = b.m_R; + var rX = tMat.col1.x * this.m_localAnchor.x + tMat.col2.x * this.m_localAnchor.y; + var rY = tMat.col1.y * this.m_localAnchor.x + tMat.col2.y * this.m_localAnchor.y; + + // this.K = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) * invI2 * skew(r2)] + // = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y -r1.x*r1.y] + // [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x] + var invMass = b.m_invMass; + var invI = b.m_invI; + + //b2Mat22 this.K1; + this.K1.col1.x = invMass; this.K1.col2.x = 0.0; + this.K1.col1.y = 0.0; this.K1.col2.y = invMass; + + //b2Mat22 this.K2; + 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; + + //b2Mat22 this.K = this.K1 + this.K2; + 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.m_ptpMass = this.K.Invert(); + this.K.Invert(this.m_ptpMass); + + //this.m_C = b.m_position + r - this.m_target; + this.m_C.x = b.m_position.x + rX - this.m_target.x; + this.m_C.y = b.m_position.y + rY - this.m_target.y; + + // Cheat with some damping + b.m_angularVelocity *= 0.98; + + // Warm starting. + //b2Vec2 P = this.m_impulse; + var PX = this.m_impulse.x; + var PY = this.m_impulse.y; + //b.m_linearVelocity += invMass * P; + b.m_linearVelocity.x += invMass * PX; + b.m_linearVelocity.y += invMass * PY; + //b.m_angularVelocity += invI * b2Cross(r, P); + b.m_angularVelocity += invI * (rX * PY - rY * PX); + }, + + + SolveVelocityConstraints: function(step){ + var body = this.m_body2; + + var tMat; + + // Compute the effective mass matrix. + //b2Vec2 r = b2Mul(body.m_R, this.m_localAnchor); + tMat = body.m_R; + var rX = tMat.col1.x * this.m_localAnchor.x + tMat.col2.x * this.m_localAnchor.y; + var rY = tMat.col1.y * this.m_localAnchor.x + tMat.col2.y * this.m_localAnchor.y; + + // Cdot = v + cross(w, r) + //b2Vec2 Cdot = body->m_linearVelocity + b2Cross(body->m_angularVelocity, r); + var CdotX = body.m_linearVelocity.x + (-body.m_angularVelocity * rY); + var CdotY = body.m_linearVelocity.y + (body.m_angularVelocity * rX); + //b2Vec2 impulse = -b2Mul(this.m_ptpMass, Cdot + (this.m_beta * step->inv_dt) * this.m_C + this.m_gamma * this.m_impulse); + tMat = this.m_ptpMass; + var tX = CdotX + (this.m_beta * step.inv_dt) * this.m_C.x + this.m_gamma * this.m_impulse.x; + var tY = CdotY + (this.m_beta * step.inv_dt) * 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 += impulse; + this.m_impulse.x += impulseX; + this.m_impulse.y += impulseY; + var length = this.m_impulse.Length(); + if (length > step.dt * this.m_maxForce) + { + //this.m_impulse *= step.dt * this.m_maxForce / length; + this.m_impulse.Multiply(step.dt * this.m_maxForce / length); + } + //impulse = this.m_impulse - oldImpulse; + impulseX = this.m_impulse.x - oldImpulseX; + impulseY = this.m_impulse.y - oldImpulseY; + + //body.m_linearVelocity += body->m_invMass * impulse; + body.m_linearVelocity.x += body.m_invMass * impulseX; + body.m_linearVelocity.y += body.m_invMass * impulseY; + //body.m_angularVelocity += body->m_invI * b2Cross(r, impulse); + body.m_angularVelocity += body.m_invI * (rX * impulseY - rY * impulseX); + }, + SolvePositionConstraints: function(){ + return true; + }, + + m_localAnchor: new b2Vec2(), + m_target: new b2Vec2(), + m_impulse: new b2Vec2(), + + m_ptpMass: new b2Mat22(), + m_C: new b2Vec2(), + m_maxForce: null, + m_beta: null, + m_gamma: null}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2MouseJointDef.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2MouseJointDef.js new file mode 100644 index 00000000..b9a3b5cb --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2MouseJointDef.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2MouseJointDef = Class.create(); +Object.extend(b2MouseJointDef.prototype, b2JointDef.prototype); +Object.extend(b2MouseJointDef.prototype, +{ + initialize: function() + { + // The constructor for b2JointDef + this.type = b2Joint.e_unknownJoint; + this.userData = null; + this.body1 = null; + this.body2 = null; + this.collideConnected = false; + // + + // initialize instance variables for references + this.target = new b2Vec2(); + // + + this.type = b2Joint.e_mouseJoint; + this.maxForce = 0.0; + this.frequencyHz = 5.0; + this.dampingRatio = 0.7; + this.timeStep = 1.0 / 60.0; + }, + + target: new b2Vec2(), + maxForce: null, + frequencyHz: null, + dampingRatio: null, + timeStep: null}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2PrismaticJoint.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2PrismaticJoint.js new file mode 100644 index 00000000..94bfcf82 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2PrismaticJoint.js @@ -0,0 +1,676 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +// Linear constraint (point-to-line) +// d = p2 - p1 = x2 + r2 - x1 - r1 +// C = dot(ay1, d) +// Cdot = dot(d, cross(w1, ay1)) + dot(ay1, v2 + cross(w2, r2) - v1 - cross(w1, r1)) +// = -dot(ay1, v1) - dot(cross(d + r1, ay1), w1) + dot(ay1, v2) + dot(cross(r2, ay1), v2) +// J = [-ay1 -cross(d+r1,ay1) ay1 cross(r2,ay1)] +// +// Angular constraint +// C = a2 - a1 + a_initial +// Cdot = w2 - w1 +// J = [0 0 -1 0 0 1] + +// Motor/Limit linear constraint +// C = dot(ax1, d) +// Cdot = = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) + dot(cross(r2, ax1), v2) +// J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)] + + +var b2PrismaticJoint = Class.create(); +Object.extend(b2PrismaticJoint.prototype, b2Joint.prototype); +Object.extend(b2PrismaticJoint.prototype, +{ + GetAnchor1: function(){ + var b1 = this.m_body1; + //return b2Math.AddVV(b1.m_position, b2Math.b2MulMV(b1.m_R, this.m_localAnchor1)); + var tVec = new b2Vec2(); + tVec.SetV(this.m_localAnchor1); + tVec.MulM(b1.m_R); + tVec.Add(b1.m_position); + return tVec; + }, + GetAnchor2: function(){ + var b2 = this.m_body2; + //return b2Math.AddVV(b2.m_position, b2Math.b2MulMV(b2.m_R, this.m_localAnchor2)); + var tVec = new b2Vec2(); + tVec.SetV(this.m_localAnchor2); + tVec.MulM(b2.m_R); + tVec.Add(b2.m_position); + return tVec; + }, + GetJointTranslation: function(){ + var b1 = this.m_body1; + var b2 = this.m_body2; + + var tMat; + + //var r1 = b2Math.b2MulMV(b1.m_R, this.m_localAnchor1); + tMat = b1.m_R; + var r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + var r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //var r2 = b2Math.b2MulMV(b2.m_R, this.m_localAnchor2); + tMat = b2.m_R; + var r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + var r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + //var p1 = b2Math.AddVV(b1.m_position , r1); + var p1X = b1.m_position.x + r1X; + var p1Y = b1.m_position.y + r1Y; + //var p2 = b2Math.AddVV(b2.m_position , r2); + var p2X = b2.m_position.x + r2X; + var p2Y = b2.m_position.y + r2Y; + //var d = b2Math.SubtractVV(p2, p1); + var dX = p2X - p1X; + var dY = p2Y - p1Y; + //var ax1 = b2Math.b2MulMV(b1.m_R, this.m_localXAxis1); + tMat = b1.m_R; + var ax1X = tMat.col1.x * this.m_localXAxis1.x + tMat.col2.x * this.m_localXAxis1.y; + var ax1Y = tMat.col1.y * this.m_localXAxis1.x + tMat.col2.y * this.m_localXAxis1.y; + + //var translation = b2Math.b2Dot(ax1, d); + var translation = ax1X*dX + ax1Y*dY; + return translation; + }, + GetJointSpeed: function(){ + var b1 = this.m_body1; + var b2 = this.m_body2; + + var tMat; + + //var r1 = b2Math.b2MulMV(b1.m_R, this.m_localAnchor1); + tMat = b1.m_R; + var r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + var r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //var r2 = b2Math.b2MulMV(b2.m_R, this.m_localAnchor2); + tMat = b2.m_R; + var r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + var r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + //var p1 = b2Math.AddVV(b1.m_position , r1); + var p1X = b1.m_position.x + r1X; + var p1Y = b1.m_position.y + r1Y; + //var p2 = b2Math.AddVV(b2.m_position , r2); + var p2X = b2.m_position.x + r2X; + var p2Y = b2.m_position.y + r2Y; + //var d = b2Math.SubtractVV(p2, p1); + var dX = p2X - p1X; + var dY = p2Y - p1Y; + //var ax1 = b2Math.b2MulMV(b1.m_R, this.m_localXAxis1); + tMat = b1.m_R; + var ax1X = tMat.col1.x * this.m_localXAxis1.x + tMat.col2.x * this.m_localXAxis1.y; + var ax1Y = tMat.col1.y * this.m_localXAxis1.x + tMat.col2.y * this.m_localXAxis1.y; + + var v1 = b1.m_linearVelocity; + var v2 = b2.m_linearVelocity; + var w1 = b1.m_angularVelocity; + var w2 = b2.m_angularVelocity; + + //var speed = b2Math.b2Dot(d, b2Math.b2CrossFV(w1, ax1)) + b2Math.b2Dot(ax1, b2Math.SubtractVV( b2Math.SubtractVV( b2Math.AddVV( v2 , b2Math.b2CrossFV(w2, r2)) , v1) , b2Math.b2CrossFV(w1, r1))); + //var b2D = (dX*(-w1 * ax1Y) + dY*(w1 * ax1X)); + //var b2D2 = (ax1X * ((( v2.x + (-w2 * r2Y)) - v1.x) - (-w1 * r1Y)) + ax1Y * ((( v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X))); + var speed = (dX*(-w1 * ax1Y) + dY*(w1 * ax1X)) + (ax1X * ((( v2.x + (-w2 * r2Y)) - v1.x) - (-w1 * r1Y)) + ax1Y * ((( v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X))); + + return speed; + }, + GetMotorForce: function(invTimeStep){ + return invTimeStep * this.m_motorImpulse; + }, + + SetMotorSpeed: function(speed) + { + this.m_motorSpeed = speed; + }, + + SetMotorForce: function(force) + { + this.m_maxMotorForce = force; + }, + + GetReactionForce: function(invTimeStep) + { + var tImp = invTimeStep * this.m_limitImpulse; + var tMat; + + //var ax1 = b2Math.b2MulMV(this.m_body1.m_R, this.m_localXAxis1); + tMat = this.m_body1.m_R; + var ax1X = tImp * (tMat.col1.x * this.m_localXAxis1.x + tMat.col2.x * this.m_localXAxis1.y); + var ax1Y = tImp * (tMat.col1.y * this.m_localXAxis1.x + tMat.col2.y * this.m_localXAxis1.y); + //var ay1 = b2Math.b2MulMV(this.m_body1.m_R, this.m_localYAxis1); + var ay1X = tImp * (tMat.col1.x * this.m_localYAxis1.x + tMat.col2.x * this.m_localYAxis1.y); + var ay1Y = tImp * (tMat.col1.y * this.m_localYAxis1.x + tMat.col2.y * this.m_localYAxis1.y); + + //return (invTimeStep * this.m_limitImpulse) * ax1 + (invTimeStep * this.m_linearImpulse) * ay1; + + return new b2Vec2(ax1X+ay1X, ax1Y+ay1Y); + }, + + GetReactionTorque: function(invTimeStep) + { + return invTimeStep * this.m_angularImpulse; + }, + + + //--------------- Internals Below ------------------- + + initialize: function(def){ + // The constructor for b2Joint + // initialize instance variables for references + this.m_node1 = new b2JointNode(); + this.m_node2 = new b2JointNode(); + // + this.m_type = def.type; + this.m_prev = null; + this.m_next = null; + this.m_body1 = def.body1; + this.m_body2 = def.body2; + this.m_collideConnected = def.collideConnected; + this.m_islandFlag = false; + this.m_userData = def.userData; + // + + // initialize instance variables for references + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_localXAxis1 = new b2Vec2(); + this.m_localYAxis1 = new b2Vec2(); + this.m_linearJacobian = new b2Jacobian(); + this.m_motorJacobian = new b2Jacobian(); + // + + //super(def); + + var tMat; + var tX; + var tY; + + //this.m_localAnchor1 = b2Math.b2MulTMV(this.m_body1.m_R, b2Math.SubtractVV(def.anchorPoint , this.m_body1.m_position)); + tMat = this.m_body1.m_R; + tX = (def.anchorPoint.x - this.m_body1.m_position.x); + tY = (def.anchorPoint.y - this.m_body1.m_position.y); + this.m_localAnchor1.Set((tX*tMat.col1.x + tY*tMat.col1.y), (tX*tMat.col2.x + tY*tMat.col2.y)); + + //this.m_localAnchor2 = b2Math.b2MulTMV(this.m_body2.m_R, b2Math.SubtractVV(def.anchorPoint , this.m_body2.m_position)); + tMat = this.m_body2.m_R; + tX = (def.anchorPoint.x - this.m_body2.m_position.x); + tY = (def.anchorPoint.y - this.m_body2.m_position.y); + this.m_localAnchor2.Set((tX*tMat.col1.x + tY*tMat.col1.y), (tX*tMat.col2.x + tY*tMat.col2.y)); + + //this.m_localXAxis1 = b2Math.b2MulTMV(this.m_body1.m_R, def.axis); + tMat = this.m_body1.m_R; + tX = def.axis.x; + tY = def.axis.y; + this.m_localXAxis1.Set((tX*tMat.col1.x + tY*tMat.col1.y), (tX*tMat.col2.x + tY*tMat.col2.y)); + + //this.m_localYAxis1 = b2Math.b2CrossFV(1.0, this.m_localXAxis1); + this.m_localYAxis1.x = -this.m_localXAxis1.y; + this.m_localYAxis1.y = this.m_localXAxis1.x; + + this.m_initialAngle = this.m_body2.m_rotation - this.m_body1.m_rotation; + + this.m_linearJacobian.SetZero(); + this.m_linearMass = 0.0; + this.m_linearImpulse = 0.0; + + this.m_angularMass = 0.0; + this.m_angularImpulse = 0.0; + + this.m_motorJacobian.SetZero(); + this.m_motorMass = 0.0; + this.m_motorImpulse = 0.0; + this.m_limitImpulse = 0.0; + this.m_limitPositionImpulse = 0.0; + + this.m_lowerTranslation = def.lowerTranslation; + this.m_upperTranslation = def.upperTranslation; + this.m_maxMotorForce = def.motorForce; + this.m_motorSpeed = def.motorSpeed; + this.m_enableLimit = def.enableLimit; + this.m_enableMotor = def.enableMotor; + }, + + PrepareVelocitySolver: function(){ + var b1 = this.m_body1; + var b2 = this.m_body2; + + var tMat; + + // Compute the effective masses. + //b2Vec2 r1 = b2Mul(b1->m_R, this.m_localAnchor1); + tMat = b1.m_R; + var r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + var r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //b2Vec2 r2 = b2Mul(b2->m_R, this.m_localAnchor2); + tMat = b2.m_R; + var r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + var r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + + //float32 invMass1 = b1->m_invMass, invMass2 = b2->m_invMass; + var invMass1 = b1.m_invMass; + var invMass2 = b2.m_invMass; + //float32 invI1 = b1->m_invI, invI2 = b2->m_invI; + var invI1 = b1.m_invI; + var invI2 = b2.m_invI; + + // Compute point to line constraint effective mass. + // J = [-ay1 -cross(d+r1,ay1) ay1 cross(r2,ay1)] + //b2Vec2 ay1 = b2Mul(b1->m_R, this.m_localYAxis1); + tMat = b1.m_R; + var ay1X = tMat.col1.x * this.m_localYAxis1.x + tMat.col2.x * this.m_localYAxis1.y; + var ay1Y = tMat.col1.y * this.m_localYAxis1.x + tMat.col2.y * this.m_localYAxis1.y; + //b2Vec2 e = b2->m_position + r2 - b1->m_position; + var eX = b2.m_position.x + r2X - b1.m_position.x; + var eY = b2.m_position.y + r2Y - b1.m_position.y; + + //this.m_linearJacobian.Set(-ay1, -b2Math.b2Cross(e, ay1), ay1, b2Math.b2Cross(r2, ay1)); + this.m_linearJacobian.linear1.x = -ay1X; + this.m_linearJacobian.linear1.y = -ay1Y; + this.m_linearJacobian.linear2.x = ay1X; + this.m_linearJacobian.linear2.y = ay1Y; + this.m_linearJacobian.angular1 = -(eX * ay1Y - eY * ay1X); + this.m_linearJacobian.angular2 = r2X * ay1Y - r2Y * ay1X; + + this.m_linearMass = invMass1 + invI1 * this.m_linearJacobian.angular1 * this.m_linearJacobian.angular1 + + invMass2 + invI2 * this.m_linearJacobian.angular2 * this.m_linearJacobian.angular2; + //b2Settings.b2Assert(this.m_linearMass > Number.MIN_VALUE); + this.m_linearMass = 1.0 / this.m_linearMass; + + // Compute angular constraint effective mass. + this.m_angularMass = 1.0 / (invI1 + invI2); + + // Compute motor and limit terms. + if (this.m_enableLimit || this.m_enableMotor) + { + // The motor and limit share a Jacobian and effective mass. + //b2Vec2 ax1 = b2Mul(b1->m_R, this.m_localXAxis1); + tMat = b1.m_R; + var ax1X = tMat.col1.x * this.m_localXAxis1.x + tMat.col2.x * this.m_localXAxis1.y; + var ax1Y = tMat.col1.y * this.m_localXAxis1.x + tMat.col2.y * this.m_localXAxis1.y; + //this.m_motorJacobian.Set(-ax1, -b2Cross(e, ax1), ax1, b2Cross(r2, ax1)); + this.m_motorJacobian.linear1.x = -ax1X; this.m_motorJacobian.linear1.y = -ax1Y; + this.m_motorJacobian.linear2.x = ax1X; this.m_motorJacobian.linear2.y = ax1Y; + this.m_motorJacobian.angular1 = -(eX * ax1Y - eY * ax1X); + this.m_motorJacobian.angular2 = r2X * ax1Y - r2Y * ax1X; + + this.m_motorMass = invMass1 + invI1 * this.m_motorJacobian.angular1 * this.m_motorJacobian.angular1 + + invMass2 + invI2 * this.m_motorJacobian.angular2 * this.m_motorJacobian.angular2; + //b2Settings.b2Assert(this.m_motorMass > Number.MIN_VALUE); + this.m_motorMass = 1.0 / this.m_motorMass; + + if (this.m_enableLimit) + { + //b2Vec2 d = e - r1; + var dX = eX - r1X; + var dY = eY - r1Y; + //float32 jointTranslation = b2Dot(ax1, d); + var jointTranslation = ax1X * dX + ax1Y * dY; + if (b2Math.b2Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) + { + this.m_limitState = b2Joint.e_equalLimits; + } + else if (jointTranslation <= this.m_lowerTranslation) + { + if (this.m_limitState != b2Joint.e_atLowerLimit) + { + this.m_limitImpulse = 0.0; + } + this.m_limitState = b2Joint.e_atLowerLimit; + } + else if (jointTranslation >= this.m_upperTranslation) + { + if (this.m_limitState != b2Joint.e_atUpperLimit) + { + this.m_limitImpulse = 0.0; + } + this.m_limitState = b2Joint.e_atUpperLimit; + } + else + { + this.m_limitState = b2Joint.e_inactiveLimit; + this.m_limitImpulse = 0.0; + } + } + } + + if (this.m_enableMotor == false) + { + this.m_motorImpulse = 0.0; + } + + if (this.m_enableLimit == false) + { + this.m_limitImpulse = 0.0; + } + + if (b2World.s_enableWarmStarting) + { + //b2Vec2 P1 = this.m_linearImpulse * this.m_linearJacobian.linear1 + (this.m_motorImpulse + this.m_limitImpulse) * this.m_motorJacobian.linear1; + var P1X = this.m_linearImpulse * this.m_linearJacobian.linear1.x + (this.m_motorImpulse + this.m_limitImpulse) * this.m_motorJacobian.linear1.x; + var P1Y = this.m_linearImpulse * this.m_linearJacobian.linear1.y + (this.m_motorImpulse + this.m_limitImpulse) * this.m_motorJacobian.linear1.y; + //b2Vec2 P2 = this.m_linearImpulse * this.m_linearJacobian.linear2 + (this.m_motorImpulse + this.m_limitImpulse) * this.m_motorJacobian.linear2; + var P2X = this.m_linearImpulse * this.m_linearJacobian.linear2.x + (this.m_motorImpulse + this.m_limitImpulse) * this.m_motorJacobian.linear2.x; + var P2Y = this.m_linearImpulse * this.m_linearJacobian.linear2.y + (this.m_motorImpulse + this.m_limitImpulse) * this.m_motorJacobian.linear2.y; + //float32 L1 = this.m_linearImpulse * this.m_linearJacobian.angular1 - this.m_angularImpulse + (this.m_motorImpulse + this.m_limitImpulse) * this.m_motorJacobian.angular1; + var L1 = this.m_linearImpulse * this.m_linearJacobian.angular1 - this.m_angularImpulse + (this.m_motorImpulse + this.m_limitImpulse) * this.m_motorJacobian.angular1; + //float32 L2 = this.m_linearImpulse * this.m_linearJacobian.angular2 + this.m_angularImpulse + (this.m_motorImpulse + this.m_limitImpulse) * this.m_motorJacobian.angular2; + var L2 = this.m_linearImpulse * this.m_linearJacobian.angular2 + this.m_angularImpulse + (this.m_motorImpulse + this.m_limitImpulse) * this.m_motorJacobian.angular2; + + //b1->m_linearVelocity += invMass1 * P1; + b1.m_linearVelocity.x += invMass1 * P1X; + b1.m_linearVelocity.y += invMass1 * P1Y; + //b1->m_angularVelocity += invI1 * L1; + b1.m_angularVelocity += invI1 * L1; + + //b2->m_linearVelocity += invMass2 * P2; + b2.m_linearVelocity.x += invMass2 * P2X; + b2.m_linearVelocity.y += invMass2 * P2Y; + //b2->m_angularVelocity += invI2 * L2; + b2.m_angularVelocity += invI2 * L2; + } + else + { + this.m_linearImpulse = 0.0; + this.m_angularImpulse = 0.0; + this.m_limitImpulse = 0.0; + this.m_motorImpulse = 0.0; + } + + this.m_limitPositionImpulse = 0.0; + + }, + + SolveVelocityConstraints: function(step){ + var b1 = this.m_body1; + var b2 = this.m_body2; + + var invMass1 = b1.m_invMass; + var invMass2 = b2.m_invMass; + var invI1 = b1.m_invI; + var invI2 = b2.m_invI; + + var oldLimitImpulse; + + // Solve linear constraint. + var linearCdot = this.m_linearJacobian.Compute(b1.m_linearVelocity, b1.m_angularVelocity, b2.m_linearVelocity, b2.m_angularVelocity); + var linearImpulse = -this.m_linearMass * linearCdot; + this.m_linearImpulse += linearImpulse; + + //b1->m_linearVelocity += (invMass1 * linearImpulse) * this.m_linearJacobian.linear1; + b1.m_linearVelocity.x += (invMass1 * linearImpulse) * this.m_linearJacobian.linear1.x; + b1.m_linearVelocity.y += (invMass1 * linearImpulse) * this.m_linearJacobian.linear1.y; + //b1->m_angularVelocity += invI1 * linearImpulse * this.m_linearJacobian.angular1; + b1.m_angularVelocity += invI1 * linearImpulse * this.m_linearJacobian.angular1; + + //b2->m_linearVelocity += (invMass2 * linearImpulse) * this.m_linearJacobian.linear2; + b2.m_linearVelocity.x += (invMass2 * linearImpulse) * this.m_linearJacobian.linear2.x; + b2.m_linearVelocity.y += (invMass2 * linearImpulse) * this.m_linearJacobian.linear2.y; + //b2.m_angularVelocity += invI2 * linearImpulse * this.m_linearJacobian.angular2; + b2.m_angularVelocity += invI2 * linearImpulse * this.m_linearJacobian.angular2; + + // Solve angular constraint. + var angularCdot = b2.m_angularVelocity - b1.m_angularVelocity; + var angularImpulse = -this.m_angularMass * angularCdot; + this.m_angularImpulse += angularImpulse; + + b1.m_angularVelocity -= invI1 * angularImpulse; + b2.m_angularVelocity += invI2 * angularImpulse; + + // Solve linear motor constraint. + if (this.m_enableMotor && this.m_limitState != b2Joint.e_equalLimits) + { + var motorCdot = this.m_motorJacobian.Compute(b1.m_linearVelocity, b1.m_angularVelocity, b2.m_linearVelocity, b2.m_angularVelocity) - this.m_motorSpeed; + var motorImpulse = -this.m_motorMass * motorCdot; + var oldMotorImpulse = this.m_motorImpulse; + this.m_motorImpulse = b2Math.b2Clamp(this.m_motorImpulse + motorImpulse, -step.dt * this.m_maxMotorForce, step.dt * this.m_maxMotorForce); + motorImpulse = this.m_motorImpulse - oldMotorImpulse; + + //b1.m_linearVelocity += (invMass1 * motorImpulse) * this.m_motorJacobian.linear1; + b1.m_linearVelocity.x += (invMass1 * motorImpulse) * this.m_motorJacobian.linear1.x; + b1.m_linearVelocity.y += (invMass1 * motorImpulse) * this.m_motorJacobian.linear1.y; + //b1.m_angularVelocity += invI1 * motorImpulse * this.m_motorJacobian.angular1; + b1.m_angularVelocity += invI1 * motorImpulse * this.m_motorJacobian.angular1; + + //b2->m_linearVelocity += (invMass2 * motorImpulse) * this.m_motorJacobian.linear2; + b2.m_linearVelocity.x += (invMass2 * motorImpulse) * this.m_motorJacobian.linear2.x; + b2.m_linearVelocity.y += (invMass2 * motorImpulse) * this.m_motorJacobian.linear2.y; + //b2->m_angularVelocity += invI2 * motorImpulse * this.m_motorJacobian.angular2; + b2.m_angularVelocity += invI2 * motorImpulse * this.m_motorJacobian.angular2; + } + + // Solve linear limit constraint. + if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) + { + var limitCdot = this.m_motorJacobian.Compute(b1.m_linearVelocity, b1.m_angularVelocity, b2.m_linearVelocity, b2.m_angularVelocity); + var limitImpulse = -this.m_motorMass * limitCdot; + + if (this.m_limitState == b2Joint.e_equalLimits) + { + this.m_limitImpulse += limitImpulse; + } + else if (this.m_limitState == b2Joint.e_atLowerLimit) + { + oldLimitImpulse = this.m_limitImpulse; + this.m_limitImpulse = b2Math.b2Max(this.m_limitImpulse + limitImpulse, 0.0); + limitImpulse = this.m_limitImpulse - oldLimitImpulse; + } + else if (this.m_limitState == b2Joint.e_atUpperLimit) + { + oldLimitImpulse = this.m_limitImpulse; + this.m_limitImpulse = b2Math.b2Min(this.m_limitImpulse + limitImpulse, 0.0); + limitImpulse = this.m_limitImpulse - oldLimitImpulse; + } + + //b1->m_linearVelocity += (invMass1 * limitImpulse) * this.m_motorJacobian.linear1; + b1.m_linearVelocity.x += (invMass1 * limitImpulse) * this.m_motorJacobian.linear1.x; + b1.m_linearVelocity.y += (invMass1 * limitImpulse) * this.m_motorJacobian.linear1.y; + //b1->m_angularVelocity += invI1 * limitImpulse * this.m_motorJacobian.angular1; + b1.m_angularVelocity += invI1 * limitImpulse * this.m_motorJacobian.angular1; + + //b2->m_linearVelocity += (invMass2 * limitImpulse) * this.m_motorJacobian.linear2; + b2.m_linearVelocity.x += (invMass2 * limitImpulse) * this.m_motorJacobian.linear2.x; + b2.m_linearVelocity.y += (invMass2 * limitImpulse) * this.m_motorJacobian.linear2.y; + //b2->m_angularVelocity += invI2 * limitImpulse * this.m_motorJacobian.angular2; + b2.m_angularVelocity += invI2 * limitImpulse * this.m_motorJacobian.angular2; + } + }, + + + + SolvePositionConstraints: function(){ + + var limitC; + var oldLimitImpulse; + + var b1 = this.m_body1; + var b2 = this.m_body2; + + var invMass1 = b1.m_invMass; + var invMass2 = b2.m_invMass; + var invI1 = b1.m_invI; + var invI2 = b2.m_invI; + + var tMat; + + //b2Vec2 r1 = b2Mul(b1->m_R, this.m_localAnchor1); + tMat = b1.m_R; + var r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + var r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //b2Vec2 r2 = b2Mul(b2->m_R, this.m_localAnchor2); + tMat = b2.m_R; + var r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + var r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + //b2Vec2 p1 = b1->m_position + r1; + var p1X = b1.m_position.x + r1X; + var p1Y = b1.m_position.y + r1Y; + //b2Vec2 p2 = b2->m_position + r2; + var p2X = b2.m_position.x + r2X; + var p2Y = b2.m_position.y + r2Y; + //b2Vec2 d = p2 - p1; + var dX = p2X - p1X; + var dY = p2Y - p1Y; + //b2Vec2 ay1 = b2Mul(b1->m_R, this.m_localYAxis1); + tMat = b1.m_R; + var ay1X = tMat.col1.x * this.m_localYAxis1.x + tMat.col2.x * this.m_localYAxis1.y; + var ay1Y = tMat.col1.y * this.m_localYAxis1.x + tMat.col2.y * this.m_localYAxis1.y; + + // Solve linear (point-to-line) constraint. + //float32 linearC = b2Dot(ay1, d); + var linearC = ay1X*dX + ay1Y*dY; + // Prevent overly large corrections. + linearC = b2Math.b2Clamp(linearC, -b2Settings.b2_maxLinearCorrection, b2Settings.b2_maxLinearCorrection); + var linearImpulse = -this.m_linearMass * linearC; + + //b1->m_position += (invMass1 * linearImpulse) * this.m_linearJacobian.linear1; + b1.m_position.x += (invMass1 * linearImpulse) * this.m_linearJacobian.linear1.x; + b1.m_position.y += (invMass1 * linearImpulse) * this.m_linearJacobian.linear1.y; + //b1->m_rotation += invI1 * linearImpulse * this.m_linearJacobian.angular1; + b1.m_rotation += invI1 * linearImpulse * this.m_linearJacobian.angular1; + //b1->m_R.Set(b1->m_rotation); + //b2->m_position += (invMass2 * linearImpulse) * this.m_linearJacobian.linear2; + b2.m_position.x += (invMass2 * linearImpulse) * this.m_linearJacobian.linear2.x; + b2.m_position.y += (invMass2 * linearImpulse) * this.m_linearJacobian.linear2.y; + b2.m_rotation += invI2 * linearImpulse * this.m_linearJacobian.angular2; + //b2->m_R.Set(b2->m_rotation); + + var positionError = b2Math.b2Abs(linearC); + + // Solve angular constraint. + var angularC = b2.m_rotation - b1.m_rotation - this.m_initialAngle; + // Prevent overly large corrections. + angularC = b2Math.b2Clamp(angularC, -b2Settings.b2_maxAngularCorrection, b2Settings.b2_maxAngularCorrection); + var angularImpulse = -this.m_angularMass * angularC; + + b1.m_rotation -= b1.m_invI * angularImpulse; + b1.m_R.Set(b1.m_rotation); + b2.m_rotation += b2.m_invI * angularImpulse; + b2.m_R.Set(b2.m_rotation); + + var angularError = b2Math.b2Abs(angularC); + + // Solve linear limit constraint. + if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) + { + + //b2Vec2 r1 = b2Mul(b1->m_R, this.m_localAnchor1); + tMat = b1.m_R; + r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //b2Vec2 r2 = b2Mul(b2->m_R, this.m_localAnchor2); + tMat = b2.m_R; + r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + //b2Vec2 p1 = b1->m_position + r1; + p1X = b1.m_position.x + r1X; + p1Y = b1.m_position.y + r1Y; + //b2Vec2 p2 = b2->m_position + r2; + p2X = b2.m_position.x + r2X; + p2Y = b2.m_position.y + r2Y; + //b2Vec2 d = p2 - p1; + dX = p2X - p1X; + dY = p2Y - p1Y; + //b2Vec2 ax1 = b2Mul(b1->m_R, this.m_localXAxis1); + tMat = b1.m_R; + var ax1X = tMat.col1.x * this.m_localXAxis1.x + tMat.col2.x * this.m_localXAxis1.y; + var ax1Y = tMat.col1.y * this.m_localXAxis1.x + tMat.col2.y * this.m_localXAxis1.y; + + //float32 translation = b2Dot(ax1, d); + var translation = (ax1X*dX + ax1Y*dY); + var limitImpulse = 0.0; + + if (this.m_limitState == b2Joint.e_equalLimits) + { + // Prevent large angular corrections + limitC = b2Math.b2Clamp(translation, -b2Settings.b2_maxLinearCorrection, b2Settings.b2_maxLinearCorrection); + limitImpulse = -this.m_motorMass * limitC; + positionError = b2Math.b2Max(positionError, b2Math.b2Abs(angularC)); + } + else if (this.m_limitState == b2Joint.e_atLowerLimit) + { + limitC = translation - this.m_lowerTranslation; + positionError = b2Math.b2Max(positionError, -limitC); + + // Prevent large linear corrections and allow some slop. + limitC = b2Math.b2Clamp(limitC + b2Settings.b2_linearSlop, -b2Settings.b2_maxLinearCorrection, 0.0); + limitImpulse = -this.m_motorMass * limitC; + oldLimitImpulse = this.m_limitPositionImpulse; + this.m_limitPositionImpulse = b2Math.b2Max(this.m_limitPositionImpulse + limitImpulse, 0.0); + limitImpulse = this.m_limitPositionImpulse - oldLimitImpulse; + } + else if (this.m_limitState == b2Joint.e_atUpperLimit) + { + limitC = translation - this.m_upperTranslation; + positionError = b2Math.b2Max(positionError, limitC); + + // Prevent large linear corrections and allow some slop. + limitC = b2Math.b2Clamp(limitC - b2Settings.b2_linearSlop, 0.0, b2Settings.b2_maxLinearCorrection); + limitImpulse = -this.m_motorMass * limitC; + oldLimitImpulse = this.m_limitPositionImpulse; + this.m_limitPositionImpulse = b2Math.b2Min(this.m_limitPositionImpulse + limitImpulse, 0.0); + limitImpulse = this.m_limitPositionImpulse - oldLimitImpulse; + } + + //b1->m_position += (invMass1 * limitImpulse) * this.m_motorJacobian.linear1; + b1.m_position.x += (invMass1 * limitImpulse) * this.m_motorJacobian.linear1.x; + b1.m_position.y += (invMass1 * limitImpulse) * this.m_motorJacobian.linear1.y; + //b1->m_rotation += invI1 * limitImpulse * this.m_motorJacobian.angular1; + b1.m_rotation += invI1 * limitImpulse * this.m_motorJacobian.angular1; + b1.m_R.Set(b1.m_rotation); + //b2->m_position += (invMass2 * limitImpulse) * this.m_motorJacobian.linear2; + b2.m_position.x += (invMass2 * limitImpulse) * this.m_motorJacobian.linear2.x; + b2.m_position.y += (invMass2 * limitImpulse) * this.m_motorJacobian.linear2.y; + //b2->m_rotation += invI2 * limitImpulse * this.m_motorJacobian.angular2; + b2.m_rotation += invI2 * limitImpulse * this.m_motorJacobian.angular2; + b2.m_R.Set(b2.m_rotation); + } + + return positionError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop; + + }, + + m_localAnchor1: new b2Vec2(), + m_localAnchor2: new b2Vec2(), + m_localXAxis1: new b2Vec2(), + m_localYAxis1: new b2Vec2(), + m_initialAngle: null, + + m_linearJacobian: new b2Jacobian(), + m_linearMass: null, + m_linearImpulse: null, + + m_angularMass: null, + m_angularImpulse: null, + + m_motorJacobian: new b2Jacobian(), + m_motorMass: null, + m_motorImpulse: null, + m_limitImpulse: null, + m_limitPositionImpulse: null, + + m_lowerTranslation: null, + m_upperTranslation: null, + m_maxMotorForce: null, + m_motorSpeed: null, + + m_enableLimit: null, + m_enableMotor: null, + m_limitState: 0}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2PrismaticJointDef.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2PrismaticJointDef.js new file mode 100644 index 00000000..42d5743a --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2PrismaticJointDef.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +var b2PrismaticJointDef = Class.create(); +Object.extend(b2PrismaticJointDef.prototype, b2JointDef.prototype); +Object.extend(b2PrismaticJointDef.prototype, +{ + initialize: function() + { + // The constructor for b2JointDef + this.type = b2Joint.e_unknownJoint; + this.userData = null; + this.body1 = null; + this.body2 = null; + this.collideConnected = false; + // + + this.type = b2Joint.e_prismaticJoint; + this.anchorPoint = new b2Vec2(0.0, 0.0); + this.axis = new b2Vec2(0.0, 0.0); + this.lowerTranslation = 0.0; + this.upperTranslation = 0.0; + this.motorForce = 0.0; + this.motorSpeed = 0.0; + this.enableLimit = false; + this.enableMotor = false; + }, + + anchorPoint: null, + axis: null, + lowerTranslation: null, + upperTranslation: null, + motorForce: null, + motorSpeed: null, + enableLimit: null, + enableMotor: null}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2PulleyJoint.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2PulleyJoint.js new file mode 100644 index 00000000..8b8506d6 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2PulleyJoint.js @@ -0,0 +1,618 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + + +var b2PulleyJoint = Class.create(); +Object.extend(b2PulleyJoint.prototype, b2Joint.prototype); +Object.extend(b2PulleyJoint.prototype, +{ + GetAnchor1: function(){ + //return this.m_body1->m_position + b2Mul(this.m_body1->m_R, this.m_localAnchor1); + var tMat = this.m_body1.m_R; + return new b2Vec2( this.m_body1.m_position.x + (tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y), + this.m_body1.m_position.y + (tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y)); + }, + GetAnchor2: function(){ + //return this.m_body2->m_position + b2Mul(this.m_body2->m_R, this.m_localAnchor2); + var tMat = this.m_body2.m_R; + return new b2Vec2( this.m_body2.m_position.x + (tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y), + this.m_body2.m_position.y + (tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y)); + }, + + GetGroundPoint1: function(){ + //return this.m_ground->m_position + this.m_groundAnchor1; + return new b2Vec2(this.m_ground.m_position.x + this.m_groundAnchor1.x, this.m_ground.m_position.y + this.m_groundAnchor1.y); + }, + GetGroundPoint2: function(){ + return new b2Vec2(this.m_ground.m_position.x + this.m_groundAnchor2.x, this.m_ground.m_position.y + this.m_groundAnchor2.y); + }, + + GetReactionForce: function(invTimeStep){ + //b2Vec2 F(0.0f, 0.0f); + return new b2Vec2(); + }, + GetReactionTorque: function(invTimeStep){ + return 0.0; + }, + + GetLength1: function(){ + var tMat; + //b2Vec2 p = this.m_body1->m_position + b2Mul(this.m_body1->m_R, this.m_localAnchor1); + tMat = this.m_body1.m_R; + var pX = this.m_body1.m_position.x + (tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y); + var pY = this.m_body1.m_position.y + (tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y); + //b2Vec2 s = this.m_ground->m_position + this.m_groundAnchor1; + //b2Vec2 d = p - s; + var dX = pX - (this.m_ground.m_position.x + this.m_groundAnchor1.x); + var dY = pY - (this.m_ground.m_position.y + this.m_groundAnchor1.y); + return Math.sqrt(dX*dX + dY*dY); + }, + GetLength2: function(){ + var tMat; + //b2Vec2 p = this.m_body2->m_position + b2Mul(this.m_body2->m_R, this.m_localAnchor2); + tMat = this.m_body2.m_R; + var pX = this.m_body2.m_position.x + (tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y); + var pY = this.m_body2.m_position.y + (tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y); + //b2Vec2 s = this.m_ground->m_position + this.m_groundAnchor2; + //b2Vec2 d = p - s; + var dX = pX - (this.m_ground.m_position.x + this.m_groundAnchor2.x); + var dY = pY - (this.m_ground.m_position.y + this.m_groundAnchor2.y); + return Math.sqrt(dX*dX + dY*dY); + }, + + GetRatio: function(){ + return this.m_ratio; + }, + + //--------------- Internals Below ------------------- + + initialize: function(def){ + // The constructor for b2Joint + // initialize instance variables for references + this.m_node1 = new b2JointNode(); + this.m_node2 = new b2JointNode(); + // + this.m_type = def.type; + this.m_prev = null; + this.m_next = null; + this.m_body1 = def.body1; + this.m_body2 = def.body2; + this.m_collideConnected = def.collideConnected; + this.m_islandFlag = false; + this.m_userData = def.userData; + // + + // initialize instance variables for references + 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(); + // + + + // parent + //super(def); + + var tMat; + var tX; + var tY; + + this.m_ground = this.m_body1.m_world.m_groundBody; + //this.m_groundAnchor1 = def.groundPoint1 - this.m_ground.m_position; + this.m_groundAnchor1.x = def.groundPoint1.x - this.m_ground.m_position.x; + this.m_groundAnchor1.y = def.groundPoint1.y - this.m_ground.m_position.y; + //this.m_groundAnchor2 = def.groundPoint2 - this.m_ground.m_position; + this.m_groundAnchor2.x = def.groundPoint2.x - this.m_ground.m_position.x; + this.m_groundAnchor2.y = def.groundPoint2.y - this.m_ground.m_position.y; + //this.m_localAnchor1 = b2MulT(this.m_body1.m_R, def.anchorPoint1 - this.m_body1.m_position); + tMat = this.m_body1.m_R; + tX = def.anchorPoint1.x - this.m_body1.m_position.x; + tY = def.anchorPoint1.y - this.m_body1.m_position.y; + this.m_localAnchor1.x = tX*tMat.col1.x + tY*tMat.col1.y; + this.m_localAnchor1.y = tX*tMat.col2.x + tY*tMat.col2.y; + //this.m_localAnchor2 = b2MulT(this.m_body2.m_R, def.anchorPoint2 - this.m_body2.m_position); + tMat = this.m_body2.m_R; + tX = def.anchorPoint2.x - this.m_body2.m_position.x; + tY = def.anchorPoint2.y - this.m_body2.m_position.y; + this.m_localAnchor2.x = tX*tMat.col1.x + tY*tMat.col1.y; + this.m_localAnchor2.y = tX*tMat.col2.x + tY*tMat.col2.y; + + this.m_ratio = def.ratio; + + //var d1 = def.groundPoint1 - def.anchorPoint1; + tX = def.groundPoint1.x - def.anchorPoint1.x; + tY = def.groundPoint1.y - def.anchorPoint1.y; + var d1Len = Math.sqrt(tX*tX + tY*tY); + //var d2 = def.groundPoint2 - def.anchorPoint2; + tX = def.groundPoint2.x - def.anchorPoint2.x; + tY = def.groundPoint2.y - def.anchorPoint2.y; + var d2Len = Math.sqrt(tX*tX + tY*tY); + + var length1 = b2Math.b2Max(0.5 * b2PulleyJoint.b2_minPulleyLength, d1Len); + var length2 = b2Math.b2Max(0.5 * b2PulleyJoint.b2_minPulleyLength, d2Len); + + this.m_constant = length1 + this.m_ratio * length2; + + this.m_maxLength1 = b2Math.b2Clamp(def.maxLength1, length1, this.m_constant - this.m_ratio * b2PulleyJoint.b2_minPulleyLength); + this.m_maxLength2 = b2Math.b2Clamp(def.maxLength2, length2, (this.m_constant - b2PulleyJoint.b2_minPulleyLength) / this.m_ratio); + + this.m_pulleyImpulse = 0.0; + this.m_limitImpulse1 = 0.0; + this.m_limitImpulse2 = 0.0; + + }, + + PrepareVelocitySolver: function(){ + var b1 = this.m_body1; + var b2 = this.m_body2; + + var tMat; + + //b2Vec2 r1 = b2Mul(b1->m_R, this.m_localAnchor1); + tMat = b1.m_R; + var r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + var r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //b2Vec2 r2 = b2Mul(b2->m_R, this.m_localAnchor2); + tMat = b2.m_R; + var r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + var r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + + //b2Vec2 p1 = b1->m_position + r1; + var p1X = b1.m_position.x + r1X; + var p1Y = b1.m_position.y + r1Y; + //b2Vec2 p2 = b2->m_position + r2; + var p2X = b2.m_position.x + r2X; + var p2Y = b2.m_position.y + r2Y; + + //b2Vec2 s1 = this.m_ground->m_position + this.m_groundAnchor1; + var s1X = this.m_ground.m_position.x + this.m_groundAnchor1.x; + var s1Y = this.m_ground.m_position.y + this.m_groundAnchor1.y; + //b2Vec2 s2 = this.m_ground->m_position + this.m_groundAnchor2; + var s2X = this.m_ground.m_position.x + this.m_groundAnchor2.x; + var s2Y = this.m_ground.m_position.y + this.m_groundAnchor2.y; + + // Get the pulley axes. + //this.m_u1 = p1 - s1; + this.m_u1.Set(p1X - s1X, p1Y - s1Y); + //this.m_u2 = p2 - s2; + 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 *= 1.0f / length1; + this.m_u1.Multiply(1.0 / length1); + } + else + { + this.m_u1.SetZero(); + } + + if (length2 > b2Settings.b2_linearSlop) + { + //this.m_u2 *= 1.0f / length2; + this.m_u2.Multiply(1.0 / length2); + } + else + { + this.m_u2.SetZero(); + } + + if (length1 < this.m_maxLength1) + { + this.m_limitState1 = b2Joint.e_inactiveLimit; + this.m_limitImpulse1 = 0.0; + } + else + { + this.m_limitState1 = b2Joint.e_atUpperLimit; + this.m_limitPositionImpulse1 = 0.0; + } + + if (length2 < this.m_maxLength2) + { + this.m_limitState2 = b2Joint.e_inactiveLimit; + this.m_limitImpulse2 = 0.0; + } + else + { + this.m_limitState2 = b2Joint.e_atUpperLimit; + this.m_limitPositionImpulse2 = 0.0; + } + + // Compute effective mass. + //var cr1u1 = b2Cross(r1, this.m_u1); + var cr1u1 = r1X * this.m_u1.y - r1Y * this.m_u1.x; + //var cr2u2 = b2Cross(r2, this.m_u2); + var cr2u2 = r2X * this.m_u2.y - r2Y * this.m_u2.x; + + this.m_limitMass1 = b1.m_invMass + b1.m_invI * cr1u1 * cr1u1; + this.m_limitMass2 = b2.m_invMass + b2.m_invI * cr2u2 * cr2u2; + this.m_pulleyMass = this.m_limitMass1 + this.m_ratio * this.m_ratio * this.m_limitMass2; + //b2Settings.b2Assert(this.m_limitMass1 > Number.MIN_VALUE); + //b2Settings.b2Assert(this.m_limitMass2 > Number.MIN_VALUE); + //b2Settings.b2Assert(this.m_pulleyMass > Number.MIN_VALUE); + this.m_limitMass1 = 1.0 / this.m_limitMass1; + this.m_limitMass2 = 1.0 / this.m_limitMass2; + this.m_pulleyMass = 1.0 / this.m_pulleyMass; + + // Warm starting. + //b2Vec2 P1 = (-this.m_pulleyImpulse - this.m_limitImpulse1) * this.m_u1; + var P1X = (-this.m_pulleyImpulse - this.m_limitImpulse1) * this.m_u1.x; + var P1Y = (-this.m_pulleyImpulse - this.m_limitImpulse1) * this.m_u1.y; + //b2Vec2 P2 = (-this.m_ratio * this.m_pulleyImpulse - this.m_limitImpulse2) * this.m_u2; + var P2X = (-this.m_ratio * this.m_pulleyImpulse - this.m_limitImpulse2) * this.m_u2.x; + var P2Y = (-this.m_ratio * this.m_pulleyImpulse - this.m_limitImpulse2) * this.m_u2.y; + //b1.m_linearVelocity += b1.m_invMass * P1; + b1.m_linearVelocity.x += b1.m_invMass * P1X; + b1.m_linearVelocity.y += b1.m_invMass * P1Y; + //b1.m_angularVelocity += b1.m_invI * b2Cross(r1, P1); + b1.m_angularVelocity += b1.m_invI * (r1X * P1Y - r1Y * P1X); + //b2.m_linearVelocity += b2.m_invMass * P2; + b2.m_linearVelocity.x += b2.m_invMass * P2X; + b2.m_linearVelocity.y += b2.m_invMass * P2Y; + //b2.m_angularVelocity += b2.m_invI * b2Cross(r2, P2); + b2.m_angularVelocity += b2.m_invI * (r2X * P2Y - r2Y * P2X); + }, + + SolveVelocityConstraints: function(step){ + var b1 = this.m_body1; + var b2 = this.m_body2; + + var tMat; + + //var r1 = b2Mul(b1.m_R, this.m_localAnchor1); + tMat = b1.m_R; + var r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + var r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //var r2 = b2Mul(b2.m_R, this.m_localAnchor2); + tMat = b2.m_R; + var r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + var r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + + // temp vars + var v1X; + var v1Y; + var v2X; + var v2Y; + var P1X; + var P1Y; + var P2X; + var P2Y; + var Cdot; + var impulse; + var oldLimitImpulse; + + //{ + //b2Vec2 v1 = b1->m_linearVelocity + b2Cross(b1->m_angularVelocity, r1); + v1X = b1.m_linearVelocity.x + (-b1.m_angularVelocity * r1Y); + v1Y = b1.m_linearVelocity.y + (b1.m_angularVelocity * r1X); + //b2Vec2 v2 = b2->m_linearVelocity + b2Cross(b2->m_angularVelocity, r2); + v2X = b2.m_linearVelocity.x + (-b2.m_angularVelocity * r2Y); + v2Y = b2.m_linearVelocity.y + (b2.m_angularVelocity * r2X); + + //Cdot = -b2Dot(this.m_u1, v1) - this.m_ratio * b2Dot(this.m_u2, v2); + 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; + this.m_pulleyImpulse += impulse; + + //b2Vec2 P1 = -impulse * this.m_u1; + P1X = -impulse * this.m_u1.x; + P1Y = -impulse * this.m_u1.y; + //b2Vec2 P2 = -this.m_ratio * impulse * this.m_u2; + P2X = -this.m_ratio * impulse * this.m_u2.x; + P2Y = -this.m_ratio * impulse * this.m_u2.y; + //b1.m_linearVelocity += b1.m_invMass * P1; + b1.m_linearVelocity.x += b1.m_invMass * P1X; + b1.m_linearVelocity.y += b1.m_invMass * P1Y; + //b1.m_angularVelocity += b1.m_invI * b2Cross(r1, P1); + b1.m_angularVelocity += b1.m_invI * (r1X * P1Y - r1Y * P1X); + //b2.m_linearVelocity += b2.m_invMass * P2; + b2.m_linearVelocity.x += b2.m_invMass * P2X; + b2.m_linearVelocity.y += b2.m_invMass * P2Y; + //b2.m_angularVelocity += b2.m_invI * b2Cross(r2, P2); + b2.m_angularVelocity += b2.m_invI * (r2X * P2Y - r2Y * P2X); + //} + + if (this.m_limitState1 == b2Joint.e_atUpperLimit) + { + //b2Vec2 v1 = b1->m_linearVelocity + b2Cross(b1->m_angularVelocity, r1); + v1X = b1.m_linearVelocity.x + (-b1.m_angularVelocity * r1Y); + v1Y = b1.m_linearVelocity.y + (b1.m_angularVelocity * r1X); + + //float32 Cdot = -b2Dot(this.m_u1, v1); + Cdot = -(this.m_u1.x * v1X + this.m_u1.y * v1Y); + impulse = -this.m_limitMass1 * Cdot; + oldLimitImpulse = this.m_limitImpulse1; + this.m_limitImpulse1 = b2Math.b2Max(0.0, this.m_limitImpulse1 + impulse); + impulse = this.m_limitImpulse1 - oldLimitImpulse; + //b2Vec2 P1 = -impulse * this.m_u1; + P1X = -impulse * this.m_u1.x; + P1Y = -impulse * this.m_u1.y; + //b1.m_linearVelocity += b1->m_invMass * P1; + b1.m_linearVelocity.x += b1.m_invMass * P1X; + b1.m_linearVelocity.y += b1.m_invMass * P1Y; + //b1.m_angularVelocity += b1->m_invI * b2Cross(r1, P1); + b1.m_angularVelocity += b1.m_invI * (r1X * P1Y - r1Y * P1X); + } + + if (this.m_limitState2 == b2Joint.e_atUpperLimit) + { + //b2Vec2 v2 = b2->m_linearVelocity + b2Cross(b2->m_angularVelocity, r2); + v2X = b2.m_linearVelocity.x + (-b2.m_angularVelocity * r2Y); + v2Y = b2.m_linearVelocity.y + (b2.m_angularVelocity * r2X); + + //float32 Cdot = -b2Dot(this.m_u2, v2); + Cdot = -(this.m_u2.x * v2X + this.m_u2.y * v2Y); + impulse = -this.m_limitMass2 * Cdot; + oldLimitImpulse = this.m_limitImpulse2; + this.m_limitImpulse2 = b2Math.b2Max(0.0, this.m_limitImpulse2 + impulse); + impulse = this.m_limitImpulse2 - oldLimitImpulse; + //b2Vec2 P2 = -impulse * this.m_u2; + P2X = -impulse * this.m_u2.x; + P2Y = -impulse * this.m_u2.y; + //b2->m_linearVelocity += b2->m_invMass * P2; + b2.m_linearVelocity.x += b2.m_invMass * P2X; + b2.m_linearVelocity.y += b2.m_invMass * P2Y; + //b2->m_angularVelocity += b2->m_invI * b2Cross(r2, P2); + b2.m_angularVelocity += b2.m_invI * (r2X * P2Y - r2Y * P2X); + } + }, + + + + SolvePositionConstraints: function(){ + var b1 = this.m_body1; + var b2 = this.m_body2; + + var tMat; + + //b2Vec2 s1 = this.m_ground->m_position + this.m_groundAnchor1; + var s1X = this.m_ground.m_position.x + this.m_groundAnchor1.x; + var s1Y = this.m_ground.m_position.y + this.m_groundAnchor1.y; + //b2Vec2 s2 = this.m_ground->m_position + this.m_groundAnchor2; + var s2X = this.m_ground.m_position.x + this.m_groundAnchor2.x; + var s2Y = this.m_ground.m_position.y + this.m_groundAnchor2.y; + + // temp vars + var r1X; + var r1Y; + var r2X; + var r2Y; + var p1X; + var p1Y; + var p2X; + var p2Y; + var length1; + var length2; + var C; + var impulse; + var oldLimitPositionImpulse; + + var linearError = 0.0; + + { + //var r1 = b2Mul(b1.m_R, this.m_localAnchor1); + tMat = b1.m_R; + r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //var r2 = b2Mul(b2.m_R, this.m_localAnchor2); + tMat = b2.m_R; + r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + + //b2Vec2 p1 = b1->m_position + r1; + p1X = b1.m_position.x + r1X; + p1Y = b1.m_position.y + r1Y; + //b2Vec2 p2 = b2->m_position + r2; + p2X = b2.m_position.x + r2X; + p2Y = b2.m_position.y + r2Y; + + // Get the pulley axes. + //this.m_u1 = p1 - s1; + this.m_u1.Set(p1X - s1X, p1Y - s1Y); + //this.m_u2 = p2 - s2; + 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 *= 1.0f / length1; + this.m_u1.Multiply( 1.0 / length1 ); + } + else + { + this.m_u1.SetZero(); + } + + if (length2 > b2Settings.b2_linearSlop) + { + //this.m_u2 *= 1.0f / length2; + this.m_u2.Multiply( 1.0 / length2 ); + } + else + { + this.m_u2.SetZero(); + } + + C = this.m_constant - length1 - this.m_ratio * length2; + linearError = b2Math.b2Max(linearError, Math.abs(C)); + C = b2Math.b2Clamp(C, -b2Settings.b2_maxLinearCorrection, b2Settings.b2_maxLinearCorrection); + 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; + + b1.m_position.x += b1.m_invMass * p1X; + b1.m_position.y += b1.m_invMass * p1Y; + b1.m_rotation += b1.m_invI * (r1X * p1Y - r1Y * p1X); + b2.m_position.x += b2.m_invMass * p2X; + b2.m_position.y += b2.m_invMass * p2Y; + b2.m_rotation += b2.m_invI * (r2X * p2Y - r2Y * p2X); + + b1.m_R.Set(b1.m_rotation); + b2.m_R.Set(b2.m_rotation); + } + + if (this.m_limitState1 == b2Joint.e_atUpperLimit) + { + //b2Vec2 r1 = b2Mul(b1->m_R, this.m_localAnchor1); + tMat = b1.m_R; + r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //b2Vec2 p1 = b1->m_position + r1; + p1X = b1.m_position.x + r1X; + p1Y = b1.m_position.y + r1Y; + + //this.m_u1 = p1 - s1; + this.m_u1.Set(p1X - s1X, p1Y - s1Y); + + length1 = this.m_u1.Length(); + + if (length1 > b2Settings.b2_linearSlop) + { + //this.m_u1 *= 1.0 / length1; + 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.b2Max(linearError, -C); + C = b2Math.b2Clamp(C + b2Settings.b2_linearSlop, -b2Settings.b2_maxLinearCorrection, 0.0); + impulse = -this.m_limitMass1 * C; + oldLimitPositionImpulse = this.m_limitPositionImpulse1; + this.m_limitPositionImpulse1 = b2Math.b2Max(0.0, this.m_limitPositionImpulse1 + impulse); + impulse = this.m_limitPositionImpulse1 - oldLimitPositionImpulse; + + //P1 = -impulse * this.m_u1; + p1X = -impulse * this.m_u1.x; + p1Y = -impulse * this.m_u1.y; + + b1.m_position.x += b1.m_invMass * p1X; + b1.m_position.y += b1.m_invMass * p1Y; + //b1.m_rotation += b1.m_invI * b2Cross(r1, P1); + b1.m_rotation += b1.m_invI * (r1X * p1Y - r1Y * p1X); + b1.m_R.Set(b1.m_rotation); + } + + if (this.m_limitState2 == b2Joint.e_atUpperLimit) + { + //b2Vec2 r2 = b2Mul(b2->m_R, this.m_localAnchor2); + tMat = b2.m_R; + r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + //b2Vec2 p2 = b2->m_position + r2; + p2X = b2.m_position.x + r2X; + p2Y = b2.m_position.y + r2Y; + + //this.m_u2 = p2 - s2; + this.m_u2.Set(p2X - s2X, p2Y - s2Y); + + length2 = this.m_u2.Length(); + + if (length2 > b2Settings.b2_linearSlop) + { + //this.m_u2 *= 1.0 / length2; + 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.b2Max(linearError, -C); + C = b2Math.b2Clamp(C + b2Settings.b2_linearSlop, -b2Settings.b2_maxLinearCorrection, 0.0); + impulse = -this.m_limitMass2 * C; + oldLimitPositionImpulse = this.m_limitPositionImpulse2; + this.m_limitPositionImpulse2 = b2Math.b2Max(0.0, this.m_limitPositionImpulse2 + impulse); + impulse = this.m_limitPositionImpulse2 - oldLimitPositionImpulse; + + //P2 = -impulse * this.m_u2; + p2X = -impulse * this.m_u2.x; + p2Y = -impulse * this.m_u2.y; + + //b2.m_position += b2.m_invMass * P2; + b2.m_position.x += b2.m_invMass * p2X; + b2.m_position.y += b2.m_invMass * p2Y; + //b2.m_rotation += b2.m_invI * b2Cross(r2, P2); + b2.m_rotation += b2.m_invI * (r2X * p2Y - r2Y * p2X); + b2.m_R.Set(b2.m_rotation); + } + + return linearError < b2Settings.b2_linearSlop; + }, + + + + m_ground: null, + m_groundAnchor1: new b2Vec2(), + m_groundAnchor2: new b2Vec2(), + m_localAnchor1: new b2Vec2(), + m_localAnchor2: new b2Vec2(), + + m_u1: new b2Vec2(), + m_u2: new b2Vec2(), + + m_constant: null, + m_ratio: null, + + m_maxLength1: null, + m_maxLength2: null, + + // Effective masses + m_pulleyMass: null, + m_limitMass1: null, + m_limitMass2: null, + + // Impulses for accumulation/warm starting. + m_pulleyImpulse: null, + m_limitImpulse1: null, + m_limitImpulse2: null, + + // Position impulses for accumulation. + m_limitPositionImpulse1: null, + m_limitPositionImpulse2: null, + + m_limitState1: 0, + m_limitState2: 0 + + // static +}); + + + +b2PulleyJoint.b2_minPulleyLength = b2Settings.b2_lengthUnitsPerMeter; diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2PulleyJointDef.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2PulleyJointDef.js new file mode 100644 index 00000000..28d0acbb --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2PulleyJointDef.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + +// The pulley joint is connected to two bodies and two fixed ground points. +// The pulley supports a ratio such that: +// length1 + ratio * length2 = constant +// Yes, the force transmitted is scaled by the ratio. +// The pulley also enforces a maximum length limit on both sides. This is +// useful to prevent one side of the pulley hitting the top. + +var b2PulleyJointDef = Class.create(); +Object.extend(b2PulleyJointDef.prototype, b2JointDef.prototype); +Object.extend(b2PulleyJointDef.prototype, +{ + initialize: function() + { + // The constructor for b2JointDef + this.type = b2Joint.e_unknownJoint; + this.userData = null; + this.body1 = null; + this.body2 = null; + this.collideConnected = false; + // + + // initialize instance variables for references + this.groundPoint1 = new b2Vec2(); + this.groundPoint2 = new b2Vec2(); + this.anchorPoint1 = new b2Vec2(); + this.anchorPoint2 = new b2Vec2(); + // + + this.type = b2Joint.e_pulleyJoint; + this.groundPoint1.Set(-1.0, 1.0); + this.groundPoint2.Set(1.0, 1.0); + this.anchorPoint1.Set(-1.0, 0.0); + this.anchorPoint2.Set(1.0, 0.0); + this.maxLength1 = 0.5 * b2PulleyJoint.b2_minPulleyLength; + this.maxLength2 = 0.5 * b2PulleyJoint.b2_minPulleyLength; + this.ratio = 1.0; + this.collideConnected = true; + }, + + groundPoint1: new b2Vec2(), + groundPoint2: new b2Vec2(), + anchorPoint1: new b2Vec2(), + anchorPoint2: new b2Vec2(), + maxLength1: null, + maxLength2: null, + ratio: null}); + diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2RevoluteJoint.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2RevoluteJoint.js new file mode 100644 index 00000000..db5738bb --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2RevoluteJoint.js @@ -0,0 +1,491 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + +// Point-to-point constraint +// C = p2 - p1 +// Cdot = v2 - v1 +// = v2 + cross(w2, r2) - v1 - cross(w1, r1) +// J = [-I -r1_skew I r2_skew ] +// Identity used: +// w k % (rx i + ry j) = w * (-ry i + rx j) + +// Motor constraint +// Cdot = w2 - w1 +// J = [0 0 -1 0 0 1] +// K = invI1 + invI2 + +var b2RevoluteJoint = Class.create(); +Object.extend(b2RevoluteJoint.prototype, b2Joint.prototype); +Object.extend(b2RevoluteJoint.prototype, +{ + GetAnchor1: function(){ + var tMat = this.m_body1.m_R; + return new b2Vec2( this.m_body1.m_position.x + (tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y), + this.m_body1.m_position.y + (tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y)); + }, + GetAnchor2: function(){ + var tMat = this.m_body2.m_R; + return new b2Vec2( this.m_body2.m_position.x + (tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y), + this.m_body2.m_position.y + (tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y)); + }, + GetJointAngle: function(){ + return this.m_body2.m_rotation - this.m_body1.m_rotation; + }, + GetJointSpeed: function(){ + return this.m_body2.m_angularVelocity - this.m_body1.m_angularVelocity; + }, + GetMotorTorque: function(invTimeStep){ + return invTimeStep * this.m_motorImpulse; + }, + + SetMotorSpeed: function(speed) + { + this.m_motorSpeed = speed; + }, + + SetMotorTorque: function(torque) + { + this.m_maxMotorTorque = torque; + }, + + GetReactionForce: function(invTimeStep) + { + var tVec = this.m_ptpImpulse.Copy(); + tVec.Multiply(invTimeStep); + //return invTimeStep * this.m_ptpImpulse; + return tVec; + }, + + GetReactionTorque: function(invTimeStep) + { + return invTimeStep * this.m_limitImpulse; + }, + + //--------------- Internals Below ------------------- + + initialize: function(def){ + // The constructor for b2Joint + // initialize instance variables for references + this.m_node1 = new b2JointNode(); + this.m_node2 = new b2JointNode(); + // + this.m_type = def.type; + this.m_prev = null; + this.m_next = null; + this.m_body1 = def.body1; + this.m_body2 = def.body2; + this.m_collideConnected = def.collideConnected; + this.m_islandFlag = false; + this.m_userData = def.userData; + // + + // initialize instance variables for references + this.K = new b2Mat22(); + this.K1 = new b2Mat22(); + this.K2 = new b2Mat22(); + this.K3 = new b2Mat22(); + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_ptpImpulse = new b2Vec2(); + this.m_ptpMass = new b2Mat22(); + // + + //super(def); + + var tMat; + var tX; + var tY; + + //this.m_localAnchor1 = b2Math.b2MulTMV(this.m_body1.m_R, b2Math.SubtractVV( def.anchorPoint, this.m_body1.m_position)); + tMat = this.m_body1.m_R; + tX = def.anchorPoint.x - this.m_body1.m_position.x; + tY = def.anchorPoint.y - this.m_body1.m_position.y; + this.m_localAnchor1.x = tX * tMat.col1.x + tY * tMat.col1.y; + this.m_localAnchor1.y = tX * tMat.col2.x + tY * tMat.col2.y; + //this.m_localAnchor2 = b2Math.b2MulTMV(this.m_body2.m_R, b2Math.SubtractVV( def.anchorPoint, this.m_body2.m_position)); + tMat = this.m_body2.m_R; + tX = def.anchorPoint.x - this.m_body2.m_position.x; + tY = def.anchorPoint.y - this.m_body2.m_position.y; + this.m_localAnchor2.x = tX * tMat.col1.x + tY * tMat.col1.y; + this.m_localAnchor2.y = tX * tMat.col2.x + tY * tMat.col2.y; + + this.m_intialAngle = this.m_body2.m_rotation - this.m_body1.m_rotation; + + this.m_ptpImpulse.Set(0.0, 0.0); + this.m_motorImpulse = 0.0; + this.m_limitImpulse = 0.0; + this.m_limitPositionImpulse = 0.0; + + this.m_lowerAngle = def.lowerAngle; + this.m_upperAngle = def.upperAngle; + this.m_maxMotorTorque = def.motorTorque; + this.m_motorSpeed = def.motorSpeed; + this.m_enableLimit = def.enableLimit; + this.m_enableMotor = def.enableMotor; + }, + + // internal vars + K: new b2Mat22(), + K1: new b2Mat22(), + K2: new b2Mat22(), + K3: new b2Mat22(), + PrepareVelocitySolver: function(){ + var b1 = this.m_body1; + var b2 = this.m_body2; + + var tMat; + + // Compute the effective mass matrix. + //b2Vec2 r1 = b2Mul(b1->m_R, this.m_localAnchor1); + tMat = b1.m_R; + var r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + var r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //b2Vec2 r2 = b2Mul(b2->m_R, this.m_localAnchor2); + tMat = b2.m_R; + var r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + var r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + + // this.K = [(1/m1 + 1/m2) * eye(2) - skew(r1) * invI1 * skew(r1) - skew(r2) * invI2 * skew(r2)] + // = [1/m1+1/m2 0 ] + invI1 * [r1.y*r1.y -r1.x*r1.y] + invI2 * [r1.y*r1.y -r1.x*r1.y] + // [ 0 1/m1+1/m2] [-r1.x*r1.y r1.x*r1.x] [-r1.x*r1.y r1.x*r1.x] + var invMass1 = b1.m_invMass; + var invMass2 = b2.m_invMass; + var invI1 = b1.m_invI; + var invI2 = b2.m_invI; + + //var this.K1 = new b2Mat22(); + this.K1.col1.x = invMass1 + invMass2; this.K1.col2.x = 0.0; + this.K1.col1.y = 0.0; this.K1.col2.y = invMass1 + invMass2; + + //var this.K2 = new b2Mat22(); + 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; + + //var this.K3 = new b2Mat22(); + 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; + + //var this.K = b2Math.AddMM(b2Math.AddMM(this.K1, this.K2), this.K3); + this.K.SetM(this.K1); + this.K.AddM(this.K2); + this.K.AddM(this.K3); + + //this.m_ptpMass = this.K.Invert(); + this.K.Invert(this.m_ptpMass); + + this.m_motorMass = 1.0 / (invI1 + invI2); + + if (this.m_enableMotor == false) + { + this.m_motorImpulse = 0.0; + } + + if (this.m_enableLimit) + { + var jointAngle = b2.m_rotation - b1.m_rotation - this.m_intialAngle; + if (b2Math.b2Abs(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_limitImpulse = 0.0; + } + this.m_limitState = b2Joint.e_atLowerLimit; + } + else if (jointAngle >= this.m_upperAngle) + { + if (this.m_limitState != b2Joint.e_atUpperLimit) + { + this.m_limitImpulse = 0.0; + } + this.m_limitState = b2Joint.e_atUpperLimit; + } + else + { + this.m_limitState = b2Joint.e_inactiveLimit; + this.m_limitImpulse = 0.0; + } + } + else + { + this.m_limitImpulse = 0.0; + } + + // Warm starting. + if (b2World.s_enableWarmStarting) + { + //b1.m_linearVelocity.Subtract( b2Math.MulFV( invMass1, this.m_ptpImpulse) ); + b1.m_linearVelocity.x -= invMass1 * this.m_ptpImpulse.x; + b1.m_linearVelocity.y -= invMass1 * this.m_ptpImpulse.y; + //b1.m_angularVelocity -= invI1 * (b2Math.b2CrossVV(r1, this.m_ptpImpulse) + this.m_motorImpulse + this.m_limitImpulse); + b1.m_angularVelocity -= invI1 * ((r1X * this.m_ptpImpulse.y - r1Y * this.m_ptpImpulse.x) + this.m_motorImpulse + this.m_limitImpulse); + + //b2.m_linearVelocity.Add( b2Math.MulFV( invMass2 , this.m_ptpImpulse )); + b2.m_linearVelocity.x += invMass2 * this.m_ptpImpulse.x; + b2.m_linearVelocity.y += invMass2 * this.m_ptpImpulse.y; + //b2.m_angularVelocity += invI2 * (b2Math.b2CrossVV(r2, this.m_ptpImpulse) + this.m_motorImpulse + this.m_limitImpulse); + b2.m_angularVelocity += invI2 * ((r2X * this.m_ptpImpulse.y - r2Y * this.m_ptpImpulse.x) + this.m_motorImpulse + this.m_limitImpulse); + } + else{ + this.m_ptpImpulse.SetZero(); + this.m_motorImpulse = 0.0; + this.m_limitImpulse = 0.0; + } + + this.m_limitPositionImpulse = 0.0; + }, + + + SolveVelocityConstraints: function(step){ + var b1 = this.m_body1; + var b2 = this.m_body2; + + var tMat; + + //var r1 = b2Math.b2MulMV(b1.m_R, this.m_localAnchor1); + tMat = b1.m_R; + var r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + var r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //var r2 = b2Math.b2MulMV(b2.m_R, this.m_localAnchor2); + tMat = b2.m_R; + var r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + var r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + + var oldLimitImpulse; + + // Solve point-to-point constraint + //b2Vec2 ptpCdot = b2.m_linearVelocity + b2Cross(b2.m_angularVelocity, r2) - b1.m_linearVelocity - b2Cross(b1.m_angularVelocity, r1); + var ptpCdotX = b2.m_linearVelocity.x + (-b2.m_angularVelocity * r2Y) - b1.m_linearVelocity.x - (-b1.m_angularVelocity * r1Y); + var ptpCdotY = b2.m_linearVelocity.y + (b2.m_angularVelocity * r2X) - b1.m_linearVelocity.y - (b1.m_angularVelocity * r1X); + + //b2Vec2 ptpImpulse = -b2Mul(this.m_ptpMass, ptpCdot); + var ptpImpulseX = -(this.m_ptpMass.col1.x * ptpCdotX + this.m_ptpMass.col2.x * ptpCdotY); + var ptpImpulseY = -(this.m_ptpMass.col1.y * ptpCdotX + this.m_ptpMass.col2.y * ptpCdotY); + this.m_ptpImpulse.x += ptpImpulseX; + this.m_ptpImpulse.y += ptpImpulseY; + + //b1->m_linearVelocity -= b1->m_invMass * ptpImpulse; + b1.m_linearVelocity.x -= b1.m_invMass * ptpImpulseX; + b1.m_linearVelocity.y -= b1.m_invMass * ptpImpulseY; + //b1->m_angularVelocity -= b1->m_invI * b2Cross(r1, ptpImpulse); + b1.m_angularVelocity -= b1.m_invI * (r1X * ptpImpulseY - r1Y * ptpImpulseX); + + //b2->m_linearVelocity += b2->m_invMass * ptpImpulse; + b2.m_linearVelocity.x += b2.m_invMass * ptpImpulseX; + b2.m_linearVelocity.y += b2.m_invMass * ptpImpulseY; + //b2->m_angularVelocity += b2->m_invI * b2Cross(r2, ptpImpulse); + b2.m_angularVelocity += b2.m_invI * (r2X * ptpImpulseY - r2Y * ptpImpulseX); + + if (this.m_enableMotor && this.m_limitState != b2Joint.e_equalLimits) + { + var motorCdot = b2.m_angularVelocity - b1.m_angularVelocity - this.m_motorSpeed; + var motorImpulse = -this.m_motorMass * motorCdot; + var oldMotorImpulse = this.m_motorImpulse; + this.m_motorImpulse = b2Math.b2Clamp(this.m_motorImpulse + motorImpulse, -step.dt * this.m_maxMotorTorque, step.dt * this.m_maxMotorTorque); + motorImpulse = this.m_motorImpulse - oldMotorImpulse; + b1.m_angularVelocity -= b1.m_invI * motorImpulse; + b2.m_angularVelocity += b2.m_invI * motorImpulse; + } + + if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) + { + var limitCdot = b2.m_angularVelocity - b1.m_angularVelocity; + var limitImpulse = -this.m_motorMass * limitCdot; + + if (this.m_limitState == b2Joint.e_equalLimits) + { + this.m_limitImpulse += limitImpulse; + } + else if (this.m_limitState == b2Joint.e_atLowerLimit) + { + oldLimitImpulse = this.m_limitImpulse; + this.m_limitImpulse = b2Math.b2Max(this.m_limitImpulse + limitImpulse, 0.0); + limitImpulse = this.m_limitImpulse - oldLimitImpulse; + } + else if (this.m_limitState == b2Joint.e_atUpperLimit) + { + oldLimitImpulse = this.m_limitImpulse; + this.m_limitImpulse = b2Math.b2Min(this.m_limitImpulse + limitImpulse, 0.0); + limitImpulse = this.m_limitImpulse - oldLimitImpulse; + } + + b1.m_angularVelocity -= b1.m_invI * limitImpulse; + b2.m_angularVelocity += b2.m_invI * limitImpulse; + } + }, + + + SolvePositionConstraints: function(){ + + var oldLimitImpulse; + var limitC; + + var b1 = this.m_body1; + var b2 = this.m_body2; + + var positionError = 0.0; + + var tMat; + + // Solve point-to-point position error. + //var r1 = b2Math.b2MulMV(b1.m_R, this.m_localAnchor1); + tMat = b1.m_R; + var r1X = tMat.col1.x * this.m_localAnchor1.x + tMat.col2.x * this.m_localAnchor1.y; + var r1Y = tMat.col1.y * this.m_localAnchor1.x + tMat.col2.y * this.m_localAnchor1.y; + //var r2 = b2Math.b2MulMV(b2.m_R, this.m_localAnchor2); + tMat = b2.m_R; + var r2X = tMat.col1.x * this.m_localAnchor2.x + tMat.col2.x * this.m_localAnchor2.y; + var r2Y = tMat.col1.y * this.m_localAnchor2.x + tMat.col2.y * this.m_localAnchor2.y; + + //b2Vec2 p1 = b1->m_position + r1; + var p1X = b1.m_position.x + r1X; + var p1Y = b1.m_position.y + r1Y; + //b2Vec2 p2 = b2->m_position + r2; + var p2X = b2.m_position.x + r2X; + var p2Y = b2.m_position.y + r2Y; + + //b2Vec2 ptpC = p2 - p1; + var ptpCX = p2X - p1X; + var ptpCY = p2Y - p1Y; + + //float32 positionError = ptpC.Length(); + positionError = Math.sqrt(ptpCX*ptpCX + ptpCY*ptpCY); + + // Prevent overly large corrections. + //b2Vec2 dpMax(b2_maxLinearCorrection, b2_maxLinearCorrection); + //ptpC = b2Clamp(ptpC, -dpMax, dpMax); + + //float32 invMass1 = b1->m_invMass, invMass2 = b2->m_invMass; + var invMass1 = b1.m_invMass; + var invMass2 = b2.m_invMass; + //float32 invI1 = b1->m_invI, invI2 = b2->m_invI; + var invI1 = b1.m_invI; + var invI2 = b2.m_invI; + + //b2Mat22 this.K1; + this.K1.col1.x = invMass1 + invMass2; this.K1.col2.x = 0.0; + this.K1.col1.y = 0.0; this.K1.col2.y = invMass1 + invMass2; + + //b2Mat22 this.K2; + 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; + + //b2Mat22 this.K3; + 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; + + //b2Mat22 this.K = this.K1 + this.K2 + this.K3; + this.K.SetM(this.K1); + this.K.AddM(this.K2); + this.K.AddM(this.K3); + //b2Vec2 impulse = this.K.Solve(-ptpC); + this.K.Solve(b2RevoluteJoint.tImpulse, -ptpCX, -ptpCY); + var impulseX = b2RevoluteJoint.tImpulse.x; + var impulseY = b2RevoluteJoint.tImpulse.y; + + //b1.m_position -= b1.m_invMass * impulse; + b1.m_position.x -= b1.m_invMass * impulseX; + b1.m_position.y -= b1.m_invMass * impulseY; + //b1.m_rotation -= b1.m_invI * b2Cross(r1, impulse); + b1.m_rotation -= b1.m_invI * (r1X * impulseY - r1Y * impulseX); + b1.m_R.Set(b1.m_rotation); + + //b2.m_position += b2.m_invMass * impulse; + b2.m_position.x += b2.m_invMass * impulseX; + b2.m_position.y += b2.m_invMass * impulseY; + //b2.m_rotation += b2.m_invI * b2Cross(r2, impulse); + b2.m_rotation += b2.m_invI * (r2X * impulseY - r2Y * impulseX); + b2.m_R.Set(b2.m_rotation); + + + // Handle limits. + var angularError = 0.0; + + if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) + { + var angle = b2.m_rotation - b1.m_rotation - this.m_intialAngle; + var limitImpulse = 0.0; + + if (this.m_limitState == b2Joint.e_equalLimits) + { + // Prevent large angular corrections + limitC = b2Math.b2Clamp(angle, -b2Settings.b2_maxAngularCorrection, b2Settings.b2_maxAngularCorrection); + limitImpulse = -this.m_motorMass * limitC; + angularError = b2Math.b2Abs(limitC); + } + else if (this.m_limitState == b2Joint.e_atLowerLimit) + { + limitC = angle - this.m_lowerAngle; + angularError = b2Math.b2Max(0.0, -limitC); + + // Prevent large angular corrections and allow some slop. + limitC = b2Math.b2Clamp(limitC + b2Settings.b2_angularSlop, -b2Settings.b2_maxAngularCorrection, 0.0); + limitImpulse = -this.m_motorMass * limitC; + oldLimitImpulse = this.m_limitPositionImpulse; + this.m_limitPositionImpulse = b2Math.b2Max(this.m_limitPositionImpulse + limitImpulse, 0.0); + limitImpulse = this.m_limitPositionImpulse - oldLimitImpulse; + } + else if (this.m_limitState == b2Joint.e_atUpperLimit) + { + limitC = angle - this.m_upperAngle; + angularError = b2Math.b2Max(0.0, limitC); + + // Prevent large angular corrections and allow some slop. + limitC = b2Math.b2Clamp(limitC - b2Settings.b2_angularSlop, 0.0, b2Settings.b2_maxAngularCorrection); + limitImpulse = -this.m_motorMass * limitC; + oldLimitImpulse = this.m_limitPositionImpulse; + this.m_limitPositionImpulse = b2Math.b2Min(this.m_limitPositionImpulse + limitImpulse, 0.0); + limitImpulse = this.m_limitPositionImpulse - oldLimitImpulse; + } + + b1.m_rotation -= b1.m_invI * limitImpulse; + b1.m_R.Set(b1.m_rotation); + b2.m_rotation += b2.m_invI * limitImpulse; + b2.m_R.Set(b2.m_rotation); + } + + return positionError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop; + }, + + m_localAnchor1: new b2Vec2(), + m_localAnchor2: new b2Vec2(), + m_ptpImpulse: new b2Vec2(), + m_motorImpulse: null, + m_limitImpulse: null, + m_limitPositionImpulse: null, + + m_ptpMass: new b2Mat22(), + m_motorMass: null, + m_intialAngle: null, + m_lowerAngle: null, + m_upperAngle: null, + m_maxMotorTorque: null, + m_motorSpeed: null, + + m_enableLimit: null, + m_enableMotor: null, + m_limitState: 0}); + +b2RevoluteJoint.tImpulse = new b2Vec2(); diff --git a/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2RevoluteJointDef.js b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2RevoluteJointDef.js new file mode 100644 index 00000000..4466785c --- /dev/null +++ b/views/archive/j/box2d-car-game/js/box2d/dynamics/joints/b2RevoluteJointDef.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http: +* +* 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, and must not be +* misrepresented the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ + + + + + + +var b2RevoluteJointDef = Class.create(); +Object.extend(b2RevoluteJointDef.prototype, b2JointDef.prototype); +Object.extend(b2RevoluteJointDef.prototype, +{ + initialize: function() + { + // The constructor for b2JointDef + this.type = b2Joint.e_unknownJoint; + this.userData = null; + this.body1 = null; + this.body2 = null; + this.collideConnected = false; + // + + this.type = b2Joint.e_revoluteJoint; + this.anchorPoint = new b2Vec2(0.0, 0.0); + this.lowerAngle = 0.0; + this.upperAngle = 0.0; + this.motorTorque = 0.0; + this.motorSpeed = 0.0; + this.enableLimit = false; + this.enableMotor = false; + }, + + anchorPoint: null, + lowerAngle: null, + upperAngle: null, + motorTorque: null, + motorSpeed: null, + enableLimit: null, + enableMotor: null}); + diff --git a/views/archive/j/box2d-car-game/js/excanvas.js b/views/archive/j/box2d-car-game/js/excanvas.js new file mode 100644 index 00000000..3e1aedf8 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/excanvas.js @@ -0,0 +1,785 @@ +// Copyright 2006 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +// Known Issues: +// +// * Patterns are not implemented. +// * Radial gradient are not implemented. The VML version of these look very +// different from the canvas one. +// * Clipping paths are not implemented. +// * Coordsize. The width and height attribute have higher priority than the +// width and height style values which isn't correct. +// * Painting mode isn't implemented. +// * Canvas width/height should is using content-box by default. IE in +// Quirks mode will draw the canvas using border-box. Either change your +// doctype to HTML5 +// (http://www.whatwg.org/specs/web-apps/current-work/#the-doctype) +// or use Box Sizing Behavior from WebFX +// (http://webfx.eae.net/dhtml/boxsizing/boxsizing.html) +// * Optimize. There is always room for speed improvements. + +// only add this code if we do not already have a canvas implementation +if (!window.CanvasRenderingContext2D) { + +(function () { + + // alias some functions to make (compiled) code shorter + var m = Math; + var mr = m.round; + var ms = m.sin; + var mc = m.cos; + + // this is used for sub pixel precision + var Z = 10; + var Z2 = Z / 2; + + var G_vmlCanvasManager_ = { + init: function (opt_doc) { + var doc = opt_doc || document; + if (/MSIE/.test(navigator.userAgent) && !window.opera) { + var self = this; + doc.attachEvent("onreadystatechange", function () { + self.init_(doc); + }); + } + }, + + init_: function (doc) { + if (doc.readyState == "complete") { + // create xmlns + if (!doc.namespaces["g_vml_"]) { + doc.namespaces.add("g_vml_", "urn:schemas-microsoft-com:vml"); + } + + // setup default css + var ss = doc.createStyleSheet(); + ss.cssText = "canvas{display:inline-block;overflow:hidden;" + + // default size is 300x150 in Gecko and Opera + "text-align:left;width:300px;height:150px}" + + "g_vml_\\:*{behavior:url(#default#VML)}"; + + // find all canvas elements + var els = doc.getElementsByTagName("canvas"); + for (var i = 0; i < els.length; i++) { + if (!els[i].getContext) { + this.initElement(els[i]); + } + } + } + }, + + fixElement_: function (el) { + // in IE before version 5.5 we would need to add HTML: to the tag name + // but we do not care about IE before version 6 + var outerHTML = el.outerHTML; + + var newEl = el.ownerDocument.createElement(outerHTML); + // if the tag is still open IE has created the children as siblings and + // it has also created a tag with the name "/FOO" + if (outerHTML.slice(-2) != "/>") { + var tagName = "/" + el.tagName; + var ns; + // remove content + while ((ns = el.nextSibling) && ns.tagName != tagName) { + ns.removeNode(); + } + // remove the incorrect closing tag + if (ns) { + ns.removeNode(); + } + } + el.parentNode.replaceChild(newEl, el); + return newEl; + }, + + /** + * Public initializes a canvas element so that it can be used as canvas + * element from now on. This is called automatically before the page is + * loaded but if you are creating elements using createElement you need to + * make sure this is called on the element. + * @param {HTMLElement} el The canvas element to initialize. + * @return {HTMLElement} the element that was created. + */ + initElement: function (el) { + el = this.fixElement_(el); + el.getContext = function () { + if (this.context_) { + return this.context_; + } + return this.context_ = new CanvasRenderingContext2D_(this); + }; + + // do not use inline function because that will leak memory + el.attachEvent('onpropertychange', onPropertyChange); + el.attachEvent('onresize', onResize); + + var attrs = el.attributes; + if (attrs.width && attrs.width.specified) { + // TODO: use runtimeStyle and coordsize + // el.getContext().setWidth_(attrs.width.nodeValue); + el.style.width = attrs.width.nodeValue + "px"; + } else { + el.width = el.clientWidth; + } + if (attrs.height && attrs.height.specified) { + // TODO: use runtimeStyle and coordsize + // el.getContext().setHeight_(attrs.height.nodeValue); + el.style.height = attrs.height.nodeValue + "px"; + } else { + el.height = el.clientHeight; + } + //el.getContext().setCoordsize_() + return el; + } + }; + + function onPropertyChange(e) { + var el = e.srcElement; + + switch (e.propertyName) { + case 'width': + el.style.width = el.attributes.width.nodeValue + "px"; + el.getContext().clearRect(); + break; + case 'height': + el.style.height = el.attributes.height.nodeValue + "px"; + el.getContext().clearRect(); + break; + } + } + + function onResize(e) { + var el = e.srcElement; + if (el.firstChild) { + el.firstChild.style.width = el.clientWidth + 'px'; + el.firstChild.style.height = el.clientHeight + 'px'; + } + } + + G_vmlCanvasManager_.init(); + + // precompute "00" to "FF" + var dec2hex = []; + for (var i = 0; i < 16; i++) { + for (var j = 0; j < 16; j++) { + dec2hex[i * 16 + j] = i.toString(16) + j.toString(16); + } + } + + function createMatrixIdentity() { + return [ + [1, 0, 0], + [0, 1, 0], + [0, 0, 1] + ]; + } + + function matrixMultiply(m1, m2) { + var result = createMatrixIdentity(); + + for (var x = 0; x < 3; x++) { + for (var y = 0; y < 3; y++) { + var sum = 0; + + for (var z = 0; z < 3; z++) { + sum += m1[x][z] * m2[z][y]; + } + + result[x][y] = sum; + } + } + return result; + } + + function copyState(o1, o2) { + o2.fillStyle = o1.fillStyle; + o2.lineCap = o1.lineCap; + o2.lineJoin = o1.lineJoin; + o2.lineWidth = o1.lineWidth; + o2.miterLimit = o1.miterLimit; + o2.shadowBlur = o1.shadowBlur; + o2.shadowColor = o1.shadowColor; + o2.shadowOffsetX = o1.shadowOffsetX; + o2.shadowOffsetY = o1.shadowOffsetY; + o2.strokeStyle = o1.strokeStyle; + o2.arcScaleX_ = o1.arcScaleX_; + o2.arcScaleY_ = o1.arcScaleY_; + } + + function processStyle(styleString) { + var str, alpha = 1; + + styleString = String(styleString); + if (styleString.substring(0, 3) == "rgb") { + var start = styleString.indexOf("(", 3); + var end = styleString.indexOf(")", start + 1); + var guts = styleString.substring(start + 1, end).split(","); + + str = "#"; + for (var i = 0; i < 3; i++) { + str += dec2hex[Number(guts[i])]; + } + + if ((guts.length == 4) && (styleString.substr(3, 1) == "a")) { + alpha = guts[3]; + } + } else { + str = styleString; + } + + return [str, alpha]; + } + + function processLineCap(lineCap) { + switch (lineCap) { + case "butt": + return "flat"; + case "round": + return "round"; + case "square": + default: + return "square"; + } + } + + /** + * This class implements CanvasRenderingContext2D interface as described by + * the WHATWG. + * @param {HTMLElement} surfaceElement The element that the 2D context should + * be associated with + */ + function CanvasRenderingContext2D_(surfaceElement) { + this.m_ = createMatrixIdentity(); + + this.mStack_ = []; + this.aStack_ = []; + this.currentPath_ = []; + + // Canvas context properties + this.strokeStyle = "#000"; + this.fillStyle = "#000"; + + this.lineWidth = 1; + this.lineJoin = "miter"; + this.lineCap = "butt"; + this.miterLimit = Z * 1; + this.globalAlpha = 1; + this.canvas = surfaceElement; + + var el = surfaceElement.ownerDocument.createElement('div'); + el.style.width = surfaceElement.clientWidth + 'px'; + el.style.height = surfaceElement.clientHeight + 'px'; + el.style.overflow = 'hidden'; + el.style.position = 'absolute'; + surfaceElement.appendChild(el); + + this.element_ = el; + this.arcScaleX_ = 1; + this.arcScaleY_ = 1; + }; + + var contextPrototype = CanvasRenderingContext2D_.prototype; + contextPrototype.clearRect = function() { + this.element_.innerHTML = ""; + this.currentPath_ = []; + }; + + contextPrototype.beginPath = function() { + // TODO: Branch current matrix so that save/restore has no effect + // as per safari docs. + + this.currentPath_ = []; + }; + + contextPrototype.moveTo = function(aX, aY) { + this.currentPath_.push({type: "moveTo", x: aX, y: aY}); + this.currentX_ = aX; + this.currentY_ = aY; + }; + + contextPrototype.lineTo = function(aX, aY) { + this.currentPath_.push({type: "lineTo", x: aX, y: aY}); + this.currentX_ = aX; + this.currentY_ = aY; + }; + + contextPrototype.bezierCurveTo = function(aCP1x, aCP1y, + aCP2x, aCP2y, + aX, aY) { + this.currentPath_.push({type: "bezierCurveTo", + cp1x: aCP1x, + cp1y: aCP1y, + cp2x: aCP2x, + cp2y: aCP2y, + x: aX, + y: aY}); + this.currentX_ = aX; + this.currentY_ = aY; + }; + + contextPrototype.quadraticCurveTo = function(aCPx, aCPy, aX, aY) { + // the following is lifted almost directly from + // http://developer.mozilla.org/en/docs/Canvas_tutorial:Drawing_shapes + var cp1x = this.currentX_ + 2.0 / 3.0 * (aCPx - this.currentX_); + var cp1y = this.currentY_ + 2.0 / 3.0 * (aCPy - this.currentY_); + var cp2x = cp1x + (aX - this.currentX_) / 3.0; + var cp2y = cp1y + (aY - this.currentY_) / 3.0; + this.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, aX, aY); + }; + + contextPrototype.arc = function(aX, aY, aRadius, + aStartAngle, aEndAngle, aClockwise) { + aRadius *= Z; + var arcType = aClockwise ? "at" : "wa"; + + var xStart = aX + (mc(aStartAngle) * aRadius) - Z2; + var yStart = aY + (ms(aStartAngle) * aRadius) - Z2; + + var xEnd = aX + (mc(aEndAngle) * aRadius) - Z2; + var yEnd = aY + (ms(aEndAngle) * aRadius) - Z2; + + // IE won't render arches drawn counter clockwise if xStart == xEnd. + if (xStart == xEnd && !aClockwise) { + xStart += 0.125; // Offset xStart by 1/80 of a pixel. Use something + // that can be represented in binary + } + + this.currentPath_.push({type: arcType, + x: aX, + y: aY, + radius: aRadius, + xStart: xStart, + yStart: yStart, + xEnd: xEnd, + yEnd: yEnd}); + + }; + + contextPrototype.rect = function(aX, aY, aWidth, aHeight) { + this.moveTo(aX, aY); + this.lineTo(aX + aWidth, aY); + this.lineTo(aX + aWidth, aY + aHeight); + this.lineTo(aX, aY + aHeight); + this.closePath(); + }; + + contextPrototype.strokeRect = function(aX, aY, aWidth, aHeight) { + // Will destroy any existing path (same as FF behaviour) + this.beginPath(); + this.moveTo(aX, aY); + this.lineTo(aX + aWidth, aY); + this.lineTo(aX + aWidth, aY + aHeight); + this.lineTo(aX, aY + aHeight); + this.closePath(); + this.stroke(); + }; + + contextPrototype.fillRect = function(aX, aY, aWidth, aHeight) { + // Will destroy any existing path (same as FF behaviour) + this.beginPath(); + this.moveTo(aX, aY); + this.lineTo(aX + aWidth, aY); + this.lineTo(aX + aWidth, aY + aHeight); + this.lineTo(aX, aY + aHeight); + this.closePath(); + this.fill(); + }; + + contextPrototype.createLinearGradient = function(aX0, aY0, aX1, aY1) { + var gradient = new CanvasGradient_("gradient"); + return gradient; + }; + + contextPrototype.createRadialGradient = function(aX0, aY0, + aR0, aX1, + aY1, aR1) { + var gradient = new CanvasGradient_("gradientradial"); + gradient.radius1_ = aR0; + gradient.radius2_ = aR1; + gradient.focus_.x = aX0; + gradient.focus_.y = aY0; + return gradient; + }; + + contextPrototype.drawImage = function (image, var_args) { + var dx, dy, dw, dh, sx, sy, sw, sh; + + // to find the original width we overide the width and height + var oldRuntimeWidth = image.runtimeStyle.width; + var oldRuntimeHeight = image.runtimeStyle.height; + image.runtimeStyle.width = 'auto'; + image.runtimeStyle.height = 'auto'; + + // get the original size + var w = image.width; + var h = image.height; + + // and remove overides + image.runtimeStyle.width = oldRuntimeWidth; + image.runtimeStyle.height = oldRuntimeHeight; + + if (arguments.length == 3) { + dx = arguments[1]; + dy = arguments[2]; + sx = sy = 0; + sw = dw = w; + sh = dh = h; + } else if (arguments.length == 5) { + dx = arguments[1]; + dy = arguments[2]; + dw = arguments[3]; + dh = arguments[4]; + sx = sy = 0; + sw = w; + sh = h; + } else if (arguments.length == 9) { + sx = arguments[1]; + sy = arguments[2]; + sw = arguments[3]; + sh = arguments[4]; + dx = arguments[5]; + dy = arguments[6]; + dw = arguments[7]; + dh = arguments[8]; + } else { + throw "Invalid number of arguments"; + } + + var d = this.getCoords_(dx, dy); + + var w2 = sw / 2; + var h2 = sh / 2; + + var vmlStr = []; + + var W = 10; + var H = 10; + + // For some reason that I've now forgotten, using divs didn't work + vmlStr.push(' ' , + '', + ''); + + this.element_.insertAdjacentHTML("BeforeEnd", + vmlStr.join("")); + }; + + contextPrototype.stroke = function(aFill) { + var lineStr = []; + var lineOpen = false; + var a = processStyle(aFill ? this.fillStyle : this.strokeStyle); + var color = a[0]; + var opacity = a[1] * this.globalAlpha; + + var W = 10; + var H = 10; + + lineStr.push(' max.x) { + max.x = c.x; + } + if (min.y == null || c.y < min.y) { + min.y = c.y; + } + if (max.y == null || c.y > max.y) { + max.y = c.y; + } + } + } + lineStr.push(' ">'); + + if (typeof this.fillStyle == "object") { + var focus = {x: "50%", y: "50%"}; + var width = (max.x - min.x); + var height = (max.y - min.y); + var dimension = (width > height) ? width : height; + + focus.x = mr((this.fillStyle.focus_.x / width) * 100 + 50) + "%"; + focus.y = mr((this.fillStyle.focus_.y / height) * 100 + 50) + "%"; + + var colors = []; + + // inside radius (%) + if (this.fillStyle.type_ == "gradientradial") { + var inside = (this.fillStyle.radius1_ / dimension * 100); + + // percentage that outside radius exceeds inside radius + var expansion = (this.fillStyle.radius2_ / dimension * 100) - inside; + } else { + var inside = 0; + var expansion = 100; + } + + var insidecolor = {offset: null, color: null}; + var outsidecolor = {offset: null, color: null}; + + // We need to sort 'colors' by percentage, from 0 > 100 otherwise ie + // won't interpret it correctly + this.fillStyle.colors_.sort(function (cs1, cs2) { + return cs1.offset - cs2.offset; + }); + + for (var i = 0; i < this.fillStyle.colors_.length; i++) { + var fs = this.fillStyle.colors_[i]; + + colors.push( (fs.offset * expansion) + inside, "% ", fs.color, ","); + + if (fs.offset > insidecolor.offset || insidecolor.offset == null) { + insidecolor.offset = fs.offset; + insidecolor.color = fs.color; + } + + if (fs.offset < outsidecolor.offset || outsidecolor.offset == null) { + outsidecolor.offset = fs.offset; + outsidecolor.color = fs.color; + } + } + colors.pop(); + + lineStr.push(''); + } else if (aFill) { + lineStr.push(''); + } else { + lineStr.push( + '' + ); + } + + lineStr.push(""); + + this.element_.insertAdjacentHTML("beforeEnd", lineStr.join("")); + + this.currentPath_ = []; + }; + + contextPrototype.fill = function() { + this.stroke(true); + } + + contextPrototype.closePath = function() { + this.currentPath_.push({type: "close"}); + }; + + /** + * @private + */ + contextPrototype.getCoords_ = function(aX, aY) { + return { + x: Z * (aX * this.m_[0][0] + aY * this.m_[1][0] + this.m_[2][0]) - Z2, + y: Z * (aX * this.m_[0][1] + aY * this.m_[1][1] + this.m_[2][1]) - Z2 + } + }; + + contextPrototype.save = function() { + var o = {}; + copyState(this, o); + this.aStack_.push(o); + this.mStack_.push(this.m_); + this.m_ = matrixMultiply(createMatrixIdentity(), this.m_); + }; + + contextPrototype.restore = function() { + copyState(this.aStack_.pop(), this); + this.m_ = this.mStack_.pop(); + }; + + contextPrototype.translate = function(aX, aY) { + var m1 = [ + [1, 0, 0], + [0, 1, 0], + [aX, aY, 1] + ]; + + this.m_ = matrixMultiply(m1, this.m_); + }; + + contextPrototype.rotate = function(aRot) { + var c = mc(aRot); + var s = ms(aRot); + + var m1 = [ + [c, s, 0], + [-s, c, 0], + [0, 0, 1] + ]; + + this.m_ = matrixMultiply(m1, this.m_); + }; + + contextPrototype.scale = function(aX, aY) { + this.arcScaleX_ *= aX; + this.arcScaleY_ *= aY; + var m1 = [ + [aX, 0, 0], + [0, aY, 0], + [0, 0, 1] + ]; + + this.m_ = matrixMultiply(m1, this.m_); + }; + + /******** STUBS ********/ + contextPrototype.clip = function() { + // TODO: Implement + }; + + contextPrototype.arcTo = function() { + // TODO: Implement + }; + + contextPrototype.createPattern = function() { + return new CanvasPattern_; + }; + + // Gradient / Pattern Stubs + function CanvasGradient_(aType) { + this.type_ = aType; + this.radius1_ = 0; + this.radius2_ = 0; + this.colors_ = []; + this.focus_ = {x: 0, y: 0}; + } + + CanvasGradient_.prototype.addColorStop = function(aOffset, aColor) { + aColor = processStyle(aColor); + this.colors_.push({offset: 1-aOffset, color: aColor}); + }; + + function CanvasPattern_() {} + + // set up externs + G_vmlCanvasManager = G_vmlCanvasManager_; + CanvasRenderingContext2D = CanvasRenderingContext2D_; + CanvasGradient = CanvasGradient_; + CanvasPattern = CanvasPattern_; + +})(); + +} // if diff --git a/views/archive/j/box2d-car-game/js/html5games.box2dcargame.js b/views/archive/j/box2d-car-game/js/html5games.box2dcargame.js new file mode 100644 index 00000000..258c563a --- /dev/null +++ b/views/archive/j/box2d-car-game/js/html5games.box2dcargame.js @@ -0,0 +1,379 @@ +/*! + * Box2D Car Game Example + * http://42games.net/html5games/box2d-car-game/ + * + * This is an example game for the book HTML5 Games Development: A Beginning Guide. + * + * Copyright 2011, Thomas Seng Hin Mak + * makzan@42games.net + * + * All Right Reserved. + */ + + + +var carGame = { + // game state constant + STATE_STARTING_SCREEN : 1, + STATE_PLAYING : 2, + STATE_GAMEOVER_SCREEN : 3, + + state : 0, + + fuel: 0, + fuelMax: 0, + + currentLevel: 0 +} + +carGame.levels = new Array(); +carGame.levels[0] = [{"type":"car","x":50,"y":210,"fuel":12}, +{"type":"box","x":250, "y":270, "width":250, "height":25, "rotation":0}, +{"type":"box","x":500,"y":250,"width":65,"height":15,"rotation":-10}, +{"type":"box","x":600,"y":225,"width":80,"height":15,"rotation":-20}, +{"type":"box","x":950,"y":225,"width":80,"height":15,"rotation":20}, +{"type":"box","x":1100,"y":250,"width":100,"height":15,"rotation":0}, +{"type":"win","x":1200,"y":215,"width":15,"height":25,"rotation":0}]; + +carGame.levels[1] = [{"type":"car","x":50,"y":310,"fuel":20}, +{"type":"box","x":250, "y":370, "width":250, "height":25, "rotation":0}, +{"type":"box","x":500,"y":350,"width":65,"height":15,"rotation":-10}, +{"type":"box","x":600,"y":325,"width":80,"height":15,"rotation":-20}, +{"type":"box","x":666,"y":285,"width":80,"height":15,"rotation":-32}, +{"type":"box","x":950,"y":225,"width":80,"height":15,"rotation":15}, +{"type":"box","x":1100,"y":250,"width":100,"height":15,"rotation":0}, +{"type":"win","x":1200,"y":215,"width":15,"height":25,"rotation":0}]; + +carGame.levels[2] = [{"type":"car","x":50,"y":310,"fuel":50}, +{"type":"box","x":150, "y":370, "width":150, "height":25, "rotation":0}, +{"type":"box","x":300,"y":356,"width":25,"height":15,"rotation":-10}, +{"type":"box","x":500,"y":350,"width":65,"height":15,"rotation":-10}, +{"type":"box","x":600,"y":325,"width":80,"height":15,"rotation":-20}, +{"type":"box","x":666,"y":285,"width":80,"height":15,"rotation":-32}, +{"type":"box","x":950,"y":225,"width":80,"height":15,"rotation":10}, +{"type":"box","x":1100,"y":250,"width":100,"height":15,"rotation":0}, +{"type":"win","x":1200,"y":215,"width":15,"height":25,"rotation":0}]; + +carGame.levels[3] = [{"type":"car","x":50,"y":210,"fuel":20}, +{"type":"box","x":100, "y":270, "width":190, "height":15, "rotation":20}, +{"type":"box","x":380, "y":320, "width":100, "height":15, "rotation":-10}, +{"type":"box","x":666,"y":285,"width":80,"height":15,"rotation":-32}, +{"type":"box","x":950,"y":295,"width":80,"height":15,"rotation":20}, +{"type":"box","x":1100,"y":310,"width":100,"height":15,"rotation":0}, +{"type":"win","x":1200,"y":275,"width":15,"height":25,"rotation":0}]; + +carGame.levels[4] = [{"type":"car","x":50,"y":210,"fuel":20}, +{"type":"box","x":100, "y":270, "width":190, "height":15, "rotation":20}, +{"type":"box","x":380, "y":320, "width":100, "height":15, "rotation":-10}, +{"type":"box","x":686,"y":285,"width":80,"height":15,"rotation":-32}, +{"type":"box","x":250,"y":495,"width":80,"height":15,"rotation":40}, +{"type":"box","x":500,"y":540,"width":200,"height":15,"rotation":0}, +{"type":"win","x":220,"y":425,"width":15,"height":25,"rotation":23}]; + + +var canvas; +var ctx; +var canvasWidth; +var canvasHeight; + +$(function() { + + // Keyboard event + $(document).keydown(function(e){ + switch(e.keyCode) { + case 88: // x key to apply force towards right + if (carGame.fuel > 0) + { + var force = new b2Vec2(10000000, 0); + carGame.car.ApplyForce(force, carGame.car.GetCenterPosition()); + carGame.fuel--; + $(".fuel-value").width(carGame.fuel/carGame.fuelMax * 100 +'%'); + } + break; + case 90: // z key to apply force towards left + if (carGame.fuel > 0) + { + var force = new b2Vec2(-10000000, 0); + carGame.car.ApplyForce(force, carGame.car.GetCenterPosition()); + carGame.fuel--; + $(".fuel-value").width(carGame.fuel/carGame.fuelMax * 100 +'%'); + } + break; + case 82: // r key to restart the game + restartGame(carGame.currentLevel); + break; + } + }); + + // set the game state as "starting screen" + carGame.state = carGame.STATE_STARTING_SCREEN; + + // start the game when clicking anywhere in starting screen + $('#game').click(function(){ + if (carGame.state == carGame.STATE_STARTING_SCREEN) + { + // change the state to playing. + carGame.state = carGame.STATE_PLAYING; + + // start new game + restartGame(carGame.currentLevel); + + // start advancing the step + step(); + } + }); + + + + + console.log("The world is created. ", carGame.world); + + // get the reference of the context + canvas = document.getElementById('game'); + ctx = canvas.getContext('2d'); + canvasWidth = parseInt(canvas.width); + canvasHeight = parseInt(canvas.height); + + + +}); + + +function step() { + carGame.world.Step(1.0/60, 1); + ctx.clearRect(0, 0, canvasWidth, canvasHeight); + + drawWorld(carGame.world, ctx); + + setTimeout(step, 10); + + + // loop all contact list to check if the car hits the winning wall + for (var cn = carGame.world.GetContactList(); cn != null; cn = cn.GetNext()) + { + var body1 = cn.GetShape1().GetBody(); + var body2 = cn.GetShape2().GetBody(); + if ((body1 == carGame.car && body2 == carGame.gamewinWall) || + (body2 == carGame.car && body1 == carGame.gamewinWall)) + { + console.log("Level Passed!"); + + + if (carGame.currentLevel < 4) + { + restartGame(carGame.currentLevel+1); + } + else + { + // show game over screen + $('#game').removeClass().addClass('gamebg_won'); + + // clear the physics world + carGame.world = createWorld(); + + } + + } + + } +} + +function restartGame(level) +{ + $("#level").html("Level " + (level+1)); + + carGame.currentLevel = level; + + // change the background image to fit the level + $('#game').removeClass().addClass('gamebg_level'+level); + + + // create the world + carGame.world = createWorld(); + + // create a ground in our newly created world + // load the ground info from level data + for(var i=0;i").appendTo("body"),d=b.css("display");b.remove();if(d==="none"||d===""){ci||(ci=c.createElement("iframe"),ci.frameBorder=ci.width=ci.height=0),c.body.appendChild(ci);if(!cj||!ci.createElement)cj=(ci.contentWindow||ci.contentDocument).document,cj.write("");b=cj.createElement(a),cj.body.appendChild(b),d=f.css(b,"display"),c.body.removeChild(ci)}ch[a]=d}return ch[a]}function cs(a,b){var c={};f.each(cn.concat.apply([],cn.slice(0,b)),function(){c[this]=a});return c}function cr(){co=b}function cq(){setTimeout(cr,0);return co=f.now()}function cg(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function cf(){try{return new a.XMLHttpRequest}catch(b){}}function b_(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g=0===c})}function V(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function N(a,b){return(a&&a!=="*"?a+".":"")+b.replace(z,"`").replace(A,"&")}function M(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;ic)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function K(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function E(){return!0}function D(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){name="data-"+c.replace(j,"$1-$2").toLowerCase(),d=a.getAttribute(name);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(e){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function H(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(H,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=d.userAgent,x,y,z,A=Object.prototype.toString,B=Object.prototype.hasOwnProperty,C=Array.prototype.push,D=Array.prototype.slice,E=String.prototype.trim,F=Array.prototype.indexOf,G={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)==="<"&&a.charAt(a.length-1)===">"&&a.length>=3?g=[null,a,null]:g=i.exec(a);if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6",length:0,size:function(){return this.length},toArray:function(){return D.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?C.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),y.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(D.apply(this,arguments),"slice",D.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:C,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;y.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!y){y=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",z,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",z),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&H()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):G[A.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;if(a.constructor&&!B.call(a,"constructor")&&!B.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a);return c===b||B.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(b,c,d){a.DOMParser?(d=new DOMParser,c=d.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),d=c.documentElement,(!d||!d.nodeName||d.nodeName==="parsererror")&&e.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c
a",b=a.getElementsByTagName("*"),d=a.getElementsByTagName("a")[0];if(!b||!b.length||!d)return{};e=c.createElement("select"),f=e.appendChild(c.createElement("option")),g=a.getElementsByTagName("input")[0],i={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(d.getAttribute("style")),hrefNormalized:d.getAttribute("href")==="/a",opacity:/^0.55$/.test(d.style.opacity),cssFloat:!!d.style.cssFloat,checkOn:g.value==="on",optSelected:f.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},g.checked=!0,i.noCloneChecked=g.cloneNode(!0).checked,e.disabled=!0,i.optDisabled=!f.disabled;try{delete a.test}catch(r){i.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function click(){i.noCloneEvent=!1,a.detachEvent("onclick",click)}),a.cloneNode(!0).fireEvent("onclick")),g=c.createElement("input"),g.value="t",g.setAttribute("type","radio"),i.radioValue=g.value==="t",g.setAttribute("checked","checked"),a.appendChild(g),j=c.createDocumentFragment(),j.appendChild(a.firstChild),i.checkClone=j.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",k=c.createElement("body"),l={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"};for(p in l)k.style[p]=l[p];k.appendChild(a),c.documentElement.appendChild(k),i.appendChecked=g.checked,i.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,i.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
",i.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
t
",m=a.getElementsByTagName("td"),q=m[0].offsetHeight===0,m[0].style.display="",m[1].style.display="none",i.reliableHiddenOffsets=q&&m[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(h=c.createElement("div"),h.style.width="0",h.style.marginRight="0",a.appendChild(h),i.reliableMarginRight=(parseInt(c.defaultView.getComputedStyle(h,null).marginRight,10)||0)===0),k.innerHTML="",c.documentElement.removeChild(k);if(a.attachEvent)for(p in{submit:1,change:1,focusin:1})o="on"+p,q=o in a,q||(a.setAttribute(o,"return;"),q=typeof a[o]=="function"),i[p+"Bubbles"]=q;return i}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([a-z])([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g=f.expando,h=typeof c=="string",i,j=a.nodeType,k=j?f.cache:a,l=j?a[f.expando]:a[f.expando]&&f.expando;if((!l||e&&l&&!k[l][g])&&h&&d===b)return;l||(j?a[f.expando]=l=++f.uuid:l=f.expando),k[l]||(k[l]={},j||(k[l].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?k[l][g]=f.extend(k[l][g],c):k[l]=f.extend(k[l],c);i=k[l],e&&(i[g]||(i[g]={}),i=i[g]),d!==b&&(i[c]=d);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[c]:i}},removeData:function(b,c,d){if(!!f.acceptData(b)){var e=f.expando,g=b.nodeType,h=g?f.cache:b,i=g?b[f.expando]:f.expando;if(!h[i])return;if(c){var j=d?h[i][e]:h[i];if(j){delete j[c];if(!l(j))return}}if(d){delete h[i][e];if(!l(h[i]))return}var k=h[i][e];f.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=k):g&&(f.support.deleteExpando?delete b[f.expando]:b.removeAttribute?b.removeAttribute(f.expando):b[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;return(e.value||"").replace(p,"")}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||"set"in c&&c.set(this,h,"value")===b)this.value=h}})}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b=a.selectedIndex,c=[],d=a.options,e=a.type==="select-one";if(b<0)return null;for(var g=e?b:0,h=e?b+1:d.length;g=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex",readonly:"readOnly"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);var h,i,j=g!==1||!f.isXMLDoc(a);c=j&&f.attrFix[c]||c,i=f.attrHooks[c]||(v&&(f.nodeName(a,"form")||u.test(c))?v:b);if(d!==b){if(d===null||d===!1&&!t.test(c)){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;d===!0&&!t.test(c)&&(d=c),a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j)return i.get(a,c);h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){a.nodeType===1&&(b=f.attrFix[b]||b,f.support.getSetAttribute?a.removeAttribute(b):(f.attr(a,b,""),a.removeAttributeNode(a.getAttributeNode(b))))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.getAttribute("value");a.setAttribute("type",b),c&&(a.value=c);return b}}},tabIndex:{get:function(a){var c=a.getAttributeNode("tabIndex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}}},propFix:{},prop:function(a,c,d){var e=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);c=i&&f.propFix[c]||c,h=f.propHooks[c];return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==b?g:a[c]},propHooks:{}}),f.support.getSetAttribute||(f.attrFix=f.extend(f.attrFix,{"for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder"}),v=f.attrHooks.name=f.attrHooks.value=f.valHooks.button={get:function(a,c){var d;if(c==="value"&&!f.nodeName(a,"button"))return a.getAttribute(c);d=a.getAttributeNode(c);return d&&d.specified?d.nodeValue:b},set:function(a,b,c){var d=a.getAttributeNode(c);if(d){d.nodeValue=b;return b}}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex)}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var w=Object.prototype.hasOwnProperty,x=/\.(.*)$/,y=/^(?:textarea|input|select)$/i,z=/\./g,A=/ /g,B=/[^\w\s.|`]/g,C=function(a){return a.replace(B,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=D;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=D);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),C).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},J=function J(a){var c=a.target,d,e;if(!!y.test(c.nodeName)&&!c.readOnly){d=f._data(c,"_change_data"),e=I(c),(a.type!=="focusout"||c.type!=="radio")&&f._data(c,"_change_data",e);if(d===b||e===d)return;if(d!=null||e)a.type="change",a.liveFired=b,f.event.trigger(a,arguments[1],c)}};f.event.special.change={filters:{focusout:J,beforedeactivate:J,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&J.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&J.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",I(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in H)f.event.add(this,c+".specialChange",H[c]);return y.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return y.test(this.nodeName)}},H=f.event.special.change.filters,H.focus=H.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){return a.nodeName.toLowerCase()==="input"&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g0)for(h=g;h0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=T.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a=="string")return f.inArray(this[0],a?f(a):this.parent().children());return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(V(c[0])||V(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=S.call(arguments);O.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!U[a]?f.unique(e):e,(this.length>1||Q.test(d))&&P.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var X=/ jQuery\d+="(?:\d+|null)"/g,Y=/^\s+/,Z=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,$=/<([\w:]+)/,_=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};be.optgroup=be.option,be.tbody=be.tfoot=be.colgroup=be.caption=be.thead,be.th=be.td,f.support.htmlSerialize||(be._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(X,""):null;if(typeof a=="string"&&!bb.test(a)&&(f.support.leadingWhitespace||!Y.test(a))&&!be[($.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Z,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bh(a,d),e=bi(a),g=bi(d);for(h=0;e[h];++h)bh(e[h],g[h])}if(b){bg(a,d);if(c){e=bi(a),g=bi(d);for(h=0;e[h];++h)bg(e[h],g[h])}}return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[];for(var i=0,j;(j=a[i])!=null;i++){typeof j=="number"&&(j+="");if(!j)continue;if(typeof j=="string")if(!ba.test(j))j=b.createTextNode(j);else{j=j.replace(Z,"<$1>");var k=($.exec(j)||["",""])[1].toLowerCase(),l=be[k]||be._default,m=l[0],n=b.createElement("div");n.innerHTML=l[1]+j+l[2];while(m--)n=n.lastChild;if(!f.support.tbody){var o=_.test(j),p=k==="table"&&!o?n.firstChild&&n.firstChild.childNodes:l[1]===""&&!o?n.childNodes:[];for(var q=p.length-1;q>=0;--q)f.nodeName(p[q],"tbody")&&!p[q].childNodes.length&&p[q].parentNode.removeChild(p[q])}!f.support.leadingWhitespace&&Y.test(j)&&n.insertBefore(b.createTextNode(Y.exec(j)[0]),n.firstChild),j=n.childNodes}var r;if(!f.support.appendChecked)if(j[0]&&typeof (r=j.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bn.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle;c.zoom=1;var e=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.filter=bm.test(g)?g.replace(bm,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bx(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(by=function(a,c){var d,e,g;c=c.replace(bp,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bz=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bq.test(d)&&br.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bx=by||bz,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bC=/%20/g,bD=/\[\]$/,bE=/\r?\n/g,bF=/#.*$/,bG=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bH=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bI=/^(?:about|app|app\-storage|.+\-extension|file|widget):$/,bJ=/^(?:GET|HEAD)$/,bK=/^\/\//,bL=/\?/,bM=/)<[^<]*)*<\/script>/gi,bN=/^(?:select|textarea)/i,bO=/\s+/,bP=/([?&])_=[^&]*/,bQ=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bR=f.fn.load,bS={},bT={},bU,bV;try{bU=e.href}catch(bW){bU=c.createElement("a"),bU.href="",bU=bU.href}bV=bQ.exec(bU.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bR)return bR.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bM,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bN.test(this.nodeName)||bH.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bE,"\r\n")}}):{name:b.name,value:c.replace(bE,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?f.extend(!0,a,f.ajaxSettings,b):(b=a,a=f.extend(!0,f.ajaxSettings,b));for(var c in{context:1,url:1})c in b?a[c]=b[c]:c in f.ajaxSettings&&(a[c]=f.ajaxSettings[c]);return a},ajaxSettings:{url:bU,isLocal:bI.test(bV[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML}},ajaxPrefilter:bX(bS),ajaxTransport:bX(bT),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a?4:0;var o,r,u,w=l?b$(d,v,l):b,x,y;if(a>=200&&a<300||a===304){if(d.ifModified){if(x=v.getResponseHeader("Last-Modified"))f.lastModified[k]=x;if(y=v.getResponseHeader("Etag"))f.etag[k]=y}if(a===304)c="notmodified",o=!0;else try{r=b_(d,w),c="success",o=!0}catch(z){c="parsererror",u=z}}else{u=c;if(!c||a)c="error",a<0&&(a=0)}v.status=a,v.statusText=c,o?h.resolveWith(e,[r,c,v]):h.rejectWith(e,[v,c,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,c]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bG.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bF,"").replace(bK,bV[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bO),d.crossDomain==null&&(r=bQ.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bV[1]&&r[2]==bV[2]&&(r[3]||(r[1]==="http:"?80:443))==(bV[3]||(bV[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bY(bS,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bJ.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bL.test(d.url)?"&":"?")+d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bP,"$1_="+x);d.url=y+(y===d.url?(bL.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", */*; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bY(bT,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){status<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)bZ(g,a[g],c,e);return d.join("&").replace(bC,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var ca=f.now(),cb=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+ca++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cb.test(b.url)||e&&cb.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cb,l),b.url===j&&(e&&(k=k.replace(cb,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cc=a.ActiveXObject?function(){for(var a in ce)ce[a](0,1)}:!1,cd=0,ce;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&cf()||cg()}:cf,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cc&&delete ce[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cd,cc&&(ce||(ce={},f(a).unload(cc)),ce[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ch={},ci,cj,ck=/^(?:toggle|show|hide)$/,cl=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cm,cn=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],co,cp=a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cs("show",3),a,b,c);for(var g=0,h=this.length;g=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a=f.timers,b=a.length;while(b--)a[b]()||a.splice(b,1);a.length||f.fx.stop()},interval:13,stop:function(){clearInterval(cm),cm=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){f.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit:a.elem[a.prop]=a.now}}}),f.expr&&f.expr.filters&&(f.expr.filters.animated=function(a){return f.grep(f.timers,function(b){return a===b.elem}).length});var cu=/^t(?:able|d|h)$/i,cv=/^(?:body|html)$/i;"getBoundingClientRect"in c.documentElement?f.fn.offset=function(a){var b=this[0],c;if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);try{c=b.getBoundingClientRect()}catch(d){}var e=b.ownerDocument,g=e.documentElement;if(!c||!f.contains(g,b))return c?{top:c.top,left:c.left}:{top:0,left:0};var h=e.body,i=cw(e),j=g.clientTop||h.clientTop||0,k=g.clientLeft||h.clientLeft||0,l=i.pageYOffset||f.support.boxModel&&g.scrollTop||h.scrollTop,m=i.pageXOffset||f.support.boxModel&&g.scrollLeft||h.scrollLeft,n=c.top+l-j,o=c.left+m-k;return{top:n,left:o}}:f.fn.offset=function(a){var b=this[0];if(a)return this.each(function(b){f.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return f.offset.bodyOffset(b);f.offset.initialize();var c,d=b.offsetParent,e=b,g=b.ownerDocument,h=g.documentElement,i=g.body,j=g.defaultView,k=j?j.getComputedStyle(b,null):b.currentStyle,l=b.offsetTop,m=b.offsetLeft;while((b=b.parentNode)&&b!==i&&b!==h){if(f.offset.supportsFixedPosition&&k.position==="fixed")break;c=j?j.getComputedStyle(b,null):b.currentStyle,l-=b.scrollTop,m-=b.scrollLeft,b===d&&(l+=b.offsetTop,m+=b.offsetLeft,f.offset.doesNotAddBorder&&(!f.offset.doesAddBorderForTableAndCells||!cu.test(b.nodeName))&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),e=d,d=b.offsetParent),f.offset.subtractsBorderForOverflowNotVisible&&c.overflow!=="visible"&&(l+=parseFloat(c.borderTopWidth)||0,m+=parseFloat(c.borderLeftWidth)||0),k=c}if(k.position==="relative"||k.position==="static")l+=i.offsetTop,m+=i.offsetLeft;f.offset.supportsFixedPosition&&k.position==="fixed"&&(l+=Math.max(h.scrollTop,i.scrollTop),m+=Math.max(h.scrollLeft,i.scrollLeft));return{top:l,left:m}},f.offset={initialize:function(){var a=c.body,b=c.createElement("div"),d,e,g,h,i=parseFloat(f.css(a,"marginTop"))||0,j="
";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cv.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cv.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cw(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cw(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){return this[0]?parseFloat(f.css(this[0],d,"padding")):null},f.fn["outer"+c]=function(a){return this[0]?parseFloat(f.css(this[0],d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c];return e.document.compatMode==="CSS1Compat"&&g||e.document.body["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var h=f.css(e,d),i=parseFloat(h);return f.isNaN(i)?h:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window); \ No newline at end of file diff --git a/views/archive/j/box2d-car-game/js/protoclass.js b/views/archive/j/box2d-car-game/js/protoclass.js new file mode 100644 index 00000000..47b08c00 --- /dev/null +++ b/views/archive/j/box2d-car-game/js/protoclass.js @@ -0,0 +1,178 @@ + +/* Based on Alex Arnell's inheritance implementation. */ +var Class = { + create: function() { + var parent = null, properties = $A(arguments); + if (Object.isFunction(properties[0])) + parent = properties.shift(); + + function klass() { + this.initialize.apply(this, arguments); + } + + Object.extend(klass, Class.Methods); + klass.superclass = parent; + klass.subclasses = []; + + if (parent) { + var subclass = function() { }; + subclass.prototype = parent.prototype; + klass.prototype = new subclass; + parent.subclasses.push(klass); + } + + for (var i = 0; i < properties.length; i++) + klass.addMethods(properties[i]); + + if (!klass.prototype.initialize) + klass.prototype.initialize = this.emptyFunction; + + klass.prototype.constructor = klass; + + return klass; + }, + emptyFunction:function () {} + +}; + +Class.Methods = { + addMethods: function(source) { + var ancestor = this.superclass && this.superclass.prototype; + var properties = Object.keys(source); + + if (!Object.keys({ toString: true }).length) + properties.push("toString", "valueOf"); + + for (var i = 0, length = properties.length; i < length; i++) { + var property = properties[i], value = source[property]; + if (ancestor && Object.isFunction(value) && + value.argumentNames().first() == "$super") { + var method = value, value = Object.extend((function(m) { + return function() { return ancestor[m].apply(this, arguments) }; + })(property).wrap(method), { + valueOf: function() { return method }, + toString: function() { return method.toString() } + }); + } + this.prototype[property] = value; + } + + return this; + } +}; + +Object.extend = function(destination, source) { + for (var property in source) + destination[property] = source[property]; + return destination; +}; + +Object.extend(Object, { + inspect: function(object) { + try { + if (Object.isUndefined(object)) return 'undefined'; + if (object === null) return 'null'; + return object.inspect ? object.inspect() : String(object); + } catch (e) { + if (e instanceof RangeError) return '...'; + throw e; + } + }, + + toJSON: function(object) { + var type = typeof object; + switch (type) { + case 'undefined': + case 'function': + case 'unknown': return; + case 'boolean': return object.toString(); + } + + if (object === null) return 'null'; + if (object.toJSON) return object.toJSON(); + if (Object.isElement(object)) return; + + var results = []; + for (var property in object) { + var value = Object.toJSON(object[property]); + if (!Object.isUndefined(value)) + results.push(property.toJSON() + ': ' + value); + } + + return '{' + results.join(', ') + '}'; + }, + + toQueryString: function(object) { + return $H(object).toQueryString(); + }, + + toHTML: function(object) { + return object && object.toHTML ? object.toHTML() : String.interpret(object); + }, + + keys: function(object) { + var keys = []; + for (var property in object) + keys.push(property); + return keys; + }, + + values: function(object) { + var values = []; + for (var property in object) + values.push(object[property]); + return values; + }, + + clone: function(object) { + return Object.extend({ }, object); + }, + + isElement: function(object) { + return object && object.nodeType == 1; + }, + + isArray: function(object) { + return object != null && typeof object == "object" && + 'splice' in object && 'join' in object; + }, + + isHash: function(object) { + return object instanceof Hash; + }, + + isFunction: function(object) { + return typeof object == "function"; + }, + + isString: function(object) { + return typeof object == "string"; + }, + + isNumber: function(object) { + return typeof object == "number"; + }, + + isUndefined: function(object) { + return typeof object == "undefined"; + } +}); + +function $A(iterable) { + if (!iterable) return []; + if (iterable.toArray) return iterable.toArray(); + var length = iterable.length || 0, results = new Array(length); + while (length--) results[length] = iterable[length]; + return results; +} + +if (WebKit = navigator.userAgent.indexOf('AppleWebKit/') > -1) { + $A = function(iterable) { + if (!iterable) return []; + if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') && + iterable.toArray) return iterable.toArray(); + var length = iterable.length || 0, results = new Array(length); + while (length--) results[length] = iterable[length]; + return results; + }; +} diff --git a/views/archive/j/box2d-car-game/readme.md b/views/archive/j/box2d-car-game/readme.md new file mode 100644 index 00000000..929db3ed --- /dev/null +++ b/views/archive/j/box2d-car-game/readme.md @@ -0,0 +1,7 @@ +# Box2D Car Game + +This game integrates Box2D 1.2 into canvas. + +This example is originally from the book [HTML5 Games Development by Examples][1]. + +[1]: http://www.packtpub.com/html5-games-development-using-css-javascript-beginners-guide/book diff --git a/views/archive/j/canvas-untangle-game/css/untangle.css b/views/archive/j/canvas-untangle-game/css/untangle.css new file mode 100644 index 00000000..a56823d1 --- /dev/null +++ b/views/archive/j/canvas-untangle-game/css/untangle.css @@ -0,0 +1,62 @@ +canvas { + + /* for iOS devices */ + -webkit-tap-highlight-color: transparent; +} + +html, body { + background: url(../images/title_bg.png) 50% 0 no-repeat, + url(../images/bg_repeat.png) 50% 0 repeat-y #889ba7; + margin: 0; + color: #111; +} + +#game{ + position:relative; +} + +#page { + width: 820px; + min-height: 800px; + margin: 0 auto; + padding: 0; + text-align: center; + text-shadow: 0 1px 5px rgba(60,60,60,.6); +} + +header { + height: 88px; + padding-top: 36px; + margin-bottom: 50px; + font-family: "Rock Salt", Arial, sans-serif; + font-size: 14px; + text-shadow: 0 1px 0 rgba(200,200,200,.5); + color: #121; +} + +/* Layers */ +#layers { + position: relative; + margin: 0 auto; + width:768px; + height: 400px; +} +#layers canvas{ + top: 0; + left: 0; + position: absolute; +} +#guide { + opacity: 0.7; + transition: opacity 0.5s ease-out; +} +#guide.fadeout { + opacity: 0; +} +#ui { + transition: opacity 0.3s ease-out; +} +#ui.dim { + opacity: 0.3; +} + diff --git a/views/archive/j/canvas-untangle-game/images/bg_repeat.png b/views/archive/j/canvas-untangle-game/images/bg_repeat.png new file mode 100644 index 00000000..c8766945 Binary files /dev/null and b/views/archive/j/canvas-untangle-game/images/bg_repeat.png differ diff --git a/views/archive/j/canvas-untangle-game/images/board.png b/views/archive/j/canvas-untangle-game/images/board.png new file mode 100644 index 00000000..14f40ff6 Binary files /dev/null and b/views/archive/j/canvas-untangle-game/images/board.png differ diff --git a/views/archive/j/canvas-untangle-game/images/guide_sprite.png b/views/archive/j/canvas-untangle-game/images/guide_sprite.png new file mode 100644 index 00000000..15dc117e Binary files /dev/null and b/views/archive/j/canvas-untangle-game/images/guide_sprite.png differ diff --git a/views/archive/j/canvas-untangle-game/images/title_bg.png b/views/archive/j/canvas-untangle-game/images/title_bg.png new file mode 100644 index 00000000..bb0275b7 Binary files /dev/null and b/views/archive/j/canvas-untangle-game/images/title_bg.png differ diff --git a/views/archive/j/canvas-untangle-game/index.html b/views/archive/j/canvas-untangle-game/index.html new file mode 100644 index 00000000..6f7ee617 --- /dev/null +++ b/views/archive/j/canvas-untangle-game/index.html @@ -0,0 +1,40 @@ + + + + + Untangle Puzzle Game in Canvas + + + + +
+
+

Untangle Puzzle Game in Canvas

+
+ +
+ + This is an interactive game with circles and lines connecting them. + + + + +
+ +

Puzzle 0, Completeness: 0%

+ +
+

This is an example of Untangle Puzzle Game in Canvas.

+
+
+ + + + + + + + + + + diff --git a/views/archive/j/canvas-untangle-game/js/jquery-2.1.3.min.js b/views/archive/j/canvas-untangle-game/js/jquery-2.1.3.min.js new file mode 100644 index 00000000..fbeab192 --- /dev/null +++ b/views/archive/j/canvas-untangle-game/js/jquery-2.1.3.min.js @@ -0,0 +1,3519 @@ +/*! jQuery v2.1.3 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ +!function(a, b) { + "object" == typeof module && "object" == typeof module.exports ? module.exports = a.document ? b(a, !0) : function(a) { + if (!a.document) + throw new Error("jQuery requires a window with a document"); + return b(a) + } : b(a) +}("undefined" != typeof window ? window : this, function(a, b) { + var c = [], + d = c.slice, + e = c.concat, + f = c.push, + g = c.indexOf, + h = {}, + i = h.toString, + j = h.hasOwnProperty, + k = {}, + l = a.document, + m = "2.1.3", + n = function(a, b) { + return new n.fn.init(a, b) + }, + o = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, + p = /^-ms-/, + q = /-([\da-z])/gi, + r = function(a, b) { + return b.toUpperCase() + }; + n.fn = n.prototype = { + jquery: m, + constructor: n, + selector: "", + length: 0, + toArray: function() { + return d.call(this) + }, + get: function(a) { + return null != a ? 0 > a ? this[a + this.length] : this[a] : d.call(this) + }, + pushStack: function(a) { + var b = n.merge(this.constructor(), a); + return b.prevObject = this, b.context = this.context, b + }, + each: function(a, b) { + return n.each(this, a, b) + }, + map: function(a) { + return this.pushStack(n.map(this, function(b, c) { + return a.call(b, c, b) + })) + }, + slice: function() { + return this.pushStack(d.apply(this, arguments)) + }, + first: function() { + return this.eq(0) + }, + last: function() { + return this.eq(-1) + }, + eq: function(a) { + var b = this.length, + c = +a + (0 > a ? b : 0); + return this.pushStack(c >= 0 && b > c ? [this[c]] : []) + }, + end: function() { + return this.prevObject || this.constructor(null) + }, + push: f, + sort: c.sort, + splice: c.splice + }, n.extend = n.fn.extend = function() { + var a, + b, + c, + d, + e, + f, + g = arguments[0] || {}, + h = 1, + i = arguments.length, + j = !1; + for ("boolean" == typeof g && (j = g, g = arguments[h] || {}, h++), "object" == typeof g || n.isFunction(g) || (g = {}), h === i && (g = this, h--); i > h; h++) + if (null != (a = arguments[h])) + for (b in a) + c = g[b], d = a[b], g !== d && (j && d && (n.isPlainObject(d) || (e = n.isArray(d))) ? (e ? (e = !1, f = c && n.isArray(c) ? c : []) : f = c && n.isPlainObject(c) ? c : {}, g[b] = n.extend(j, f, d)) : void 0 !== d && (g[b] = d)); + return g + }, n.extend({ + expando: "jQuery" + (m + Math.random()).replace(/\D/g, ""), + isReady: !0, + error: function(a) { + throw new Error(a) + }, + noop: function() {}, + isFunction: function(a) { + return "function" === n.type(a) + }, + isArray: Array.isArray, + isWindow: function(a) { + return null != a && a === a.window + }, + isNumeric: function(a) { + return !n.isArray(a) && a - parseFloat(a) + 1 >= 0 + }, + isPlainObject: function(a) { + return "object" !== n.type(a) || a.nodeType || n.isWindow(a) ? !1 : a.constructor && !j.call(a.constructor.prototype, "isPrototypeOf") ? !1 : !0 + }, + isEmptyObject: function(a) { + var b; + for (b in a) + return !1; + return !0 + }, + type: function(a) { + return null == a ? a + "" : "object" == typeof a || "function" == typeof a ? h[i.call(a)] || "object" : typeof a + }, + globalEval: function(a) { + var b, + c = eval; + a = n.trim(a), a && (1 === a.indexOf("use strict") ? (b = l.createElement("script"), b.text = a, l.head.appendChild(b).parentNode.removeChild(b)) : c(a)) + }, + camelCase: function(a) { + return a.replace(p, "ms-").replace(q, r) + }, + nodeName: function(a, b) { + return a.nodeName && a.nodeName.toLowerCase() === b.toLowerCase() + }, + each: function(a, b, c) { + var d, + e = 0, + f = a.length, + g = s(a); + if (c) { + if (g) { + for (; f > e; e++) + if (d = b.apply(a[e], c), d === !1) + break + } else + for (e in a) + if (d = b.apply(a[e], c), d === !1) + break + } else if (g) { + for (; f > e; e++) + if (d = b.call(a[e], e, a[e]), d === !1) + break + } else + for (e in a) + if (d = b.call(a[e], e, a[e]), d === !1) + break; + return a + }, + trim: function(a) { + return null == a ? "" : (a + "").replace(o, "") + }, + makeArray: function(a, b) { + var c = b || []; + return null != a && (s(Object(a)) ? n.merge(c, "string" == typeof a ? [a] : a) : f.call(c, a)), c + }, + inArray: function(a, b, c) { + return null == b ? -1 : g.call(b, a, c) + }, + merge: function(a, b) { + for (var c = +b.length, d = 0, e = a.length; c > d; d++) + a[e++] = b[d]; + return a.length = e, a + }, + grep: function(a, b, c) { + for (var d, e = [], f = 0, g = a.length, h = !c; g > f; f++) + d = !b(a[f], f), d !== h && e.push(a[f]); + return e + }, + map: function(a, b, c) { + var d, + f = 0, + g = a.length, + h = s(a), + i = []; + if (h) + for (; g > f; f++) + d = b(a[f], f, c), null != d && i.push(d); + else + for (f in a) + d = b(a[f], f, c), null != d && i.push(d); + return e.apply([], i) + }, + guid: 1, + proxy: function(a, b) { + var c, + e, + f; + return "string" == typeof b && (c = a[b], b = a, a = c), n.isFunction(a) ? (e = d.call(arguments, 2), f = function() { + return a.apply(b || this, e.concat(d.call(arguments))) + }, f.guid = a.guid = a.guid || n.guid++, f) : void 0 + }, + now: Date.now, + support: k + }), n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(a, b) { + h["[object " + b + "]"] = b.toLowerCase() + }); + function s(a) { + var b = a.length, + c = n.type(a); + return "function" === c || n.isWindow(a) ? !1 : 1 === a.nodeType && b ? !0 : "array" === c || 0 === b || "number" == typeof b && b > 0 && b - 1 in a + } + var t = function(a) { + var b, + c, + d, + e, + f, + g, + h, + i, + j, + k, + l, + m, + n, + o, + p, + q, + r, + s, + t, + u = "sizzle" + 1 * new Date, + v = a.document, + w = 0, + x = 0, + y = hb(), + z = hb(), + A = hb(), + B = function(a, b) { + return a === b && (l = !0), 0 + }, + C = 1 << 31, + D = {}.hasOwnProperty, + E = [], + F = E.pop, + G = E.push, + H = E.push, + I = E.slice, + J = function(a, b) { + for (var c = 0, d = a.length; d > c; c++) + if (a[c] === b) + return c; + return -1 + }, + K = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", + L = "[\\x20\\t\\r\\n\\f]", + M = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", + N = M.replace("w", "w#"), + O = "\\[" + L + "*(" + M + ")(?:" + L + "*([*^$|!~]?=)" + L + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + N + "))|)" + L + "*\\]", + P = ":(" + M + ")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|" + O + ")*)|.*)\\)|)", + Q = new RegExp(L + "+", "g"), + R = new RegExp("^" + L + "+|((?:^|[^\\\\])(?:\\\\.)*)" + L + "+$", "g"), + S = new RegExp("^" + L + "*," + L + "*"), + T = new RegExp("^" + L + "*([>+~]|" + L + ")" + L + "*"), + U = new RegExp("=" + L + "*([^\\]'\"]*?)" + L + "*\\]", "g"), + V = new RegExp(P), + W = new RegExp("^" + N + "$"), + X = { + ID: new RegExp("^#(" + M + ")"), + CLASS: new RegExp("^\\.(" + M + ")"), + TAG: new RegExp("^(" + M.replace("w", "w*") + ")"), + ATTR: new RegExp("^" + O), + PSEUDO: new RegExp("^" + P), + CHILD: new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + L + "*(even|odd|(([+-]|)(\\d*)n|)" + L + "*(?:([+-]|)" + L + "*(\\d+)|))" + L + "*\\)|)", "i"), + bool: new RegExp("^(?:" + K + ")$", "i"), + needsContext: new RegExp("^" + L + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + L + "*((?:-\\d)?\\d*)" + L + "*\\)|)(?=[^-]|$)", "i") + }, + Y = /^(?:input|select|textarea|button)$/i, + Z = /^h\d$/i, + $ = /^[^{]+\{\s*\[native \w/, + _ = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, + ab = /[+~]/, + bb = /'|\\/g, + cb = new RegExp("\\\\([\\da-f]{1,6}" + L + "?|(" + L + ")|.)", "ig"), + db = function(a, b, c) { + var d = "0x" + b - 65536; + return d !== d || c ? b : 0 > d ? String.fromCharCode(d + 65536) : String.fromCharCode(d >> 10 | 55296, 1023 & d | 56320) + }, + eb = function() { + m() + }; + try { + H.apply(E = I.call(v.childNodes), v.childNodes), E[v.childNodes.length].nodeType + } catch (fb) { + H = { + apply: E.length ? function(a, b) { + G.apply(a, I.call(b)) + } : function(a, b) { + var c = a.length, + d = 0; + while (a[c++] = b[d++]) + ; + a.length = c - 1 + } + } + } + function gb(a, b, d, e) { + var f, + h, + j, + k, + l, + o, + r, + s, + w, + x; + if ((b ? b.ownerDocument || b : v) !== n && m(b), b = b || n, d = d || [], k = b.nodeType, "string" != typeof a || !a || 1 !== k && 9 !== k && 11 !== k) + return d; + if (!e && p) { + if (11 !== k && (f = _.exec(a))) + if (j = f[1]) { + if (9 === k) { + if (h = b.getElementById(j), !h || !h.parentNode) + return d; + if (h.id === j) + return d.push(h), d + } else if (b.ownerDocument && (h = b.ownerDocument.getElementById(j)) && t(b, h) && h.id === j) + return d.push(h), d + } else { + if (f[2]) + return H.apply(d, b.getElementsByTagName(a)), d; + if ((j = f[3]) && c.getElementsByClassName) + return H.apply(d, b.getElementsByClassName(j)), d + } + if (c.qsa && (!q || !q.test(a))) { + if (s = r = u, w = b, x = 1 !== k && a, 1 === k && "object" !== b.nodeName.toLowerCase()) { + o = g(a), (r = b.getAttribute("id")) ? s = r.replace(bb, "\\$&") : b.setAttribute("id", s), s = "[id='" + s + "'] ", l = o.length; + while (l--) + o[l] = s + rb(o[l]); + w = ab.test(a) && pb(b.parentNode) || b, x = o.join(",") + } + if (x) + try { + return H.apply(d, w.querySelectorAll(x)), d + } catch (y) {} finally { + r || b.removeAttribute("id") + } + } + } + return i(a.replace(R, "$1"), b, d, e) + } + function hb() { + var a = []; + function b(c, e) { + return a.push(c + " ") > d.cacheLength && delete b[a.shift()], b[c + " "] = e + } + return b + } + function ib(a) { + return a[u] = !0, a + } + function jb(a) { + var b = n.createElement("div"); + try { + return !!a(b) + } catch (c) { + return !1 + } finally { + b.parentNode && b.parentNode.removeChild(b), b = null + } + } + function kb(a, b) { + var c = a.split("|"), + e = a.length; + while (e--) + d.attrHandle[c[e]] = b + } + function lb(a, b) { + var c = b && a, + d = c && 1 === a.nodeType && 1 === b.nodeType && (~b.sourceIndex || C) - (~a.sourceIndex || C); + if (d) + return d; + if (c) + while (c = c.nextSibling) + if (c === b) + return -1; + return a ? 1 : -1 + } + function mb(a) { + return function(b) { + var c = b.nodeName.toLowerCase(); + return "input" === c && b.type === a + } + } + function nb(a) { + return function(b) { + var c = b.nodeName.toLowerCase(); + return ("input" === c || "button" === c) && b.type === a + } + } + function ob(a) { + return ib(function(b) { + return b = +b, ib(function(c, d) { + var e, + f = a([], c.length, b), + g = f.length; + while (g--) + c[e = f[g]] && (c[e] = !(d[e] = c[e])) + }) + }) + } + function pb(a) { + return a && "undefined" != typeof a.getElementsByTagName && a + } + c = gb.support = {}, f = gb.isXML = function(a) { + var b = a && (a.ownerDocument || a).documentElement; + return b ? "HTML" !== b.nodeName : !1 + }, m = gb.setDocument = function(a) { + var b, + e, + g = a ? a.ownerDocument || a : v; + return g !== n && 9 === g.nodeType && g.documentElement ? (n = g, o = g.documentElement, e = g.defaultView, e && e !== e.top && (e.addEventListener ? e.addEventListener("unload", eb, !1) : e.attachEvent && e.attachEvent("onunload", eb)), p = !f(g), c.attributes = jb(function(a) { + return a.className = "i", !a.getAttribute("className") + }), c.getElementsByTagName = jb(function(a) { + return a.appendChild(g.createComment("")), !a.getElementsByTagName("*").length + }), c.getElementsByClassName = $.test(g.getElementsByClassName), c.getById = jb(function(a) { + return o.appendChild(a).id = u, !g.getElementsByName || !g.getElementsByName(u).length + }), c.getById ? (d.find.ID = function(a, b) { + if ("undefined" != typeof b.getElementById && p) { + var c = b.getElementById(a); + return c && c.parentNode ? [c] : [] + } + }, d.filter.ID = function(a) { + var b = a.replace(cb, db); + return function(a) { + return a.getAttribute("id") === b + } + }) : (delete d.find.ID, d.filter.ID = function(a) { + var b = a.replace(cb, db); + return function(a) { + var c = "undefined" != typeof a.getAttributeNode && a.getAttributeNode("id"); + return c && c.value === b + } + }), d.find.TAG = c.getElementsByTagName ? function(a, b) { + return "undefined" != typeof b.getElementsByTagName ? b.getElementsByTagName(a) : c.qsa ? b.querySelectorAll(a) : void 0 + } : function(a, b) { + var c, + d = [], + e = 0, + f = b.getElementsByTagName(a); + if ("*" === a) { + while (c = f[e++]) + 1 === c.nodeType && d.push(c); + return d + } + return f + }, d.find.CLASS = c.getElementsByClassName && function(a, b) { + return p ? b.getElementsByClassName(a) : void 0 + }, r = [], q = [], (c.qsa = $.test(g.querySelectorAll)) && (jb(function(a) { + o.appendChild(a).innerHTML = "", a.querySelectorAll("[msallowcapture^='']").length && q.push("[*^$]=" + L + "*(?:''|\"\")"), a.querySelectorAll("[selected]").length || q.push("\\[" + L + "*(?:value|" + K + ")"), a.querySelectorAll("[id~=" + u + "-]").length || q.push("~="), a.querySelectorAll(":checked").length || q.push(":checked"), a.querySelectorAll("a#" + u + "+*").length || q.push(".#.+[+~]") + }), jb(function(a) { + var b = g.createElement("input"); + b.setAttribute("type", "hidden"), a.appendChild(b).setAttribute("name", "D"), a.querySelectorAll("[name=d]").length && q.push("name" + L + "*[*^$|!~]?="), a.querySelectorAll(":enabled").length || q.push(":enabled", ":disabled"), a.querySelectorAll("*,:x"), q.push(",.*:") + })), (c.matchesSelector = $.test(s = o.matches || o.webkitMatchesSelector || o.mozMatchesSelector || o.oMatchesSelector || o.msMatchesSelector)) && jb(function(a) { + c.disconnectedMatch = s.call(a, "div"), s.call(a, "[s!='']:x"), r.push("!=", P) + }), q = q.length && new RegExp(q.join("|")), r = r.length && new RegExp(r.join("|")), b = $.test(o.compareDocumentPosition), t = b || $.test(o.contains) ? function(a, b) { + var c = 9 === a.nodeType ? a.documentElement : a, + d = b && b.parentNode; + return a === d || !(!d || 1 !== d.nodeType || !(c.contains ? c.contains(d) : a.compareDocumentPosition && 16 & a.compareDocumentPosition(d))) + } : function(a, b) { + if (b) + while (b = b.parentNode) + if (b === a) + return !0; + return !1 + }, B = b ? function(a, b) { + if (a === b) + return l = !0, 0; + var d = !a.compareDocumentPosition - !b.compareDocumentPosition; + return d ? d : (d = (a.ownerDocument || a) === (b.ownerDocument || b) ? a.compareDocumentPosition(b) : 1, 1 & d || !c.sortDetached && b.compareDocumentPosition(a) === d ? a === g || a.ownerDocument === v && t(v, a) ? -1 : b === g || b.ownerDocument === v && t(v, b) ? 1 : k ? J(k, a) - J(k, b) : 0 : 4 & d ? -1 : 1) + } : function(a, b) { + if (a === b) + return l = !0, 0; + var c, + d = 0, + e = a.parentNode, + f = b.parentNode, + h = [a], + i = [b]; + if (!e || !f) + return a === g ? -1 : b === g ? 1 : e ? -1 : f ? 1 : k ? J(k, a) - J(k, b) : 0; + if (e === f) + return lb(a, b); + c = a; + while (c = c.parentNode) + h.unshift(c); + c = b; + while (c = c.parentNode) + i.unshift(c); + while (h[d] === i[d]) + d++; + return d ? lb(h[d], i[d]) : h[d] === v ? -1 : i[d] === v ? 1 : 0 + }, g) : n + }, gb.matches = function(a, b) { + return gb(a, null, null, b) + }, gb.matchesSelector = function(a, b) { + if ((a.ownerDocument || a) !== n && m(a), b = b.replace(U, "='$1']"), !(!c.matchesSelector || !p || r && r.test(b) || q && q.test(b))) + try { + var d = s.call(a, b); + if (d || c.disconnectedMatch || a.document && 11 !== a.document.nodeType) + return d + } catch (e) {} + return gb(b, n, null, [a]).length > 0 + }, gb.contains = function(a, b) { + return (a.ownerDocument || a) !== n && m(a), t(a, b) + }, gb.attr = function(a, b) { + (a.ownerDocument || a) !== n && m(a); + var e = d.attrHandle[b.toLowerCase()], + f = e && D.call(d.attrHandle, b.toLowerCase()) ? e(a, b, !p) : void 0; + return void 0 !== f ? f : c.attributes || !p ? a.getAttribute(b) : (f = a.getAttributeNode(b)) && f.specified ? f.value : null + }, gb.error = function(a) { + throw new Error("Syntax error, unrecognized expression: " + a) + }, gb.uniqueSort = function(a) { + var b, + d = [], + e = 0, + f = 0; + if (l = !c.detectDuplicates, k = !c.sortStable && a.slice(0), a.sort(B), l) { + while (b = a[f++]) + b === a[f] && (e = d.push(f)); + while (e--) + a.splice(d[e], 1) + } + return k = null, a + }, e = gb.getText = function(a) { + var b, + c = "", + d = 0, + f = a.nodeType; + if (f) { + if (1 === f || 9 === f || 11 === f) { + if ("string" == typeof a.textContent) + return a.textContent; + for (a = a.firstChild; a; a = a.nextSibling) + c += e(a) + } else if (3 === f || 4 === f) + return a.nodeValue + } else + while (b = a[d++]) + c += e(b); + return c + }, d = gb.selectors = { + cacheLength: 50, + createPseudo: ib, + match: X, + attrHandle: {}, + find: {}, + relative: { + ">": { + dir: "parentNode", + first: !0 + }, + " ": { + dir: "parentNode" + }, + "+": { + dir: "previousSibling", + first: !0 + }, + "~": { + dir: "previousSibling" + } + }, + preFilter: { + ATTR: function(a) { + return a[1] = a[1].replace(cb, db), a[3] = (a[3] || a[4] || a[5] || "").replace(cb, db), "~=" === a[2] && (a[3] = " " + a[3] + " "), a.slice(0, 4) + }, + CHILD: function(a) { + return a[1] = a[1].toLowerCase(), "nth" === a[1].slice(0, 3) ? (a[3] || gb.error(a[0]), a[4] = +(a[4] ? a[5] + (a[6] || 1) : 2 * ("even" === a[3] || "odd" === a[3])), a[5] = +(a[7] + a[8] || "odd" === a[3])) : a[3] && gb.error(a[0]), a + }, + PSEUDO: function(a) { + var b, + c = !a[6] && a[2]; + return X.CHILD.test(a[0]) ? null : (a[3] ? a[2] = a[4] || a[5] || "" : c && V.test(c) && (b = g(c, !0)) && (b = c.indexOf(")", c.length - b) - c.length) && (a[0] = a[0].slice(0, b), a[2] = c.slice(0, b)), a.slice(0, 3)) + } + }, + filter: { + TAG: function(a) { + var b = a.replace(cb, db).toLowerCase(); + return "*" === a ? function() { + return !0 + } : function(a) { + return a.nodeName && a.nodeName.toLowerCase() === b + } + }, + CLASS: function(a) { + var b = y[a + " "]; + return b || (b = new RegExp("(^|" + L + ")" + a + "(" + L + "|$)")) && y(a, function(a) { + return b.test("string" == typeof a.className && a.className || "undefined" != typeof a.getAttribute && a.getAttribute("class") || "") + }) + }, + ATTR: function(a, b, c) { + return function(d) { + var e = gb.attr(d, a); + return null == e ? "!=" === b : b ? (e += "", "=" === b ? e === c : "!=" === b ? e !== c : "^=" === b ? c && 0 === e.indexOf(c) : "*=" === b ? c && e.indexOf(c) > -1 : "$=" === b ? c && e.slice(-c.length) === c : "~=" === b ? (" " + e.replace(Q, " ") + " ").indexOf(c) > -1 : "|=" === b ? e === c || e.slice(0, c.length + 1) === c + "-" : !1) : !0 + } + }, + CHILD: function(a, b, c, d, e) { + var f = "nth" !== a.slice(0, 3), + g = "last" !== a.slice(-4), + h = "of-type" === b; + return 1 === d && 0 === e ? function(a) { + return !!a.parentNode + } : function(b, c, i) { + var j, + k, + l, + m, + n, + o, + p = f !== g ? "nextSibling" : "previousSibling", + q = b.parentNode, + r = h && b.nodeName.toLowerCase(), + s = !i && !h; + if (q) { + if (f) { + while (p) { + l = b; + while (l = l[p]) + if (h ? l.nodeName.toLowerCase() === r : 1 === l.nodeType) + return !1; + o = p = "only" === a && !o && "nextSibling" + } + return !0 + } + if (o = [g ? q.firstChild : q.lastChild], g && s) { + k = q[u] || (q[u] = {}), j = k[a] || [], n = j[0] === w && j[1], m = j[0] === w && j[2], l = n && q.childNodes[n]; + while (l = ++n && l && l[p] || (m = n = 0) || o.pop()) + if (1 === l.nodeType && ++m && l === b) { + k[a] = [w, n, m]; + break + } + } else if (s && (j = (b[u] || (b[u] = {}))[a]) && j[0] === w) + m = j[1]; + else + while (l = ++n && l && l[p] || (m = n = 0) || o.pop()) + if ((h ? l.nodeName.toLowerCase() === r : 1 === l.nodeType) && ++m && (s && ((l[u] || (l[u] = {}))[a] = [w, m]), l === b)) + break; + return m -= e, m === d || m % d === 0 && m / d >= 0 + } + } + }, + PSEUDO: function(a, b) { + var c, + e = d.pseudos[a] || d.setFilters[a.toLowerCase()] || gb.error("unsupported pseudo: " + a); + return e[u] ? e(b) : e.length > 1 ? (c = [a, a, "", b], d.setFilters.hasOwnProperty(a.toLowerCase()) ? ib(function(a, c) { + var d, + f = e(a, b), + g = f.length; + while (g--) + d = J(a, f[g]), a[d] = !(c[d] = f[g]) + }) : function(a) { + return e(a, 0, c) + }) : e + } + }, + pseudos: { + not: ib(function(a) { + var b = [], + c = [], + d = h(a.replace(R, "$1")); + return d[u] ? ib(function(a, b, c, e) { + var f, + g = d(a, null, e, []), + h = a.length; + while (h--) + (f = g[h]) && (a[h] = !(b[h] = f)) + }) : function(a, e, f) { + return b[0] = a, d(b, null, f, c), b[0] = null, !c.pop() + } + }), + has: ib(function(a) { + return function(b) { + return gb(a, b).length > 0 + } + }), + contains: ib(function(a) { + return a = a.replace(cb, db), function(b) { + return (b.textContent || b.innerText || e(b)).indexOf(a) > -1 + } + }), + lang: ib(function(a) { + return W.test(a || "") || gb.error("unsupported lang: " + a), a = a.replace(cb, db).toLowerCase(), function(b) { + var c; + do if (c = p ? b.lang : b.getAttribute("xml:lang") || b.getAttribute("lang")) + return c = c.toLowerCase(), c === a || 0 === c.indexOf(a + "-"); + while ((b = b.parentNode) && 1 === b.nodeType); + return !1 + } + }), + target: function(b) { + var c = a.location && a.location.hash; + return c && c.slice(1) === b.id + }, + root: function(a) { + return a === o + }, + focus: function(a) { + return a === n.activeElement && (!n.hasFocus || n.hasFocus()) && !!(a.type || a.href || ~a.tabIndex) + }, + enabled: function(a) { + return a.disabled === !1 + }, + disabled: function(a) { + return a.disabled === !0 + }, + checked: function(a) { + var b = a.nodeName.toLowerCase(); + return "input" === b && !!a.checked || "option" === b && !!a.selected + }, + selected: function(a) { + return a.parentNode && a.parentNode.selectedIndex, a.selected === !0 + }, + empty: function(a) { + for (a = a.firstChild; a; a = a.nextSibling) + if (a.nodeType < 6) + return !1; + return !0 + }, + parent: function(a) { + return !d.pseudos.empty(a) + }, + header: function(a) { + return Z.test(a.nodeName) + }, + input: function(a) { + return Y.test(a.nodeName) + }, + button: function(a) { + var b = a.nodeName.toLowerCase(); + return "input" === b && "button" === a.type || "button" === b + }, + text: function(a) { + var b; + return "input" === a.nodeName.toLowerCase() && "text" === a.type && (null == (b = a.getAttribute("type")) || "text" === b.toLowerCase()) + }, + first: ob(function() { + return [0] + }), + last: ob(function(a, b) { + return [b - 1] + }), + eq: ob(function(a, b, c) { + return [0 > c ? c + b : c] + }), + even: ob(function(a, b) { + for (var c = 0; b > c; c += 2) + a.push(c); + return a + }), + odd: ob(function(a, b) { + for (var c = 1; b > c; c += 2) + a.push(c); + return a + }), + lt: ob(function(a, b, c) { + for (var d = 0 > c ? c + b : c; --d >= 0;) + a.push(d); + return a + }), + gt: ob(function(a, b, c) { + for (var d = 0 > c ? c + b : c; ++d < b;) + a.push(d); + return a + }) + } + }, d.pseudos.nth = d.pseudos.eq; + for (b in { + radio: !0, + checkbox: !0, + file: !0, + password: !0, + image: !0 + }) + d.pseudos[b] = mb(b); + for (b in { + submit: !0, + reset: !0 + }) + d.pseudos[b] = nb(b); + function qb() {} + qb.prototype = d.filters = d.pseudos, d.setFilters = new qb, g = gb.tokenize = function(a, b) { + var c, + e, + f, + g, + h, + i, + j, + k = z[a + " "]; + if (k) + return b ? 0 : k.slice(0); + h = a, i = [], j = d.preFilter; + while (h) { + (!c || (e = S.exec(h))) && (e && (h = h.slice(e[0].length) || h), i.push(f = [])), c = !1, (e = T.exec(h)) && (c = e.shift(), f.push({ + value: c, + type: e[0].replace(R, " ") + }), h = h.slice(c.length)); + for (g in d.filter) + !(e = X[g].exec(h)) || j[g] && !(e = j[g](e)) || (c = e.shift(), f.push({ + value: c, + type: g, + matches: e + }), h = h.slice(c.length)); + if (!c) + break + } + return b ? h.length : h ? gb.error(a) : z(a, i).slice(0) + }; + function rb(a) { + for (var b = 0, c = a.length, d = ""; c > b; b++) + d += a[b].value; + return d + } + function sb(a, b, c) { + var d = b.dir, + e = c && "parentNode" === d, + f = x++; + return b.first ? function(b, c, f) { + while (b = b[d]) + if (1 === b.nodeType || e) + return a(b, c, f) + } : function(b, c, g) { + var h, + i, + j = [w, f]; + if (g) { + while (b = b[d]) + if ((1 === b.nodeType || e) && a(b, c, g)) + return !0 + } else + while (b = b[d]) + if (1 === b.nodeType || e) { + if (i = b[u] || (b[u] = {}), (h = i[d]) && h[0] === w && h[1] === f) + return j[2] = h[2]; + if (i[d] = j, j[2] = a(b, c, g)) + return !0 + } + } + } + function tb(a) { + return a.length > 1 ? function(b, c, d) { + var e = a.length; + while (e--) + if (!a[e](b, c, d)) + return !1; + return !0 + } : a[0] + } + function ub(a, b, c) { + for (var d = 0, e = b.length; e > d; d++) + gb(a, b[d], c); + return c + } + function vb(a, b, c, d, e) { + for (var f, g = [], h = 0, i = a.length, j = null != b; i > h; h++) + (f = a[h]) && (!c || c(f, d, e)) && (g.push(f), j && b.push(h)); + return g + } + function wb(a, b, c, d, e, f) { + return d && !d[u] && (d = wb(d)), e && !e[u] && (e = wb(e, f)), ib(function(f, g, h, i) { + var j, + k, + l, + m = [], + n = [], + o = g.length, + p = f || ub(b || "*", h.nodeType ? [h] : h, []), + q = !a || !f && b ? p : vb(p, m, a, h, i), + r = c ? e || (f ? a : o || d) ? [] : g : q; + if (c && c(q, r, h, i), d) { + j = vb(r, n), d(j, [], h, i), k = j.length; + while (k--) + (l = j[k]) && (r[n[k]] = !(q[n[k]] = l)) + } + if (f) { + if (e || a) { + if (e) { + j = [], k = r.length; + while (k--) + (l = r[k]) && j.push(q[k] = l); + e(null, r = [], j, i) + } + k = r.length; + while (k--) + (l = r[k]) && (j = e ? J(f, l) : m[k]) > -1 && (f[j] = !(g[j] = l)) + } + } else + r = vb(r === g ? r.splice(o, r.length) : r), e ? e(null, g, r, i) : H.apply(g, r) + }) + } + function xb(a) { + for (var b, c, e, f = a.length, g = d.relative[a[0].type], h = g || d.relative[" "], i = g ? 1 : 0, k = sb(function(a) { + return a === b + }, h, !0), l = sb(function(a) { + return J(b, a) > -1 + }, h, !0), m = [function(a, c, d) { + var e = !g && (d || c !== j) || ((b = c).nodeType ? k(a, c, d) : l(a, c, d)); + return b = null, e + }]; f > i; i++) + if (c = d.relative[a[i].type]) + m = [sb(tb(m), c)]; + else { + if (c = d.filter[a[i].type].apply(null, a[i].matches), c[u]) { + for (e = ++i; f > e; e++) + if (d.relative[a[e].type]) + break; + return wb(i > 1 && tb(m), i > 1 && rb(a.slice(0, i - 1).concat({ + value: " " === a[i - 2].type ? "*" : "" + })).replace(R, "$1"), c, e > i && xb(a.slice(i, e)), f > e && xb(a = a.slice(e)), f > e && rb(a)) + } + m.push(c) + } + return tb(m) + } + function yb(a, b) { + var c = b.length > 0, + e = a.length > 0, + f = function(f, g, h, i, k) { + var l, + m, + o, + p = 0, + q = "0", + r = f && [], + s = [], + t = j, + u = f || e && d.find.TAG("*", k), + v = w += null == t ? 1 : Math.random() || .1, + x = u.length; + for (k && (j = g !== n && g); q !== x && null != (l = u[q]); q++) { + if (e && l) { + m = 0; + while (o = a[m++]) + if (o(l, g, h)) { + i.push(l); + break + } + k && (w = v) + } + c && ((l = !o && l) && p--, f && r.push(l)) + } + if (p += q, c && q !== p) { + m = 0; + while (o = b[m++]) + o(r, s, g, h); + if (f) { + if (p > 0) + while (q--) + r[q] || s[q] || (s[q] = F.call(i)); + s = vb(s) + } + H.apply(i, s), k && !f && s.length > 0 && p + b.length > 1 && gb.uniqueSort(i) + } + return k && (w = v, j = t), r + }; + return c ? ib(f) : f + } + return h = gb.compile = function(a, b) { + var c, + d = [], + e = [], + f = A[a + " "]; + if (!f) { + b || (b = g(a)), c = b.length; + while (c--) + f = xb(b[c]), f[u] ? d.push(f) : e.push(f); + f = A(a, yb(e, d)), f.selector = a + } + return f + }, i = gb.select = function(a, b, e, f) { + var i, + j, + k, + l, + m, + n = "function" == typeof a && a, + o = !f && g(a = n.selector || a); + if (e = e || [], 1 === o.length) { + if (j = o[0] = o[0].slice(0), j.length > 2 && "ID" === (k = j[0]).type && c.getById && 9 === b.nodeType && p && d.relative[j[1].type]) { + if (b = (d.find.ID(k.matches[0].replace(cb, db), b) || [])[0], !b) + return e; + n && (b = b.parentNode), a = a.slice(j.shift().value.length) + } + i = X.needsContext.test(a) ? 0 : j.length; + while (i--) { + if (k = j[i], d.relative[l = k.type]) + break; + if ((m = d.find[l]) && (f = m(k.matches[0].replace(cb, db), ab.test(j[0].type) && pb(b.parentNode) || b))) { + if (j.splice(i, 1), a = f.length && rb(j), !a) + return H.apply(e, f), e; + break + } + } + } + return (n || h(a, o))(f, b, !p, e, ab.test(a) && pb(b.parentNode) || b), e + }, c.sortStable = u.split("").sort(B).join("") === u, c.detectDuplicates = !!l, m(), c.sortDetached = jb(function(a) { + return 1 & a.compareDocumentPosition(n.createElement("div")) + }), jb(function(a) { + return a.innerHTML = "", "#" === a.firstChild.getAttribute("href") + }) || kb("type|href|height|width", function(a, b, c) { + return c ? void 0 : a.getAttribute(b, "type" === b.toLowerCase() ? 1 : 2) + }), c.attributes && jb(function(a) { + return a.innerHTML = "", a.firstChild.setAttribute("value", ""), "" === a.firstChild.getAttribute("value") + }) || kb("value", function(a, b, c) { + return c || "input" !== a.nodeName.toLowerCase() ? void 0 : a.defaultValue + }), jb(function(a) { + return null == a.getAttribute("disabled") + }) || kb(K, function(a, b, c) { + var d; + return c ? void 0 : a[b] === !0 ? b.toLowerCase() : (d = a.getAttributeNode(b)) && d.specified ? d.value : null + }), gb + }(a); + n.find = t, n.expr = t.selectors, n.expr[":"] = n.expr.pseudos, n.unique = t.uniqueSort, n.text = t.getText, n.isXMLDoc = t.isXML, n.contains = t.contains; + var u = n.expr.match.needsContext, + v = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, + w = /^.[^:#\[\.,]*$/; + function x(a, b, c) { + if (n.isFunction(b)) + return n.grep(a, function(a, d) { + return !!b.call(a, d, a) !== c + }); + if (b.nodeType) + return n.grep(a, function(a) { + return a === b !== c + }); + if ("string" == typeof b) { + if (w.test(b)) + return n.filter(b, a, c); + b = n.filter(b, a) + } + return n.grep(a, function(a) { + return g.call(b, a) >= 0 !== c + }) + } + n.filter = function(a, b, c) { + var d = b[0]; + return c && (a = ":not(" + a + ")"), 1 === b.length && 1 === d.nodeType ? n.find.matchesSelector(d, a) ? [d] : [] : n.find.matches(a, n.grep(b, function(a) { + return 1 === a.nodeType + })) + }, n.fn.extend({ + find: function(a) { + var b, + c = this.length, + d = [], + e = this; + if ("string" != typeof a) + return this.pushStack(n(a).filter(function() { + for (b = 0; c > b; b++) + if (n.contains(e[b], this)) + return !0 + })); + for (b = 0; c > b; b++) + n.find(a, e[b], d); + return d = this.pushStack(c > 1 ? n.unique(d) : d), d.selector = this.selector ? this.selector + " " + a : a, d + }, + filter: function(a) { + return this.pushStack(x(this, a || [], !1)) + }, + not: function(a) { + return this.pushStack(x(this, a || [], !0)) + }, + is: function(a) { + return !!x(this, "string" == typeof a && u.test(a) ? n(a) : a || [], !1).length + } + }); + var y, + z = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, + A = n.fn.init = function(a, b) { + var c, + d; + if (!a) + return this; + if ("string" == typeof a) { + if (c = "<" === a[0] && ">" === a[a.length - 1] && a.length >= 3 ? [null, a, null] : z.exec(a), !c || !c[1] && b) + return !b || b.jquery ? (b || y).find(a) : this.constructor(b).find(a); + if (c[1]) { + if (b = b instanceof n ? b[0] : b, n.merge(this, n.parseHTML(c[1], b && b.nodeType ? b.ownerDocument || b : l, !0)), v.test(c[1]) && n.isPlainObject(b)) + for (c in b) + n.isFunction(this[c]) ? this[c](b[c]) : this.attr(c, b[c]); + return this + } + return d = l.getElementById(c[2]), d && d.parentNode && (this.length = 1, this[0] = d), this.context = l, this.selector = a, this + } + return a.nodeType ? (this.context = this[0] = a, this.length = 1, this) : n.isFunction(a) ? "undefined" != typeof y.ready ? y.ready(a) : a(n) : (void 0 !== a.selector && (this.selector = a.selector, this.context = a.context), n.makeArray(a, this)) + }; + A.prototype = n.fn, y = n(l); + var B = /^(?:parents|prev(?:Until|All))/, + C = { + children: !0, + contents: !0, + next: !0, + prev: !0 + }; + n.extend({ + dir: function(a, b, c) { + var d = [], + e = void 0 !== c; + while ((a = a[b]) && 9 !== a.nodeType) + if (1 === a.nodeType) { + if (e && n(a).is(c)) + break; + d.push(a) + } + return d + }, + sibling: function(a, b) { + for (var c = []; a; a = a.nextSibling) + 1 === a.nodeType && a !== b && c.push(a); + return c + } + }), n.fn.extend({ + has: function(a) { + var b = n(a, this), + c = b.length; + return this.filter(function() { + for (var a = 0; c > a; a++) + if (n.contains(this, b[a])) + return !0 + }) + }, + closest: function(a, b) { + for (var c, d = 0, e = this.length, f = [], g = u.test(a) || "string" != typeof a ? n(a, b || this.context) : 0; e > d; d++) + for (c = this[d]; c && c !== b; c = c.parentNode) + if (c.nodeType < 11 && (g ? g.index(c) > -1 : 1 === c.nodeType && n.find.matchesSelector(c, a))) { + f.push(c); + break + } + return this.pushStack(f.length > 1 ? n.unique(f) : f) + }, + index: function(a) { + return a ? "string" == typeof a ? g.call(n(a), this[0]) : g.call(this, a.jquery ? a[0] : a) : this[0] && this[0].parentNode ? this.first().prevAll().length : -1 + }, + add: function(a, b) { + return this.pushStack(n.unique(n.merge(this.get(), n(a, b)))) + }, + addBack: function(a) { + return this.add(null == a ? this.prevObject : this.prevObject.filter(a)) + } + }); + function D(a, b) { + while ((a = a[b]) && 1 !== a.nodeType) + ; + return a + } + n.each({ + parent: function(a) { + var b = a.parentNode; + return b && 11 !== b.nodeType ? b : null + }, + parents: function(a) { + return n.dir(a, "parentNode") + }, + parentsUntil: function(a, b, c) { + return n.dir(a, "parentNode", c) + }, + next: function(a) { + return D(a, "nextSibling") + }, + prev: function(a) { + return D(a, "previousSibling") + }, + nextAll: function(a) { + return n.dir(a, "nextSibling") + }, + prevAll: function(a) { + return n.dir(a, "previousSibling") + }, + nextUntil: function(a, b, c) { + return n.dir(a, "nextSibling", c) + }, + prevUntil: function(a, b, c) { + return n.dir(a, "previousSibling", c) + }, + siblings: function(a) { + return n.sibling((a.parentNode || {}).firstChild, a) + }, + children: function(a) { + return n.sibling(a.firstChild) + }, + contents: function(a) { + return a.contentDocument || n.merge([], a.childNodes) + } + }, function(a, b) { + n.fn[a] = function(c, d) { + var e = n.map(this, b, c); + return "Until" !== a.slice(-5) && (d = c), d && "string" == typeof d && (e = n.filter(d, e)), this.length > 1 && (C[a] || n.unique(e), B.test(a) && e.reverse()), this.pushStack(e) + } + }); + var E = /\S+/g, + F = {}; + function G(a) { + var b = F[a] = {}; + return n.each(a.match(E) || [], function(a, c) { + b[c] = !0 + }), b + } + n.Callbacks = function(a) { + a = "string" == typeof a ? F[a] || G(a) : n.extend({}, a); + var b, + c, + d, + e, + f, + g, + h = [], + i = !a.once && [], + j = function(l) { + for (b = a.memory && l, c = !0, g = e || 0, e = 0, f = h.length, d = !0; h && f > g; g++) + if (h[g].apply(l[0], l[1]) === !1 && a.stopOnFalse) { + b = !1; + break + } + d = !1, h && (i ? i.length && j(i.shift()) : b ? h = [] : k.disable()) + }, + k = { + add: function() { + if (h) { + var c = h.length; + !function g(b) { + n.each(b, function(b, c) { + var d = n.type(c); + "function" === d ? a.unique && k.has(c) || h.push(c) : c && c.length && "string" !== d && g(c) + }) + }(arguments), d ? f = h.length : b && (e = c, j(b)) + } + return this + }, + remove: function() { + return h && n.each(arguments, function(a, b) { + var c; + while ((c = n.inArray(b, h, c)) > -1) + h.splice(c, 1), d && (f >= c && f--, g >= c && g--) + }), this + }, + has: function(a) { + return a ? n.inArray(a, h) > -1 : !(!h || !h.length) + }, + empty: function() { + return h = [], f = 0, this + }, + disable: function() { + return h = i = b = void 0, this + }, + disabled: function() { + return !h + }, + lock: function() { + return i = void 0, b || k.disable(), this + }, + locked: function() { + return !i + }, + fireWith: function(a, b) { + return !h || c && !i || (b = b || [], b = [a, b.slice ? b.slice() : b], d ? i.push(b) : j(b)), this + }, + fire: function() { + return k.fireWith(this, arguments), this + }, + fired: function() { + return !!c + } + }; + return k + }, n.extend({ + Deferred: function(a) { + var b = [["resolve", "done", n.Callbacks("once memory"), "resolved"], ["reject", "fail", n.Callbacks("once memory"), "rejected"], ["notify", "progress", n.Callbacks("memory")]], + c = "pending", + d = { + state: function() { + return c + }, + always: function() { + return e.done(arguments).fail(arguments), this + }, + then: function() { + var a = arguments; + return n.Deferred(function(c) { + n.each(b, function(b, f) { + var g = n.isFunction(a[b]) && a[b]; + e[f[1]](function() { + var a = g && g.apply(this, arguments); + a && n.isFunction(a.promise) ? a.promise().done(c.resolve).fail(c.reject).progress(c.notify) : c[f[0] + "With"](this === d ? c.promise() : this, g ? [a] : arguments) + }) + }), a = null + }).promise() + }, + promise: function(a) { + return null != a ? n.extend(a, d) : d + } + }, + e = {}; + return d.pipe = d.then, n.each(b, function(a, f) { + var g = f[2], + h = f[3]; + d[f[1]] = g.add, h && g.add(function() { + c = h + }, b[1 ^ a][2].disable, b[2][2].lock), e[f[0]] = function() { + return e[f[0] + "With"](this === e ? d : this, arguments), this + }, e[f[0] + "With"] = g.fireWith + }), d.promise(e), a && a.call(e, e), e + }, + when: function(a) { + var b = 0, + c = d.call(arguments), + e = c.length, + f = 1 !== e || a && n.isFunction(a.promise) ? e : 0, + g = 1 === f ? a : n.Deferred(), + h = function(a, b, c) { + return function(e) { + b[a] = this, c[a] = arguments.length > 1 ? d.call(arguments) : e, c === i ? g.notifyWith(b, c) : --f || g.resolveWith(b, c) + } + }, + i, + j, + k; + if (e > 1) + for (i = new Array(e), j = new Array(e), k = new Array(e); e > b; b++) + c[b] && n.isFunction(c[b].promise) ? c[b].promise().done(h(b, k, c)).fail(g.reject).progress(h(b, j, i)) : --f; + return f || g.resolveWith(k, c), g.promise() + } + }); + var H; + n.fn.ready = function(a) { + return n.ready.promise().done(a), this + }, n.extend({ + isReady: !1, + readyWait: 1, + holdReady: function(a) { + a ? n.readyWait++ : n.ready(!0) + }, + ready: function(a) { + (a === !0 ? --n.readyWait : n.isReady) || (n.isReady = !0, a !== !0 && --n.readyWait > 0 || (H.resolveWith(l, [n]), n.fn.triggerHandler && (n(l).triggerHandler("ready"), n(l).off("ready")))) + } + }); + function I() { + l.removeEventListener("DOMContentLoaded", I, !1), a.removeEventListener("load", I, !1), n.ready() + } + n.ready.promise = function(b) { + return H || (H = n.Deferred(), "complete" === l.readyState ? setTimeout(n.ready) : (l.addEventListener("DOMContentLoaded", I, !1), a.addEventListener("load", I, !1))), H.promise(b) + }, n.ready.promise(); + var J = n.access = function(a, b, c, d, e, f, g) { + var h = 0, + i = a.length, + j = null == c; + if ("object" === n.type(c)) { + e = !0; + for (h in c) + n.access(a, b, h, c[h], !0, f, g) + } else if (void 0 !== d && (e = !0, n.isFunction(d) || (g = !0), j && (g ? (b.call(a, d), b = null) : (j = b, b = function(a, b, c) { + return j.call(n(a), c) + })), b)) + for (; i > h; h++) + b(a[h], c, g ? d : d.call(a[h], h, b(a[h], c))); + return e ? a : j ? b.call(a) : i ? b(a[0], c) : f + }; + n.acceptData = function(a) { + return 1 === a.nodeType || 9 === a.nodeType || !+a.nodeType + }; + function K() { + Object.defineProperty(this.cache = {}, 0, { + get: function() { + return {} + } + }), this.expando = n.expando + K.uid++ + } + K.uid = 1, K.accepts = n.acceptData, K.prototype = { + key: function(a) { + if (!K.accepts(a)) + return 0; + var b = {}, + c = a[this.expando]; + if (!c) { + c = K.uid++; + try { + b[this.expando] = { + value: c + }, Object.defineProperties(a, b) + } catch (d) { + b[this.expando] = c, n.extend(a, b) + } + } + return this.cache[c] || (this.cache[c] = {}), c + }, + set: function(a, b, c) { + var d, + e = this.key(a), + f = this.cache[e]; + if ("string" == typeof b) + f[b] = c; + else if (n.isEmptyObject(f)) + n.extend(this.cache[e], b); + else + for (d in b) + f[d] = b[d]; + return f + }, + get: function(a, b) { + var c = this.cache[this.key(a)]; + return void 0 === b ? c : c[b] + }, + access: function(a, b, c) { + var d; + return void 0 === b || b && "string" == typeof b && void 0 === c ? (d = this.get(a, b), void 0 !== d ? d : this.get(a, n.camelCase(b))) : (this.set(a, b, c), void 0 !== c ? c : b) + }, + remove: function(a, b) { + var c, + d, + e, + f = this.key(a), + g = this.cache[f]; + if (void 0 === b) + this.cache[f] = {}; + else { + n.isArray(b) ? d = b.concat(b.map(n.camelCase)) : (e = n.camelCase(b), b in g ? d = [b, e] : (d = e, d = d in g ? [d] : d.match(E) || [])), c = d.length; + while (c--) + delete g[d[c]] + } + }, + hasData: function(a) { + return !n.isEmptyObject(this.cache[a[this.expando]] || {}) + }, + discard: function(a) { + a[this.expando] && delete this.cache[a[this.expando]] + } + }; + var L = new K, + M = new K, + N = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, + O = /([A-Z])/g; + function P(a, b, c) { + var d; + if (void 0 === c && 1 === a.nodeType) + if (d = "data-" + b.replace(O, "-$1").toLowerCase(), c = a.getAttribute(d), "string" == typeof c) { + try { + c = "true" === c ? !0 : "false" === c ? !1 : "null" === c ? null : +c + "" === c ? +c : N.test(c) ? n.parseJSON(c) : c + } catch (e) {} + M.set(a, b, c) + } else + c = void 0; + return c + } + n.extend({ + hasData: function(a) { + return M.hasData(a) || L.hasData(a) + }, + data: function(a, b, c) { + return M.access(a, b, c) + }, + removeData: function(a, b) { + M.remove(a, b) + }, + _data: function(a, b, c) { + return L.access(a, b, c) + }, + _removeData: function(a, b) { + L.remove(a, b) + } + }), n.fn.extend({ + data: function(a, b) { + var c, + d, + e, + f = this[0], + g = f && f.attributes; + if (void 0 === a) { + if (this.length && (e = M.get(f), 1 === f.nodeType && !L.get(f, "hasDataAttrs"))) { + c = g.length; + while (c--) + g[c] && (d = g[c].name, 0 === d.indexOf("data-") && (d = n.camelCase(d.slice(5)), P(f, d, e[d]))); + L.set(f, "hasDataAttrs", !0) + } + return e + } + return "object" == typeof a ? this.each(function() { + M.set(this, a) + }) : J(this, function(b) { + var c, + d = n.camelCase(a); + if (f && void 0 === b) { + if (c = M.get(f, a), void 0 !== c) + return c; + if (c = M.get(f, d), void 0 !== c) + return c; + if (c = P(f, d, void 0), void 0 !== c) + return c + } else + this.each(function() { + var c = M.get(this, d); + M.set(this, d, b), -1 !== a.indexOf("-") && void 0 !== c && M.set(this, a, b) + }) + }, null, b, arguments.length > 1, null, !0) + }, + removeData: function(a) { + return this.each(function() { + M.remove(this, a) + }) + } + }), n.extend({ + queue: function(a, b, c) { + var d; + return a ? (b = (b || "fx") + "queue", d = L.get(a, b), c && (!d || n.isArray(c) ? d = L.access(a, b, n.makeArray(c)) : d.push(c)), d || []) : void 0 + }, + dequeue: function(a, b) { + b = b || "fx"; + var c = n.queue(a, b), + d = c.length, + e = c.shift(), + f = n._queueHooks(a, b), + g = function() { + n.dequeue(a, b) + }; + "inprogress" === e && (e = c.shift(), d--), e && ("fx" === b && c.unshift("inprogress"), delete f.stop, e.call(a, g, f)), !d && f && f.empty.fire() + }, + _queueHooks: function(a, b) { + var c = b + "queueHooks"; + return L.get(a, c) || L.access(a, c, { + empty: n.Callbacks("once memory").add(function() { + L.remove(a, [b + "queue", c]) + }) + }) + } + }), n.fn.extend({ + queue: function(a, b) { + var c = 2; + return "string" != typeof a && (b = a, a = "fx", c--), arguments.length < c ? n.queue(this[0], a) : void 0 === b ? this : this.each(function() { + var c = n.queue(this, a, b); + n._queueHooks(this, a), "fx" === a && "inprogress" !== c[0] && n.dequeue(this, a) + }) + }, + dequeue: function(a) { + return this.each(function() { + n.dequeue(this, a) + }) + }, + clearQueue: function(a) { + return this.queue(a || "fx", []) + }, + promise: function(a, b) { + var c, + d = 1, + e = n.Deferred(), + f = this, + g = this.length, + h = function() { + --d || e.resolveWith(f, [f]) + }; + "string" != typeof a && (b = a, a = void 0), a = a || "fx"; + while (g--) + c = L.get(f[g], a + "queueHooks"), c && c.empty && (d++, c.empty.add(h)); + return h(), e.promise(b) + } + }); + var Q = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source, + R = ["Top", "Right", "Bottom", "Left"], + S = function(a, b) { + return a = b || a, "none" === n.css(a, "display") || !n.contains(a.ownerDocument, a) + }, + T = /^(?:checkbox|radio)$/i; + !function() { + var a = l.createDocumentFragment(), + b = a.appendChild(l.createElement("div")), + c = l.createElement("input"); + c.setAttribute("type", "radio"), c.setAttribute("checked", "checked"), c.setAttribute("name", "t"), b.appendChild(c), k.checkClone = b.cloneNode(!0).cloneNode(!0).lastChild.checked, b.innerHTML = "", k.noCloneChecked = !!b.cloneNode(!0).lastChild.defaultValue + }(); + var U = "undefined"; + k.focusinBubbles = "onfocusin" in a; + var V = /^key/, + W = /^(?:mouse|pointer|contextmenu)|click/, + X = /^(?:focusinfocus|focusoutblur)$/, + Y = /^([^.]*)(?:\.(.+)|)$/; + function Z() { + return !0 + } + function $() { + return !1 + } + function _() { + try { + return l.activeElement + } catch (a) {} + } + n.event = { + global: {}, + add: function(a, b, c, d, e) { + var f, + g, + h, + i, + j, + k, + l, + m, + o, + p, + q, + r = L.get(a); + if (r) { + c.handler && (f = c, c = f.handler, e = f.selector), c.guid || (c.guid = n.guid++), (i = r.events) || (i = r.events = {}), (g = r.handle) || (g = r.handle = function(b) { + return typeof n !== U && n.event.triggered !== b.type ? n.event.dispatch.apply(a, arguments) : void 0 + }), b = (b || "").match(E) || [""], j = b.length; + while (j--) + h = Y.exec(b[j]) || [], o = q = h[1], p = (h[2] || "").split(".").sort(), o && (l = n.event.special[o] || {}, o = (e ? l.delegateType : l.bindType) || o, l = n.event.special[o] || {}, k = n.extend({ + type: o, + origType: q, + data: d, + handler: c, + guid: c.guid, + selector: e, + needsContext: e && n.expr.match.needsContext.test(e), + namespace: p.join(".") + }, f), (m = i[o]) || (m = i[o] = [], m.delegateCount = 0, l.setup && l.setup.call(a, d, p, g) !== !1 || a.addEventListener && a.addEventListener(o, g, !1)), l.add && (l.add.call(a, k), k.handler.guid || (k.handler.guid = c.guid)), e ? m.splice(m.delegateCount++, 0, k) : m.push(k), n.event.global[o] = !0) + } + }, + remove: function(a, b, c, d, e) { + var f, + g, + h, + i, + j, + k, + l, + m, + o, + p, + q, + r = L.hasData(a) && L.get(a); + if (r && (i = r.events)) { + b = (b || "").match(E) || [""], j = b.length; + while (j--) + if (h = Y.exec(b[j]) || [], o = q = h[1], p = (h[2] || "").split(".").sort(), o) { + l = n.event.special[o] || {}, o = (d ? l.delegateType : l.bindType) || o, m = i[o] || [], h = h[2] && new RegExp("(^|\\.)" + p.join("\\.(?:.*\\.|)") + "(\\.|$)"), g = f = m.length; + while (f--) + k = m[f], !e && q !== k.origType || c && c.guid !== k.guid || h && !h.test(k.namespace) || d && d !== k.selector && ("**" !== d || !k.selector) || (m.splice(f, 1), k.selector && m.delegateCount--, l.remove && l.remove.call(a, k)); + g && !m.length && (l.teardown && l.teardown.call(a, p, r.handle) !== !1 || n.removeEvent(a, o, r.handle), delete i[o]) + } else + for (o in i) + n.event.remove(a, o + b[j], c, d, !0); + n.isEmptyObject(i) && (delete r.handle, L.remove(a, "events")) + } + }, + trigger: function(b, c, d, e) { + var f, + g, + h, + i, + k, + m, + o, + p = [d || l], + q = j.call(b, "type") ? b.type : b, + r = j.call(b, "namespace") ? b.namespace.split(".") : []; + if (g = h = d = d || l, 3 !== d.nodeType && 8 !== d.nodeType && !X.test(q + n.event.triggered) && (q.indexOf(".") >= 0 && (r = q.split("."), q = r.shift(), r.sort()), k = q.indexOf(":") < 0 && "on" + q, b = b[n.expando] ? b : new n.Event(q, "object" == typeof b && b), b.isTrigger = e ? 2 : 3, b.namespace = r.join("."), b.namespace_re = b.namespace ? new RegExp("(^|\\.)" + r.join("\\.(?:.*\\.|)") + "(\\.|$)") : null, b.result = void 0, b.target || (b.target = d), c = null == c ? [b] : n.makeArray(c, [b]), o = n.event.special[q] || {}, e || !o.trigger || o.trigger.apply(d, c) !== !1)) { + if (!e && !o.noBubble && !n.isWindow(d)) { + for (i = o.delegateType || q, X.test(i + q) || (g = g.parentNode); g; g = g.parentNode) + p.push(g), h = g; + h === (d.ownerDocument || l) && p.push(h.defaultView || h.parentWindow || a) + } + f = 0; + while ((g = p[f++]) && !b.isPropagationStopped()) + b.type = f > 1 ? i : o.bindType || q, m = (L.get(g, "events") || {})[b.type] && L.get(g, "handle"), m && m.apply(g, c), m = k && g[k], m && m.apply && n.acceptData(g) && (b.result = m.apply(g, c), b.result === !1 && b.preventDefault()); + return b.type = q, e || b.isDefaultPrevented() || o._default && o._default.apply(p.pop(), c) !== !1 || !n.acceptData(d) || k && n.isFunction(d[q]) && !n.isWindow(d) && (h = d[k], h && (d[k] = null), n.event.triggered = q, d[q](), n.event.triggered = void 0, h && (d[k] = h)), b.result + } + }, + dispatch: function(a) { + a = n.event.fix(a); + var b, + c, + e, + f, + g, + h = [], + i = d.call(arguments), + j = (L.get(this, "events") || {})[a.type] || [], + k = n.event.special[a.type] || {}; + if (i[0] = a, a.delegateTarget = this, !k.preDispatch || k.preDispatch.call(this, a) !== !1) { + h = n.event.handlers.call(this, a, j), b = 0; + while ((f = h[b++]) && !a.isPropagationStopped()) { + a.currentTarget = f.elem, c = 0; + while ((g = f.handlers[c++]) && !a.isImmediatePropagationStopped()) + (!a.namespace_re || a.namespace_re.test(g.namespace)) && (a.handleObj = g, a.data = g.data, e = ((n.event.special[g.origType] || {}).handle || g.handler).apply(f.elem, i), void 0 !== e && (a.result = e) === !1 && (a.preventDefault(), a.stopPropagation())) + } + return k.postDispatch && k.postDispatch.call(this, a), a.result + } + }, + handlers: function(a, b) { + var c, + d, + e, + f, + g = [], + h = b.delegateCount, + i = a.target; + if (h && i.nodeType && (!a.button || "click" !== a.type)) + for (; i !== this; i = i.parentNode || this) + if (i.disabled !== !0 || "click" !== a.type) { + for (d = [], c = 0; h > c; c++) + f = b[c], e = f.selector + " ", void 0 === d[e] && (d[e] = f.needsContext ? n(e, this).index(i) >= 0 : n.find(e, this, null, [i]).length), d[e] && d.push(f); + d.length && g.push({ + elem: i, + handlers: d + }) + } + return h < b.length && g.push({ + elem: this, + handlers: b.slice(h) + }), g + }, + props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), + fixHooks: {}, + keyHooks: { + props: "char charCode key keyCode".split(" "), + filter: function(a, b) { + return null == a.which && (a.which = null != b.charCode ? b.charCode : b.keyCode), a + } + }, + mouseHooks: { + props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "), + filter: function(a, b) { + var c, + d, + e, + f = b.button; + return null == a.pageX && null != b.clientX && (c = a.target.ownerDocument || l, d = c.documentElement, e = c.body, a.pageX = b.clientX + (d && d.scrollLeft || e && e.scrollLeft || 0) - (d && d.clientLeft || e && e.clientLeft || 0), a.pageY = b.clientY + (d && d.scrollTop || e && e.scrollTop || 0) - (d && d.clientTop || e && e.clientTop || 0)), a.which || void 0 === f || (a.which = 1 & f ? 1 : 2 & f ? 3 : 4 & f ? 2 : 0), a + } + }, + fix: function(a) { + if (a[n.expando]) + return a; + var b, + c, + d, + e = a.type, + f = a, + g = this.fixHooks[e]; + g || (this.fixHooks[e] = g = W.test(e) ? this.mouseHooks : V.test(e) ? this.keyHooks : {}), d = g.props ? this.props.concat(g.props) : this.props, a = new n.Event(f), b = d.length; + while (b--) + c = d[b], a[c] = f[c]; + return a.target || (a.target = l), 3 === a.target.nodeType && (a.target = a.target.parentNode), g.filter ? g.filter(a, f) : a + }, + special: { + load: { + noBubble: !0 + }, + focus: { + trigger: function() { + return this !== _() && this.focus ? (this.focus(), !1) : void 0 + }, + delegateType: "focusin" + }, + blur: { + trigger: function() { + return this === _() && this.blur ? (this.blur(), !1) : void 0 + }, + delegateType: "focusout" + }, + click: { + trigger: function() { + return "checkbox" === this.type && this.click && n.nodeName(this, "input") ? (this.click(), !1) : void 0 + }, + _default: function(a) { + return n.nodeName(a.target, "a") + } + }, + beforeunload: { + postDispatch: function(a) { + void 0 !== a.result && a.originalEvent && (a.originalEvent.returnValue = a.result) + } + } + }, + simulate: function(a, b, c, d) { + var e = n.extend(new n.Event, c, { + type: a, + isSimulated: !0, + originalEvent: {} + }); + d ? n.event.trigger(e, null, b) : n.event.dispatch.call(b, e), e.isDefaultPrevented() && c.preventDefault() + } + }, n.removeEvent = function(a, b, c) { + a.removeEventListener && a.removeEventListener(b, c, !1) + }, n.Event = function(a, b) { + return this instanceof n.Event ? (a && a.type ? (this.originalEvent = a, this.type = a.type, this.isDefaultPrevented = a.defaultPrevented || void 0 === a.defaultPrevented && a.returnValue === !1 ? Z : $) : this.type = a, b && n.extend(this, b), this.timeStamp = a && a.timeStamp || n.now(), void (this[n.expando] = !0)) : new n.Event(a, b) + }, n.Event.prototype = { + isDefaultPrevented: $, + isPropagationStopped: $, + isImmediatePropagationStopped: $, + preventDefault: function() { + var a = this.originalEvent; + this.isDefaultPrevented = Z, a && a.preventDefault && a.preventDefault() + }, + stopPropagation: function() { + var a = this.originalEvent; + this.isPropagationStopped = Z, a && a.stopPropagation && a.stopPropagation() + }, + stopImmediatePropagation: function() { + var a = this.originalEvent; + this.isImmediatePropagationStopped = Z, a && a.stopImmediatePropagation && a.stopImmediatePropagation(), this.stopPropagation() + } + }, n.each({ + mouseenter: "mouseover", + mouseleave: "mouseout", + pointerenter: "pointerover", + pointerleave: "pointerout" + }, function(a, b) { + n.event.special[a] = { + delegateType: b, + bindType: b, + handle: function(a) { + var c, + d = this, + e = a.relatedTarget, + f = a.handleObj; + return (!e || e !== d && !n.contains(d, e)) && (a.type = f.origType, c = f.handler.apply(this, arguments), a.type = b), c + } + } + }), k.focusinBubbles || n.each({ + focus: "focusin", + blur: "focusout" + }, function(a, b) { + var c = function(a) { + n.event.simulate(b, a.target, n.event.fix(a), !0) + }; + n.event.special[b] = { + setup: function() { + var d = this.ownerDocument || this, + e = L.access(d, b); + e || d.addEventListener(a, c, !0), L.access(d, b, (e || 0) + 1) + }, + teardown: function() { + var d = this.ownerDocument || this, + e = L.access(d, b) - 1; + e ? L.access(d, b, e) : (d.removeEventListener(a, c, !0), L.remove(d, b)) + } + } + }), n.fn.extend({ + on: function(a, b, c, d, e) { + var f, + g; + if ("object" == typeof a) { + "string" != typeof b && (c = c || b, b = void 0); + for (g in a) + this.on(g, b, c, a[g], e); + return this + } + if (null == c && null == d ? (d = b, c = b = void 0) : null == d && ("string" == typeof b ? (d = c, c = void 0) : (d = c, c = b, b = void 0)), d === !1) + d = $; + else if (!d) + return this; + return 1 === e && (f = d, d = function(a) { + return n().off(a), f.apply(this, arguments) + }, d.guid = f.guid || (f.guid = n.guid++)), this.each(function() { + n.event.add(this, a, d, c, b) + }) + }, + one: function(a, b, c, d) { + return this.on(a, b, c, d, 1) + }, + off: function(a, b, c) { + var d, + e; + if (a && a.preventDefault && a.handleObj) + return d = a.handleObj, n(a.delegateTarget).off(d.namespace ? d.origType + "." + d.namespace : d.origType, d.selector, d.handler), this; + if ("object" == typeof a) { + for (e in a) + this.off(e, b, a[e]); + return this + } + return (b === !1 || "function" == typeof b) && (c = b, b = void 0), c === !1 && (c = $), this.each(function() { + n.event.remove(this, a, c, b) + }) + }, + trigger: function(a, b) { + return this.each(function() { + n.event.trigger(a, b, this) + }) + }, + triggerHandler: function(a, b) { + var c = this[0]; + return c ? n.event.trigger(a, b, c, !0) : void 0 + } + }); + var ab = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, + bb = /<([\w:]+)/, + cb = /<|&#?\w+;/, + db = /<(?:script|style|link)/i, + eb = /checked\s*(?:[^=]|=\s*.checked.)/i, + fb = /^$|\/(?:java|ecma)script/i, + gb = /^true\/(.*)/, + hb = /^\s*\s*$/g, + ib = { + option: [1, ""], + thead: [1, "", "
"], + col: [2, "", "
"], + tr: [2, "", "
"], + td: [3, "", "
"], + _default: [0, "", ""] + }; + ib.optgroup = ib.option, ib.tbody = ib.tfoot = ib.colgroup = ib.caption = ib.thead, ib.th = ib.td; + function jb(a, b) { + return n.nodeName(a, "table") && n.nodeName(11 !== b.nodeType ? b : b.firstChild, "tr") ? a.getElementsByTagName("tbody")[0] || a.appendChild(a.ownerDocument.createElement("tbody")) : a + } + function kb(a) { + return a.type = (null !== a.getAttribute("type")) + "/" + a.type, a + } + function lb(a) { + var b = gb.exec(a.type); + return b ? a.type = b[1] : a.removeAttribute("type"), a + } + function mb(a, b) { + for (var c = 0, d = a.length; d > c; c++) + L.set(a[c], "globalEval", !b || L.get(b[c], "globalEval")) + } + function nb(a, b) { + var c, + d, + e, + f, + g, + h, + i, + j; + if (1 === b.nodeType) { + if (L.hasData(a) && (f = L.access(a), g = L.set(b, f), j = f.events)) { + delete g.handle, g.events = {}; + for (e in j) + for (c = 0, d = j[e].length; d > c; c++) + n.event.add(b, e, j[e][c]) + } + M.hasData(a) && (h = M.access(a), i = n.extend({}, h), M.set(b, i)) + } + } + function ob(a, b) { + var c = a.getElementsByTagName ? a.getElementsByTagName(b || "*") : a.querySelectorAll ? a.querySelectorAll(b || "*") : []; + return void 0 === b || b && n.nodeName(a, b) ? n.merge([a], c) : c + } + function pb(a, b) { + var c = b.nodeName.toLowerCase(); + "input" === c && T.test(a.type) ? b.checked = a.checked : ("input" === c || "textarea" === c) && (b.defaultValue = a.defaultValue) + } + n.extend({ + clone: function(a, b, c) { + var d, + e, + f, + g, + h = a.cloneNode(!0), + i = n.contains(a.ownerDocument, a); + if (!(k.noCloneChecked || 1 !== a.nodeType && 11 !== a.nodeType || n.isXMLDoc(a))) + for (g = ob(h), f = ob(a), d = 0, e = f.length; e > d; d++) + pb(f[d], g[d]); + if (b) + if (c) + for (f = f || ob(a), g = g || ob(h), d = 0, e = f.length; e > d; d++) + nb(f[d], g[d]); + else + nb(a, h); + return g = ob(h, "script"), g.length > 0 && mb(g, !i && ob(a, "script")), h + }, + buildFragment: function(a, b, c, d) { + for (var e, f, g, h, i, j, k = b.createDocumentFragment(), l = [], m = 0, o = a.length; o > m; m++) + if (e = a[m], e || 0 === e) + if ("object" === n.type(e)) + n.merge(l, e.nodeType ? [e] : e); + else if (cb.test(e)) { + f = f || k.appendChild(b.createElement("div")), g = (bb.exec(e) || ["", ""])[1].toLowerCase(), h = ib[g] || ib._default, f.innerHTML = h[1] + e.replace(ab, "<$1>") + h[2], j = h[0]; + while (j--) + f = f.lastChild; + n.merge(l, f.childNodes), f = k.firstChild, f.textContent = "" + } else + l.push(b.createTextNode(e)); + k.textContent = "", m = 0; + while (e = l[m++]) + if ((!d || -1 === n.inArray(e, d)) && (i = n.contains(e.ownerDocument, e), f = ob(k.appendChild(e), "script"), i && mb(f), c)) { + j = 0; + while (e = f[j++]) + fb.test(e.type || "") && c.push(e) + } + return k + }, + cleanData: function(a) { + for (var b, c, d, e, f = n.event.special, g = 0; void 0 !== (c = a[g]); g++) { + if (n.acceptData(c) && (e = c[L.expando], e && (b = L.cache[e]))) { + if (b.events) + for (d in b.events) + f[d] ? n.event.remove(c, d) : n.removeEvent(c, d, b.handle); + L.cache[e] && delete L.cache[e] + } + delete M.cache[c[M.expando]] + } + } + }), n.fn.extend({ + text: function(a) { + return J(this, function(a) { + return void 0 === a ? n.text(this) : this.empty().each(function() { + (1 === this.nodeType || 11 === this.nodeType || 9 === this.nodeType) && (this.textContent = a) + }) + }, null, a, arguments.length) + }, + append: function() { + return this.domManip(arguments, function(a) { + if (1 === this.nodeType || 11 === this.nodeType || 9 === this.nodeType) { + var b = jb(this, a); + b.appendChild(a) + } + }) + }, + prepend: function() { + return this.domManip(arguments, function(a) { + if (1 === this.nodeType || 11 === this.nodeType || 9 === this.nodeType) { + var b = jb(this, a); + b.insertBefore(a, b.firstChild) + } + }) + }, + before: function() { + return this.domManip(arguments, function(a) { + this.parentNode && this.parentNode.insertBefore(a, this) + }) + }, + after: function() { + return this.domManip(arguments, function(a) { + this.parentNode && this.parentNode.insertBefore(a, this.nextSibling) + }) + }, + remove: function(a, b) { + for (var c, d = a ? n.filter(a, this) : this, e = 0; null != (c = d[e]); e++) + b || 1 !== c.nodeType || n.cleanData(ob(c)), c.parentNode && (b && n.contains(c.ownerDocument, c) && mb(ob(c, "script")), c.parentNode.removeChild(c)); + return this + }, + empty: function() { + for (var a, b = 0; null != (a = this[b]); b++) + 1 === a.nodeType && (n.cleanData(ob(a, !1)), a.textContent = ""); + return this + }, + clone: function(a, b) { + return a = null == a ? !1 : a, b = null == b ? a : b, this.map(function() { + return n.clone(this, a, b) + }) + }, + html: function(a) { + return J(this, function(a) { + var b = this[0] || {}, + c = 0, + d = this.length; + if (void 0 === a && 1 === b.nodeType) + return b.innerHTML; + if ("string" == typeof a && !db.test(a) && !ib[(bb.exec(a) || ["", ""])[1].toLowerCase()]) { + a = a.replace(ab, "<$1>"); + try { + for (; d > c; c++) + b = this[c] || {}, 1 === b.nodeType && (n.cleanData(ob(b, !1)), b.innerHTML = a); + b = 0 + } catch (e) {} + } + b && this.empty().append(a) + }, null, a, arguments.length) + }, + replaceWith: function() { + var a = arguments[0]; + return this.domManip(arguments, function(b) { + a = this.parentNode, n.cleanData(ob(this)), a && a.replaceChild(b, this) + }), a && (a.length || a.nodeType) ? this : this.remove() + }, + detach: function(a) { + return this.remove(a, !0) + }, + domManip: function(a, b) { + a = e.apply([], a); + var c, + d, + f, + g, + h, + i, + j = 0, + l = this.length, + m = this, + o = l - 1, + p = a[0], + q = n.isFunction(p); + if (q || l > 1 && "string" == typeof p && !k.checkClone && eb.test(p)) + return this.each(function(c) { + var d = m.eq(c); + q && (a[0] = p.call(this, c, d.html())), d.domManip(a, b) + }); + if (l && (c = n.buildFragment(a, this[0].ownerDocument, !1, this), d = c.firstChild, 1 === c.childNodes.length && (c = d), d)) { + for (f = n.map(ob(c, "script"), kb), g = f.length; l > j; j++) + h = c, j !== o && (h = n.clone(h, !0, !0), g && n.merge(f, ob(h, "script"))), b.call(this[j], h, j); + if (g) + for (i = f[f.length - 1].ownerDocument, n.map(f, lb), j = 0; g > j; j++) + h = f[j], fb.test(h.type || "") && !L.access(h, "globalEval") && n.contains(i, h) && (h.src ? n._evalUrl && n._evalUrl(h.src) : n.globalEval(h.textContent.replace(hb, ""))) + } + return this + } + }), n.each({ + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" + }, function(a, b) { + n.fn[a] = function(a) { + for (var c, d = [], e = n(a), g = e.length - 1, h = 0; g >= h; h++) + c = h === g ? this : this.clone(!0), n(e[h])[b](c), f.apply(d, c.get()); + return this.pushStack(d) + } + }); + var qb, + rb = {}; + function sb(b, c) { + var d, + e = n(c.createElement(b)).appendTo(c.body), + f = a.getDefaultComputedStyle && (d = a.getDefaultComputedStyle(e[0])) ? d.display : n.css(e[0], "display"); + return e.detach(), f + } + function tb(a) { + var b = l, + c = rb[a]; + return c || (c = sb(a, b), "none" !== c && c || (qb = (qb || n("