diff --git a/README.md b/README.md new file mode 100644 index 0000000..adb65e2 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +###WE BECOME WHAT WE BEHOLD +*a game about news cycles, vicious cycles, infinite cycles* + +![looping animation](https://i.imgur.com/CTANpQP.gif) + +**[PLAY ON ITCH.IO](https://ncase.itch.io/wbwwb)** + +--- + +###Made with open culture, for open culture! + +I'm releasing all my code and art to the public domain, under the [Creative Commons Zero](http://creativecommons.org/publicdomain/zero/1.0/) un-license. Which means if you wanna remix this to make your own way-too-meta game, or use it in a presentation or classroom or whatever, you already have my permission! + +However, not *all* the code/art is mine. Credit's due where credit's due, so... + +**CODE:** +- [PIXI.js](https://github.com/pixijs/pixi.js), for rendering the graphics (MIT License) +- [Howler.js](https://github.com/goldfire/howler.js), for playing the sounds (MIT License) + +**SOUNDS:** +- [squeak!](https://www.freesound.org/people/ermfilm/sounds/130011/) (CC BY) +- [park ambience](https://www.freesound.org/people/Mafon2/sounds/274175/) (CC Zero) +- [camera shutter](https://www.freesound.org/people/uEffects/sounds/207865/) (CC Zero) +- [single cricket](https://www.freesound.org/people/cs272/sounds/77034/) (CC-BY) +- [multiple crickets](https://www.freesound.org/people/alienistcog/sounds/124583/) (CC Zero) +- [news jingle](https://www.freesound.org/people/Tuben/sounds/272044/) (CC Zero) +- [scream #1](https://www.freesound.org/people/GreatNate98/sounds/353086/) (CC Zero) +- [scream #2](https://www.freesound.org/people/mariallinas/sounds/222649/) (CC Zero) +- [gunshot](https://www.freesound.org/people/mitchelk/sounds/136766/) (CC Zero) +- [gun cocked](https://www.freesound.org/people/martian/sounds/182229/) (CC Zero) +- [shotgun](https://www.freesound.org/people/lensflare8642/sounds/145209/) (CC Zero) +- [bloody impact](https://www.freesound.org/people/Hybrid_V/sounds/319590/) (CC BY) +- [creepy warp sound](https://www.freesound.org/people/Andromadax24/sounds/184476/) (CC BY) +- [crowd screaming](https://www.freesound.org/people/MultiMax2121/sounds/156860/) (CC Zero) + +**ART:** +- For the ending, I modified [this photo of a laptop](https://unsplash.com/photos/XyNi3rUEReE). (CC Zero) diff --git a/UNCOPYRIGHT b/UNCOPYRIGHT new file mode 100644 index 0000000..827bfb5 --- /dev/null +++ b/UNCOPYRIGHT @@ -0,0 +1,5 @@ +You can copy, modify, distribute and perform this work, +even for commercial purposes, all without asking permission. + +Creative Commons Zero - Public Domain Dedication: +http://creativecommons.org/publicdomain/zero/1.0/ \ No newline at end of file diff --git a/css/Poppins-Medium.ttf b/css/Poppins-Medium.ttf new file mode 100755 index 0000000..07e5c5d Binary files /dev/null and b/css/Poppins-Medium.ttf differ diff --git a/css/game.css b/css/game.css new file mode 100644 index 0000000..b7852e1 --- /dev/null +++ b/css/game.css @@ -0,0 +1,59 @@ +@font-face { + font-family: 'Poppins'; + font-style: normal; + font-weight: 400; + src: url('Poppins-Medium.ttf') format('truetype'); +} + +html, body{ + width: 100%; + height: 100%; +} +body{ + font-family: 'Poppins'; + margin: 0; + background: #222; + position:relative; +} +#stage{ + background: #000; + width:960px; height:540px; + position:absolute; + margin:auto; + top:0; left:0; right:0; bottom:0; + cursor: none; +} +.overlay{ + + display: none; + + text-align: center; + color: #fff; + letter-spacing: 1px; + + width:500px; height:170px; + + position:absolute; + margin:auto; + top:0; left:0; right:0; bottom:0; + +} +.overlay > div:nth-child(1){ + font-size: 100px; + line-height: 100px; +} +.overlay > div:nth-child(2){ + font-size: 20px; +} +#modal_shade{ + display: none; + background: rgba(0,0,0,0.8); + width:960px; height:540px; + position:absolute; + margin:auto; + top:0; left:0; right:0; bottom:0; + cursor: pointer; +} +#paused{ + cursor: pointer; +} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..f2459d0 --- /dev/null +++ b/index.html @@ -0,0 +1,98 @@ + + + + + +
+ +
+
oh noes
+
+ your browser doesn't support webgl.
+ try a different browser or computer? +
+
+
+
paused
+
+ click anywhere to resume +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/js/core/Game.js b/js/core/Game.js new file mode 100644 index 0000000..9e75eac --- /dev/null +++ b/js/core/Game.js @@ -0,0 +1,177 @@ +/************************************** + +GAME CLASS SINGLETON: +Handles the DOM, load, init, update & render loops + +**************************************/ + +(function(exports){ + +// Singleton +var Game = {}; +exports.Game = Game; + +// PROPERTIES +Game.width = 960; +Game.height = 540; +Game.stats = true; + +// INIT +Game.init = function(HACK){ + + // Set up PIXI + Game.renderer = new PIXI.WebGLRenderer(Game.width, Game.height); + document.querySelector("#stage").appendChild(Game.renderer.view); + Game.stage = new PIXI.Container(); + Game.stage.interactive = true; + + // Mr Doob Stats + if(Game.stats){ + Game.stats = new Stats(); + Game.stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom + document.body.appendChild(Game.stats.dom); + } + + // Scene Manager + Game.scene = null; + Game.sceneManager = new SceneManager(); + + if(HACK){ + // NOT preloader - jump direct to a scene + Game.loadAssets(function(){ // well, also get preloader assets... + Game.loadAssets(function(){ + Game.sceneManager.gotoScene(HACK); + setInterval(Game.update,1000/60); + Game.animate(); + }, function(){}, false); + }, function(){}, true); + }else{ + // Preloader + Game.loadAssets(function(){ + Game.sceneManager.gotoScene("Preloader"); + setInterval(Game.update,1000/60); + Game.animate(); + }, function(){}, true); + } + +}; + +// UPDATE & ANIMATE + +Game.paused = false; + +Game.update = function(){ + if(Game.paused) return; + Tween.tick(); + Game.sceneManager.update(); +}; + +Game.animate = function(){ + if(Game.stats) Game.stats.begin(); + if(!Game.paused){ + Game.renderer.render(Game.stage); + } + if(Game.stats) Game.stats.end(); + requestAnimationFrame(Game.animate); +}; + +// GAME PAUSED? +// ON BLUR & PAUSE + +var modal_shade = document.getElementById("modal_shade"); +var paused = document.getElementById("paused"); +window.onblur = function(){ + if(Game.scene && Game.scene.UNPAUSEABLE) return; + modal_shade.style.display = "block"; + paused.style.display = "block"; + Game.paused = true; + Howler.mute(true); +} +modal_shade.onclick = paused.onclick = function(){ + modal_shade.style.display = "none"; + paused.style.display = "none"; + Game.paused = false; + Howler.mute(false); +}; + +// LOADING, and ADDING TO MANIFEST. +// TO DO: Progress, too + +Game.manifest = {}; +Game.manifest2 = {}; // FOR PRELOADER +Game.sounds = {}; + +Game.loadAssets = function(completeCallback, progressCallback, PRELOADER){ + + var manifest = PRELOADER ? Game.manifest2 : Game.manifest; + + // ABSOLUTE NUMBER OF ASSETS! + var _totalAssetsLoaded = 0; + var _totalAssetsToLoad = 0; + for(var key in manifest){ + var src = manifest[key]; + if(src.slice(-5)==".json"){ + // Is Sprite. Actually TWO assets. + _totalAssetsToLoad += 2; + }else{ + _totalAssetsToLoad += 1; + } + } + var _onAssetLoad = function(){ + _totalAssetsLoaded++; + progressCallback(_totalAssetsLoaded/_totalAssetsToLoad); // PROGRESS. + }; + + // META: Groups To Load – just images & sounds + var _groupsToLoad = PRELOADER ? 1 : 2; + var _onGroupLoaded = function(){ + _groupsToLoad--; + if(_groupsToLoad==0) completeCallback(); // DONE. + }; + + // Howler + var _soundsToLoad = 0; + var _onSoundLoad = function(){ + _soundsToLoad--; + _onAssetLoad(); + if(_soundsToLoad==0) _onGroupLoaded(); + }; + + // PIXI + var loader = PIXI.loader; + var resources = PIXI.loader.resources; + + for(var key in manifest){ + + var src = manifest[key]; + + // Is MP3. Leave it to Howler. + if(src.slice(-4)==".mp3"){ + var sound = new Howl({ src:[src] }); + _soundsToLoad++; + sound.once('load', _onSoundLoad); + Game.sounds[key] = sound; + continue; + } + + // Otherwise, is an image. Leave it to PIXI. + loader.add(key, src); + + } + + // PIXI + loader.on('progress',_onAssetLoad); + loader.once('complete', _onGroupLoaded); + loader.load(); + +}; + +// Add To Manifest +Game.addToManifest = function(keyValues, PRELOADER){ + var manifest = PRELOADER ? Game.manifest2 : Game.manifest; + for(var key in keyValues){ + manifest[key] = keyValues[key]; + } +}; + +})(window); \ No newline at end of file diff --git a/js/core/Scene.js b/js/core/Scene.js new file mode 100644 index 0000000..ad2e4e6 --- /dev/null +++ b/js/core/Scene.js @@ -0,0 +1,17 @@ +/************************************ + +SCENE BASE CLASS + +*************************************/ + +function Scene(){ + + var self = this; + + // TO IMPLEMENT + self.update = function(){}; + + // TO IMPLEMENT + self.kill = function(){}; + +} \ No newline at end of file diff --git a/js/core/SceneManager.js b/js/core/SceneManager.js new file mode 100644 index 0000000..97d8872 --- /dev/null +++ b/js/core/SceneManager.js @@ -0,0 +1,32 @@ +/************************************ + +SCENE MANAGER +Basically just swaps out scenes. + +*************************************/ + +function SceneManager(){ + + var self = this; + + self.gotoScene = function(sceneName){ + + // Old scene + Game.stage.removeChildren(); + var oldScene = Game.scene; + if(oldScene) oldScene.kill(); + + // New scene + var Scene_Class = window["Scene_"+sceneName]; + var newScene = new Scene_Class(); + Game.scene = newScene; + + }; + + self.update = function(){ + if(Game.scene){ + Game.scene.update(); + } + }; + +} \ No newline at end of file diff --git a/js/game/AnimationProp.js b/js/game/AnimationProp.js new file mode 100644 index 0000000..11088ce --- /dev/null +++ b/js/game/AnimationProp.js @@ -0,0 +1,69 @@ +/******** + +Just plays an animation. + +*********/ + +function AnimationProp(scene){ + + var self = this; + self._CLASS_ = "AnimationProp"; + + // Properties + self.scene = scene; + + // Not known yet! + self.mc = null; + self.x = -1; + self.y = -1; + self.width = -1; + self.height = -1; + + // Graphics + var g = new PIXI.Container(); + self.graphics = g; + + // DO IT. + self.DRAWING_SCALE = 0.65; + self.init = function(x, y, resourceName){ + + // Make it! + var mc = MakeMovieClip(resourceName); + mc.scale.x = mc.scale.y = self.DRAWING_SCALE; + g.addChild(mc); + + // Position & Dimensions + self.x = x; + self.y = y; + self.width = mc.width; + self.height = mc.height; + + // MOVIECLIP + self.mc = mc; + + // Update! + self.update(); + + }; + + // Update + // TO IMPLEMENT: YOUR OWN ANIMATION CODDE + self.update = function(){ + g.x = self.x; + g.y = self.y; + self.updateAnimation(); + }; + self.updateAnimation = function(){}; + + ///////////// + // THE END // + ///////////// + + // KILL ME + self.kill = function(){ + var world = self.scene.world; + world.props.splice(world.props.indexOf(self),1); + world.layers.props.removeChild(self.graphics); + }; + +} \ No newline at end of file diff --git a/js/game/Blood.js b/js/game/Blood.js new file mode 100644 index 0000000..84a832c --- /dev/null +++ b/js/game/Blood.js @@ -0,0 +1,64 @@ +Game.addToManifest({ + blood: "sprites/peeps/blood.json" +}); + +/************************************** + +Just expand to proper size. Then stop. + +**************************************/ + +function Blood(scene){ + + var self = this; + self._CLASS_ = "Blood"; + + // Graphics: Layers to this peep. + self.DRAWING_SCALE = 0.65; + var g = new PIXI.Container(); + self.graphics = g; + self.mc = MakeMovieClip("blood"); + self.mc.anchor.x = 0.5; + self.mc.anchor.y = 0.5; + self.mc.gotoAndStop(Math.floor(Math.random()*3)); + self.mc.scale.x = self.mc.scale.y = 0; + g.addChild(self.mc); + + // What scale to go to? + self.x = 0; + self.y = 0; + self.scale = 0; + self.gotoScale = 0; + self.init = function(options){ + self.x = options.x; + self.y = options.y; + self.gotoScale = options.scale; + }; + + // Update! + self.update = function(){ + + // DONE + if(self.DONE) return; + if(Math.abs(self.scale-self.gotoScale)<0.01) self.DONE=true; + + // Scaling... + self.scale = (self.scale*0.8) + (self.gotoScale*0.2); + + // Convert to Graphics! + g.x = self.x; + g.y = self.y; + self.mc.scale.x = self.mc.scale.y = self.scale; + + }; + + // KILL HALF THE *STILL* PARTICLES WHENEVER TV CUTS OUT. + // KILL ME + self.kill = function(){ + var world = self.scene.world; + world.bg.splice(world.bg.indexOf(self),1); + world.layers.bg.removeChild(self.graphics); + }; + + +} \ No newline at end of file diff --git a/js/game/Camera.js b/js/game/Camera.js new file mode 100644 index 0000000..26a60f3 --- /dev/null +++ b/js/game/Camera.js @@ -0,0 +1,248 @@ +/************************************** + +CAMERA: +The graphics & controls for this sucka + +**************************************/ + +Game.addToManifest({ + + cam_frame: "sprites/cam/cam.png", + cam_flash: "sprites/cam/cam-flash.png", + cam_instructions: "sprites/cam/cam-instructions.png", + + cam_snap: "sounds/cam_snap.mp3" + +}); + +Camera.WIDTH = Game.width/4; +Camera.HEIGHT = Game.height/4; + +function Camera(scene, options){ + + var self = this; + options = options || {}; + + // Properties + self.scene = scene; + self.x = Game.width/2; + self.y = Game.height/2; + self.width = Camera.WIDTH; + self.height = Camera.HEIGHT; + + + + //////////////////////////////// + ///// GRAPHICS ///////////////// + //////////////////////////////// + + // MAIN CONTAINER + self.graphics = new PIXI.Container(); + scene.graphics.addChild(self.graphics); + + // PHOTO + self.photo = new PIXI.Container(); + self.graphics.addChild(self.photo); + self.photoTexture = null; + + // FLASH, FRAME, INSTRUCTIONS + var resources = PIXI.loader.resources; + + self.flash = new PIXI.Sprite(resources.cam_flash.texture); + self.flash.scale.x = self.flash.scale.y = 0.5; + self.flash.anchor.x = self.flash.anchor.y = 0.5; + self.flash.alpha = 0; + self.graphics.addChild(self.flash); + + self.frame = new PIXI.Sprite(resources.cam_frame.texture); + self.frame.scale.x = self.frame.scale.y = 0.5; + self.frame.anchor.x = self.frame.anchor.y = 0.5; + self.graphics.addChild(self.frame); + + if(!options.noIntro){ + self.instructions = new PIXI.Sprite(resources.cam_instructions.texture); + self.instructions.scale.x = self.instructions.scale.y = 0.5; + self.instructions.anchor.x = 0.5; + self.instructions.anchor.y = 0; + self.instructions.y = 67.5; + self.graphics.addChild(self.instructions); + self.instructions.alpha = 0; + Tween_get(self.instructions) + .wait(_s(BEAT)) + .to({alpha:1}, _s(BEAT*0.5)); + } + + + //////////////////////////////// + ///// CONTROLS ///////////////// + //////////////////////////////// + + // Controls! + self.frozen = false; + Game.stage.mousemove = function(mouseData){ + var pos = mouseData.data.global; + self.x = pos.x; + self.y = pos.y; + }; + Game.stage.mousedown = function(mouseData){ + + // ONLY ONCE. FREEZE. + if(self.frozen) return; + if(!options.streaming){ + self.frozen = true; + } + + // Take Texture + self.takePhoto(); + + // Tell the director + if(!options.streaming){ + scene.director.takePhoto(self); + } + + // SOUND! + if(self.noSounds) return; + Game.sounds.cam_snap.play(); + + }; + Game.stage.mouseup = function(mouseData){}; // nothing at all + + + + ///////////////////////////////////// + ///// PHOTO - TAKE, HIDE, RESET ///// + ///////////////////////////////////// + + // Take Photo! + self.takePhoto = function(){ + + if(!options.streaming){ + + // Just update that... + self.updatePosition(); + + // Save the texture + self.photoTexture = self.getTexture(); + + // Make it part of my graphics + var photo = new PIXI.Sprite(self.photoTexture); + photo.anchor.x = photo.anchor.y = 0.5; + self.photo.removeChildren(); + self.photo.addChild(photo); + + } + + // Flash! + self.flash.alpha = 1; + Tween_get(self.flash).to({alpha:0}, _s(0.25)); + + // Fade out instructions... + if(!options.noIntro){ + var instr = self.instructions; + if(instr.alpha>0){ + Tween_get(instr).to({alpha:0}, _s(BEAT*0.25)); + } + } + + // Callback? + if(options.onTakePhoto){ + options.onTakePhoto(); + } + + }; + + // Get texture! + var renderTexturePoolIndex = 0; + var renderTexturePool = [ + new PIXI.RenderTexture(Game.renderer, self.width, self.height), + new PIXI.RenderTexture(Game.renderer, self.width, self.height) + ]; + self.getTexture = function(){ + + // TAKE THE TEXTURE! + var sw = self.width; + var sh = self.height; + var sx = self.x-sw/2; + var sy = self.y-sh/2; + + var matrix = new PIXI.Matrix(); + matrix.translate(-scene.graphics.x, -scene.graphics.y); + matrix.scale(1/scene.graphics.scale.x, 1/scene.graphics.scale.y); + matrix.translate(-sx,-sy); + + var renderTexture = renderTexturePool[renderTexturePoolIndex]; + renderTexture.render(scene.world.graphics, matrix); // TO DO: higher rez + renderTexturePoolIndex = (renderTexturePoolIndex+1)%renderTexturePool.length; + + // Return texture! + return renderTexture; + + }; + + // Hide Camera + self.hide = function(){ + self.graphics.visible = false; + self.photo.removeChildren(); + }; + + // Reset Camera + self.reset = function(){ + var g = self.graphics; + g.scale.x = g.scale.y = 1; + g.visible = true; + self.frozen = false; + self.updatePosition(); + }; + + + + + ////////////////////////// + ///// UPDATE ///////////// + ////////////////////////// + + // Update + self.updatePosition = function(){ + + // Constraints + if(self.xGame.width-self.width/2) self.x=Game.width-self.width/2; + if(self.yGame.height-self.height/2) self.y=Game.height-self.height/2; + + // Container moves! + self.graphics.x = self.x; + self.graphics.y = self.y; + + }; + self.update = function(){ + if(!self.frozen) self.updatePosition(); + }; + + // And that's all she wrote. + self.update(); + + + + + ////////////////////////// + ///// MISC CRAP ////////// + ////////////////////////// + + self.isOverTV = function(smaller){ + var x = self.x; + var y = self.y; + var cx = Game.width/2; + var cy = Game.height/2; + var w = smaller ? 140 : self.width; + var h = smaller ? 90 : self.height; + var l = cx - w/2; + var r = cx + w/2; + var t = cy - h/2; + var b = cy + h/2; + return (l=0){ + self.z=0; + self.vx *= 0.8; + self.vr *= 0.8; + if(Math.abs(self.vz)>1){ + + // BLOOD FOR THE BLOOD GOD + var blood = new Blood(scene); + blood.init({ + x: self.x, + y: self.y, + scale: 0.5 + Math.abs(self.vz)*0.1 + }); + scene.world.addBG(blood); + + // Bounce + self.vz *= -0.3; + + }else{ + self.vz = 0; + } + } + + // Rotation: HOW MUCH OFF THE GROUND? + // 0 -> 0, -50 -> TAU/4 + self.rotation = (Math.abs(self.z)/50)*(Math.TAU/4); + if(self.rotation>Math.TAU*0.2){ + self.rotation = Math.TAU*0.2; + } + + // Convert to Graphics! + g.x = self.x; + g.y = self.y + self.z; + self.mc.rotation = self.rotation; + g.scale.x = (self.flip>0) ? 1 : -1; + + }; + + // KILL ME + self.kill = function(){ + var world = self.scene.world; + world.props.splice(world.props.indexOf(self),1); + world.layers.props.removeChild(self.graphics); + }; + + +} \ No newline at end of file diff --git a/js/game/Director.js b/js/game/Director.js new file mode 100644 index 0000000..72c907e --- /dev/null +++ b/js/game/Director.js @@ -0,0 +1,505 @@ +/************************************** + +THE DIRECTOR: SINGLETON + +When you click to take a photo, the Director... +- gets what's inside the camera's bounds +- makes the camera take the texture shot +- controls the movement of the camera & viewport +- decides what the chyron should say +- decides which TV to put it in +- decides what other events should happen around the world + +**************************************/ + +Game.addToManifest({ + crickets: "sounds/crickets.mp3", + breaking_news: "sounds/breaking_news.mp3" +}); + +function Director(scene){ + + var self = this; + + // Scene + self.scene = scene; + + // Stages + self.callbacks = {}; + self.callback = function(callbackName){ + var cb = self.callbacks[callbackName]; + if(cb) cb(self); + }; + + // TAKE PHOTO + self.photoData = null; + self.photoTexture = null; + self.isWatchingTV = false; + self.takePhoto = function(camera){ + + // Get a photo texture at Camera's position + self.photoTexture = camera.photoTexture; + + // Which tv... + self.tv = scene.tv; + + // Animation! + Tween_get(self).wait(_s(0.25)) // flash + .call(_anim.movePhoto).wait(_s(BEAT)) // tween takes 1 sec + .call(_anim.cutToTV).wait(_s(BEAT*1.5)) // stay on TV for 1.5 secs + .call(_anim.zoomOut1).wait(_s(BEAT*2)) // tween takes 2 secs + .wait(_s(BEAT*1.5)) // see viewers (or lack thereof) for 1.5 sec + .call(_anim.zoomOut2).wait(_s(BEAT*2)) // tween takes 2 secs + .call(_anim.reset); + + // CALLBACK + self.chyron = "[NO CHYRON]"; + self.photoData = {}; + self.photoData.audience = 0; + self.callback("takePhoto"); + + }; + + // ANIM CONSTANTS + Director.ZOOM_OUT_1_TIME = 2; + Director.SEE_VIEWERS_TIME = 1.5 + 0.5; // hack. + Director.ZOOM_OUT_2_TIME = 2; + + + + ///////////////////////////////// + ///// AUDIENCE & TV HELPERS ///// + ///////////////////////////////// + + self.audience_movePhoto = function(){ + var data = self.photoData; + if(self.noSounds) return; + if(data.audience>0 || data.audienceCircles>0 || data.audienceSquares>0){ + Game.sounds.breaking_news.play(); + } + if(data.forceChyron){ + Game.sounds.breaking_news.play(); + } + }; + + self.audience_cutToTV = function(doSomethingElse, filterAudience){ + + // AUDIENCE? + var data = self.photoData; + var circlesLeft = data.audience; + var squaresLeft = data.audience; + if(data.HIJACK){ + circlesLeft = data.audienceCircles; + squaresLeft = data.audienceSquares; + data.audience = data.audienceCircles+data.audienceSquares; + }else{ + data.audienceCircles = data.audience; + data.audienceSquares = data.audience; + } + var peeps = self.scene.world.peeps.slice(0); // clone + + // GET OUT THE WAY (AGAIN) + for(var i=0;i0){ + + // Who to watch TV, now? + if(filterAudience) peeps=peeps.filter(filterAudience); // filter + peeps.sort(function(){ return Math.random()<0.5; }); // shuffle + for(var i=0;i0){ + flip = 1; + offset = 60 + (data.audienceCircles-circlesLeft)*40; + watchTV = true; + circlesLeft--; + } + if(p.type=="square" && squaresLeft>0){ + flip = -1; + offset = 60 + (data.audienceSquares-squaresLeft)*40; + watchTV = true; + squaresLeft--; + } + + // Watch the TV? Otherwise move, get out the way. + if(watchTV){ + p.x = self.tv.x; + p.x -= flip*offset; + p.y = self.tv.y+Math.random(); // tiny offset to avoid glitchy depth-sort + if(doSomethingElse){ + doSomethingElse(p); + }else{ + p.watchTV(); + } + } + + } + + } + + // Did anyone watch? + return (data.audience>0); + + }; + + + + + //////////////////////////////// + ///// CAM BOUNDS /////////////// + //////////////////////////////// + + // EVEN BETTER DECLARATIVE HELPER + self.tryChyron = function(catchemFunc){ + + // Did it catch 'em? + var caught = catchemFunc(self); + + // "otherwise" chaining + // if caught something, DO NO MORE. else, keep trying! + if(caught){ + var blankChain = { + otherwise: function(){ return blankChain; } + }; + return blankChain; + }else{ + return { + otherwise: self.tryChyron + }; + } + + }; + self.tryCut2TV = self.tryChyron; // SAME DAMN THING. + + // Declarative Helper or whatever + // LIKE THIS: + /******* + var caught = d.caught({ + peeps: {_CLASS_:"NormalPeep"}, + shocked: {_CLASS_:"NormalPeep", shocked:true} + crazy: {_CLASS_:"CrazyPeep"}, + tv: {_CLASS_:"TV"} + }); + *******/ + self.caught = function(catchem){ + + var caught = {}; + + for(var selector in catchem){ + + var properties = catchem[selector]; + var returnAll = properties["returnAll"]; + + var caughtProps = self.getPropsInCamera(function(prop){ + + // It fits all the properties... + var isSelected = true; + for(var key in properties){ + + // Forget this one + if(key=="returnAll") continue; + + // Test all keys + var value = properties[key]; + if(prop[key]!=value){ + isSelected = false; + } + + } + return isSelected; + + }); + + caught[selector] = returnAll ? caughtProps : caughtProps[0]; // return all or one? + + } + + return caught; + + }; + + // Get everything that's at least 33% inside the camera frame + self.getPropsInCamera = function(filterFunc){ + + // Those caught in the camera + var caught = []; + + // cam top-left-right-bottom + var cam = scene.camera; + var cl = cam.x-cam.width/2; + var cr = cam.x+cam.width/2; + var ct = cam.y-cam.height/2; + var cb = cam.y+cam.height/2; + + for(var i=0;icr) continue; + if(pbcb) continue; + + // overlapping a little bit... but how much? + var l = Math.max(cl,pl); + var t = Math.max(ct,pt); + var r = Math.min(cr,pr); + var b = Math.min(cb,pb); + var overlapArea = (r-l)*(b-t); + var overlapRatio = overlapArea/totalArea; + + // If 33% or more, yes! + if(overlapRatio>0.33){ + caught.push(prop); + } + + } + + // Filter?... + if(filterFunc){ + caught = caught.filter(filterFunc); + } + + return caught; + + }; + + + + + //////////////////////////////// + ///// ANIMATION //////////////// + //////////////////////////////// + + var _anim = {}; + _anim.movePhoto = function(){ + + var cam = scene.camera; + + // Pan: Center + Tween_get(cam.graphics) + .to({ x:Game.width/2, y:Game.height/2 }, _s(BEAT), Ease.circInOut); + + // Scale: fullscreen + var scale = Game.width/cam.width; + Tween_get(cam.graphics.scale) + .to({ x:scale, y:scale }, _s(BEAT), Ease.circInOut); + + // CALLBACK + self.callback("movePhoto"); + + }; + _anim.cutToTV = function(){ + + // YUP, WATCHING TV. + self.isWatchingTV = true; + + // Hide Camera + scene.camera.hide(); + + // SOUND? + var data = self.photoData; + var fail = false; + var nothing = data.ITS_NOTHING; + if(!data.forceChyron){ + if(data.audience==0 && !data.audienceCircles && !data.audienceSquares){ + + Game.sounds.crickets.play(); + fail = true; + + // SHOW CRICKET + var cricket = new Cricket(scene); + cricket.watchTV(); + scene.world.addProp(cricket); + + // OR... MULTIPLE CRICKETS! + if(data.CAUGHT_A_CRICKET){ + + var cricket = new Cricket(scene); + cricket.watchTV(); + cricket.x += 30; + cricket.hopAwayTimeout += 15; + scene.world.addProp(cricket); + + var cricket = new Cricket(scene); + cricket.watchTV(); + cricket.x += 60; + cricket.hopAwayTimeout += 30; + scene.world.addProp(cricket); + + } + + } + } + + // Add photo texture to the TV + var text = self.chyron; + var tv = self.tv; + tv.placePhoto({ + photo: self.photoTexture, + text: text, + fail: fail, + nothing: nothing + }); + + // Where to cut viewport to + self.cutViewportTo({ + x: tv.x + tv.offset.x, + y: tv.y + tv.offset.y, + scale: tv.offset.scale + }); + + // GET OUT THE WAY + var peeps = self.scene.world.peeps.slice(0); + for(var i=0;i=0){ + self.z=0; + self.vx *= 0.8; + self.vy *= 0.8; + self.vr *= 0.8; + if(Math.abs(self.vz)>1){ + + // BLOOD FOR THE BLOOD GOD + var blood = new Blood(scene); + blood.init({ + x: self.x, + y: self.y, + scale: Math.abs(self.vz)*0.02 + }); + scene.world.addBG(blood); + + // Bounce + self.vz *= -0.2; + + }else{ + self.vz = 0; + } + } + + // Convert to Graphics! + g.x = self.x; + g.y = self.y + self.z; + g.rotation = self.rotation; + + }; + + // KILL ME + self.kill = function(){ + var world = self.scene.world; + world.props.splice(world.props.indexOf(self),1); + world.layers.props.removeChild(self.graphics); + }; + + +} \ No newline at end of file diff --git a/js/game/Peep.js b/js/game/Peep.js new file mode 100644 index 0000000..a92426e --- /dev/null +++ b/js/game/Peep.js @@ -0,0 +1,315 @@ +/************************************** + +PEEP: +Walks around. + +**************************************/ + +function Peep(scene){ + + var self = this; + self._CLASS_ = "Peep"; + + // Properties + self.scene = scene; + self.x = Math.random()*Game.width; + self.y = Math.random()*Game.height; + self.DRAWING_SCALE = 0.65; + self.width = 80*self.DRAWING_SCALE; + self.height = 120*self.DRAWING_SCALE; + + // Callbacks + self.callbacks = {}; + self.callback = function(callbackName){ + var cb = self.callbacks[callbackName]; + if(cb) cb(self); + }; + + // Graphics: Layers to this peep. + var g = new PIXI.Container(); + self.graphics = g; + + // Hop! And bounce INDEPENDENT of anim. Bouncy math! + + self.hop = Math.random(); + self._lastHop = self.hop; + + self.speed = 1 + Math.random()*0.5; + self.direction = Math.random()*Math.PI*2; + self.vel = {x:0,y:0}; + self.flip = 1; + + self.isWalking = true; + self.loop = true; + + self.bounce = 1; + self.bounceVel = 0; + self.bounceAcc = 0.2; + self.bounceDamp = 0.6; + + self.goThroughSpots = false; + //self.allowToStay = false; + + self.update = function(){ + + ///////////// + // WALKING // + ///////////// + + // Walk velocity + var vx, vy; + if(self.isWalking){ + var vx = Math.cos(self.direction)*self.speed; + var vy = Math.sin(self.direction)*self.speed; + }else{ + vx = vy = 0; // stand still + } + + // Move it + self.vel.x = self.vel.x*0.9 + vx*0.1; + self.vel.y = self.vel.y*0.9 + vy*0.1; + self.x += self.vel.x; + self.y += self.vel.y; + + // Borders + if(self.loop){ + var margin = 50; + if(self.x<-margin) self.x=Game.width+margin; + if(self.x>Game.width+margin) self.x=-margin; + if(self.y<0) self.y=Game.height+margin*2; + if(self.y>Game.height+margin*2) self.y=0; + } + + //////////////////// + // AVOIDING SPOTS // + //////////////////// + + if(scene.avoidSpots && !self.goThroughSpots){ + var avoid = scene.avoidSpots; + avoid.forEach(function(spot){ + + var dx = spot.x-self.x; + var dy = spot.y-self.y; + + if(dx*dx+dy*dy < spot.radius*spot.radius){ + self.direction = Math.atan2(dy,dx)+Math.PI; // insta-walk AWAY. + } + + }); + } + + /*if(scene.director.isWatchingTV && !self.allowToStay){ + // TV Rect Bounds + var gx = Game.width/2; + var gy = Game.height/2; + var cw = (440)/2; + var ch = (220)/2; + var rect = { + l:gx-cw, r:gx+cw, + t:gy-ch, b:gy+ch+80 + }; + if(self.x>rect.l && self.xrect.t && self.ygx) self.x=rect.r; + if(self.ygy) self.y=rect.b; + } + }*/ + + ///////////////////// + // ANIMATION QUEUE // + ///////////////////// + + if(!(self.pauseAnimsWhenNotWatching && self.scene.director.isWatchingTV)){ // HACK + for(var i=0;i1) self.hop--; + self.flip = (self.vel.x<0) ? -1 : 1; + + // Sway back & forth + var t = self.hop*Math.PI*2; + g.rotation = Math.sin(t)*0.1; + g.pivot.y = Math.abs(Math.sin(t))*10; + + // Squash at the bottom of your cycle + if(self._lastHop<0.5 && self.hop>=0.5) self.bounce = 1.2; + if(self._lastHop>0.9 && self.hop<=0.1) self.bounce = 1.2; + + }; + + // Can be overridden + self.standAnim = function(){ + g.rotation = 0; + g.pivot.y = 0; + }; + + + //////////////////// + // ACTION HELPERS // + //////////////////// + + self.touchingPeeps = function(radius, filterFunc, oneSided){ + + // Close to + var touching = []; + var peeps = scene.world.peeps; + for(var i=0;i0 && other.x>self.x) touching.push(other); + if(self.flip<0 && other.xrect.r && self.vel.x>0) self.direction += turn; + if(self.yrect.b && self.vel.y>0) self.direction += turn; + }; + + /*self.stayOutsideRect = function(rect, turn){ + if(self.x>rect.l && self.vel.x>0) self.direction += turn; + if(self.xrect.t && self.vel.y>0) self.direction += turn; + if(self.ymax){ // more than [max] chars... + fontsize = Math.floor(max*fontsize/text.length); + } + var text = new PIXI.Text(text, {font:"bold "+fontsize+"px Poppins", fill:"#FFF"}); + text.scale.x = text.scale.y = 0.2; + text.anchor.x = 0; + text.anchor.y = 0.5; + text.x = 45; + text.y = 115; + chyron.addChild(text); + } + + } + + // Update! + self.update(); + +} \ No newline at end of file diff --git a/js/game/World.js b/js/game/World.js new file mode 100644 index 0000000..efc1d0b --- /dev/null +++ b/js/game/World.js @@ -0,0 +1,137 @@ +Game.addToManifest({ + bg: "sprites/bg.png", + bg_dark: "sprites/bg_dark.png" +}); + +/************************************** + +WORLD: +Layers for the background, the people, objects, particles, etc + +**************************************/ + +function World(scene, options){ + + var self = this; + options = options || {}; + + // Properties + self.scene = scene; + + // PIXI GRAPHICS + var g = new PIXI.Container(); + self.graphics = g; + g.x = g.pivot.x = Game.width/2; + g.y = g.pivot.y = Game.height/2; + scene.graphics.addChild(self.graphics); + self.layers = {}; + + // LAYER: BG + self.layers.bg = new PIXI.Container(); + g.addChild(self.layers.bg); + var bg = MakeSprite(options.bg ? options.bg : "bg"); + bg.position.x = -100; + bg.position.y = -100; + self.layers.bg.addChild(bg); + self.bg = []; + self.addBG = function(bg){ + self.bg.push(bg); + self.layers.bg.addChild(bg.graphics); + }; + + // LAYER: PROPS + self.layers.props = new PIXI.Container(); + g.addChild(self.layers.props); + self.props = []; + self.addProp = function(prop){ + prop.graphics._REFERENCE_ = prop; // HACK. REFERENCE. + self.props.push(prop); + self.layers.props.addChild(prop.graphics); + }; + + // SUB-LAYER: PEEPS + self.peeps = []; + self.addPeep = function(peep){ + self.peeps.push(peep); + self.addProp(peep); + }; + self.clearPeeps = function(){ + while(self.peeps.length>0){ + self.peeps[0].kill(); + } + }; + self.addBalancedPeeps = function(howMany){ + + // Count circles & squares... + var circleCount = 0; + var squareCount = 0; + for(var i=0;i= 0 && vol <= 1) { + self._volume = vol; + + // Don't update any of the nodes if we are muted. + if (self._muted) { + return self; + } + + // When using Web Audio, we just need to adjust the master gain. + if (self.usingWebAudio) { + self.masterGain.gain.value = vol; + } + + // Loop through and change volume for all HTML5 audio nodes. + for (var i=0; i=0; i--) { + self._howls[i].unload(); + } + + // Create a new AudioContext to make sure it is fully reset. + if (self.usingWebAudio && typeof self.ctx.close !== 'undefined') { + self.ctx.close(); + self.ctx = null; + setupAudioContext(); + } + + return self; + }, + + /** + * Check for codec support of specific extension. + * @param {String} ext Audio file extention. + * @return {Boolean} + */ + codecs: function(ext) { + return (this || Howler)._codecs[ext]; + }, + + /** + * Setup various state values for global tracking. + * @return {Howler} + */ + _setup: function() { + var self = this || Howler; + + // Keeps track of the suspend/resume state of the AudioContext. + self.state = self.ctx ? self.ctx.state || 'running' : 'running'; + + // Automatically begin the 30-second suspend process + self._autoSuspend(); + + // Check for supported codecs. + if (!self.noAudio) { + self._setupCodecs(); + } + + return self; + }, + + /** + * Check for browser support for various codecs and cache the results. + * @return {Howler} + */ + _setupCodecs: function() { + var self = this || Howler; + var audioTest = (typeof Audio !== 'undefined') ? new Audio() : null; + + if (!audioTest || typeof audioTest.canPlayType !== 'function') { + return self; + } + + var mpegTest = audioTest.canPlayType('audio/mpeg;').replace(/^no$/, ''); + + // Opera version <33 has mixed MP3 support, so we need to check for and block it. + var checkOpera = self._navigator && self._navigator.userAgent.match(/OPR\/([0-6].)/g); + var isOldOpera = (checkOpera && parseInt(checkOpera[0].split('/')[1], 10) < 33); + + self._codecs = { + mp3: !!(!isOldOpera && (mpegTest || audioTest.canPlayType('audio/mp3;').replace(/^no$/, ''))), + mpeg: !!mpegTest, + opus: !!audioTest.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, ''), + ogg: !!audioTest.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ''), + oga: !!audioTest.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ''), + wav: !!audioTest.canPlayType('audio/wav; codecs="1"').replace(/^no$/, ''), + aac: !!audioTest.canPlayType('audio/aac;').replace(/^no$/, ''), + caf: !!audioTest.canPlayType('audio/x-caf;').replace(/^no$/, ''), + m4a: !!(audioTest.canPlayType('audio/x-m4a;') || audioTest.canPlayType('audio/m4a;') || audioTest.canPlayType('audio/aac;')).replace(/^no$/, ''), + mp4: !!(audioTest.canPlayType('audio/x-mp4;') || audioTest.canPlayType('audio/mp4;') || audioTest.canPlayType('audio/aac;')).replace(/^no$/, ''), + weba: !!audioTest.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, ''), + webm: !!audioTest.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, ''), + dolby: !!audioTest.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/, '') + }; + + return self; + }, + + /** + * Mobile browsers will only allow audio to be played after a user interaction. + * Attempt to automatically unlock audio on the first user interaction. + * Concept from: http://paulbakaus.com/tutorials/html5/web-audio-on-ios/ + * @return {Howler} + */ + _enableMobileAudio: function() { + var self = this || Howler; + + // Only run this on mobile devices if audio isn't already eanbled. + var isMobile = /iPhone|iPad|iPod|Android|BlackBerry|BB10|Silk|Mobi/i.test(self._navigator && self._navigator.userAgent); + var isTouch = !!(('ontouchend' in window) || (self._navigator && self._navigator.maxTouchPoints > 0) || (self._navigator && self._navigator.msMaxTouchPoints > 0)); + if (self._mobileEnabled || !self.ctx || (!isMobile && !isTouch)) { + return; + } + + self._mobileEnabled = false; + + // Some mobile devices/platforms have distortion issues when opening/closing tabs and/or web views. + // Bugs in the browser (especially Mobile Safari) can cause the sampleRate to change from 44100 to 48000. + // By calling Howler.unload(), we create a new AudioContext with the correct sampleRate. + if (!self._mobileUnloaded && self.ctx.sampleRate !== 44100) { + self._mobileUnloaded = true; + self.unload(); + } + + // Scratch buffer for enabling iOS to dispose of web audio buffers correctly, as per: + // http://stackoverflow.com/questions/24119684 + self._scratchBuffer = self.ctx.createBuffer(1, 1, 22050); + + // Call this method on touch start to create and play a buffer, + // then check if the audio actually played to determine if + // audio has now been unlocked on iOS, Android, etc. + var unlock = function() { + // Create an empty buffer. + var source = self.ctx.createBufferSource(); + source.buffer = self._scratchBuffer; + source.connect(self.ctx.destination); + + // Play the empty buffer. + if (typeof source.start === 'undefined') { + source.noteOn(0); + } else { + source.start(0); + } + + // Setup a timeout to check that we are unlocked on the next event loop. + source.onended = function() { + source.disconnect(0); + + // Update the unlocked state and prevent this check from happening again. + self._mobileEnabled = true; + self.mobileAutoEnable = false; + + // Remove the touch start listener. + document.removeEventListener('touchend', unlock, true); + }; + }; + + // Setup a touch start listener to attempt an unlock in. + document.addEventListener('touchend', unlock, true); + + return self; + }, + + /** + * Automatically suspend the Web Audio AudioContext after no sound has played for 30 seconds. + * This saves processing/energy and fixes various browser-specific bugs with audio getting stuck. + * @return {Howler} + */ + _autoSuspend: function() { + var self = this; + + if (!self.autoSuspend || !self.ctx || typeof self.ctx.suspend === 'undefined' || !Howler.usingWebAudio) { + return; + } + + // Check if any sounds are playing. + for (var i=0; i 0 ? sound._seek : self._sprite[sprite][0] / 1000; + var duration = ((self._sprite[sprite][0] + self._sprite[sprite][1]) / 1000) - seek; + var timeout = (duration * 1000) / Math.abs(sound._rate); + + // Update the parameters of the sound + sound._paused = false; + sound._ended = false; + sound._sprite = sprite; + sound._seek = seek; + sound._start = self._sprite[sprite][0] / 1000; + sound._stop = (self._sprite[sprite][0] + self._sprite[sprite][1]) / 1000; + sound._loop = !!(sound._loop || self._sprite[sprite][2]); + + // Begin the actual playback. + var node = sound._node; + if (self._webAudio) { + // Fire this when the sound is ready to play to begin Web Audio playback. + var playWebAudio = function() { + self._refreshBuffer(sound); + + // Setup the playback params. + var vol = (sound._muted || self._muted) ? 0 : sound._volume; + node.gain.setValueAtTime(vol, Howler.ctx.currentTime); + sound._playStart = Howler.ctx.currentTime; + + // Play the sound using the supported method. + if (typeof node.bufferSource.start === 'undefined') { + sound._loop ? node.bufferSource.noteGrainOn(0, seek, 86400) : node.bufferSource.noteGrainOn(0, seek, duration); + } else { + sound._loop ? node.bufferSource.start(0, seek, 86400) : node.bufferSource.start(0, seek, duration); + } + + // Start a new timer if none is present. + if (timeout !== Infinity) { + self._endTimers[sound._id] = setTimeout(self._ended.bind(self, sound), timeout); + } + + if (!internal) { + setTimeout(function() { + self._emit('play', sound._id); + }, 0); + } + }; + + if (self._state === 'loaded') { + playWebAudio(); + } else { + // Wait for the audio to load and then begin playback. + self.once('load', playWebAudio, sound._id); + + // Cancel the end timer. + self._clearTimer(sound._id); + } + } else { + // Fire this when the sound is ready to play to begin HTML5 Audio playback. + var playHtml5 = function() { + node.currentTime = seek; + node.muted = sound._muted || self._muted || Howler._muted || node.muted; + node.volume = sound._volume * Howler.volume(); + node.playbackRate = sound._rate; + + setTimeout(function() { + node.play(); + + // Setup the new end timer. + if (timeout !== Infinity) { + self._endTimers[sound._id] = setTimeout(self._ended.bind(self, sound), timeout); + } + + if (!internal) { + self._emit('play', sound._id); + } + }, 0); + }; + + // Play immediately if ready, or wait for the 'canplaythrough'e vent. + var loadedNoReadyState = (self._state === 'loaded' && (window && window.ejecta || !node.readyState && Howler._navigator.isCocoonJS)); + if (node.readyState === 4 || loadedNoReadyState) { + playHtml5(); + } else { + var listener = function() { + // Begin playback. + playHtml5(); + + // Clear this listener. + node.removeEventListener(Howler._canPlayEvent, listener, false); + }; + node.addEventListener(Howler._canPlayEvent, listener, false); + + // Cancel the end timer. + self._clearTimer(sound._id); + } + } + + return sound._id; + }, + + /** + * Pause playback and save current position. + * @param {Number} id The sound ID (empty to pause all in group). + * @return {Howl} + */ + pause: function(id) { + var self = this; + + // If the sound hasn't loaded, add it to the load queue to pause when capable. + if (self._state !== 'loaded') { + self._queue.push({ + event: 'pause', + action: function() { + self.pause(id); + } + }); + + return self; + } + + // If no id is passed, get all ID's to be paused. + var ids = self._getSoundIds(id); + + for (var i=0; i Returns the group's volume value. + * volume(id) -> Returns the sound id's current volume. + * volume(vol) -> Sets the volume of all sounds in this Howl group. + * volume(vol, id) -> Sets the volume of passed sound id. + * @return {Howl/Number} Returns self or current volume. + */ + volume: function() { + var self = this; + var args = arguments; + var vol, id; + + // Determine the values based on arguments. + if (args.length === 0) { + // Return the value of the groups' volume. + return self._volume; + } else if (args.length === 1) { + // First check if this is an ID, and if not, assume it is a new volume. + var ids = self._getSoundIds(); + var index = ids.indexOf(args[0]); + if (index >= 0) { + id = parseInt(args[0], 10); + } else { + vol = parseFloat(args[0]); + } + } else if (args.length >= 2) { + vol = parseFloat(args[0]); + id = parseInt(args[1], 10); + } + + // Update the volume or return the current volume. + var sound; + if (typeof vol !== 'undefined' && vol >= 0 && vol <= 1) { + // If the sound hasn't loaded, add it to the load queue to change volume when capable. + if (self._state !== 'loaded') { + self._queue.push({ + event: 'volume', + action: function() { + self.volume.apply(self, args); + } + }); + + return self; + } + + // Set the group volume. + if (typeof id === 'undefined') { + self._volume = vol; + } + + // Update one or all volumes. + id = self._getSoundIds(id); + for (var i=0; i to ? 'out' : 'in'; + var steps = diff / 0.01; + var stepLen = len / steps; + + // If the sound hasn't loaded, add it to the load queue to fade when capable. + if (self._state !== 'loaded') { + self._queue.push({ + event: 'fade', + action: function() { + self.fade(from, to, len, id); + } + }); + + return self; + } + + // Set the volume to the start position. + self.volume(from, id); + + // Fade the volume of one or all sounds. + var ids = self._getSoundIds(id); + for (var i=0; i Returns the group's loop value. + * loop(id) -> Returns the sound id's loop value. + * loop(loop) -> Sets the loop value for all sounds in this Howl group. + * loop(loop, id) -> Sets the loop value of passed sound id. + * @return {Howl/Boolean} Returns self or current loop value. + */ + loop: function() { + var self = this; + var args = arguments; + var loop, id, sound; + + // Determine the values for loop and id. + if (args.length === 0) { + // Return the grou's loop value. + return self._loop; + } else if (args.length === 1) { + if (typeof args[0] === 'boolean') { + loop = args[0]; + self._loop = loop; + } else { + // Return this sound's loop value. + sound = self._soundById(parseInt(args[0], 10)); + return sound ? sound._loop : false; + } + } else if (args.length === 2) { + loop = args[0]; + id = parseInt(args[1], 10); + } + + // If no id is passed, get all ID's to be looped. + var ids = self._getSoundIds(id); + for (var i=0; i Returns the first sound node's current playback rate. + * rate(id) -> Returns the sound id's current playback rate. + * rate(rate) -> Sets the playback rate of all sounds in this Howl group. + * rate(rate, id) -> Sets the playback rate of passed sound id. + * @return {Howl/Number} Returns self or the current playback rate. + */ + rate: function() { + var self = this; + var args = arguments; + var rate, id; + + // Determine the values based on arguments. + if (args.length === 0) { + // We will simply return the current rate of the first node. + id = self._sounds[0]._id; + } else if (args.length === 1) { + // First check if this is an ID, and if not, assume it is a new rate value. + var ids = self._getSoundIds(); + var index = ids.indexOf(args[0]); + if (index >= 0) { + id = parseInt(args[0], 10); + } else { + rate = parseFloat(args[0]); + } + } else if (args.length === 2) { + rate = parseFloat(args[0]); + id = parseInt(args[1], 10); + } + + // Update the playback rate or return the current value. + var sound; + if (typeof rate === 'number') { + // If the sound hasn't loaded, add it to the load queue to change playback rate when capable. + if (self._state !== 'loaded') { + self._queue.push({ + event: 'rate', + action: function() { + self.rate.apply(self, args); + } + }); + + return self; + } + + // Set the group rate. + if (typeof id === 'undefined') { + self._rate = rate; + } + + // Update one or all volumes. + id = self._getSoundIds(id); + for (var i=0; i Returns the first sound node's current seek position. + * seek(id) -> Returns the sound id's current seek position. + * seek(seek) -> Sets the seek position of the first sound node. + * seek(seek, id) -> Sets the seek position of passed sound id. + * @return {Howl/Number} Returns self or the current seek position. + */ + seek: function() { + var self = this; + var args = arguments; + var seek, id; + + // Determine the values based on arguments. + if (args.length === 0) { + // We will simply return the current position of the first node. + id = self._sounds[0]._id; + } else if (args.length === 1) { + // First check if this is an ID, and if not, assume it is a new seek position. + var ids = self._getSoundIds(); + var index = ids.indexOf(args[0]); + if (index >= 0) { + id = parseInt(args[0], 10); + } else { + id = self._sounds[0]._id; + seek = parseFloat(args[0]); + } + } else if (args.length === 2) { + seek = parseFloat(args[0]); + id = parseInt(args[1], 10); + } + + // If there is no ID, bail out. + if (typeof id === 'undefined') { + return self; + } + + // If the sound hasn't loaded, add it to the load queue to seek when capable. + if (self._state !== 'loaded') { + self._queue.push({ + event: 'seek', + action: function() { + self.seek.apply(self, args); + } + }); + + return self; + } + + // Get the sound. + var sound = self._soundById(id); + + if (sound) { + if (typeof seek === 'number' && seek >= 0) { + // Pause the sound and update position for restarting playback. + var playing = self.playing(id); + if (playing) { + self.pause(id, true); + } + + // Move the position of the track and cancel timer. + sound._seek = seek; + sound._ended = false; + self._clearTimer(id); + + // Restart the playback if the sound was playing. + if (playing) { + self.play(id, true); + } + + // Update the seek position for HTML5 Audio. + if (!self._webAudio && sound._node) { + sound._node.currentTime = seek; + } + + self._emit('seek', id); + } else { + if (self._webAudio) { + var realTime = self.playing(id) ? Howler.ctx.currentTime - sound._playStart : 0; + var rateSeek = sound._rateSeek ? sound._rateSeek - sound._seek : 0; + return sound._seek + (rateSeek + realTime * Math.abs(sound._rate)); + } else { + return sound._node.currentTime; + } + } + } + + return self; + }, + + /** + * Check if a specific sound is currently playing or not (if id is provided), or check if at least one of the sounds in the group is playing or not. + * @param {Number} id The sound id to check. If none is passed, the whole sound group is checked. + * @return {Boolean} True if playing and false if not. + */ + playing: function(id) { + var self = this; + + // Check the passed sound ID (if any). + if (typeof id === 'number') { + var sound = self._soundById(id); + return sound ? !sound._paused : false; + } + + // Otherwise, loop through all sounds and check if any are playing. + for (var i=0; i= 0) { + Howler._howls.splice(index, 1); + } + } + + // Delete this sound from the cache (if no other Howl is using it). + var remCache = true; + for (i=0; i=0; i--) { + if (!events[i].id || events[i].id === id || event === 'load') { + setTimeout(function(fn) { + fn.call(this, id, msg); + }.bind(self, events[i].fn), 0); + + // If this event was setup with `once`, remove it. + if (events[i].once) { + self.off(event, events[i].fn, events[i].id); + } + } + } + + return self; + }, + + /** + * Queue of actions initiated before the sound has loaded. + * These will be called in sequence, with the next only firing + * after the previous has finished executing (even if async like play). + * @return {Howl} + */ + _loadQueue: function() { + var self = this; + + if (self._queue.length > 0) { + var task = self._queue[0]; + + // don't move onto the next task until this one is done + self.once(task.event, function() { + self._queue.shift(); + self._loadQueue(); + }); + + task.action(); + } + + return self; + }, + + /** + * Fired when playback ends at the end of the duration. + * @param {Sound} sound The sound object to work with. + * @return {Howl} + */ + _ended: function(sound) { + var self = this; + var sprite = sound._sprite; + + // Should this sound loop? + var loop = !!(sound._loop || self._sprite[sprite][2]); + + // Fire the ended event. + self._emit('end', sound._id); + + // Restart the playback for HTML5 Audio loop. + if (!self._webAudio && loop) { + self.stop(sound._id, true).play(sound._id); + } + + // Restart this timer if on a Web Audio loop. + if (self._webAudio && loop) { + self._emit('play', sound._id); + sound._seek = sound._start || 0; + sound._rateSeek = 0; + sound._playStart = Howler.ctx.currentTime; + + var timeout = ((sound._stop - sound._start) * 1000) / Math.abs(sound._rate); + self._endTimers[sound._id] = setTimeout(self._ended.bind(self, sound), timeout); + } + + // Mark the node as paused. + if (self._webAudio && !loop) { + sound._paused = true; + sound._ended = true; + sound._seek = sound._start || 0; + sound._rateSeek = 0; + self._clearTimer(sound._id); + + // Clean up the buffer source. + self._cleanBuffer(sound._node); + + // Attempt to auto-suspend AudioContext if no sounds are still playing. + Howler._autoSuspend(); + } + + // When using a sprite, end the track. + if (!self._webAudio && !loop) { + self.stop(sound._id); + } + + return self; + }, + + /** + * Clear the end timer for a sound playback. + * @param {Number} id The sound ID. + * @return {Howl} + */ + _clearTimer: function(id) { + var self = this; + + if (self._endTimers[id]) { + clearTimeout(self._endTimers[id]); + delete self._endTimers[id]; + } + + return self; + }, + + /** + * Return the sound identified by this ID, or return null. + * @param {Number} id Sound ID + * @return {Object} Sound object or null. + */ + _soundById: function(id) { + var self = this; + + // Loop through all sounds and find the one with this ID. + for (var i=0; i=0; i--) { + if (cnt <= limit) { + return; + } + + if (self._sounds[i]._ended) { + // Disconnect the audio source when using Web Audio. + if (self._webAudio && self._sounds[i]._node) { + self._sounds[i]._node.disconnect(0); + } + + // Remove sounds until we have the pool size. + self._sounds.splice(i, 1); + cnt--; + } + } + }, + + /** + * Get all ID's from the sounds pool. + * @param {Number} id Only return one ID if one is passed. + * @return {Array} Array of IDs. + */ + _getSoundIds: function(id) { + var self = this; + + if (typeof id === 'undefined') { + var ids = []; + for (var i=0; i 0) { + cache[self._src] = buffer; + loadSound(self, buffer); + } + }, function() { + self._emit('loaderror', null, 'Decoding audio data failed.'); + }); + }; + + /** + * Sound is now loaded, so finish setting everything up and fire the loaded event. + * @param {Howl} self + * @param {Object} buffer The decoded buffer sound source. + */ + var loadSound = function(self, buffer) { + // Set the duration. + if (buffer && !self._duration) { + self._duration = buffer.duration; + } + + // Setup a sprite if none is defined. + if (Object.keys(self._sprite).length === 0) { + self._sprite = {__default: [0, self._duration * 1000]}; + } + + // Fire the loaded event. + if (self._state !== 'loaded') { + self._state = 'loaded'; + self._emit('load'); + self._loadQueue(); + } + + // Begin playback if specified. + if (self._autoplay) { + self.play(); + } + }; + + /** + * Setup the audio context when available, or switch to HTML5 Audio mode. + */ + var setupAudioContext = function() { + Howler.noAudio = false; + + // Check if we are using Web Audio and setup the AudioContext if we are. + try { + if (typeof AudioContext !== 'undefined') { + Howler.ctx = new AudioContext(); + } else if (typeof webkitAudioContext !== 'undefined') { + Howler.ctx = new webkitAudioContext(); + } else { + Howler.usingWebAudio = false; + } + } catch(e) { + Howler.usingWebAudio = false; + } + + if (!Howler.usingWebAudio) { + // No audio is available on this system if noAudio is set to true. + if (typeof Audio !== 'undefined') { + try { + var test = new Audio(); + + // Check if the canplaythrough event is available. + if (typeof test.oncanplaythrough === 'undefined') { + Howler._canPlayEvent = 'canplay'; + } + } catch(e) { + Howler.noAudio = true; + } + } else { + Howler.noAudio = true; + } + } + + // Test to make sure audio isn't disabled in Internet Explorer + try { + var test = new Audio(); + if (test.muted) { + Howler.noAudio = true; + } + } catch (e) {} + + // Check if a webview is being used on iOS8 or earlier (rather than the browser). + // If it is, disable Web Audio as it causes crashing. + var iOS = (/iP(hone|od|ad)/.test(Howler._navigator && Howler._navigator.platform)); + var appVersion = Howler._navigator && Howler._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/); + var version = appVersion ? parseInt(appVersion[1], 10) : null; + if (iOS && version && version < 9) { + var safari = /safari/.test(Howler._navigator && Howler._navigator.userAgent.toLowerCase()); + if (Howler._navigator && Howler._navigator.standalone && !safari || Howler._navigator && !Howler._navigator.standalone && !safari) { + Howler.usingWebAudio = false; + } + } + + // Create and expose the master GainNode when using Web Audio (useful for plugins or advanced usage). + if (Howler.usingWebAudio) { + Howler.masterGain = (typeof Howler.ctx.createGain === 'undefined') ? Howler.ctx.createGainNode() : Howler.ctx.createGain(); + Howler.masterGain.gain.value = 1; + Howler.masterGain.connect(Howler.ctx.destination); + } + + // Re-run the setup on Howler. + Howler._setup(); + }; + + // Add support for AMD (Asynchronous Module Definition) libraries such as require.js. + if (typeof define === 'function' && define.amd) { + define([], function() { + return { + Howler: Howler, + Howl: Howl + }; + }); + } + + // Add support for CommonJS libraries such as browserify. + if (typeof exports !== 'undefined') { + exports.Howler = Howler; + exports.Howl = Howl; + } + + // Define globally in case AMD is not available or unused. + if (typeof window !== 'undefined') { + window.HowlerGlobal = HowlerGlobal; + window.Howler = Howler; + window.Howl = Howl; + window.Sound = Sound; + } else if (typeof global !== 'undefined') { // Add to global in Node.js (for testing, etc). + global.HowlerGlobal = HowlerGlobal; + global.Howler = Howler; + global.Howl = Howl; + global.Sound = Sound; + } +})(); + + +/*! + * Spatial Plugin - Adds support for stereo and 3D audio where Web Audio is supported. + * + * howler.js v2.0.0 + * howlerjs.com + * + * (c) 2013-2016, James Simpson of GoldFire Studios + * goldfirestudios.com + * + * MIT License + */ + +(function() { + + 'use strict'; + + // Setup default properties. + HowlerGlobal.prototype._pos = [0, 0, 0]; + HowlerGlobal.prototype._orientation = [0, 0, -1, 0, 1, 0]; + + /** Global Methods **/ + /***************************************************************************/ + + /** + * Helper method to update the stereo panning position of all current Howls. + * Future Howls will not use this value unless explicitly set. + * @param {Number} pan A value of -1.0 is all the way left and 1.0 is all the way right. + * @return {Howler/Number} Self or current stereo panning value. + */ + HowlerGlobal.prototype.stereo = function(pan) { + var self = this; + + // Stop right here if not using Web Audio. + if (!self.ctx || !self.ctx.listener) { + return self; + } + + // Loop through all Howls and update their stereo panning. + for (var i=self._howls.length-1; i>=0; i--) { + self._howls[i].stereo(pan); + } + + return self; + }; + + /** + * Get/set the position of the listener in 3D cartesian space. Sounds using + * 3D position will be relative to the listener's position. + * @param {Number} x The x-position of the listener. + * @param {Number} y The y-position of the listener. + * @param {Number} z The z-position of the listener. + * @return {Howler/Array} Self or current listener position. + */ + HowlerGlobal.prototype.pos = function(x, y, z) { + var self = this; + + // Stop right here if not using Web Audio. + if (!self.ctx || !self.ctx.listener) { + return self; + } + + // Set the defaults for optional 'y' & 'z'. + y = (typeof y !== 'number') ? self._pos[1] : y; + z = (typeof z !== 'number') ? self._pos[2] : z; + + if (typeof x === 'number') { + self._pos = [x, y, z]; + self.ctx.listener.setPosition(self._pos[0], self._pos[1], self._pos[2]); + } else { + return self._pos; + } + + return self; + }; + + /** + * Get/set the direction the listener is pointing in the 3D cartesian space. + * A front and up vector must be provided. The front is the direction the + * face of the listener is pointing, and up is the direction the top of the + * listener is pointing. Thus, these values are expected to be at right angles + * from each other. + * @param {Number} x The x-orientation of the listener. + * @param {Number} y The y-orientation of the listener. + * @param {Number} z The z-orientation of the listener. + * @param {Number} xUp The x-orientation of the top of the listener. + * @param {Number} yUp The y-orientation of the top of the listener. + * @param {Number} zUp The z-orientation of the top of the listener. + * @return {Howler/Array} Returns self or the current orientation vectors. + */ + HowlerGlobal.prototype.orientation = function(x, y, z, xUp, yUp, zUp) { + var self = this; + + // Stop right here if not using Web Audio. + if (!self.ctx || !self.ctx.listener) { + return self; + } + + // Set the defaults for optional 'y' & 'z'. + var or = self._orientation; + y = (typeof y !== 'number') ? or[1] : y; + z = (typeof z !== 'number') ? or[2] : z; + xUp = (typeof xUp !== 'number') ? or[3] : xUp; + yUp = (typeof yUp !== 'number') ? or[4] : yUp; + zUp = (typeof zUp !== 'number') ? or[5] : zUp; + + if (typeof x === 'number') { + self._orientation = [x, y, z, xUp, yUp, zUp]; + self.ctx.listener.setOrientation(x, y, z, xUp, yUp, zUp); + } else { + return or; + } + + return self; + }; + + /** Group Methods **/ + /***************************************************************************/ + + /** + * Add new properties to the core init. + * @param {Function} _super Core init method. + * @return {Howl} + */ + Howl.prototype.init = (function(_super) { + return function(o) { + var self = this; + + // Setup user-defined default properties. + self._orientation = o.orientation || [1, 0, 0]; + self._stereo = o.stereo || null; + self._pos = o.pos || null; + self._pannerAttr = { + coneInnerAngle: typeof o.coneInnerAngle !== 'undefined' ? o.coneInnerAngle : 360, + coneOuterAngle: typeof o.coneOuterAngle !== 'undefined' ? o.coneOuterAngle : 360, + coneOuterGain: typeof o.coneOuterGain !== 'undefined' ? o.coneOuterGain : 0, + distanceModel: typeof o.distanceModel !== 'undefined' ? o.distanceModel : 'inverse', + maxDistance: typeof o.maxDistance !== 'undefined' ? o.maxDistance : 10000, + panningModel: typeof o.panningModel !== 'undefined' ? o.panningModel : 'HRTF', + refDistance: typeof o.refDistance !== 'undefined' ? o.refDistance : 1, + rolloffFactor: typeof o.rolloffFactor !== 'undefined' ? o.rolloffFactor : 1 + }; + + // Setup event listeners. + self._onstereo = o.onstereo ? [{fn: o.onstereo}] : []; + self._onpos = o.onpos ? [{fn: o.onpos}] : []; + self._onorientation = o.onorientation ? [{fn: o.onorientation}] : []; + + // Complete initilization with howler.js core's init function. + return _super.call(this, o); + }; + })(Howl.prototype.init); + + /** + * Get/set the stereo panning of the audio source for this sound or all in the group. + * @param {Number} pan A value of -1.0 is all the way left and 1.0 is all the way right. + * @param {Number} id (optional) The sound ID. If none is passed, all in group will be updated. + * @return {Howl/Number} Returns self or the current stereo panning value. + */ + Howl.prototype.stereo = function(pan, id) { + var self = this; + + // Stop right here if not using Web Audio. + if (!self._webAudio) { + return self; + } + + // If the sound hasn't loaded, add it to the load queue to change stereo pan when capable. + if (self._state !== 'loaded') { + self._queue.push({ + event: 'stereo', + action: function() { + self.stereo(pan, id); + } + }); + + return self; + } + + // Check for PannerStereoNode support and fallback to PannerNode if it doesn't exist. + var pannerType = (typeof Howler.ctx.createStereoPanner === 'undefined') ? 'spatial' : 'stereo'; + + // Setup the group's stereo panning if no ID is passed. + if (typeof id === 'undefined') { + // Return the group's stereo panning if no parameters are passed. + if (typeof pan === 'number') { + self._stereo = pan; + self._pos = [pan, 0, 0]; + } else { + return self._stereo; + } + } + + // Change the streo panning of one or all sounds in group. + var ids = self._getSoundIds(id); + for (var i=0; i Returns the group's values. + * pannerAttr(id) -> Returns the sound id's values. + * pannerAttr(o) -> Set's the values of all sounds in this Howl group. + * pannerAttr(o, id) -> Set's the values of passed sound id. + * + * Attributes: + * coneInnerAngle - (360 by default) There will be no volume reduction inside this angle. + * coneOuterAngle - (360 by default) The volume will be reduced to a constant value of + * `coneOuterGain` outside this angle. + * coneOuterGain - (0 by default) The amount of volume reduction outside of `coneOuterAngle`. + * distanceModel - ('inverse' by default) Determines algorithm to use to reduce volume as audio moves + * away from listener. Can be `linear`, `inverse` or `exponential`. + * maxDistance - (10000 by default) Volume won't reduce between source/listener beyond this distance. + * panningModel - ('HRTF' by default) Determines which spatialization algorithm is used to position audio. + * Can be `HRTF` or `equalpower`. + * refDistance - (1 by default) A reference distance for reducing volume as the source + * moves away from the listener. + * rolloffFactor - (1 by default) How quickly the volume reduces as source moves from listener. + * + * @return {Howl/Object} Returns self or current panner attributes. + */ + Howl.prototype.pannerAttr = function() { + var self = this; + var args = arguments; + var o, id, sound; + + // Stop right here if not using Web Audio. + if (!self._webAudio) { + return self; + } + + // Determine the values based on arguments. + if (args.length === 0) { + // Return the group's panner attribute values. + return self._pannerAttr; + } else if (args.length === 1) { + if (typeof args[0] === 'object') { + o = args[0]; + + // Set the grou's panner attribute values. + if (typeof id === 'undefined') { + self._pannerAttr = { + coneInnerAngle: typeof o.coneInnerAngle !== 'undefined' ? o.coneInnerAngle : self._coneInnerAngle, + coneOuterAngle: typeof o.coneOuterAngle !== 'undefined' ? o.coneOuterAngle : self._coneOuterAngle, + coneOuterGain: typeof o.coneOuterGain !== 'undefined' ? o.coneOuterGain : self._coneOuterGain, + distanceModel: typeof o.distanceModel !== 'undefined' ? o.distanceModel : self._distanceModel, + maxDistance: typeof o.maxDistance !== 'undefined' ? o.maxDistance : self._maxDistance, + panningModel: typeof o.panningModel !== 'undefined' ? o.panningModel : self._panningModel, + refDistance: typeof o.refDistance !== 'undefined' ? o.refDistance : self._refDistance, + rolloffFactor: typeof o.rolloffFactor !== 'undefined' ? o.rolloffFactor : self._rolloffFactor + }; + } + } else { + // Return this sound's panner attribute values. + sound = self._soundById(parseInt(args[0], 10)); + return sound ? sound._pannerAttr : self._pannerAttr; + } + } else if (args.length === 2) { + o = args[0]; + id = parseInt(args[1], 10); + } + + // Update the values of the specified sounds. + var ids = self._getSoundIds(id); + for (var i=0; i0)-(t<0)},r.abs=function(t){var e=t>>n-1;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(t65535)<<4,t>>>=e,r=(t>255)<<3,t>>>=r,e|=r,r=(t>15)<<2,t>>>=r,e|=r,r=(t>3)<<1,t>>>=r,e|=r,e|t>>1},r.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},r.popCount=function(t){return t-=t>>>1&1431655765,t=(858993459&t)+(t>>>2&858993459),16843009*(t+(t>>>4)&252645135)>>>24},r.countTrailingZeros=i,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,t&=15,27030>>>t&1};var s=new Array(256);!function(t){for(var e=0;e<256;++e){var r=e,i=e,n=7;for(r>>>=1;r;r>>>=1)i<<=1,i|=1&r,--n;t[e]=i<>>8&255]<<16|s[t>>>16&255]<<8|s[t>>>24&255]},r.interleave2=function(t,e){return t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},r.deinterleave2=function(t,e){return t=t>>>e&1431655765,t=858993459&(t|t>>>1),t=252645135&(t|t>>>2),t=16711935&(t|t>>>4),t=65535&(t|t>>>16),t<<16>>16},r.interleave3=function(t,e,r){return t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t|=e<<1,r&=1023,r=4278190335&(r|r<<16),r=251719695&(r|r<<8),r=3272356035&(r|r<<4),r=1227133513&(r|r<<2),t|r<<2},r.deinterleave3=function(t,e){return t=t>>>e&1227133513,t=3272356035&(t|t>>>2),t=251719695&(t|t>>>4),t=4278190335&(t|t>>>8),t=1023&(t|t>>>16),t<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>i(t)+1}},{}],2:[function(t,e,r){"use strict";function i(t,e,r){r=r||2;var i=e&&e.length,s=i?e[0]*r:t.length,a=n(t,0,s,r,!0),h=[];if(!a)return h;var u,l,d,p,f,v,g;if(i&&(a=c(t,e,a,r)),t.length>80*r){u=d=t[0],l=p=t[1];for(var y=r;yd&&(d=f),v>p&&(p=v);g=Math.max(d-u,p-l)}return o(a,h,r,u,l,g),h}function n(t,e,r,i,n){var s,o;if(n===D(t,e,r,i)>0)for(s=e;s=e;s-=i)o=M(s,t[s],t[s+1],o);return o&&T(o,o.next)&&(A(o),o=o.next),o}function s(t,e){if(!t)return t;e||(e=t);var r,i=t;do if(r=!1,i.steiner||!T(i,i.next)&&0!==b(i.prev,i,i.next))i=i.next;else{if(A(i),i=e=i.prev,i===i.next)return null;r=!0}while(r||i!==e);return e}function o(t,e,r,i,n,c,d){if(t){!d&&c&&v(t,i,n,c);for(var p,f,g=t;t.prev!==t.next;)if(p=t.prev,f=t.next,c?h(t,i,n,c):a(t))e.push(p.i/r),e.push(t.i/r),e.push(f.i/r),A(t),t=f.next,g=f.next;else if(t=f,t===g){d?1===d?(t=u(t,e,r),o(t,e,r,i,n,c,2)):2===d&&l(t,e,r,i,n,c):o(s(t),e,r,i,n,c,1);break}}}function a(t){var e=t.prev,r=t,i=t.next;if(b(e,r,i)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(m(e.x,e.y,r.x,r.y,i.x,i.y,n.x,n.y)&&b(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function h(t,e,r,i){var n=t.prev,s=t,o=t.next;if(b(n,s,o)>=0)return!1;for(var a=n.xs.x?n.x>o.x?n.x:o.x:s.x>o.x?s.x:o.x,l=n.y>s.y?n.y>o.y?n.y:o.y:s.y>o.y?s.y:o.y,c=y(a,h,e,r,i),d=y(u,l,e,r,i),p=t.nextZ;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&m(n.x,n.y,s.x,s.y,o.x,o.y,p.x,p.y)&&b(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=c;){if(p!==t.prev&&p!==t.next&&m(n.x,n.y,s.x,s.y,o.x,o.y,p.x,p.y)&&b(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function u(t,e,r){var i=t;do{var n=i.prev,s=i.next.next;!T(n,s)&&E(n,i,i.next,s)&&S(n,s)&&S(s,n)&&(e.push(n.i/r),e.push(i.i/r),e.push(s.i/r),A(i),A(i.next),i=t=s),i=i.next}while(i!==t);return i}function l(t,e,r,i,n,a){var h=t;do{for(var u=h.next.next;u!==h.prev;){if(h.i!==u.i&&_(h,u)){var l=R(h,u);return h=s(h,h.next),l=s(l,l.next),o(h,e,r,i,n,a),void o(l,e,r,i,n,a)}u=u.next}h=h.next}while(h!==t)}function c(t,e,r,i){var o,a,h,u,l,c=[];for(o=0,a=e.length;o=i.next.y){var a=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=n&&a>o){if(o=a,a===n){if(s===i.y)return i;if(s===i.next.y)return i.next}r=i.x=i.x&&i.x>=l&&m(sr.x)&&S(i,t)&&(r=i,d=h)),i=i.next;return r}function v(t,e,r,i){var n=t;do null===n.z&&(n.z=y(n.x,n.y,e,r,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,g(n)}function g(t){var e,r,i,n,s,o,a,h,u=1;do{for(r=t,t=null,s=null,o=0;r;){for(o++,i=r,a=0,e=0;e0||h>0&&i;)0===a?(n=i,i=i.nextZ,h--):0!==h&&i?r.z<=i.z?(n=r,r=r.nextZ,a--):(n=i,i=i.nextZ,h--):(n=r,r=r.nextZ,a--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;r=i}s.nextZ=null,u*=2}while(o>1);return t}function y(t,e,r,i,n){return t=32767*(t-r)/n,e=32767*(e-i)/n,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1}function x(t){var e=t,r=t;do e.x=0&&(t-o)*(i-a)-(r-o)*(e-a)>=0&&(r-o)*(s-a)-(n-o)*(i-a)>=0}function _(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!w(t,e)&&S(t,e)&&S(e,t)&&C(t,e)}function b(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function T(t,e){return t.x===e.x&&t.y===e.y}function E(t,e,r,i){return!!(T(t,e)&&T(r,i)||T(t,i)&&T(r,e))||b(t,e,r)>0!=b(t,e,i)>0&&b(r,i,t)>0!=b(r,i,e)>0}function w(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&E(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function S(t,e){return b(t.prev,t,t.next)<0?b(t,e,t.next)>=0&&b(t,t.prev,e)>=0:b(t,e,t.prev)<0||b(t,t.next,e)<0}function C(t,e){var r=t,i=!1,n=(t.x+e.x)/2,s=(t.y+e.y)/2;do r.y>s!=r.next.y>s&&n<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next;while(r!==t);return i}function R(t,e){var r=new O(t.i,t.x,t.y),i=new O(e.i,e.x,e.y),n=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,i.next=r,r.prev=i,s.next=i,i.prev=s,i}function M(t,e,r,i){var n=new O(t,e,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function A(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function O(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function D(t,e,r,i){for(var n=0,s=e,o=r-i;s0&&(i+=t[n-1].length,r.holes.push(i))}return r}},{}],3:[function(t,e,r){"use strict";function i(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function n(){}var s=Object.prototype.hasOwnProperty,o="function"!=typeof Object.create&&"~";n.prototype._events=void 0,n.prototype.eventNames=function(){var t,e=this._events,r=[];if(!e)return r;for(t in e)s.call(e,t)&&r.push(o?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},n.prototype.listeners=function(t,e){var r=o?o+t:t,i=this._events&&this._events[r];if(e)return!!i;if(!i)return[];if(i.fn)return[i.fn];for(var n=0,s=i.length,a=new Array(s);n=t.byteLength?i.bufferSubData(this.type,e,t):i.bufferData(this.type,t,this.drawType),this.data=t},n.prototype.bind=function(){var t=this.gl;t.bindBuffer(this.type,this.buffer)},n.createVertexBuffer=function(t,e,r){return new n(t,t.ARRAY_BUFFER,e,r)},n.createIndexBuffer=function(t,e,r){return new n(t,t.ELEMENT_ARRAY_BUFFER,e,r)},n.create=function(t,e,r,i){return new n(t,e,i)},n.prototype.destroy=function(){this.gl.deleteBuffer(this.buffer)},e.exports=n},{}],7:[function(t,e,r){var i=t("./GLTexture"),n=function(t,e,r){this.gl=t,this.framebuffer=t.createFramebuffer(),this.stencil=null,this.texture=null,this.width=e||100,this.height=r||100};n.prototype.enableTexture=function(t){var e=this.gl;this.texture=t||new i(e),this.texture.bind(),this.bind(),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this.texture.texture,0)},n.prototype.enableStencil=function(){if(!this.stencil){var t=this.gl;this.stencil=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this.stencil),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,this.stencil),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,this.width,this.height)}},n.prototype.clear=function(t,e,r,i){this.bind();var n=this.gl;n.clearColor(t,e,r,i),n.clear(n.COLOR_BUFFER_BIT)},n.prototype.bind=function(){var t=this.gl;this.texture&&this.texture.unbind(),t.bindFramebuffer(t.FRAMEBUFFER,this.framebuffer)},n.prototype.unbind=function(){var t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,null)},n.prototype.resize=function(t,e){var r=this.gl;this.width=t,this.height=e,this.texture&&this.texture.uploadData(null,t,e),this.stencil&&(r.bindRenderbuffer(r.RENDERBUFFER,this.stencil),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,e))},n.prototype.destroy=function(){var t=this.gl;this.texture&&this.texture.destroy(),t.deleteFramebuffer(this.framebuffer),this.gl=null,this.stencil=null,this.texture=null},n.createRGBA=function(t,e,r){var s=i.fromData(t,null,e,r);s.enableNearestScaling(),s.enableWrapClamp();var o=new n(t,e,r);return o.enableTexture(s),o.unbind(),o},n.createFloat32=function(t,e,r,s){var o=new i.fromData(t,s,e,r);o.enableNearestScaling(),o.enableWrapClamp();var a=new n(t,e,r);return a.enableTexture(o),a.unbind(),a},e.exports=n},{"./GLTexture":9}],8:[function(t,e,r){var i=t("./shader/compileProgram"),n=t("./shader/extractAttributes"),s=t("./shader/extractUniforms"),o=t("./shader/generateUniformAccessObject"),a=function(t,e,r){this.gl=t,this.program=i(t,e,r),this.attributes=n(t,this.program);var a=s(t,this.program);this.uniforms=o(t,a)};a.prototype.bind=function(){this.gl.useProgram(this.program)},a.prototype.destroy=function(){},e.exports=a},{"./shader/compileProgram":14,"./shader/extractAttributes":16,"./shader/extractUniforms":17,"./shader/generateUniformAccessObject":18}],9:[function(t,e,r){var i=function(t,e,r,i,n){this.gl=t,this.texture=t.createTexture(),this.mipmap=!1,this.premultiplyAlpha=!1,this.width=e||0,this.height=r||0,this.format=i||t.RGBA,this.type=n||t.UNSIGNED_BYTE};i.prototype.upload=function(t){this.bind();var e=this.gl;this.width=t.videoWidth||t.width,this.height=t.videoHeight||t.height,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),e.texImage2D(e.TEXTURE_2D,0,this.format,this.format,this.type,t)};var n=!1;i.prototype.uploadData=function(t,e,r){this.bind();var i=this.gl;if(this.width=e||this.width,this.height=r||this.height,t instanceof Float32Array){if(!n){var s=i.getExtension("OES_texture_float");if(!s)throw new Error("floating point textures not available");n=!0}this.type=i.FLOAT}else this.type=i.UNSIGNED_BYTE;i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),i.texImage2D(i.TEXTURE_2D,0,this.format,this.width,this.height,0,this.format,this.type,t||null)},i.prototype.bind=function(t){var e=this.gl;void 0!==t&&e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,this.texture)},i.prototype.unbind=function(){var t=this.gl;t.bindTexture(t.TEXTURE_2D,null)},i.prototype.minFilter=function(t){var e=this.gl;this.bind(),this.mipmap?e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t?e.LINEAR_MIPMAP_LINEAR:e.NEAREST_MIPMAP_NEAREST):e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t?e.LINEAR:e.NEAREST)},i.prototype.magFilter=function(t){var e=this.gl;this.bind(),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t?e.LINEAR:e.NEAREST)},i.prototype.enableMipmap=function(){var t=this.gl;this.bind(),this.mipmap=!0,t.generateMipmap(t.TEXTURE_2D)},i.prototype.enableLinearScaling=function(){this.minFilter(!0),this.magFilter(!0)},i.prototype.enableNearestScaling=function(){this.minFilter(!1),this.magFilter(!1)},i.prototype.enableWrapClamp=function(){var t=this.gl;this.bind(),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)},i.prototype.enableWrapRepeat=function(){var t=this.gl;this.bind(),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT)},i.prototype.enableWrapMirrorRepeat=function(){var t=this.gl;this.bind(),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.MIRRORED_REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.MIRRORED_REPEAT)},i.prototype.destroy=function(){var t=this.gl;t.deleteTexture(this.texture)},i.fromSource=function(t,e,r){var n=new i(t);return n.premultiplyAlpha=r||!1,n.upload(e),n},i.fromData=function(t,e,r,n){var s=new i(t);return s.uploadData(e,r,n),s},e.exports=i},{}],10:[function(t,e,r){function i(t,e){if(this.nativeVaoExtension=null,i.FORCE_NATIVE||(this.nativeVaoExtension=t.getExtension("OES_vertex_array_object")||t.getExtension("MOZ_OES_vertex_array_object")||t.getExtension("WEBKIT_OES_vertex_array_object")),this.nativeState=e,this.nativeVaoExtension){this.nativeVao=this.nativeVaoExtension.createVertexArrayOES();var r=t.getParameter(t.MAX_VERTEX_ATTRIBS);this.nativeState={tempAttribState:new Array(r),attribState:new Array(r)}}this.gl=t,this.attributes=[],this.indexBuffer=null,this.dirty=!1}var n=t("./setVertexAttribArrays");i.prototype.constructor=i,e.exports=i,i.FORCE_NATIVE=!1,i.prototype.bind=function(){return this.nativeVao?(this.nativeVaoExtension.bindVertexArrayOES(this.nativeVao),this.dirty&&(this.dirty=!1,this.activate())):this.activate(),this},i.prototype.unbind=function(){return this.nativeVao&&this.nativeVaoExtension.bindVertexArrayOES(null),this},i.prototype.activate=function(){for(var t=this.gl,e=null,r=0;r=0;i--){var n=t[i];"."===n?t.splice(i,1):".."===n?(t.splice(i,1),r++):r&&(t.splice(i,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}function i(t,e){if(t.filter)return t.filter(e);for(var r=[],i=0;i=-1&&!n;s--){var o=s>=0?arguments[s]:t.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(r=o+"/"+r,n="/"===o.charAt(0))}return r=e(i(r.split("/"),function(t){return!!t}),!n).join("/"),(n?"/":"")+r||"."},r.normalize=function(t){var n=r.isAbsolute(t),s="/"===o(t,-1);return t=e(i(t.split("/"),function(t){return!!t}),!n).join("/"),t||n||(t="."),t&&s&&(t+="/"),(n?"/":"")+t},r.isAbsolute=function(t){return"/"===t.charAt(0)},r.join=function(){var t=Array.prototype.slice.call(arguments,0);return r.normalize(i(t,function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},r.relative=function(t,e){function i(t){for(var e=0;e=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=r.resolve(t).substr(1),e=r.resolve(e).substr(1);for(var n=i(t.split("/")),s=i(e.split("/")),o=Math.min(n.length,s.length),a=o,h=0;h1)for(var r=1;r1&&(i=r[0]+"@",t=r[1]),t=t.replace(I,".");var n=t.split("."),s=o(n,e).join(".");return i+s}function h(t){for(var e,r,i=[],n=0,s=t.length;n=55296&&e<=56319&&n65535&&(t-=65536,e+=N(t>>>10&1023|55296),t=56320|1023&t),e+=N(t)}).join("")}function l(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:E}function c(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function d(t,e,r){var i=0;for(t=r?B(t/R):t>>1,t+=B(t/e);t>F*S>>1;i+=E)t=B(t/F);return B(i+(F+1)*t/(t+C))}function p(t){var e,r,i,n,o,a,h,c,p,f,v=[],g=t.length,y=0,x=A,m=M;for(r=t.lastIndexOf(O),r<0&&(r=0),i=0;i=128&&s("not-basic"),v.push(t.charCodeAt(i));for(n=r>0?r+1:0;n=g&&s("invalid-input"),c=l(t.charCodeAt(n++)),(c>=E||c>B((T-y)/a))&&s("overflow"),y+=c*a,p=h<=m?w:h>=m+S?S:h-m,!(cB(T/f)&&s("overflow"),a*=f;e=v.length+1,m=d(y-o,e,0==o),B(y/e)>T-x&&s("overflow"),x+=B(y/e),y%=e,v.splice(y++,0,x)}return u(v)}function f(t){var e,r,i,n,o,a,u,l,p,f,v,g,y,x,m,_=[];for(t=h(t),g=t.length,e=A,r=0,o=M,a=0;a=e&&vB((T-r)/y)&&s("overflow"),r+=(u-e)*y,e=u,a=0;aT&&s("overflow"),v==e){for(l=r,p=E;f=p<=o?w:p>=o+S?S:p-o,!(l= 0x80 (not a basic code point)","invalid-input":"Invalid input"},F=E-w,B=Math.floor,N=String.fromCharCode;if(_={version:"1.4.1",ucs2:{decode:h,encode:u},decode:p,encode:f,toASCII:g,toUnicode:v},"function"==typeof t&&"object"==typeof t.amd&&t.amd)t("punycode",function(){return _});else if(y&&x)if(r.exports==y)x.exports=_;else for(b in _)_.hasOwnProperty(b)&&(y[b]=_[b]);else n.punycode=_}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],25:[function(t,e,r){"use strict";function i(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.exports=function(t,e,r,s){e=e||"&",r=r||"=";var o={};if("string"!=typeof t||0===t.length)return o;var a=/\+/g;t=t.split(e);var h=1e3;s&&"number"==typeof s.maxKeys&&(h=s.maxKeys);var u=t.length;h>0&&u>h&&(u=h);for(var l=0;l=0?(c=v.substr(0,g),d=v.substr(g+1)):(c=v,d=""),p=decodeURIComponent(c),f=decodeURIComponent(d),i(o,p)?n(o[p])?o[p].push(f):o[p]=[o[p],f]:o[p]=f}return o};var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},{}],26:[function(t,e,r){"use strict";function i(t,e){if(t.map)return t.map(e);for(var r=[],i=0;i",'"',"`"," ","\r","\n","\t"],f=["{","}","|","\\","^","`"].concat(p),v=["'"].concat(f),g=["%","/","?",";","#"].concat(v),y=["/","?","#"],x=255,m=/^[+a-z0-9A-Z_-]{0,63}$/,_=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,b={javascript:!0,"javascript:":!0},T={javascript:!0,"javascript:":!0},E={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},w=t("querystring");i.prototype.parse=function(t,e,r){if(!u.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var i=t.indexOf("?"),n=i!==-1&&i127?"x":L[B];if(!F.match(m)){var U=P.slice(0,R),k=P.slice(R+1),j=L.match(_);j&&(U.push(j[1]),k.unshift(j[2])),k.length&&(a="/"+k.join(".")+a),this.hostname=U.join(".");break}}}this.hostname.length>x?this.hostname="":this.hostname=this.hostname.toLowerCase(),D||(this.hostname=h.toASCII(this.hostname));var W=this.port?":"+this.port:"",G=this.hostname||"";this.host=G+W,this.href+=this.host,D&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!b[f])for(var R=0,I=v.length;R0)&&r.host.split("@");S&&(r.auth=S.shift(),r.host=r.hostname=S.shift())}return r.search=t.search,r.query=t.query,u.isNull(r.pathname)&&u.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!b.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var C=b.slice(-1)[0],R=(r.host||t.host||b.length>1)&&("."===C||".."===C)||""===C,M=0,A=b.length;A>=0;A--)C=b[A],"."===C?b.splice(A,1):".."===C?(b.splice(A,1),M++):M&&(b.splice(A,1),M--);if(!m&&!_)for(;M--;M)b.unshift("..");!m||""===b[0]||b[0]&&"/"===b[0].charAt(0)||b.unshift(""),R&&"/"!==b.join("/").substr(-1)&&b.push("");var O=""===b[0]||b[0]&&"/"===b[0].charAt(0);if(w){r.hostname=r.host=O?"":b.length?b.shift():"";var S=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@");S&&(r.auth=S.shift(),r.host=r.hostname=S.shift())}return m=m||r.host&&b.length,m&&!O&&b.unshift(""),b.length?r.pathname=b.join("/"):(r.pathname=null,r.path=null),u.isNull(r.pathname)&&u.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},i.prototype.parseHost=function(){var t=this.host,e=c.exec(t);e&&(e=e[0],":"!==e&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},{"./util":29,punycode:24,querystring:27}],29:[function(t,e,r){"use strict";e.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},{}],30:[function(t,e,r){"use strict";function i(){}function n(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function s(){this._events=new i,this._eventsCount=0}var o=Object.prototype.hasOwnProperty,a="~";Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(a=!1)),s.prototype.eventNames=function(){var t,e,r=[];if(0===this._eventsCount)return r;for(e in t=this._events)o.call(t,e)&&r.push(a?e.slice(1):e);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},s.prototype.listeners=function(t,e){var r=a?a+t:t,i=this._events[r];if(e)return!!i;if(!i)return[];if(i.fn)return[i.fn];for(var n=0,s=i.length,o=new Array(s);n0))return void this.abort("["+t.status+"]"+t.statusText+":"+t.responseURL);if(this.xhrType===i.XHR_RESPONSE_TYPE.TEXT)this.data=t.responseText;else if(this.xhrType===i.XHR_RESPONSE_TYPE.JSON)try{this.data=JSON.parse(t.responseText),this.isJson=!0}catch(t){return void this.abort("Error trying to parse loaded json:",t)}else if(this.xhrType===i.XHR_RESPONSE_TYPE.DOCUMENT)try{if(window.DOMParser){var r=new DOMParser;this.data=r.parseFromString(t.responseText,"text/xml")}else{var n=document.createElement("div");n.innerHTML=t.responseText,this.data=n}this.isXml=!0}catch(t){return void this.abort("Error trying to parse loaded xml:",t)}else this.data=t.response||t.responseText;this.complete()},i.prototype._determineCrossOrigin=function(t,e){if(0===t.indexOf("data:"))return"";e=e||window.location,u||(u=document.createElement("a")),u.href=t,t=a(u.href,{strictMode:!0});var r=!t.port&&""===e.port||t.port===e.port,i=t.protocol?t.protocol+":":"";return t.host===e.hostname&&r&&i===e.protocol?"":"anonymous"},i.prototype._determineXhrType=function(){return i._xhrTypeMap[this._getExtension()]||i.XHR_RESPONSE_TYPE.TEXT},i.prototype._determineLoadType=function(){return i._loadTypeMap[this._getExtension()]||i.LOAD_TYPE.XHR},i.prototype._getExtension=function(){var t=this.url,e="";if(this.isDataUrl){var r=t.indexOf("/");e=t.substring(r+1,t.indexOf(";",r))}else{var i=t.indexOf("?");i!==-1&&(t=t.substring(0,i)),e=t.substring(t.lastIndexOf(".")+1)}return e.toLowerCase()},i.prototype._getMimeFromXhrType=function(t){switch(t){case i.XHR_RESPONSE_TYPE.BUFFER:return"application/octet-binary";case i.XHR_RESPONSE_TYPE.BLOB:return"application/blob";case i.XHR_RESPONSE_TYPE.DOCUMENT:return"application/xml";case i.XHR_RESPONSE_TYPE.JSON:return"application/json";case i.XHR_RESPONSE_TYPE.DEFAULT:case i.XHR_RESPONSE_TYPE.TEXT:default:return"text/plain"}},i.LOAD_TYPE={XHR:1,IMAGE:2,AUDIO:3,VIDEO:4},i.XHR_RESPONSE_TYPE={DEFAULT:"text",BUFFER:"arraybuffer",BLOB:"blob",DOCUMENT:"document",JSON:"json",TEXT:"text"},i._loadTypeMap={gif:i.LOAD_TYPE.IMAGE,png:i.LOAD_TYPE.IMAGE,bmp:i.LOAD_TYPE.IMAGE,jpg:i.LOAD_TYPE.IMAGE,jpeg:i.LOAD_TYPE.IMAGE,tif:i.LOAD_TYPE.IMAGE,tiff:i.LOAD_TYPE.IMAGE,webp:i.LOAD_TYPE.IMAGE,tga:i.LOAD_TYPE.IMAGE,"svg+xml":i.LOAD_TYPE.IMAGE},i._xhrTypeMap={xhtml:i.XHR_RESPONSE_TYPE.DOCUMENT,html:i.XHR_RESPONSE_TYPE.DOCUMENT,htm:i.XHR_RESPONSE_TYPE.DOCUMENT,xml:i.XHR_RESPONSE_TYPE.DOCUMENT,tmx:i.XHR_RESPONSE_TYPE.DOCUMENT,tsx:i.XHR_RESPONSE_TYPE.DOCUMENT,svg:i.XHR_RESPONSE_TYPE.DOCUMENT,gif:i.XHR_RESPONSE_TYPE.BLOB,png:i.XHR_RESPONSE_TYPE.BLOB,bmp:i.XHR_RESPONSE_TYPE.BLOB,jpg:i.XHR_RESPONSE_TYPE.BLOB,jpeg:i.XHR_RESPONSE_TYPE.BLOB,tif:i.XHR_RESPONSE_TYPE.BLOB,tiff:i.XHR_RESPONSE_TYPE.BLOB,webp:i.XHR_RESPONSE_TYPE.BLOB,tga:i.XHR_RESPONSE_TYPE.BLOB,json:i.XHR_RESPONSE_TYPE.JSON,text:i.XHR_RESPONSE_TYPE.TEXT,txt:i.XHR_RESPONSE_TYPE.TEXT},i.setExtensionLoadType=function(t,e){s(i._loadTypeMap,t,e)},i.setExtensionXhrType=function(t,e){s(i._xhrTypeMap,t,e)}},{eventemitter3:30,"parse-uri":31}],34:[function(t,e,r){"use strict";function i(){}function n(t,e,r){var i=0,n=t.length;!function s(o){return o||i===n?void(r&&r(o)):void e(t[i++],s)}()}function s(t){return function(){if(null===t)throw new Error("Callback was already called.");var e=t;t=null,e.apply(this,arguments)}}function o(t,e){function r(t,e,r){if(null!=r&&"function"!=typeof r)throw new Error("task callback must be a function");if(a.started=!0,null==t&&a.idle())return void setTimeout(function(){a.drain()},1);var n={data:t,callback:"function"==typeof r?r:i};e?a._tasks.unshift(n):a._tasks.push(n),setTimeout(function(){a.process()},1)}function n(t){return function(){o-=1,t.callback.apply(t,arguments),null!=arguments[0]&&a.error(arguments[0],t.data),o<=a.concurrency-a.buffer&&a.unsaturated(),a.idle()&&a.drain(),a.process()}}if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");var o=0,a={_tasks:[],concurrency:e,saturated:i,unsaturated:i,buffer:e/4,empty:i,drain:i,error:i,started:!1,paused:!1,push:function(t,e){r(t,!1,e)},kill:function(){a.drain=i,a._tasks=[]},unshift:function(t,e){r(t,!0,e)},process:function(){for(;!a.paused&&o>2,i[1]=(3&e[0])<<4|e[1]>>4,i[2]=(15&e[1])<<2|e[2]>>6,i[3]=63&e[2],o=n-(t.length-1)){case 2:i[3]=64,i[2]=64;break;case 1:i[3]=64}for(s=0;s=0;r--)this.updateAccessibleObjects(e[r])}},i.prototype.update=function(){if(this.renderer.renderingToScreen){this.updateAccessibleObjects(this.renderer._lastObjectRendered);var t=this.renderer.view.getBoundingClientRect(),e=t.width/this.renderer.width,r=t.height/this.renderer.height,i=this.div;i.style.left=t.left+"px",i.style.top=t.top+"px",i.style.width=this.renderer.width+"px",i.style.height=this.renderer.height+"px";for(var s=0;sthis.renderer.width&&(t.width=this.renderer.width-t.x),t.y+t.height>this.renderer.height&&(t.height=this.renderer.height-t.y)},i.prototype.addChild=function(t){var e=this.pool.pop();e||(e=document.createElement("button"),e.style.width="100px",e.style.height="100px",e.style.backgroundColor=this.debug?"rgba(255,0,0,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=2,e.style.borderStyle="none",e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),t.accessibleTitle?e.title=t.accessibleTitle:t.accessibleTitle||t.accessibleHint||(e.title="displayObject "+this.tabIndex),t.accessibleHint&&e.setAttribute("aria-label",t.accessibleHint),t._accessibleActive=!0,t._accessibleDiv=e,e.displayObject=t,this.children.push(t),this.div.appendChild(t._accessibleDiv),t._accessibleDiv.tabIndex=t.tabIndex},i.prototype._onClick=function(t){var e=this.renderer.plugins.interaction;e.dispatchEvent(t.target.displayObject,"click",e.eventData)},i.prototype._onFocus=function(t){var e=this.renderer.plugins.interaction;e.dispatchEvent(t.target.displayObject,"mouseover",e.eventData)},i.prototype._onFocusOut=function(t){var e=this.renderer.plugins.interaction;e.dispatchEvent(t.target.displayObject,"mouseout",e.eventData)},i.prototype._onKeyDown=function(t){9===t.keyCode&&this.activate()},i.prototype._onMouseMove=function(){this.deactivate()},i.prototype.destroy=function(){this.div=null;for(var t=0;tthis.maxX||this.minY>this.maxY},i.prototype.clear=function(){this.updateID++,this.minX=1/0,this.minY=1/0,this.maxX=-(1/0),this.maxY=-(1/0)},i.prototype.getRectangle=function(t){return this.minX>this.maxX||this.minY>this.maxY?s.EMPTY:(t=t||new s(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)},i.prototype.addPoint=function(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)},i.prototype.addQuad=function(t){var e=this.minX,r=this.minY,i=this.maxX,n=this.maxY,s=t[0],o=t[1];e=si?s:i,n=o>n?o:n,s=t[2],o=t[3],e=si?s:i,n=o>n?o:n,s=t[4],o=t[5],e=si?s:i,n=o>n?o:n,s=t[6],o=t[7],e=si?s:i,n=o>n?o:n,this.minX=e,this.minY=r,this.maxX=i,this.maxY=n},i.prototype.addFrame=function(t,e,r,i,n){var s=t.worldTransform,o=s.a,a=s.b,h=s.c,u=s.d,l=s.tx,c=s.ty,d=this.minX,p=this.minY,f=this.maxX,v=this.maxY,g=o*e+h*r+l,y=a*e+u*r+c;d=gf?g:f,v=y>v?y:v,g=o*i+h*r+l,y=a*i+u*r+c,d=gf?g:f,v=y>v?y:v,g=o*e+h*n+l,y=a*e+u*n+c,d=gf?g:f,v=y>v?y:v,g=o*i+h*n+l,y=a*i+u*n+c,d=gf?g:f,v=y>v?y:v,this.minX=d,this.minY=p,this.maxX=f,this.maxY=v},i.prototype.addVertices=function(t,e,r,i){for(var n=t.worldTransform,s=n.a,o=n.b,a=n.c,h=n.d,u=n.tx,l=n.ty,c=this.minX,d=this.minY,p=this.maxX,f=this.maxY,v=r;vp?x:p,f=m>f?m:f}this.minX=c,this.minY=d,this.maxX=p,this.maxY=f},i.prototype.addBounds=function(t){var e=this.minX,r=this.minY,i=this.maxX,n=this.maxY;this.minX=t.minXi?t.maxX:i,this.maxY=t.maxY>n?t.maxY:n}},{"../math":67}],45:[function(t,e,r){function i(){s.call(this),this.children=[]}var n=t("../utils"),s=t("./DisplayObject");i.prototype=Object.create(s.prototype),i.prototype.constructor=i,e.exports=i,Object.defineProperties(i.prototype,{width:{get:function(){return this.scale.x*this.getLocalBounds().width},set:function(t){var e=this.getLocalBounds().width;0!==e?this.scale.x=t/e:this.scale.x=1,this._width=t}},height:{get:function(){return this.scale.y*this.getLocalBounds().height},set:function(t){var e=this.getLocalBounds().height;0!==e?this.scale.y=t/e:this.scale.y=1,this._height=t}}}),i.prototype.onChildrenChange=function(){},i.prototype.addChild=function(t){var e=arguments.length;if(e>1)for(var r=0;r=0&&e<=this.children.length)return t.parent&&t.parent.removeChild(t),t.parent=this,this.children.splice(e,0,t),this.onChildrenChange(e),t.emit("added",this),t;throw new Error(t+"addChildAt: The index "+e+" supplied is out of bounds "+this.children.length)},i.prototype.swapChildren=function(t,e){if(t!==e){var r=this.getChildIndex(t),i=this.getChildIndex(e);if(r<0||i<0)throw new Error("swapChildren: Both the supplied DisplayObjects must be children of the caller.");this.children[r]=e,this.children[i]=t,this.onChildrenChange(r=this.children.length)throw new Error("The supplied index is out of bounds");var r=this.getChildIndex(t);n.removeItems(this.children,r,1),this.children.splice(e,0,t),this.onChildrenChange(e)},i.prototype.getChildAt=function(t){if(t<0||t>=this.children.length)throw new Error("getChildAt: Supplied index "+t+" does not exist in the child list, or the supplied DisplayObject is not a child of the caller");return this.children[t]},i.prototype.removeChild=function(t){var e=arguments.length;if(e>1)for(var r=0;r0&&o<=s){for(r=this.children.splice(n,o),i=0;i=0;i--){var n=r[i];n.parent=null,n.destroy(t)}}},{"../utils":116,"./DisplayObject":46}],46:[function(t,e,r){function i(){n.call(this);var t=s.TRANSFORM_MODE.DEFAULT===s.TRANSFORM_MODE.STATIC?o:a;this.transform=new t,this.alpha=1,this.visible=!0,this.renderable=!0,this.parent=null,this.worldAlpha=1,this.filterArea=null,this._filters=null,this._enabledFilters=null,this._bounds=new h,this._boundsID=0,this._lastBoundsID=-1,this._boundsRect=null,this._localBoundsRect=null,this._mask=null}var n=t("eventemitter3"),s=t("../const"),o=t("./TransformStatic"),a=t("./Transform"),h=t("./Bounds"),u=t("../math"),l=new i;i.prototype=Object.create(n.prototype),i.prototype.constructor=i,e.exports=i,Object.defineProperties(i.prototype,{x:{get:function(){return this.position.x},set:function(t){this.transform.position.x=t}},y:{get:function(){return this.position.y},set:function(t){this.transform.position.y=t}},worldTransform:{get:function(){return this.transform.worldTransform}},localTransform:{get:function(){return this.transform.localTransform}},position:{get:function(){return this.transform.position},set:function(t){this.transform.position.copy(t)}},scale:{get:function(){return this.transform.scale},set:function(t){this.transform.scale.copy(t)}},pivot:{get:function(){return this.transform.pivot},set:function(t){this.transform.pivot.copy(t)}},skew:{get:function(){return this.transform.skew},set:function(t){this.transform.skew.copy(t)}},rotation:{get:function(){return this.transform.rotation},set:function(t){this.transform.rotation=t}},worldVisible:{get:function(){var t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}},mask:{get:function(){return this._mask},set:function(t){this._mask&&(this._mask.renderable=!0),this._mask=t,this._mask&&(this._mask.renderable=!1)}},filters:{get:function(){return this._filters&&this._filters.slice()},set:function(t){this._filters=t&&t.slice()}}}),i.prototype.updateTransform=function(){this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha,this._bounds.updateID++},i.prototype.displayObjectUpdateTransform=i.prototype.updateTransform,i.prototype._recursivePostUpdateTransform=function(){this.parent?(this.parent._recursivePostUpdateTransform(),this.transform.updateTransform(this.parent.transform)):this.transform.updateTransform(l.transform)},i.prototype.getBounds=function(t,e){return t||(this.parent?(this._recursivePostUpdateTransform(),this.updateTransform()):(this.parent=l,this.parent.transform._worldID++,this.updateTransform(),this.parent=null)),this._boundsID!==this._lastBoundsID&&this.calculateBounds(),e||(this._boundsRect||(this._boundsRect=new u.Rectangle),e=this._boundsRect),this._bounds.getRectangle(e)},i.prototype.getLocalBounds=function(t){var e=this.transform,r=this.parent;this.parent=null,this.transform=l.transform,t||(this._localBoundsRect||(this._localBoundsRect=new u.Rectangle),t=this._localBoundsRect);var i=this.getBounds(!1,t);return this.parent=r,this.transform=e,i},i.prototype.toGlobal=function(t,e,r){return r||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=l,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.apply(t,e)},i.prototype.toLocal=function(t,e,r,i){return e&&(t=e.toGlobal(t,r,i)),i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=l,this.displayObjectUpdateTransform(),this.parent=null)),this.worldTransform.applyInverse(t,r)},i.prototype.renderWebGL=function(t){},i.prototype.renderCanvas=function(t){},i.prototype.setParent=function(t){if(!t||!t.addChild)throw new Error("setParent: Argument must be a Container");return t.addChild(this),t},i.prototype.setTransform=function(t,e,r,i,n,s,o,a,h){return this.position.x=t||0,this.position.y=e||0,this.scale.x=r?r:1,this.scale.y=i?i:1,this.rotation=n||0,this.skew.x=s||0,this.skew.y=o||0,this.pivot.x=a||0,this.pivot.y=h||0,this},i.prototype.destroy=function(){this.removeAllListeners(),this.parent&&this.parent.removeChild(this),this.transform=null,this.parent=null,this._bounds=null,this._currentBounds=null,this._mask=null,this.filterArea=null,this.interactive=!1,this.interactiveChildren=!1}},{"../const":43,"../math":67,"./Bounds":44,"./Transform":47,"./TransformStatic":49,eventemitter3:3}],47:[function(t,e,r){function i(){s.call(this),this.position=new n.Point(0,0),this.scale=new n.Point(1,1),this.skew=new n.ObservablePoint(this.updateSkew,this,0,0),this.pivot=new n.Point(0,0),this._rotation=0,this._sr=Math.sin(0),this._cr=Math.cos(0),this._cy=Math.cos(0),this._sy=Math.sin(0),this._nsx=Math.sin(0),this._cx=Math.cos(0)}var n=t("../math"),s=t("./TransformBase");i.prototype=Object.create(s.prototype),i.prototype.constructor=i,i.prototype.updateSkew=function(){this._cy=Math.cos(this.skew.y),this._sy=Math.sin(this.skew.y),this._nsx=Math.sin(this.skew.x),this._cx=Math.cos(this.skew.x)},i.prototype.updateLocalTransform=function(){var t,e,r,i,n=this.localTransform;t=this._cr*this.scale.x,e=this._sr*this.scale.x,r=-this._sr*this.scale.y,i=this._cr*this.scale.y,n.a=this._cy*t+this._sy*r,n.b=this._cy*e+this._sy*i,n.c=this._nsx*t+this._cx*r,n.d=this._nsx*e+this._cx*i},i.prototype.updateTransform=function(t){var e,r,i,n,s=t.worldTransform,o=this.worldTransform,a=this.localTransform;e=this._cr*this.scale.x,r=this._sr*this.scale.x,i=-this._sr*this.scale.y,n=this._cr*this.scale.y,a.a=this._cy*e+this._sy*i,a.b=this._cy*r+this._sy*n,a.c=this._nsx*e+this._cx*i,a.d=this._nsx*r+this._cx*n,a.tx=this.position.x-(this.pivot.x*a.a+this.pivot.y*a.c),a.ty=this.position.y-(this.pivot.x*a.b+this.pivot.y*a.d),o.a=a.a*s.a+a.b*s.c,o.b=a.a*s.b+a.b*s.d,o.c=a.c*s.a+a.d*s.c,o.d=a.c*s.b+a.d*s.d,o.tx=a.tx*s.a+a.ty*s.c+s.tx,o.ty=a.tx*s.b+a.ty*s.d+s.ty,this._worldID++},i.prototype.setFromMatrix=function(t){t.decompose(this)},Object.defineProperties(i.prototype,{rotation:{get:function(){return this._rotation},set:function(t){this._rotation=t,this._sr=Math.sin(t),this._cr=Math.cos(t)}}}),e.exports=i},{"../math":67,"./TransformBase":48}],48:[function(t,e,r){function i(){this.worldTransform=new n.Matrix,this.localTransform=new n.Matrix,this._worldID=0}var n=t("../math");i.prototype.constructor=i,i.prototype.updateLocalTransform=function(){},i.prototype.updateTransform=function(t){var e=t.worldTransform,r=this.worldTransform,i=this.localTransform;r.a=i.a*e.a+i.b*e.c,r.b=i.a*e.b+i.b*e.d,r.c=i.c*e.a+i.d*e.c,r.d=i.c*e.b+i.d*e.d,r.tx=i.tx*e.a+i.ty*e.c+e.tx,r.ty=i.tx*e.b+i.ty*e.d+e.ty,this._worldID++},i.prototype.updateWorldTransform=i.prototype.updateTransform,i.IDENTITY=new i,e.exports=i},{"../math":67}],49:[function(t,e,r){function i(){s.call(this),this.position=new n.ObservablePoint(this.onChange,this,0,0),this.scale=new n.ObservablePoint(this.onChange,this,1,1),this.pivot=new n.ObservablePoint(this.onChange,this,0,0),this.skew=new n.ObservablePoint(this.updateSkew,this,0,0),this._rotation=0,this._sr=Math.sin(0),this._cr=Math.cos(0),this._cy=Math.cos(0),this._sy=Math.sin(0),this._nsx=Math.sin(0),this._cx=Math.cos(0),this._localID=0,this._currentLocalID=0}var n=t("../math"),s=t("./TransformBase");i.prototype=Object.create(s.prototype),i.prototype.constructor=i,i.prototype.onChange=function(){this._localID++},i.prototype.updateSkew=function(){this._cy=Math.cos(this.skew._y),this._sy=Math.sin(this.skew._y),this._nsx=Math.sin(this.skew._x),this._cx=Math.cos(this.skew._x),this._localID++},i.prototype.updateLocalTransform=function(){var t=this.localTransform;if(this._localID!==this._currentLocalID){var e,r,i,n;e=this._cr*this.scale._x,r=this._sr*this.scale._x,i=-this._sr*this.scale._y,n=this._cr*this.scale._y,t.a=this._cy*e+this._sy*i,t.b=this._cy*r+this._sy*n,t.c=this._nsx*e+this._cx*i,t.d=this._nsx*r+this._cx*n,t.tx=this.position._x-(this.pivot._x*t.a+this.pivot._y*t.c),t.ty=this.position._y-(this.pivot._x*t.b+this.pivot._y*t.d),this._currentLocalID=this._localID,this._parentID=-1}},i.prototype.updateTransform=function(t){var e=t.worldTransform,r=this.worldTransform,i=this.localTransform;if(this._localID!==this._currentLocalID){var n,s,o,a;n=this._cr*this.scale._x,s=this._sr*this.scale._x,o=-this._sr*this.scale._y,a=this._cr*this.scale._y,i.a=this._cy*n+this._sy*o,i.b=this._cy*s+this._sy*a,i.c=this._nsx*n+this._cx*o,i.d=this._nsx*s+this._cx*a,i.tx=this.position._x-(this.pivot._x*i.a+this.pivot._y*i.c),i.ty=this.position._y-(this.pivot._x*i.b+this.pivot._y*i.d),this._currentLocalID=this._localID,this._parentID=-1}this._parentID!==t._worldID&&(r.a=i.a*e.a+i.b*e.c,r.b=i.a*e.b+i.b*e.d,r.c=i.c*e.a+i.d*e.c,r.d=i.c*e.b+i.d*e.d,r.tx=i.tx*e.a+i.ty*e.c+e.tx,r.ty=i.tx*e.b+i.ty*e.d+e.ty,this._parentID=t._worldID,this._worldID++)},i.prototype.setFromMatrix=function(t){t.decompose(this),this._localID++},Object.defineProperties(i.prototype,{rotation:{get:function(){return this._rotation},set:function(t){this._rotation=t,this._sr=Math.sin(t),this._cr=Math.cos(t),this._localID++}}}),e.exports=i},{"../math":67,"./TransformBase":48}],50:[function(t,e,r){function i(){s.call(this),this.fillAlpha=1,this.lineWidth=0,this.lineColor=0,this.graphicsData=[],this.tint=16777215,this._prevTint=16777215,this.blendMode=c.BLEND_MODES.NORMAL,this.currentPath=null,this._webGL={},this.isMask=!1,this.boundsPadding=0,this._localBounds=new p,this.dirty=0,this.fastRectDirty=-1,this.clearDirty=0,this.boundsDirty=-1,this.cachedSpriteDirty=!1,this._spriteRect=null,this._fastRect=!1}var n,s=t("../display/Container"),o=t("../textures/RenderTexture"),a=t("../textures/Texture"),h=t("./GraphicsData"),u=t("../sprites/Sprite"),l=t("../math"),c=t("../const"),d=t("../utils"),p=t("../display/Bounds"),f=t("./utils/bezierCurveTo"),v=t("../renderers/canvas/CanvasRenderer"),g=new l.Matrix,y=new l.Point,x=new Float32Array(4),m=new Float32Array(4);i._SPRITE_TEXTURE=null,i.prototype=Object.create(s.prototype),i.prototype.constructor=i,e.exports=i,i.prototype.clone=function(){var t=new i;t.renderable=this.renderable,t.fillAlpha=this.fillAlpha,t.lineWidth=this.lineWidth,t.lineColor=this.lineColor,t.tint=this.tint,t.blendMode=this.blendMode,t.isMask=this.isMask,t.boundsPadding=this.boundsPadding,t.dirty=0,t.cachedSpriteDirty=this.cachedSpriteDirty;for(var e=0;ec*h)}return this.dirty++,this},i.prototype.arc=function(t,e,r,i,n,s){if(s=s||!1,i===n)return this;!s&&n<=i?n+=2*Math.PI:s&&i<=n&&(i+=2*Math.PI);var o=s?(i-n)*-1:n-i,a=40*Math.ceil(Math.abs(o)/(2*Math.PI));if(0===o)return this;var h=t+Math.cos(i)*r,u=e+Math.sin(i)*r;this.currentPath?this.currentPath.shape.points.push(h,u):this.moveTo(h,u);for(var l=this.currentPath.shape.points,c=o/(2*a),d=2*c,p=Math.cos(c),f=Math.sin(c),v=a-1,g=v%1/v,y=0;y<=v;y++){var x=y+g*y,m=c+i+d*x,_=Math.cos(m),b=-Math.sin(m);l.push((p*_+f*b)*r+t,(p*-b+f*_)*r+e)}return this.dirty++,this},i.prototype.beginFill=function(t,e){return this.filling=!0,this.fillColor=t||0,this.fillAlpha=void 0===e?1:e,this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this},i.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},i.prototype.drawRect=function(t,e,r,i){return this.drawShape(new l.Rectangle(t,e,r,i)),this},i.prototype.drawRoundedRect=function(t,e,r,i,n){return this.drawShape(new l.RoundedRectangle(t,e,r,i,n)),this},i.prototype.drawCircle=function(t,e,r){return this.drawShape(new l.Circle(t,e,r)),this},i.prototype.drawEllipse=function(t,e,r,i){return this.drawShape(new l.Ellipse(t,e,r,i)),this},i.prototype.drawPolygon=function(t){var e=t,r=!0;if(e instanceof l.Polygon&&(r=e.closed,e=e.points),!Array.isArray(e)){e=new Array(arguments.length);for(var i=0;ie?o+h:e,r=ai?a+u:i;else if(p===c.SHAPES.CIRC)o=n.x,a=n.y,h=n.radius+f/2,u=n.radius+f/2,t=o-he?o+h:e,r=a-ui?a+u:i;else if(p===c.SHAPES.ELIP)o=n.x,a=n.y,h=n.width+f/2,u=n.height+f/2,t=o-he?o+h:e,r=a-ui?a+u:i;else{s=n.points;for(var v=0;ve?o+f:e,r=a-fi?a+f:i}}else t=0,e=0,r=0,i=0;var g=this.boundsPadding;this._localBounds.minX=t-g,this._localBounds.maxX=e+2*g,this._localBounds.minY=r-g,this._localBounds.maxY=i+2*g},i.prototype.drawShape=function(t){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null;var e=new h(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,t);return this.graphicsData.push(e),e.type===c.SHAPES.POLY&&(e.shape.closed=e.shape.closed||this.filling,this.currentPath=e),this.dirty++,e},i.prototype.generateCanvasTexture=function(t,e){e=e||1;var r=this.getLocalBounds(),i=new o.create(r.width*e,r.height*e);n||(n=new v),g.tx=-r.x,g.ty=-r.y,n.render(this,i,!1,g);var s=a.fromCanvas(i.baseTexture._canvasRenderTarget.canvas,t);return s.baseTexture.resolution=e,s},i.prototype.closePath=function(){var t=this.currentPath;return t&&t.shape&&t.shape.close(),this},i.prototype.addHole=function(){var t=this.graphicsData.pop();return this.currentPath=this.graphicsData[this.graphicsData.length-1],this.currentPath.addHole(t.shape),this.currentPath=null,this},i.prototype.destroy=function(){s.prototype.destroy.apply(this,arguments);for(var t=0;tO?O:A,r.beginPath(),r.moveTo(S,C+A),r.lineTo(S,C+M-A),r.quadraticCurveTo(S,C+M,S+A,C+M),r.lineTo(S+R-A,C+M),r.quadraticCurveTo(S+R,C+M,S+R,C+M-A),r.lineTo(S+R,C+A),r.quadraticCurveTo(S+R,C,S+R-A,C),r.lineTo(S+A,C),r.quadraticCurveTo(S,C,S,C+A),r.closePath(),(h.fillColor||0===h.fillColor)&&(r.globalAlpha=h.fillAlpha*i,r.fillStyle="#"+("00000"+(0|l).toString(16)).substr(-6),r.fill()),h.lineWidth&&(r.globalAlpha=h.lineAlpha*i,r.strokeStyle="#"+("00000"+(0|c).toString(16)).substr(-6),r.stroke())}}},i.prototype.updateGraphicsTint=function(t){t._prevTint=t.tint;for(var e=(t.tint>>16&255)/255,r=(t.tint>>8&255)/255,i=(255&t.tint)/255,n=0;n>16&255)/255*e*255<<16)+((o>>8&255)/255*r*255<<8)+(255&o)/255*i*255,s._lineTint=((a>>16&255)/255*e*255<<16)+((a>>8&255)/255*r*255<<8)+(255&a)/255*i*255}},i.prototype.renderPolygon=function(t,e,r){r.moveTo(t[0],t[1]);for(var i=1;i32e4)&&(r=this.graphicsDataPool.pop()||new h(this.renderer.gl,this.primitiveShader,this.renderer.state.attribsState),r.reset(e),t.data.push(r)),r.dirty=!0,r}},{"../../const":43,"../../renderers/webgl/WebGLRenderer":81,"../../renderers/webgl/utils/ObjectRenderer":91,"../../utils":116,"./WebGLGraphicsData":55,"./shaders/PrimitiveShader":56,"./utils/buildCircle":57,"./utils/buildPoly":59,"./utils/buildRectangle":60,"./utils/buildRoundedRectangle":61}],55:[function(t,e,r){function i(t,e,r){this.gl=t,this.color=[0,0,0],this.points=[],this.indices=[],this.buffer=n.GLBuffer.createVertexBuffer(t),this.indexBuffer=n.GLBuffer.createIndexBuffer(t),this.dirty=!0,this.glPoints=null,this.glIndices=null,this.shader=e,this.vao=new n.VertexArrayObject(t,r).addIndex(this.indexBuffer).addAttribute(this.buffer,e.attributes.aVertexPosition,t.FLOAT,!1,24,0).addAttribute(this.buffer,e.attributes.aColor,t.FLOAT,!1,24,8)}var n=t("pixi-gl-core");i.prototype.constructor=i,e.exports=i,i.prototype.reset=function(){this.points.length=0,this.indices.length=0},i.prototype.upload=function(){this.glPoints=new Float32Array(this.points),this.buffer.upload(this.glPoints),this.glIndices=new Uint16Array(this.indices),this.indexBuffer.upload(this.glIndices),this.dirty=!1},i.prototype.destroy=function(){this.color=null,this.points=null,this.indices=null,this.vao.destroy(),this.buffer.destroy(),this.indexBuffer.destroy(),this.gl=null,this.buffer=null,this.indexBuffer=null,this.glPoints=null,this.glIndices=null}},{"pixi-gl-core":12}],56:[function(t,e,r){function i(t){n.call(this,t,["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform mat3 projectionMatrix;","uniform float alpha;","uniform vec3 tint;","varying vec4 vColor;","void main(void){"," gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"].join("\n"),["varying vec4 vColor;","void main(void){"," gl_FragColor = vColor;","}"].join("\n"))}var n=t("../../../Shader");i.prototype=Object.create(n.prototype),i.prototype.constructor=i,e.exports=i},{"../../../Shader":42}],57:[function(t,e,r){var i=t("./buildLine"),n=t("../../../const"),s=t("../../../utils"),o=function(t,e){var r,o,a=t.shape,h=a.x,u=a.y;t.type===n.SHAPES.CIRC?(r=a.radius,o=a.radius):(r=a.width,o=a.height);var l=Math.floor(30*Math.sqrt(a.radius))||Math.floor(15*Math.sqrt(a.width+a.height)),c=2*Math.PI/l,d=0;if(t.fill){var p=s.hex2rgb(t.fillColor),f=t.fillAlpha,v=p[0]*f,g=p[1]*f,y=p[2]*f,x=e.points,m=e.indices,_=x.length/6;for(m.push(_),d=0;d19600?(T=x-_,E=m-b,P=Math.sqrt(T*T+E*E),T/=P,E/=P,T*=U,E*=U,I.push(f-T,v-E),I.push(W,G,X,j),I.push(f+T,v+E),I.push(W,G,X,j),I.push(f-T,v-E),I.push(W,G,X,j),B++):(I.push(l,c),I.push(W,G,X,j),I.push(f-(l-f),v-(c-v)),I.push(W,G,X,j)));for(d=s[2*(F-2)],p=s[2*(F-2)+1],f=s[2*(F-1)],v=s[2*(F-1)+1],x=-(p-v),m=d-f,P=Math.sqrt(x*x+m*m),x/=P,m/=P,x*=U,m*=U,I.push(f-x,v-m),I.push(W,G,X,j),I.push(f+x,v+m),I.push(W,G,X,j),L.push(N),r=0;r=6){for(var o=[],a=t.holes,h=0;h0&&i(t,e)};e.exports=o},{"../../../utils":116,"./buildLine":58,earcut:2}],60:[function(t,e,r){var i=t("./buildLine"),n=t("../../../utils"),s=function(t,e){var r=t.shape,s=r.x,o=r.y,a=r.width,h=r.height;if(t.fill){var u=n.hex2rgb(t.fillColor),l=t.fillAlpha,c=u[0]*l,d=u[1]*l,p=u[2]*l,f=e.points,v=e.indices,g=f.length/6;f.push(s,o),f.push(c,d,p,l),f.push(s+a,o),f.push(c,d,p,l),f.push(s,o+h),f.push(c,d,p,l),f.push(s+a,o+h),f.push(c,d,p,l),v.push(g,g,g+1,g+2,g+3,g+3)}if(t.lineWidth){var y=t.points;t.points=[s,o,s+a,o,s+a,o+h,s,o+h,s,o],i(t,e),t.points=y}};e.exports=s},{"../../../utils":116,"./buildLine":58}],61:[function(t,e,r){var i=t("earcut"),n=t("./buildLine"),s=t("../../../utils"),o=function(t,e){var r=t.shape,o=r.x,h=r.y,u=r.width,l=r.height,c=r.radius,d=[];if(d.push(o,h+c),a(o,h+l-c,o,h+l,o+c,h+l,d),a(o+u-c,h+l,o+u,h+l,o+u,h+l-c,d),a(o+u,h+c,o+u,h,o+u-c,h,d),a(o+c,h,o,h,o,h+c+1e-10,d),t.fill){var p=s.hex2rgb(t.fillColor),f=t.fillAlpha,v=p[0]*f,g=p[1]*f,y=p[2]*f,x=e.points,m=e.indices,_=x.length/6,b=i(d,null,2),T=0;for(T=0;T0?1:0}function n(){for(var t=0;t<16;t++){var e=[];c.push(e);for(var r=0;r<16;r++)for(var n=i(s[t]*s[r]+a[t]*o[r]),d=i(o[t]*s[r]+h[t]*o[r]),p=i(s[t]*a[r]+a[t]*h[r]),f=i(o[t]*a[r]+h[t]*h[r]),v=0;v<16;v++)if(s[v]===n&&o[v]===d&&a[v]===p&&h[v]===f){e.push(v);break}}for(t=0;t<16;t++){var g=new l;g.set(s[t],o[t],a[t],h[t],0,0),u.push(g)}}var s=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],o=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],a=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],h=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],u=[],l=t("./Matrix"),c=[];n();var d={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MIRROR_HORIZONTAL:12,uX:function(t){return s[t]},uY:function(t){return o[t]},vX:function(t){return a[t]},vY:function(t){return h[t]},inv:function(t){return 8&t?15&t:7&-t},add:function(t,e){return c[t][e]},sub:function(t,e){return c[t][d.inv(e)]},rotate180:function(t){return 4^t},isSwapWidthHeight:function(t){return 2===(3&t)},byDirection:function(t,e){return 2*Math.abs(t)<=Math.abs(e)?e>=0?d.S:d.N:2*Math.abs(e)<=Math.abs(t)?t>0?d.E:d.W:e>0?t>0?d.SE:d.SW:t>0?d.NE:d.NW},matrixAppendRotationInv:function(t,e,r,i){var n=u[d.inv(e)];r=r||0,i=i||0,n.tx=r,n.ty=i,t.append(n)}};e.exports=d},{"./Matrix":64}],64:[function(t,e,r){function i(){this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this.array=null}var n=t("./Point");i.prototype.constructor=i,e.exports=i,i.prototype.fromArray=function(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]},i.prototype.set=function(t,e,r,i,n,s){return this.a=t,this.b=e,this.c=r,this.d=i,this.tx=n,this.ty=s,this},i.prototype.toArray=function(t,e){this.array||(this.array=new Float32Array(9));var r=e||this.array;return t?(r[0]=this.a,r[1]=this.b,r[2]=0,r[3]=this.c,r[4]=this.d,r[5]=0,r[6]=this.tx,r[7]=this.ty,r[8]=1):(r[0]=this.a,r[1]=this.c,r[2]=this.tx,r[3]=this.b,r[4]=this.d,r[5]=this.ty,r[6]=0,r[7]=0,r[8]=1),r},i.prototype.apply=function(t,e){e=e||new n;var r=t.x,i=t.y;return e.x=this.a*r+this.c*i+this.tx,e.y=this.b*r+this.d*i+this.ty,e},i.prototype.applyInverse=function(t,e){e=e||new n;var r=1/(this.a*this.d+this.c*-this.b),i=t.x,s=t.y;return e.x=this.d*r*i+-this.c*r*s+(this.ty*this.c-this.tx*this.d)*r,e.y=this.a*r*s+-this.b*r*i+(-this.ty*this.a+this.tx*this.b)*r,e},i.prototype.translate=function(t,e){return this.tx+=t,this.ty+=e,this},i.prototype.scale=function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},i.prototype.rotate=function(t){var e=Math.cos(t),r=Math.sin(t),i=this.a,n=this.c,s=this.tx;return this.a=i*e-this.b*r,this.b=i*r+this.b*e,this.c=n*e-this.d*r,this.d=n*r+this.d*e,this.tx=s*e-this.ty*r,this.ty=s*r+this.ty*e,this},i.prototype.append=function(t){var e=this.a,r=this.b,i=this.c,n=this.d;return this.a=t.a*e+t.b*i,this.b=t.a*r+t.b*n,this.c=t.c*e+t.d*i,this.d=t.c*r+t.d*n,this.tx=t.tx*e+t.ty*i+this.tx,this.ty=t.tx*r+t.ty*n+this.ty,this},i.prototype.setTransform=function(t,e,r,i,n,s,o,a,h){var u,l,c,d,p,f,v,g,y,x;return p=Math.sin(o),f=Math.cos(o),v=Math.cos(h),g=Math.sin(h),y=-Math.sin(a),x=Math.cos(a),u=f*n,l=p*n,c=-p*s,d=f*s,this.a=v*u+g*c,this.b=v*l+g*d,this.c=y*u+x*c,this.d=y*l+x*d,this.tx=t+(r*u+i*c),this.ty=e+(r*l+i*d),this},i.prototype.prepend=function(t){var e=this.tx;if(1!==t.a||0!==t.b||0!==t.c||1!==t.d){var r=this.a,i=this.c;this.a=r*t.a+this.b*t.c,this.b=r*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this},i.prototype.decompose=function(t){var e=this.a,r=this.b,i=this.c,n=this.d,s=Math.atan2(-i,n),o=Math.atan2(r,e),a=Math.abs(1-s/o);return a<1e-5?(t.rotation=o,e<0&&n>=0&&(t.rotation+=t.rotation<=0?Math.PI:-Math.PI),t.skew.x=t.skew.y=0):(t.skew.x=s,t.skew.y=o),t.scale.x=Math.sqrt(e*e+r*r),t.scale.y=Math.sqrt(i*i+n*n),t.position.x=this.tx,t.position.y=this.ty,t},i.prototype.invert=function(){var t=this.a,e=this.b,r=this.c,i=this.d,n=this.tx,s=t*i-e*r;return this.a=i/s,this.b=-e/s,this.c=-r/s,this.d=t/s,this.tx=(r*this.ty-i*n)/s,this.ty=-(t*this.ty-e*n)/s,this},i.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},i.prototype.clone=function(){var t=new i;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t},i.prototype.copy=function(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t},i.IDENTITY=new i,i.TEMP_MATRIX=new i},{"./Point":66}],65:[function(t,e,r){function i(t,e,r,i){this._x=r||0,this._y=i||0,this.cb=t,this.scope=e}i.prototype.constructor=i,e.exports=i,Object.defineProperties(i.prototype,{x:{get:function(){return this._x},set:function(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}},y:{get:function(){return this._y},set:function(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}}}),i.prototype.set=function(t,e){var r=t||0,i=e||(0!==e?r:0);this._x===r&&this._y===i||(this._x=r,this._y=i,this.cb.call(this.scope))},i.prototype.copy=function(t){this._x===t.x&&this._y===t.y||(this._x=t.x,this._y=t.y,this.cb.call(this.scope))}},{}],66:[function(t,e,r){function i(t,e){this.x=t||0,this.y=e||0}i.prototype.constructor=i,e.exports=i,i.prototype.clone=function(){return new i(this.x,this.y)},i.prototype.copy=function(t){this.set(t.x,t.y)},i.prototype.equals=function(t){return t.x===this.x&&t.y===this.y},i.prototype.set=function(t,e){this.x=t||0,this.y=e||(0!==e?this.x:0)}},{}],67:[function(t,e,r){e.exports={Point:t("./Point"),ObservablePoint:t("./ObservablePoint"),Matrix:t("./Matrix"),GroupD8:t("./GroupD8"),Circle:t("./shapes/Circle"),Ellipse:t("./shapes/Ellipse"),Polygon:t("./shapes/Polygon"),Rectangle:t("./shapes/Rectangle"),RoundedRectangle:t("./shapes/RoundedRectangle")}},{"./GroupD8":63,"./Matrix":64,"./ObservablePoint":65,"./Point":66,"./shapes/Circle":68,"./shapes/Ellipse":69,"./shapes/Polygon":70,"./shapes/Rectangle":71,"./shapes/RoundedRectangle":72}],68:[function(t,e,r){function i(t,e,r){this.x=t||0,this.y=e||0,this.radius=r||0,this.type=s.SHAPES.CIRC}var n=t("./Rectangle"),s=t("../../const");i.prototype.constructor=i,e.exports=i,i.prototype.clone=function(){return new i(this.x,this.y,this.radius)},i.prototype.contains=function(t,e){if(this.radius<=0)return!1;var r=this.x-t,i=this.y-e,n=this.radius*this.radius;return r*=r,i*=i,r+i<=n},i.prototype.getBounds=function(){return new n(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius)}},{"../../const":43,"./Rectangle":71}],69:[function(t,e,r){function i(t,e,r,i){this.x=t||0,this.y=e||0,this.width=r||0,this.height=i||0,this.type=s.SHAPES.ELIP}var n=t("./Rectangle"),s=t("../../const");i.prototype.constructor=i,e.exports=i,i.prototype.clone=function(){return new i(this.x,this.y,this.width,this.height)},i.prototype.contains=function(t,e){if(this.width<=0||this.height<=0)return!1;var r=(t-this.x)/this.width,i=(e-this.y)/this.height;return r*=r,i*=i,r+i<=1},i.prototype.getBounds=function(){return new n(this.x-this.width,this.y-this.height,this.width,this.height)}},{"../../const":43,"./Rectangle":71}],70:[function(t,e,r){function i(t){var e=t;if(!Array.isArray(e)){e=new Array(arguments.length);for(var r=0;re!=u>e&&t<(h-o)*(e-a)/(u-a)+o;l&&(r=!r)}return r}},{"../../const":43,"../Point":66}],71:[function(t,e,r){function i(t,e,r,i){this.x=t||0,this.y=e||0,this.width=r||0,this.height=i||0,this.type=n.SHAPES.RECT}var n=t("../../const");i.prototype.constructor=i,e.exports=i,Object.defineProperties(i.prototype,{left:{get:function(){return this.x}},right:{get:function(){return this.x+this.width}},top:{get:function(){return this.y}},bottom:{get:function(){return this.y+this.height}}}),i.EMPTY=new i(0,0,0,0),i.prototype.clone=function(){return new i(this.x,this.y,this.width,this.height)},i.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this},i.prototype.contains=function(t,e){return!(this.width<=0||this.height<=0)&&(t>=this.x&&t=this.y&&et.x+t.width&&(this.width=t.width-this.x,this.width<0&&(this.width=0)),this.y+this.height>t.y+t.height&&(this.height=t.height-this.y,this.height<0&&(this.height=0))},i.prototype.enlarge=function(t){if(t!==i.EMPTY){var e=Math.min(this.x,t.x),r=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),s=Math.max(this.y+this.height,t.y+t.height);this.x=e,this.width=r-e,this.y=n,this.height=s-n}}},{"../../const":43}],72:[function(t,e,r){function i(t,e,r,i,s){this.x=t||0,this.y=e||0,this.width=r||0,this.height=i||0,this.radius=s||20,this.type=n.SHAPES.RREC}var n=t("../../const");i.prototype.constructor=i,e.exports=i,i.prototype.clone=function(){return new i(this.x,this.y,this.width,this.height,this.radius)},i.prototype.contains=function(t,e){return!(this.width<=0||this.height<=0)&&(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height)}},{"../../const":43}],73:[function(t,e,r){function i(t,e,r,i){if(u.call(this),n.sayHello(t),i)for(var s in o.DEFAULT_RENDER_OPTIONS)"undefined"==typeof i[s]&&(i[s]=o.DEFAULT_RENDER_OPTIONS[s]);else i=o.DEFAULT_RENDER_OPTIONS;this.type=o.RENDERER_TYPE.UNKNOWN,this.width=e||800,this.height=r||600,this.view=i.view||document.createElement("canvas"),this.resolution=i.resolution,this.transparent=i.transparent,this.autoResize=i.autoResize||!1,this.blendModes=null,this.preserveDrawingBuffer=i.preserveDrawingBuffer,this.clearBeforeRender=i.clearBeforeRender,this.roundPixels=i.roundPixels,this._backgroundColor=0,this._backgroundColorRgba=[0,0,0,0],this._backgroundColorString="#000000",this.backgroundColor=i.backgroundColor||this._backgroundColor,this._tempDisplayObjectParent=new a,this._lastObjectRendered=this._tempDisplayObjectParent}var n=t("../utils"),s=t("../math"),o=t("../const"),a=t("../display/Container"),h=t("../textures/RenderTexture"),u=t("eventemitter3"),l=new s.Matrix;i.prototype=Object.create(u.prototype),i.prototype.constructor=i,e.exports=i,Object.defineProperties(i.prototype,{backgroundColor:{get:function(){return this._backgroundColor},set:function(t){this._backgroundColor=t,this._backgroundColorString=n.hex2string(t),n.hex2rgb(t,this._backgroundColorRgba)}}}),i.prototype.resize=function(t,e){this.width=t*this.resolution,this.height=e*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px")},i.prototype.generateTexture=function(t,e,r){var i=t.getLocalBounds(),n=h.create(0|i.width,0|i.height,e,r);return l.tx=-i.x,l.ty=-i.y,this.render(t,n,!1,l,!0),n},i.prototype.destroy=function(t){t&&this.view.parentNode&&this.view.parentNode.removeChild(this.view),this.type=o.RENDERER_TYPE.UNKNOWN,this.width=0,this.height=0,this.view=null,this.resolution=0,this.transparent=!1,this.autoResize=!1,this.blendModes=null,this.preserveDrawingBuffer=!1,this.clearBeforeRender=!1,this.roundPixels=!1,this._backgroundColor=0,this._backgroundColorRgba=null,this._backgroundColorString=null,this.backgroundColor=0,this._tempDisplayObjectParent=null,this._lastObjectRendered=null}},{"../const":43,"../display/Container":45,"../math":67,"../textures/RenderTexture":108,"../utils":116,eventemitter3:3}],74:[function(t,e,r){function i(t,e,r){r=r||{},n.call(this,"Canvas",t,e,r),this.type=u.RENDERER_TYPE.CANVAS,this.rootContext=this.view.getContext("2d",{alpha:this.transparent}),this.rootResolution=this.resolution,this.refresh=!0,this.maskManager=new s(this),this.smoothProperty="imageSmoothingEnabled",this.rootContext.imageSmoothingEnabled||(this.rootContext.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":this.rootContext.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":this.rootContext.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":this.rootContext.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")),this.initPlugins(),this.blendModes=a(),this._activeBlendMode=null,this.context=null,this.renderingToScreen=!1,this.resize(t,e)}var n=t("../SystemRenderer"),s=t("./utils/CanvasMaskManager"),o=t("./utils/CanvasRenderTarget"),a=t("./utils/mapCanvasBlendModesToPixi"),h=t("../../utils"),u=t("../../const");i.prototype=Object.create(n.prototype),i.prototype.constructor=i,e.exports=i,h.pluginTarget.mixin(i),i.prototype.render=function(t,e,r,i,n){if(this.view){this.renderingToScreen=!e,this.emit("prerender"),e?(e=e.baseTexture||e,e._canvasRenderTarget||(e._canvasRenderTarget=new o(e.width,e.height,e.resolution),e.source=e._canvasRenderTarget.canvas,e.valid=!0),this.context=e._canvasRenderTarget.context,this.resolution=e._canvasRenderTarget.resolution):(this.context=this.rootContext,this.resolution=this.rootResolution);var s=this.context;if(e||(this._lastObjectRendered=t),!n){var a=t.parent,h=this._tempDisplayObjectParent.transform.worldTransform;i?i.copy(h):h.identity(),t.parent=this._tempDisplayObjectParent,t.updateTransform(),t.parent=a}s.setTransform(1,0,0,1,0,0),s.globalAlpha=1,s.globalCompositeOperation=this.blendModes[u.BLEND_MODES.NORMAL],navigator.isCocoonJS&&this.view.screencanvas&&(s.fillStyle="black",s.clear()),(void 0!==r?r:this.clearBeforeRender)&&this.renderingToScreen&&(this.transparent?s.clearRect(0,0,this.width,this.height):(s.fillStyle=this._backgroundColorString,s.fillRect(0,0,this.width,this.height)));var l=this.context;this.context=s,t.renderCanvas(this),this.context=l,this.emit("postrender")}},i.prototype.setBlendMode=function(t){this._activeBlendMode!==t&&(this.context.globalCompositeOperation=this.blendModes[t])},i.prototype.destroy=function(t){this.destroyPlugins(),n.prototype.destroy.call(this,t),this.context=null,this.refresh=!0,this.maskManager.destroy(),this.maskManager=null,this.smoothProperty=null},i.prototype.resize=function(t,e){n.prototype.resize.call(this,t,e),this.smoothProperty&&(this.rootContext[this.smoothProperty]=u.SCALE_MODES.DEFAULT===u.SCALE_MODES.LINEAR)}},{"../../const":43,"../../utils":116,"../SystemRenderer":73,"./utils/CanvasMaskManager":75,"./utils/CanvasRenderTarget":76,"./utils/mapCanvasBlendModesToPixi":78}],75:[function(t,e,r){function i(t){this.renderer=t}var n=t("../../../const");i.prototype.constructor=i,e.exports=i,i.prototype.pushMask=function(t){var e=this.renderer;e.context.save();var r=t.alpha,i=t.transform.worldTransform,n=e.resolution;e.context.setTransform(i.a*n,i.b*n,i.c*n,i.d*n,i.tx*n,i.ty*n),t._texture||(this.renderGraphicsShape(t),e.context.clip()),t.worldAlpha=r},i.prototype.renderGraphicsShape=function(t){var e=this.renderer.context,r=t.graphicsData.length;if(0!==r){e.beginPath();for(var i=0;iS?S:w,e.moveTo(_,b+w),e.lineTo(_,b+E-w),e.quadraticCurveTo(_,b+E,_+w,b+E),e.lineTo(_+T-w,b+E),e.quadraticCurveTo(_+T,b+E,_+T,b+E-w),e.lineTo(_+T,b+w),e.quadraticCurveTo(_+T,b,_+T-w,b),e.lineTo(_+w,b),e.quadraticCurveTo(_,b,_,b+w),e.closePath()}}}},i.prototype.popMask=function(t){t.context.restore()},i.prototype.destroy=function(){}},{"../../../const":43}],76:[function(t,e,r){function i(t,e,r){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.resolution=r||n.RESOLUTION,this.resize(t,e)}var n=t("../../../const");i.prototype.constructor=i,e.exports=i,Object.defineProperties(i.prototype,{width:{get:function(){return this.canvas.width},set:function(t){this.canvas.width=t}},height:{get:function(){return this.canvas.height},set:function(t){this.canvas.height=t}}}),i.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)},i.prototype.resize=function(t,e){this.canvas.width=t*this.resolution,this.canvas.height=e*this.resolution},i.prototype.destroy=function(){this.context=null,this.canvas=null}},{"../../../const":43}],77:[function(t,e,r){var i=function(t){var e=document.createElement("canvas");e.width=6,e.height=1;var r=e.getContext("2d");return r.fillStyle=t,r.fillRect(0,0,6,1),e},n=function(){if("undefined"==typeof document)return!1;var t=i("#ff00ff"),e=i("#ffff00"),r=document.createElement("canvas");r.width=6,r.height=1;var n=r.getContext("2d");n.globalCompositeOperation="multiply",n.drawImage(t,0,0),n.drawImage(e,2,0);var s=n.getImageData(2,0,1,1);if(!s)return!1;var o=s.data;return 255===o[0]&&0===o[1]&&0===o[2]};e.exports=n},{}],78:[function(t,e,r){function i(t){return t=t||[],s()?(t[n.BLEND_MODES.NORMAL]="source-over",t[n.BLEND_MODES.ADD]="lighter",t[n.BLEND_MODES.MULTIPLY]="multiply",t[n.BLEND_MODES.SCREEN]="screen",t[n.BLEND_MODES.OVERLAY]="overlay",t[n.BLEND_MODES.DARKEN]="darken",t[n.BLEND_MODES.LIGHTEN]="lighten",t[n.BLEND_MODES.COLOR_DODGE]="color-dodge",t[n.BLEND_MODES.COLOR_BURN]="color-burn",t[n.BLEND_MODES.HARD_LIGHT]="hard-light",t[n.BLEND_MODES.SOFT_LIGHT]="soft-light",t[n.BLEND_MODES.DIFFERENCE]="difference",t[n.BLEND_MODES.EXCLUSION]="exclusion",t[n.BLEND_MODES.HUE]="hue",t[n.BLEND_MODES.SATURATION]="saturate",t[n.BLEND_MODES.COLOR]="color",t[n.BLEND_MODES.LUMINOSITY]="luminosity"):(t[n.BLEND_MODES.NORMAL]="source-over",t[n.BLEND_MODES.ADD]="lighter",t[n.BLEND_MODES.MULTIPLY]="source-over",t[n.BLEND_MODES.SCREEN]="source-over",t[n.BLEND_MODES.OVERLAY]="source-over",t[n.BLEND_MODES.DARKEN]="source-over",t[n.BLEND_MODES.LIGHTEN]="source-over",t[n.BLEND_MODES.COLOR_DODGE]="source-over",t[n.BLEND_MODES.COLOR_BURN]="source-over",t[n.BLEND_MODES.HARD_LIGHT]="source-over",t[n.BLEND_MODES.SOFT_LIGHT]="source-over",t[n.BLEND_MODES.DIFFERENCE]="source-over",t[n.BLEND_MODES.EXCLUSION]="source-over",t[n.BLEND_MODES.HUE]="source-over",t[n.BLEND_MODES.SATURATION]="source-over",t[n.BLEND_MODES.COLOR]="source-over",t[n.BLEND_MODES.LUMINOSITY]="source-over"),t}var n=t("../../../const"),s=t("./canUseNewCanvasBlendModes");e.exports=i},{"../../../const":43,"./canUseNewCanvasBlendModes":77}],79:[function(t,e,r){function i(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=3600,this.checkCountMax=600,this.mode=n.GC_MODES.DEFAULT}var n=t("../../const");i.prototype.constructor=i,e.exports=i,i.prototype.update=function(){this.count++,this.mode!==n.GC_MODES.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run()))},i.prototype.run=function(){var t,e,r=this.renderer.textureManager,i=r._managedTextures,n=!1;for(t=0;tthis.maxIdle&&(r.destroyTexture(s,!0),i[t]=null,n=!0)}if(n){for(e=0,t=0;t=0;r--)this.unload(t.children[r])}},{"../../const":43}],80:[function(t,e,r){var i=t("pixi-gl-core").GLTexture,n=t("../../const"),s=t("./utils/RenderTarget"),o=t("../../utils"),a=function(t){this.renderer=t,this.gl=t.gl,this._managedTextures=[]};a.prototype.bindTexture=function(){},a.prototype.getTexture=function(){},a.prototype.updateTexture=function(t){t=t.baseTexture||t;var e=!!t._glRenderTargets;if(t.hasLoaded){var r=t._glTextures[this.renderer.CONTEXT_UID];if(r)e?t._glRenderTargets[this.renderer.CONTEXT_UID].resize(t.width,t.height):r.upload(t.source);else{if(e){var o=new s(this.gl,t.width,t.height,t.scaleMode,t.resolution);o.resize(t.width,t.height),t._glRenderTargets[this.renderer.CONTEXT_UID]=o,r=o.texture}else r=new i(this.gl),r.premultiplyAlpha=!0,r.upload(t.source);t._glTextures[this.renderer.CONTEXT_UID]=r,t.on("update",this.updateTexture,this),t.on("dispose",this.destroyTexture,this),this._managedTextures.push(t),t.isPowerOfTwo?(t.mipmap&&r.enableMipmap(),t.wrapMode===n.WRAP_MODES.CLAMP?r.enableWrapClamp():t.wrapMode===n.WRAP_MODES.REPEAT?r.enableWrapRepeat():r.enableWrapMirrorRepeat()):r.enableWrapClamp(),t.scaleMode===n.SCALE_MODES.NEAREST?r.enableNearestScaling():r.enableLinearScaling()}return r}},a.prototype.destroyTexture=function(t,e){if(t=t.baseTexture||t,t.hasLoaded&&t._glTextures[this.renderer.CONTEXT_UID]&&(t._glTextures[this.renderer.CONTEXT_UID].destroy(),t.off("update",this.updateTexture,this),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.renderer.CONTEXT_UID],!e)){var r=this._managedTextures.indexOf(t);r!==-1&&o.removeItems(this._managedTextures,r,1)}},a.prototype.removeAll=function(){for(var t=0;t 0.5)"," {"," color = vec4(1.0, 0.0, 0.0, 1.0);"," }"," else"," {"," color = vec4(0.0, 1.0, 0.0, 1.0);"," }"," gl_FragColor = mix(sample, masky, 0.5);"," gl_FragColor *= sample.a;","}"].join("\n")},{"../../../const":43,"../../../utils":116,"./extractUniformsFromSrc":84}],84:[function(t,e,r){function i(t,e,r){var i=n(t,r),s=n(e,r);return Object.assign(i,s)}function n(t){for(var e,r=new RegExp("^(projectionMatrix|uSampler|filterArea)$"),i={},n=t.replace(/\s+/g," ").split(/\s*;\s*/),o=0;o-1){var h=a.split(" "),u=h[1],l=h[2],c=1;l.indexOf("[")>-1&&(e=l.split(/\[|\]/),l=e[0],c*=Number(e[1])),l.match(r)||(i[l]={value:s(u,c),name:l,type:u})}}return i}var s=t("pixi-gl-core").shader.defaultValue;e.exports=i},{"pixi-gl-core":12}],85:[function(t,e,r){var i=t("../../../math"),n=function(t,e,r){var i=t.identity();return i.translate(e.x/r.width,e.y/r.height),i.scale(r.width,r.height),i},s=function(t,e,r){var i=t.identity();i.translate(e.x/r.width,e.y/r.height);var n=r.width/e.width,s=r.height/e.height;return i.scale(n,s),i},o=function(t,e,r,n){var s=n.worldTransform.copy(i.Matrix.TEMP_MATRIX),o=n._texture.baseTexture,a=t.identity(),h=r.height/r.width;a.translate(e.x/r.width,e.y/r.height),a.scale(1,h);var u=r.width/o.width,l=r.height/o.height;return s.tx/=o.width*u,s.ty/=o.width*u,s.invert(),a.prepend(s),a.scale(1,1/h),a.scale(u,l),a.translate(n.anchor.x,n.anchor.y),a};e.exports={calculateScreenSpaceMatrix:n,calculateNormalizedScreenSpaceMatrix:s,calculateSpriteMatrix:o}},{"../../../math":67}],86:[function(t,e,r){function i(t){var e=new s.Matrix;n.call(this,"#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 otherMatrix;\n\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;\n}\n","#define GLSLIFY 1\nvarying vec2 vMaskCoord;\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform float alpha;\nuniform sampler2D mask;\n\nvoid main(void)\n{\n // check clip! this will stop the mask bleeding out from the edges\n vec2 text = abs( vMaskCoord - 0.5 );\n text = step(0.5, text);\n float clip = 1.0 - max(text.y, text.x);\n vec4 original = texture2D(uSampler, vTextureCoord);\n vec4 masky = texture2D(mask, vMaskCoord);\n original *= (masky.r * masky.a * alpha * clip);\n gl_FragColor = original;\n}\n"),t.renderable=!1,this.maskSprite=t,this.maskMatrix=e}var n=t("../Filter"),s=t("../../../../math");i.prototype=Object.create(n.prototype),i.prototype.constructor=i,e.exports=i,i.prototype.apply=function(t,e,r){var i=this.maskSprite;this.uniforms.mask=i._texture,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,i),this.uniforms.alpha=i.worldAlpha,t.applyFilter(this,e,r)}},{"../../../../math":67,"../Filter":83}],87:[function(t,e,r){function i(t){n.call(this,t),this.gl=this.renderer.gl,this.quad=new o(this.gl,t.state.attribState),this.shaderCache={},this.pool={},this.filterData=null}var n=t("./WebGLManager"),s=t("../utils/RenderTarget"),o=t("../utils/Quad"),a=t("../../../math"),h=t("../../../Shader"),u=t("../filters/filterTransforms"),l=t("bit-twiddle"),c=function(){this.renderTarget=null,this.sourceFrame=new a.Rectangle,this.destinationFrame=new a.Rectangle,this.filters=[],this.target=null,this.resolution=1};i.prototype=Object.create(n.prototype),i.prototype.constructor=i,e.exports=i,i.prototype.pushFilter=function(t,e){var r=this.renderer,i=this.filterData;if(!i){i=this.renderer._activeRenderTarget.filterStack;var n=new c;n.sourceFrame=n.destinationFrame=this.renderer._activeRenderTarget.size,n.renderTarget=r._activeRenderTarget,this.renderer._activeRenderTarget.filterData=i={index:0,stack:[n]},this.filterData=i}var s=i.stack[++i.index];s||(s=i.stack[i.index]=new c);var o=e[0].resolution,a=e[0].padding,h=t.filterArea||t.getBounds(!0),u=s.sourceFrame,l=s.destinationFrame;u.x=(h.x*o|0)/o,u.y=(h.y*o|0)/o,u.width=(h.width*o|0)/o,u.height=(h.height*o|0)/o,i.stack[0].renderTarget.transform||u.fit(i.stack[0].destinationFrame),u.pad(a),l.width=u.width,l.height=u.height;var d=this.getPotRenderTarget(r.gl,u.width,u.height,o);s.target=t,s.filters=e,s.resolution=o,s.renderTarget=d,d.setFrame(l,u),r.bindRenderTarget(d),r.clear()},i.prototype.popFilter=function(){var t=this.filterData,e=t.stack[t.index-1],r=t.stack[t.index];this.quad.map(r.renderTarget.size,r.sourceFrame).upload();var i=r.filters;if(1===i.length)i[0].apply(this,r.renderTarget,e.renderTarget,!1),this.freePotRenderTarget(r.renderTarget);else{var n=r.renderTarget,s=this.getPotRenderTarget(this.renderer.gl,r.sourceFrame.width,r.sourceFrame.height,1);s.setFrame(r.destinationFrame,r.sourceFrame);for(var o=0;o0&&(e+="\nelse "),r>16)+(65280&t)+((255&t)<<16)}},texture:{get:function(){return this._texture},set:function(t){this._texture!==t&&(this._texture=t,this.cachedTint=16777215,this._textureID=-1,t&&(t.baseTexture.hasLoaded?this._onTextureUpdate():t.once("update",this._onTextureUpdate,this)))}}}),i.prototype._onTextureUpdate=function(){this._textureID=-1,this._width&&(this.scale.x=a.sign(this.scale.x)*this._width/this.texture.orig.width),this._height&&(this.scale.y=a.sign(this.scale.y)*this._height/this.texture.orig.height)},i.prototype.onAnchorUpdate=function(){this._transformID=-1},i.prototype.calculateVertices=function(){if(this._transformID!==this.transform._worldID||this._textureID!==this._texture._updateID){this._transformID=this.transform._worldID,this._textureID=this._texture._updateID;var t,e,r,i,n=this._texture,s=this.transform.worldTransform,o=s.a,a=s.b,h=s.c,u=s.d,l=s.tx,c=s.ty,d=this.vertexData,p=n.trim,f=n.orig;p?(e=p.x-this.anchor._x*f.width,t=e+p.width,i=p.y-this.anchor._y*f.height,r=i+p.height):(t=f.width*(1-this.anchor._x),e=f.width*-this.anchor._x,r=f.height*(1-this.anchor._y),i=f.height*-this.anchor._y),d[0]=o*e+h*i+l,d[1]=u*i+a*e+c,d[2]=o*t+h*i+l,d[3]=u*i+a*t+c,d[4]=o*t+h*r+l,d[5]=u*r+a*t+c,d[6]=o*e+h*r+l,d[7]=u*r+a*e+c}},i.prototype.calculateTrimmedVertices=function(){this.vertexTrimmedData||(this.vertexTrimmedData=new Float32Array(8));var t,e,r,i,n=this._texture,s=this.vertexTrimmedData,o=n.orig,a=this.transform.worldTransform,h=a.a,u=a.b,l=a.c,c=a.d,d=a.tx,p=a.ty;t=o.width*(1-this.anchor._x),e=o.width*-this.anchor._x,r=o.height*(1-this.anchor._y),i=o.height*-this.anchor._y,s[0]=h*e+l*i+d,s[1]=c*i+u*e+p,s[2]=h*t+l*i+d,s[3]=c*i+u*t+p,s[4]=h*t+l*r+d,s[5]=c*r+u*t+p,s[6]=h*e+l*r+d,s[7]=c*r+u*e+p},i.prototype._renderWebGL=function(t){this.calculateVertices(),t.setObjectRenderer(t.plugins.sprite),t.plugins.sprite.render(this)},i.prototype._renderCanvas=function(t){t.plugins.sprite.render(this)},i.prototype._calculateBounds=function(){var t=this._texture.trim,e=this._texture.orig;!t||t.width===e.width&&t.height===e.height?(this.calculateVertices(),this._bounds.addQuad(this.vertexData)):(this.calculateTrimmedVertices(),this._bounds.addQuad(this.vertexTrimmedData))},i.prototype.getLocalBounds=function(t){return 0===this.children.length?(this._bounds.minX=-this._texture.orig.width*this.anchor._x,this._bounds.minY=-this._texture.orig.height*this.anchor._y,this._bounds.maxX=this._texture.orig.width,this._bounds.maxY=this._texture.orig.height,t||(this._localBoundsRect||(this._localBoundsRect=new n.Rectangle),t=this._localBoundsRect),this._bounds.getRectangle(t)):o.prototype.getLocalBounds.call(this,t)},i.prototype.containsPoint=function(t){this.worldTransform.applyInverse(t,u);var e,r=this._texture.orig.width,i=this._texture.orig.height,n=-r*this.anchor.x;return u.x>n&&u.xe&&u.y=this.size&&this.flush(),t.texture._uvs&&(this.sprites[this.currentIndex++]=t)},i.prototype.flush=function(){if(0!==this.currentIndex){var t,e,r,i,n,s,o,h=this.renderer.gl,u=d.nextPow2(this.currentIndex),l=d.log2(u),f=this.buffers[l],v=this.sprites,g=this.groups,y=f.float32View,x=f.uint32View,m=0,_=1,b=0,T=g[0],E=v[0].blendMode;T.textureCount=0,T.start=0,T.blend=E,p++;for(var w=0;w0&&(e+="\nelse "),r0?(this.context.shadowColor=e.dropShadowColor,this.context.shadowBlur=e.dropShadowBlur):this.context.fillStyle=e.dropShadowColor;var v=Math.cos(e.dropShadowAngle)*e.dropShadowDistance,g=Math.sin(e.dropShadowAngle)*e.dropShadowDistance;for(i=0;io;h--){for(u=0;ui)for(var u=o[a].split(""),l=0;ls?(e+="\n"+u[l],s=i-c):(0===l&&(e+=" "),e+=u[l],s-=c)}else{var d=h+this.context.measureText(" ").width;0===a||d>s?(a>0&&(e+="\n"),e+=o[a],s=i-h):(s-=d,e+=" "+o[a])}}n0&&e>0,this.width=t,this.height=e,this.realWidth=this.width*this.resolution,this.realHeight=this.height*this.resolution,this.valid&&this.emit("update",this))},i.prototype.destroy=function(){n.prototype.destroy.call(this,!0),this.renderer=null}},{"../const":43,"./BaseTexture":107}],107:[function(t,e,r){function i(t,e,r){o.call(this), +this.uid=n.uid(),this.touched=0,this.resolution=r||s.RESOLUTION,this.width=100,this.height=100,this.realWidth=100,this.realHeight=100,this.scaleMode=e||s.SCALE_MODES.DEFAULT,this.hasLoaded=!1,this.isLoading=!1,this.source=null,this.premultipliedAlpha=!0,this.imageUrl=null,this.isPowerOfTwo=!1,this.mipmap=s.MIPMAP_TEXTURES,this.wrapMode=s.WRAP_MODES.DEFAULT,this._glTextures=[],this._enabled=0,this._id=0,t&&this.loadSource(t)}var n=t("../utils"),s=t("../const"),o=t("eventemitter3"),a=t("../utils/determineCrossOrigin"),h=t("bit-twiddle");i.prototype=Object.create(o.prototype),i.prototype.constructor=i,e.exports=i,i.prototype.update=function(){this.realWidth=this.source.naturalWidth||this.source.videoWidth||this.source.width,this.realHeight=this.source.naturalHeight||this.source.videoHeight||this.source.height,this.width=this.realWidth/this.resolution,this.height=this.realHeight/this.resolution,this.isPowerOfTwo=h.isPow2(this.realWidth)&&h.isPow2(this.realHeight),this.emit("update",this)},i.prototype.loadSource=function(t){var e=this.isLoading;if(this.hasLoaded=!1,this.isLoading=!1,e&&this.source&&(this.source.onload=null,this.source.onerror=null),this.source=t,(this.source.complete||this.source.getContext)&&this.source.width&&this.source.height)this._sourceLoaded();else if(!t.getContext){this.isLoading=!0;var r=this;t.onload=function(){t.onload=null,t.onerror=null,r.isLoading&&(r.isLoading=!1,r._sourceLoaded(),r.emit("loaded",r))},t.onerror=function(){t.onload=null,t.onerror=null,r.isLoading&&(r.isLoading=!1,r.emit("error",r))},t.complete&&t.src&&(this.isLoading=!1,t.onload=null,t.onerror=null,t.width&&t.height?(this._sourceLoaded(),e&&this.emit("loaded",this)):e&&this.emit("error",this))}},i.prototype._sourceLoaded=function(){this.hasLoaded=!0,this.update()},i.prototype.destroy=function(){this.imageUrl?(delete n.BaseTextureCache[this.imageUrl],delete n.TextureCache[this.imageUrl],this.imageUrl=null,navigator.isCocoonJS||(this.source.src="")):this.source&&this.source._pixiId&&delete n.BaseTextureCache[this.source._pixiId],this.source=null,this.dispose()},i.prototype.dispose=function(){this.emit("dispose",this)},i.prototype.updateSourceImage=function(t){this.source.src=t,this.loadSource(this.source)},i.fromImage=function(t,e,r){var s=n.BaseTextureCache[t];if(!s){var o=new Image;void 0===e&&0!==t.indexOf("data:")&&(o.crossOrigin=a(t)),s=new i(o,r),s.imageUrl=t,o.src=t,n.BaseTextureCache[t]=s,s.resolution=n.getResolutionOfUrl(t)}return s},i.fromCanvas=function(t,e){t._pixiId||(t._pixiId="canvas_"+n.uid());var r=n.BaseTextureCache[t._pixiId];return r||(r=new i(t,e),n.BaseTextureCache[t._pixiId]=r),r}},{"../const":43,"../utils":116,"../utils/determineCrossOrigin":115,"bit-twiddle":1,eventemitter3:3}],108:[function(t,e,r){function i(t,e){if(this.legacyRenderer=null,!(t instanceof n)){var r=arguments[1],i=arguments[2],o=arguments[3]||0,a=arguments[4]||1;console.warn("v4 RenderTexture now expects a new BaseRenderTexture. Please use RenderTexture.create("+r+", "+i+")"),this.legacyRenderer=arguments[0],e=null,t=new n(r,i,o,a)}s.call(this,t,e),this.valid=!0,this._updateUvs()}var n=t("./BaseRenderTexture"),s=t("./Texture");i.prototype=Object.create(s.prototype),i.prototype.constructor=i,e.exports=i,i.prototype.resize=function(t,e,r){this.valid=t>0&&e>0,this._frame.width=this.orig.width=t,this._frame.height=this.orig.height=e,r||this.baseTexture.resize(t,e),this._updateUvs()},i.create=function(t,e,r,s){return new i(new n(t,e,r,s))}},{"./BaseRenderTexture":106,"./Texture":109}],109:[function(t,e,r){function i(t,e,r,n,s){if(a.call(this),this.noFrame=!1,e||(this.noFrame=!0,e=new h.Rectangle(0,0,1,1)),t instanceof i&&(t=t.baseTexture),this.baseTexture=t,this._frame=e,this.trim=n,this.valid=!1,this.requiresUpdate=!1,this._uvs=null,this.orig=r||e,this._rotate=+(s||0),s===!0)this._rotate=2;else if(this._rotate%2!==0)throw"attempt to use diamond-shaped UVs. If you are sure, set rotation manually";t.hasLoaded?(this.noFrame&&(e=new h.Rectangle(0,0,t.width,t.height),t.on("update",this.onBaseTextureUpdated,this)),this.frame=e):t.once("loaded",this.onBaseTextureLoaded,this),this._updateID=0}var n=t("./BaseTexture"),s=t("./VideoBaseTexture"),o=t("./TextureUvs"),a=t("eventemitter3"),h=t("../math"),u=t("../utils");i.prototype=Object.create(a.prototype),i.prototype.constructor=i,e.exports=i,Object.defineProperties(i.prototype,{frame:{get:function(){return this._frame},set:function(t){if(this._frame=t,this.noFrame=!1,t.x+t.width>this.baseTexture.width||t.y+t.height>this.baseTexture.height)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.valid=t&&t.width&&t.height&&this.baseTexture.hasLoaded,this.trim||this.rotate||(this.orig=t),this.valid&&this._updateUvs()}},rotate:{get:function(){return this._rotate},set:function(t){this._rotate=t,this.valid&&this._updateUvs()}},width:{get:function(){return this.orig?this.orig.width:0}},height:{get:function(){return this.orig?this.orig.height:0}}}),i.prototype.update=function(){this.baseTexture.update()},i.prototype.onBaseTextureLoaded=function(t){this._updateID++,this.noFrame?this.frame=new h.Rectangle(0,0,t.width,t.height):this.frame=this._frame,this.baseTexture.on("update",this.onBaseTextureUpdated,this),this.emit("update",this)},i.prototype.onBaseTextureUpdated=function(t){this._updateID++,this._frame.width=t.width,this._frame.height=t.height,this.emit("update",this)},i.prototype.destroy=function(t){this.baseTexture&&(t&&(u.TextureCache[this.baseTexture.imageUrl]&&delete u.TextureCache[this.baseTexture.imageUrl],this.baseTexture.destroy()),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture.off("loaded",this.onBaseTextureLoaded,this),this.baseTexture=null),this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,this.off("dispose",this.dispose,this),this.off("update",this.update,this)},i.prototype.clone=function(){return new i(this.baseTexture,this.frame,this.orig,this.trim,this.rotate)},i.prototype._updateUvs=function(){this._uvs||(this._uvs=new o),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++},i.fromImage=function(t,e,r){var s=u.TextureCache[t];return s||(s=new i(n.fromImage(t,e,r)),u.TextureCache[t]=s),s},i.fromFrame=function(t){var e=u.TextureCache[t];if(!e)throw new Error('The frameId "'+t+'" does not exist in the texture cache');return e},i.fromCanvas=function(t,e){return new i(n.fromCanvas(t,e))},i.fromVideo=function(t,e){return"string"==typeof t?i.fromVideoUrl(t,e):new i(s.fromVideo(t,e))},i.fromVideoUrl=function(t,e){return new i(s.fromUrl(t,e))},i.from=function(t){if("string"==typeof t){var e=u.TextureCache[t];if(!e){var r=null!==t.match(/\.(mp4|webm|ogg|h264|avi|mov)$/);return r?i.fromVideoUrl(t):i.fromImage(t)}return e}return t instanceof HTMLCanvasElement?i.fromCanvas(t):t instanceof HTMLVideoElement?i.fromVideo(t):t instanceof n?new i(n):t},i.addTextureToCache=function(t,e){u.TextureCache[e]=t},i.removeTextureFromCache=function(t){var e=u.TextureCache[t];return delete u.TextureCache[t],delete u.BaseTextureCache[t],e},i.EMPTY=new i(new n),i.EMPTY.destroy=function(){},i.EMPTY.on=function(){},i.EMPTY.once=function(){},i.EMPTY.emit=function(){}},{"../math":67,"../utils":116,"./BaseTexture":107,"./TextureUvs":110,"./VideoBaseTexture":111,eventemitter3:3}],110:[function(t,e,r){function i(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsUint32=new Uint32Array(4)}e.exports=i;var n=t("../math/GroupD8");i.prototype.set=function(t,e,r){var i=e.width,s=e.height;if(r){var o=t.width/2/i,a=t.height/2/s,h=t.x/i+o,u=t.y/s+a;r=n.add(r,n.NW),this.x0=h+o*n.uX(r),this.y0=u+a*n.uY(r),r=n.add(r,2),this.x1=h+o*n.uX(r),this.y1=u+a*n.uY(r),r=n.add(r,2),this.x2=h+o*n.uX(r),this.y2=u+a*n.uY(r),r=n.add(r,2),this.x3=h+o*n.uX(r),this.y3=u+a*n.uY(r)}else this.x0=t.x/i,this.y0=t.y/s,this.x1=(t.x+t.width)/i,this.y1=t.y/s,this.x2=(t.x+t.width)/i,this.y2=(t.y+t.height)/s,this.x3=t.x/i,this.y3=(t.y+t.height)/s;this.uvsUint32[0]=(65535*this.y0&65535)<<16|65535*this.x0&65535,this.uvsUint32[1]=(65535*this.y1&65535)<<16|65535*this.x1&65535,this.uvsUint32[2]=(65535*this.y2&65535)<<16|65535*this.x2&65535,this.uvsUint32[3]=(65535*this.y3&65535)<<16|65535*this.x3&65535}},{"../math/GroupD8":63}],111:[function(t,e,r){function i(t,e){if(!t)throw new Error("No video source element specified.");(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),s.call(this,t,e),this.autoUpdate=!1,this._onUpdate=this._onUpdate.bind(this),this._onCanPlay=this._onCanPlay.bind(this),t.complete||(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("play",this._onPlayStart.bind(this)),t.addEventListener("pause",this._onPlayStop.bind(this))),this.__loaded=!1}function n(t,e){e||(e="video/"+t.substr(t.lastIndexOf(".")+1));var r=document.createElement("source");return r.src=t,r.type=e,r}var s=t("./BaseTexture"),o=t("../utils");i.prototype=Object.create(s.prototype),i.prototype.constructor=i,e.exports=i,i.prototype._onUpdate=function(){this.autoUpdate&&(window.requestAnimationFrame(this._onUpdate),this.update())},i.prototype._onPlayStart=function(){this.hasLoaded||this._onCanPlay(),this.autoUpdate||(window.requestAnimationFrame(this._onUpdate),this.autoUpdate=!0)},i.prototype._onPlayStop=function(){this.autoUpdate=!1},i.prototype._onCanPlay=function(){this.hasLoaded=!0,this.source&&(this.source.removeEventListener("canplay",this._onCanPlay),this.source.removeEventListener("canplaythrough",this._onCanPlay),this.width=this.source.videoWidth,this.height=this.source.videoHeight,this.source.play(),this.__loaded||(this.__loaded=!0,this.emit("loaded",this)))},i.prototype.destroy=function(){this.source&&this.source._pixiId&&(delete o.BaseTextureCache[this.source._pixiId],delete this.source._pixiId),s.prototype.destroy.call(this)},i.fromVideo=function(t,e){t._pixiId||(t._pixiId="video_"+o.uid());var r=o.BaseTextureCache[t._pixiId];return r||(r=new i(t,e),o.BaseTextureCache[t._pixiId]=r),r},i.fromUrl=function(t,e){var r=document.createElement("video");if(Array.isArray(t))for(var s=0;sthis.lastTime?(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),this.deltaTime=e*n.TARGET_FPMS*this.speed,this._emitter.emit(o,this.deltaTime)):this.deltaTime=this.elapsedMS=0,this.lastTime=t},e.exports=i},{"../const":43,eventemitter3:3}],113:[function(t,e,r){var i=t("./Ticker"),n=new i;n.autoStart=!0,e.exports={shared:n,Ticker:i}},{"./Ticker":112}],114:[function(t,e,r){var i=function(t){for(var e=6*t,r=new Uint16Array(e),i=0,n=0;i>16&255)/255,e[1]=(t>>8&255)/255,e[2]=(255&t)/255,e},hex2string:function(t){return t=t.toString(16),t="000000".substr(0,6-t.length)+t,"#"+t},rgb2hex:function(t){return(255*t[0]<<16)+(255*t[1]<<8)+255*t[2]},getResolutionOfUrl:function(t){var e=i.RETINA_PREFIX.exec(t);return e?parseFloat(e[1]):1},sayHello:function(t){if(!n._saidHello){if(navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var e=["\n %c %c %c Pixi.js "+i.VERSION+" - ✰ "+t+" ✰ %c %c http://www.pixijs.com/ %c %c ♥%c♥%c♥ \n\n","background: #ff66a5; padding:5px 0;","background: #ff66a5; padding:5px 0;","color: #ff66a5; background: #030307; padding:5px 0;","background: #ff66a5; padding:5px 0;","background: #ffc3dc; padding:5px 0;","background: #ff66a5; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;","color: #ff2424; background: #fff; padding:5px 0;"];window.console.log.apply(console,e)}else window.console&&window.console.log("Pixi.js "+i.VERSION+" - "+t+" - http://www.pixijs.com/");n._saidHello=!0}},isWebGLSupported:function(){var t={stencil:!0,failIfMajorPerformanceCaveat:!0};try{if(!window.WebGLRenderingContext)return!1;var e=document.createElement("canvas"),r=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),i=!(!r||!r.getContextAttributes().stencil);if(r){var n=r.getExtension("WEBGL_lose_context");n&&n.loseContext()}return r=null,i}catch(t){return!1}},sign:function(t){return t?t<0?-1:1:0},removeItems:function(t,e,r){var i=t.length;if(!(e>=i||0===r)){r=e+r>i?i-e:r;for(var n=e,s=i-r;n1?this._fontStyle="italic":t.indexOf("oblique")>-1?this._fontStyle="oblique":this._fontStyle="normal",t.indexOf("small-caps")>-1?this._fontVariant="small-caps":this._fontVariant="normal";var e,r=t.split(" "),i=-1;for(this._fontSize=26,e=0;e-1&&i=0?t:16777215,this.dirty=!0}},align:{get:function(){return this._font.align},set:function(t){this._font.align=t||"left",this.dirty=!0}},anchor:{get:function(){return this._anchor},set:function(t){"number"==typeof t?this._anchor.set(t):this._anchor.copy(t)}},font:{get:function(){return this._font},set:function(t){t&&("string"==typeof t?(t=t.split(" "),this._font.name=1===t.length?t[0]:t.slice(1).join(" "),this._font.size=t.length>=2?parseInt(t[0],10):i.fonts[this._font.name].size):(this._font.name=t.name,this._font.size="number"==typeof t.size?t.size:parseInt(t.size,10)),this.dirty=!0)}},text:{get:function(){return this._text},set:function(t){t=t.toString()||" ",this._text!==t&&(this._text=t,this.dirty=!0)}}}),i.prototype.updateText=function(){for(var t=i.fonts[this._font.name],e=new n.Point,r=null,s=[],o=0,a=0,h=[],u=0,l=this._font.size/t.size,c=-1,d=0,p=0,f=0;f0&&e.x*l>this.maxWidth)n.utils.removeItems(s,c,f-c),f=c,c=-1,h.push(d),a=Math.max(a,d),u++,e.x=0,e.y+=t.lineHeight,r=null;else{var g=t.chars[v];g&&(r&&g.kerning[r]&&(e.x+=g.kerning[r]),s.push({texture:g.texture,line:u,charCode:v,position:new n.Point(e.x+g.xOffset,e.y+g.yOffset)}),o=e.x+(g.texture.width+g.xOffset),e.x+=g.xAdvance,p=Math.max(p,g.yOffset+g.texture.height),r=v)}}h.push(o),a=Math.max(a,o);var y=[];for(f=0;f<=u;f++){var x=0;"right"===this._font.align?x=a-h[f]:"center"===this._font.align&&(x=(a-h[f])/2),y.push(x)}var m=s.length,_=this.tint;for(f=0;f=this._durations[this.currentFrame];)r-=this._durations[this.currentFrame]*i,this._currentTime+=i;this._currentTime+=r/this._durations[this.currentFrame]}else this._currentTime+=e;this._currentTime<0&&!this.loop?(this.gotoAndStop(0),this.onComplete&&this.onComplete()):this._currentTime>=this._textures.length&&!this.loop?(this.gotoAndStop(this._textures.length-1),this.onComplete&&this.onComplete()):(this._texture=this._textures[this.currentFrame],this._textureID=-1)},i.prototype.destroy=function(){this.stop(),n.Sprite.prototype.destroy.call(this)},i.fromFrames=function(t){for(var e=[],r=0;re?m:e,e=b>e?b:e,e=E>e?E:e,i=x,i=_>i?_:i,i=T>i?T:i,i=w>i?w:i;var S=this._bounds;return S.x=t,S.width=e-t,S.y=r,S.height=i-r,this._currentBounds=S,S},i.prototype.containsPoint=function(t){this.worldTransform.applyInverse(t,s);var e,r=this._width,i=this._height,n=-r*this.anchor.x;return s.x>n&&s.xe&&s.y=s&&(e=t-u-1),l=l.replace("%value%",r[e]),a+=l,a+="\n"}return o=o.replace("%blur%",a),o=o.replace("%size%",t)};e.exports=s},{}],135:[function(t,e,r){var i=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","uniform float strength;","uniform mat3 projectionMatrix;","varying vec2 vBlurTexCoords[%size%];","void main(void)","{","gl_Position = vec4((projectionMatrix * vec3((aVertexPosition), 1.0)).xy, 0.0, 1.0);","%blur%","}"].join("\n"),n=function(t,e){var r,n,s=Math.ceil(t/2),o=i,a="";r=e?"vBlurTexCoords[%index%] = aTextureCoord + vec2(%sampleIndex% * strength, 0.0);":"vBlurTexCoords[%index%] = aTextureCoord + vec2(0.0, %sampleIndex% * strength);";for(var h=0;h=s&&(n=t-h-1),u=u.replace("%sampleIndex%",h-(s-1)+".0"),a+=u,a+="\n"}return o=o.replace("%blur%",a),o=o.replace("%size%",t)};e.exports=n},{}],136:[function(t,e,r){var i=function(t){for(var e=t.getParameter(t.MAX_VARYING_VECTORS),r=15;r>e;)r-=2;return r};e.exports=i},{}],137:[function(t,e,r){function i(){n.Filter.call(this,"#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","#define GLSLIFY 1\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float m[20];\n\nvoid main(void)\n{\n\n vec4 c = texture2D(uSampler, vTextureCoord);\n\n gl_FragColor.r = (m[0] * c.r);\n gl_FragColor.r += (m[1] * c.g);\n gl_FragColor.r += (m[2] * c.b);\n gl_FragColor.r += (m[3] * c.a);\n gl_FragColor.r += m[4] * c.a;\n\n gl_FragColor.g = (m[5] * c.r);\n gl_FragColor.g += (m[6] * c.g);\n gl_FragColor.g += (m[7] * c.b);\n gl_FragColor.g += (m[8] * c.a);\n gl_FragColor.g += m[9] * c.a;\n\n gl_FragColor.b = (m[10] * c.r);\n gl_FragColor.b += (m[11] * c.g);\n gl_FragColor.b += (m[12] * c.b);\n gl_FragColor.b += (m[13] * c.a);\n gl_FragColor.b += m[14] * c.a;\n\n gl_FragColor.a = (m[15] * c.r);\n gl_FragColor.a += (m[16] * c.g);\n gl_FragColor.a += (m[17] * c.b);\n gl_FragColor.a += (m[18] * c.a);\n gl_FragColor.a += m[19] * c.a;\n\n// gl_FragColor = vec4(m[0]);\n}\n"),this.uniforms.m=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]}var n=t("../../core");i.prototype=Object.create(n.Filter.prototype),i.prototype.constructor=i,e.exports=i,i.prototype._loadMatrix=function(t,e){e=!!e;var r=t;e&&(this._multiply(r,this.uniforms.m,t),r=this._colorMatrix(r)),this.uniforms.m=r},i.prototype._multiply=function(t,e,r){return t[0]=e[0]*r[0]+e[1]*r[5]+e[2]*r[10]+e[3]*r[15],t[1]=e[0]*r[1]+e[1]*r[6]+e[2]*r[11]+e[3]*r[16],t[2]=e[0]*r[2]+e[1]*r[7]+e[2]*r[12]+e[3]*r[17],t[3]=e[0]*r[3]+e[1]*r[8]+e[2]*r[13]+e[3]*r[18],t[4]=e[0]*r[4]+e[1]*r[9]+e[2]*r[14]+e[3]*r[19],t[5]=e[5]*r[0]+e[6]*r[5]+e[7]*r[10]+e[8]*r[15],t[6]=e[5]*r[1]+e[6]*r[6]+e[7]*r[11]+e[8]*r[16],t[7]=e[5]*r[2]+e[6]*r[7]+e[7]*r[12]+e[8]*r[17],t[8]=e[5]*r[3]+e[6]*r[8]+e[7]*r[13]+e[8]*r[18],t[9]=e[5]*r[4]+e[6]*r[9]+e[7]*r[14]+e[8]*r[19],t[10]=e[10]*r[0]+e[11]*r[5]+e[12]*r[10]+e[13]*r[15],t[11]=e[10]*r[1]+e[11]*r[6]+e[12]*r[11]+e[13]*r[16],t[12]=e[10]*r[2]+e[11]*r[7]+e[12]*r[12]+e[13]*r[17],t[13]=e[10]*r[3]+e[11]*r[8]+e[12]*r[13]+e[13]*r[18],t[14]=e[10]*r[4]+e[11]*r[9]+e[12]*r[14]+e[13]*r[19],t[15]=e[15]*r[0]+e[16]*r[5]+e[17]*r[10]+e[18]*r[15],t[16]=e[15]*r[1]+e[16]*r[6]+e[17]*r[11]+e[18]*r[16],t[17]=e[15]*r[2]+e[16]*r[7]+e[17]*r[12]+e[18]*r[17],t[18]=e[15]*r[3]+e[16]*r[8]+e[17]*r[13]+e[18]*r[18],t[19]=e[15]*r[4]+e[16]*r[9]+e[17]*r[14]+e[18]*r[19],t},i.prototype._colorMatrix=function(t){var e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e},i.prototype.brightness=function(t,e){var r=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(r,e)},i.prototype.greyscale=function(t,e){var r=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(r,e)},i.prototype.grayscale=i.prototype.greyscale,i.prototype.blackAndWhite=function(t){var e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)},i.prototype.hue=function(t,e){t=(t||0)/180*Math.PI;var r=Math.cos(t),i=Math.sin(t),n=Math.sqrt,s=1/3,o=n(s),a=r+(1-r)*s,h=s*(1-r)-o*i,u=s*(1-r)+o*i,l=s*(1-r)+o*i,c=r+s*(1-r),d=s*(1-r)-o*i,p=s*(1-r)-o*i,f=s*(1-r)+o*i,v=r+s*(1-r),g=[a,h,u,0,0,l,c,d,0,0,p,f,v,0,0,0,0,0,1,0];this._loadMatrix(g,e)},i.prototype.contrast=function(t,e){var r=(t||0)+1,i=-128*(r-1),n=[r,0,0,0,i,0,r,0,0,i,0,0,r,0,i,0,0,0,1,0];this._loadMatrix(n,e)},i.prototype.saturate=function(t,e){var r=2*(t||0)/3+1,i=(r-1)*-.5,n=[r,i,i,0,0,i,r,i,0,0,i,i,r,0,0,0,0,0,1,0];this._loadMatrix(n,e)},i.prototype.desaturate=function(){this.saturate(-1)},i.prototype.negative=function(t){var e=[0,1,1,0,0,1,0,1,0,0,1,1,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)},i.prototype.sepia=function(t){var e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)},i.prototype.technicolor=function(t){var e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)},i.prototype.polaroid=function(t){var e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)},i.prototype.toBGR=function(t){var e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)},i.prototype.kodachrome=function(t){var e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)},i.prototype.browni=function(t){var e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)},i.prototype.vintage=function(t){var e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)},i.prototype.colorTone=function(t,e,r,i,n){t=t||.2,e=e||.15,r=r||16770432,i=i||3375104;var s=(r>>16&255)/255,o=(r>>8&255)/255,a=(255&r)/255,h=(i>>16&255)/255,u=(i>>8&255)/255,l=(255&i)/255,c=[.3,.59,.11,0,0,s,o,a,t,0,h,u,l,e,0,s-h,o-u,a-l,0,0];this._loadMatrix(c,n)},i.prototype.night=function(t,e){t=t||.1;var r=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,2*t,0,0,0,0,0,1,0];this._loadMatrix(r,e)},i.prototype.predator=function(t,e){var r=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(r,e)},i.prototype.lsd=function(t){var e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)},i.prototype.reset=function(){var t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)},Object.defineProperties(i.prototype,{matrix:{get:function(){return this.uniforms.m},set:function(t){this.uniforms.m=t}}})},{"../../core":62}],138:[function(t,e,r){function i(t,e){var r=new n.Matrix;t.renderable=!1,n.Filter.call(this,"#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\nuniform mat3 filterMatrix;\n\nvarying vec2 vTextureCoord;\nvarying vec2 vFilterCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vFilterCoord = ( filterMatrix * vec3( aTextureCoord, 1.0) ).xy;\n vTextureCoord = aTextureCoord;\n}","#define GLSLIFY 1\nvarying vec2 vFilterCoord;\nvarying vec2 vTextureCoord;\n\nuniform vec2 scale;\n\nuniform sampler2D uSampler;\nuniform sampler2D mapSampler;\n\nuniform vec4 filterClamp;\n\nvoid main(void)\n{\n vec4 map = texture2D(mapSampler, vFilterCoord);\n\n map -= 0.5;\n map.xy *= scale;\n\n gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), filterClamp.xy, filterClamp.zw));\n}\n"),this.maskSprite=t,this.maskMatrix=r,this.uniforms.mapSampler=t.texture,this.uniforms.filterMatrix=r.toArray(!0),this.uniforms.scale={x:1,y:1},null!==e&&void 0!==e||(e=20),this.scale=new n.Point(e,e)}var n=t("../../core");i.prototype=Object.create(n.Filter.prototype),i.prototype.constructor=i,e.exports=i,i.prototype.apply=function(t,e,r){var i=1/r.destinationFrame.width*(r.size.width/e.size.width);this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x*i,this.uniforms.scale.y=this.scale.y*i,t.applyFilter(this,e,r)},Object.defineProperties(i.prototype,{map:{get:function(){return this.uniforms.mapSampler},set:function(t){this.uniforms.mapSampler=t}}})},{"../../core":62}],139:[function(t,e,r){function i(){n.Filter.call(this,"#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nuniform vec4 filterArea;\n\nvarying vec2 vTextureCoord;\n\nvec2 mapCoord( vec2 coord )\n{\n coord *= filterArea.xy;\n coord += filterArea.zw;\n\n return coord;\n}\n\nvec2 unmapCoord( vec2 coord )\n{\n coord -= filterArea.zw;\n coord /= filterArea.xy;\n\n return coord;\n}\n\nvoid texcoords(vec2 fragCoord, vec2 resolution,\n out vec2 v_rgbNW, out vec2 v_rgbNE,\n out vec2 v_rgbSW, out vec2 v_rgbSE,\n out vec2 v_rgbM) {\n vec2 inverseVP = 1.0 / resolution.xy;\n v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;\n v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;\n v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;\n v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;\n v_rgbM = vec2(fragCoord * inverseVP);\n}\n\nvoid main(void) {\n\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n\n vTextureCoord = aTextureCoord;\n\n vec2 fragCoord = vTextureCoord * filterArea.xy;\n\n texcoords(fragCoord, filterArea.xy, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n}",'#define GLSLIFY 1\nvarying vec2 v_rgbNW;\nvarying vec2 v_rgbNE;\nvarying vec2 v_rgbSW;\nvarying vec2 v_rgbSE;\nvarying vec2 v_rgbM;\n\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform vec4 filterArea;\n\n/**\n Basic FXAA implementation based on the code on geeks3d.com with the\n modification that the texture2DLod stuff was removed since it\'s\n unsupported by WebGL.\n \n --\n \n From:\n https://github.com/mitsuhiko/webgl-meincraft\n \n Copyright (c) 2011 by Armin Ronacher.\n \n Some rights reserved.\n \n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are\n met:\n \n * Redistributions of source code must retain the above copyright\n notice, this list of conditions and the following disclaimer.\n \n * Redistributions in binary form must reproduce the above\n copyright notice, this list of conditions and the following\n disclaimer in the documentation and/or other materials provided\n with the distribution.\n \n * The names of the contributors may not be used to endorse or\n promote products derived from this software without specific\n prior written permission.\n \n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef FXAA_REDUCE_MIN\n#define FXAA_REDUCE_MIN (1.0/ 128.0)\n#endif\n#ifndef FXAA_REDUCE_MUL\n#define FXAA_REDUCE_MUL (1.0 / 8.0)\n#endif\n#ifndef FXAA_SPAN_MAX\n#define FXAA_SPAN_MAX 8.0\n#endif\n\n//optimized version for mobile, where dependent\n//texture reads can be a bottleneck\nvec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,\n vec2 v_rgbNW, vec2 v_rgbNE,\n vec2 v_rgbSW, vec2 v_rgbSE,\n vec2 v_rgbM) {\n vec4 color;\n mediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);\n vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;\n vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;\n vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;\n vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;\n vec4 texColor = texture2D(tex, v_rgbM);\n vec3 rgbM = texColor.xyz;\n vec3 luma = vec3(0.299, 0.587, 0.114);\n float lumaNW = dot(rgbNW, luma);\n float lumaNE = dot(rgbNE, luma);\n float lumaSW = dot(rgbSW, luma);\n float lumaSE = dot(rgbSE, luma);\n float lumaM = dot(rgbM, luma);\n float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n \n mediump vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n \n float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *\n (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n \n float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * inverseVP;\n \n vec3 rgbA = 0.5 * (\n texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n vec3 rgbB = rgbA * 0.5 + 0.25 * (\n texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +\n texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n \n float lumaB = dot(rgbB, luma);\n if ((lumaB < lumaMin) || (lumaB > lumaMax))\n color = vec4(rgbA, texColor.a);\n else\n color = vec4(rgbB, texColor.a);\n return color;\n}\n\nvoid main() {\n\n \tvec2 fragCoord = vTextureCoord * filterArea.xy;\n\n \tvec4 color;\n\n color = fxaa(uSampler, fragCoord, filterArea.xy, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);\n\n \tgl_FragColor = color;\n}\n')}var n=t("../../core");i.prototype=Object.create(n.Filter.prototype),i.prototype.constructor=i,e.exports=i},{"../../core":62}],140:[function(t,e,r){e.exports={FXAAFilter:t("./fxaa/FXAAFilter"),NoiseFilter:t("./noise/NoiseFilter"),DisplacementFilter:t("./displacement/DisplacementFilter"),BlurFilter:t("./blur/BlurFilter"),BlurXFilter:t("./blur/BlurXFilter"),BlurYFilter:t("./blur/BlurYFilter"),ColorMatrixFilter:t("./colormatrix/ColorMatrixFilter"),VoidFilter:t("./void/VoidFilter")}},{"./blur/BlurFilter":131,"./blur/BlurXFilter":132,"./blur/BlurYFilter":133,"./colormatrix/ColorMatrixFilter":137,"./displacement/DisplacementFilter":138,"./fxaa/FXAAFilter":139,"./noise/NoiseFilter":141,"./void/VoidFilter":142}],141:[function(t,e,r){function i(){n.Filter.call(this,"#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision highp float;\n#define GLSLIFY 1\n\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\n\nuniform float noise;\nuniform sampler2D uSampler;\n\nfloat rand(vec2 co)\n{\n return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\n}\n\nvoid main()\n{\n vec4 color = texture2D(uSampler, vTextureCoord);\n\n float diff = (rand(gl_FragCoord.xy) - 0.5) * noise;\n\n color.r += diff;\n color.g += diff;\n color.b += diff;\n\n gl_FragColor = color;\n}\n"),this.noise=.5}var n=t("../../core");i.prototype=Object.create(n.Filter.prototype),i.prototype.constructor=i,e.exports=i,Object.defineProperties(i.prototype,{noise:{get:function(){return this.uniforms.noise},set:function(t){this.uniforms.noise=t}}})},{"../../core":62}],142:[function(t,e,r){function i(){n.Filter.call(this,"#define GLSLIFY 1\nattribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","#define GLSLIFY 1\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\n\nvoid main(void)\n{\n gl_FragColor = texture2D(uSampler, vTextureCoord);\n}\n"),this.glShaderKey="void"}var n=t("../../core");i.prototype=Object.create(n.Filter.prototype),i.prototype.constructor=i,e.exports=i},{"../../core":62}],143:[function(t,e,r){function i(){this.global=new n.Point,this.target=null,this.originalEvent=null}var n=t("../core");i.prototype.constructor=i,e.exports=i,i.prototype.getLocalPosition=function(t,e,r){return t.worldTransform.applyInverse(r||this.global,e)}},{"../core":62}],144:[function(t,e,r){function i(t,e){o.call(this),e=e||{},this.renderer=t,this.autoPreventDefault=void 0===e.autoPreventDefault||e.autoPreventDefault,this.interactionFrequency=e.interactionFrequency||10,this.mouse=new s,this.mouse.global.set(-999999),this.eventData={stopped:!1,target:null,type:null,data:this.mouse,stopPropagation:function(){this.stopped=!0}},this.interactiveDataPool=[],this.interactionDOMElement=null,this.moveWhenInside=!1,this.eventsAdded=!1,this.onMouseUp=this.onMouseUp.bind(this),this.processMouseUp=this.processMouseUp.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.processMouseDown=this.processMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.processMouseMove=this.processMouseMove.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.processMouseOverOut=this.processMouseOverOut.bind(this),this.onMouseOver=this.onMouseOver.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.processTouchStart=this.processTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.processTouchEnd=this.processTouchEnd.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.processTouchMove=this.processTouchMove.bind(this),this.defaultCursorStyle="inherit",this.currentCursorStyle="inherit",this._tempPoint=new n.Point,this.resolution=1,this.setTargetElement(this.renderer.view,this.renderer.resolution)}var n=t("../core"),s=t("./InteractionData"),o=t("eventemitter3");Object.assign(n.DisplayObject.prototype,t("./interactiveTarget")),i.prototype=Object.create(o.prototype),i.prototype.constructor=i,e.exports=i,i.prototype.setTargetElement=function(t,e){this.removeEvents(),this.interactionDOMElement=t,this.resolution=e||1,this.addEvents()},i.prototype.addEvents=function(){this.interactionDOMElement&&(n.ticker.shared.add(this.update,this),window.navigator.msPointerEnabled&&(this.interactionDOMElement.style["-ms-content-zooming"]="none",this.interactionDOMElement.style["-ms-touch-action"]="none"),window.document.addEventListener("mousemove",this.onMouseMove,!0),this.interactionDOMElement.addEventListener("mousedown",this.onMouseDown,!0),this.interactionDOMElement.addEventListener("mouseout",this.onMouseOut,!0),this.interactionDOMElement.addEventListener("mouseover",this.onMouseOver,!0),this.interactionDOMElement.addEventListener("touchstart",this.onTouchStart,!0),this.interactionDOMElement.addEventListener("touchend",this.onTouchEnd,!0),this.interactionDOMElement.addEventListener("touchmove",this.onTouchMove,!0),window.addEventListener("mouseup",this.onMouseUp,!0),this.eventsAdded=!0)},i.prototype.removeEvents=function(){this.interactionDOMElement&&(n.ticker.shared.remove(this.update),window.navigator.msPointerEnabled&&(this.interactionDOMElement.style["-ms-content-zooming"]="",this.interactionDOMElement.style["-ms-touch-action"]=""),window.document.removeEventListener("mousemove",this.onMouseMove,!0),this.interactionDOMElement.removeEventListener("mousedown",this.onMouseDown,!0),this.interactionDOMElement.removeEventListener("mouseout",this.onMouseOut,!0),this.interactionDOMElement.removeEventListener("mouseover",this.onMouseOver,!0),this.interactionDOMElement.removeEventListener("touchstart",this.onTouchStart,!0),this.interactionDOMElement.removeEventListener("touchend",this.onTouchEnd,!0),this.interactionDOMElement.removeEventListener("touchmove",this.onTouchMove,!0),this.interactionDOMElement=null,window.removeEventListener("mouseup",this.onMouseUp,!0),this.eventsAdded=!1)},i.prototype.update=function(t){if(this._deltaTime+=t,!(this._deltaTime=0;h--){var u=a[h];if(this.processInteractive(t,u,r,i,o)){if(!u.parent)continue;s=!0,o=!1,i=!1}}return n&&(i&&!s&&(e.hitArea?(e.worldTransform.applyInverse(t,this._tempPoint),s=e.hitArea.contains(this._tempPoint.x,this._tempPoint.y)):e.containsPoint&&(s=e.containsPoint(t))),e.interactive&&r(e,s)),s},i.prototype.onMouseDown=function(t){this.mouse.originalEvent=t,this.eventData.data=this.mouse,this.eventData.stopped=!1,this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.autoPreventDefault&&this.mouse.originalEvent.preventDefault(),this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseDown,!0);var e=2===t.button||3===t.which;this.emit(e?"rightdown":"mousedown",this.eventData)},i.prototype.processMouseDown=function(t,e){var r=this.mouse.originalEvent,i=2===r.button||3===r.which;e&&(t[i?"_isRightDown":"_isLeftDown"]=!0,this.dispatchEvent(t,i?"rightdown":"mousedown",this.eventData))},i.prototype.onMouseUp=function(t){this.mouse.originalEvent=t,this.eventData.data=this.mouse,this.eventData.stopped=!1,this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseUp,!0);var e=2===t.button||3===t.which;this.emit(e?"rightup":"mouseup",this.eventData)},i.prototype.processMouseUp=function(t,e){var r=this.mouse.originalEvent,i=2===r.button||3===r.which,n=i?"_isRightDown":"_isLeftDown";e?(this.dispatchEvent(t,i?"rightup":"mouseup",this.eventData),t[n]&&(t[n]=!1,this.dispatchEvent(t,i?"rightclick":"click",this.eventData))):t[n]&&(t[n]=!1,this.dispatchEvent(t,i?"rightupoutside":"mouseupoutside",this.eventData))},i.prototype.onMouseMove=function(t){this.mouse.originalEvent=t,this.eventData.data=this.mouse,this.eventData.stopped=!1,this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.didMove=!0,this.cursor=this.defaultCursorStyle,this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseMove,!0),this.emit("mousemove",this.eventData),this.currentCursorStyle!==this.cursor&&(this.currentCursorStyle=this.cursor,this.interactionDOMElement.style.cursor=this.cursor)},i.prototype.processMouseMove=function(t,e){this.processMouseOverOut(t,e),this.moveWhenInside&&!e||this.dispatchEvent(t,"mousemove",this.eventData)},i.prototype.onMouseOut=function(t){this.mouse.originalEvent=t,this.eventData.data=this.mouse,this.eventData.stopped=!1,this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.interactionDOMElement.style.cursor=this.defaultCursorStyle,this.mapPositionToPoint(this.mouse.global,t.clientX,t.clientY),this.processInteractive(this.mouse.global,this.renderer._lastObjectRendered,this.processMouseOverOut,!1),this.emit("mouseout",this.eventData)},i.prototype.processMouseOverOut=function(t,e){e?(t._over||(t._over=!0,this.dispatchEvent(t,"mouseover",this.eventData)),t.buttonMode&&(this.cursor=t.defaultCursor)):t._over&&(t._over=!1,this.dispatchEvent(t,"mouseout",this.eventData))},i.prototype.onMouseOver=function(t){this.mouse.originalEvent=t,this.eventData.data=this.mouse,this.eventData.stopped=!1,this.emit("mouseover",this.eventData)},i.prototype.onTouchStart=function(t){this.autoPreventDefault&&t.preventDefault();for(var e=t.changedTouches,r=e.length,i=0;i0){var T=this.canvasPadding/this.worldTransform.a,E=this.canvasPadding/this.worldTransform.d,w=(l+c+d)/3,S=(p+f+v)/3,C=l-w,R=p-S,M=Math.sqrt(C*C+R*R);l=w+C/M*(M+T),p=S+R/M*(M+E),C=c-w,R=f-S,M=Math.sqrt(C*C+R*R),c=w+C/M*(M+T),f=S+R/M*(M+E),C=d-w,R=v-S,M=Math.sqrt(C*C+R*R),d=w+C/M*(M+T),v=S+R/M*(M+E)}t.save(),t.beginPath(),t.moveTo(l,p),t.lineTo(c,f),t.lineTo(d,v),t.closePath(),t.clip();var A=g*_+m*x+y*b-_*x-m*y-g*b,O=l*_+m*d+c*b-_*d-m*c-l*b,D=g*c+l*x+y*d-c*x-l*y-g*d,P=g*_*d+m*c*x+l*y*b-l*_*x-m*y*d-g*c*b,I=p*_+m*v+f*b-_*v-m*f-p*b,L=g*f+p*x+y*v-f*x-p*y-g*v,F=g*_*v+m*f*x+p*y*b-p*_*x-m*y*v-g*f*b;t.transform(O/A,I/A,D/A,L/A,P/A,F/A),t.drawImage(a,0,0,h*o.resolution,u*o.resolution,0,0,h,u),t.restore()},i.prototype.renderMeshFlat=function(t){var e=this.context,r=t.vertices,i=r.length/2;e.beginPath();for(var n=1;n1&&(n=1),s=Math.sqrt(h*h+u*u),o=this._texture.height/2,h/=s,u/=s,h*=o,u*=o,l[i]=r.x+h,l[i+1]=r.y+u,l[i+2]=r.x-h,l[i+3]=r.y-u,a=r;this.containerUpdateTransform()}}},{"../core":62,"./Mesh":152}],156:[function(t,e,r){e.exports={Mesh:t("./Mesh"),Plane:t("./Plane"),NineSlicePlane:t("./NineSlicePlane"),Rope:t("./Rope"),MeshShader:t("./webgl/MeshShader")}},{"./Mesh":152,"./NineSlicePlane":153,"./Plane":154,"./Rope":155,"./webgl/MeshShader":157}],157:[function(t,e,r){function i(t){n.call(this,t,["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat3 translationMatrix;","uniform mat3 projectionMatrix;","varying vec2 vTextureCoord;","void main(void){"," gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);"," vTextureCoord = aTextureCoord;","}"].join("\n"),["varying vec2 vTextureCoord;","uniform float alpha;","uniform vec3 tint;","uniform sampler2D uSampler;","void main(void){"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vec4(tint * alpha, alpha);","}"].join("\n"))}var n=t("../../core/Shader");i.prototype=Object.create(n.prototype),i.prototype.constructor=i,e.exports=i},{"../../core/Shader":42}],158:[function(t,e,r){function i(t,e,r){n.Container.call(this),r=r||15e3,t=t||15e3;var i=16384;r>i&&(r=i),r>t&&(r=t),this._properties=[!1,!0,!1,!1,!1],this._maxSize=t,this._batchSize=r,this._glBuffers=[],this._bufferToUpdate=0,this.interactiveChildren=!1,this.blendMode=n.BLEND_MODES.NORMAL,this.roundPixels=!0,this.baseTexture=null,this.setProperties(e)}var n=t("../core");i.prototype=Object.create(n.Container.prototype),i.prototype.constructor=i,e.exports=i,i.prototype.setProperties=function(t){t&&(this._properties[0]="scale"in t?!!t.scale:this._properties[0],this._properties[1]="position"in t?!!t.position:this._properties[1],this._properties[2]="rotation"in t?!!t.rotation:this._properties[2],this._properties[3]="uvs"in t?!!t.uvs:this._properties[3],this._properties[4]="alpha"in t?!!t.alpha:this._properties[4])},i.prototype.updateTransform=function(){this.displayObjectUpdateTransform()},i.prototype.renderWebGL=function(t){this.visible&&!(this.worldAlpha<=0)&&this.children.length&&this.renderable&&(this.baseTexture||(this.baseTexture=this.children[0]._texture.baseTexture,this.baseTexture.hasLoaded||this.baseTexture.once("update",function(){this.onChildrenChange(0)},this)),t.setObjectRenderer(t.plugins.particle),t.plugins.particle.render(this))},i.prototype.onChildrenChange=function(t){var e=Math.floor(t/this._batchSize);ei&&(r=i);var s=t._glBuffers[this.renderer.CONTEXT_UID];s||(s=t._glBuffers[this.renderer.CONTEXT_UID]=this.generateBuffers(t)),this.renderer.setBlendMode(t.blendMode);var o=this.renderer.gl,a=t.worldTransform.copy(this.tempMatrix);a.prepend(this.renderer._activeRenderTarget.projectionMatrix),this.shader.uniforms.projectionMatrix=a.toArray(!0),this.shader.uniforms.uAlpha=t.worldAlpha;var h=e[0]._texture.baseTexture;this.renderer.bindTexture(h);for(var u=0,l=0;un&&(c=n);var d=s[l];d.uploadDynamic(e,u,c),t._bufferToUpdate===l&&(d.uploadStatic(e,u,c),t._bufferToUpdate=l+1),d.vao.bind().draw(o.TRIANGLES,6*c).unbind()}}},i.prototype.generateBuffers=function(t){var e,r=this.renderer.gl,i=[],n=t._maxSize,s=t._batchSize,a=t._properties;for(e=0;e0?1:-1})},{}],164:[function(t,e,r){Object.assign||(Object.assign=t("object-assign"))},{"object-assign":5}],165:[function(t,e,r){t("./Object.assign"),t("./requestAnimationFrame"),t("./Math.sign"),window.ArrayBuffer||(window.ArrayBuffer=Array),window.Float32Array||(window.Float32Array=Array),window.Uint32Array||(window.Uint32Array=Array),window.Uint16Array||(window.Uint16Array=Array)},{"./Math.sign":163,"./Object.assign":164,"./requestAnimationFrame":166}],166:[function(t,e,r){(function(t){if(Date.now&&Date.prototype.getTime||(Date.now=function(){return(new Date).getTime()}),!t.performance||!t.performance.now){var e=Date.now();t.performance||(t.performance={}),t.performance.now=function(){return Date.now()-e}}for(var r=Date.now(),i=["ms","moz","webkit","o"],n=0;n0;){var r=this.queue[0],n=!1;for(t=0,e=this.uploadHooks.length;t=0;e--)this.add(t.children[e]);return this},i.prototype.destroy=function(){this.ticking&&u.remove(this.tick,this),this.ticking=!1,this.addHooks=null,this.uploadHooks=null,this.renderer=null,this.completes=null,this.queue=null},h.WebGLRenderer.registerPlugin("prepare",i)},{"../../core":62}],170:[function(t,e,r){(function(r){t("./polyfill");var i=e.exports=t("./core");i.extras=t("./extras"),i.filters=t("./filters"),i.interaction=t("./interaction"),i.loaders=t("./loaders"),i.mesh=t("./mesh"),i.particles=t("./particles"),i.accessibility=t("./accessibility"),i.extract=t("./extract"),i.prepare=t("./prepare"),i.loader=new i.loaders.Loader,Object.assign(i,t("./deprecation")),r.PIXI=i}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./accessibility":41,"./core":62,"./deprecation":119,"./extract":121,"./extras":129,"./filters":140,"./interaction":145,"./loaders":148,"./mesh":156,"./particles":159,"./polyfill":165,"./prepare":168}]},{},[170])(170)}); +//# sourceMappingURL=pixi.min.js.map diff --git a/js/lib/stats.min.js b/js/lib/stats.min.js new file mode 100755 index 0000000..ef000cf --- /dev/null +++ b/js/lib/stats.min.js @@ -0,0 +1,5 @@ +// stats.js - http://github.com/mrdoob/stats.js +var Stats=function(){function h(a){c.appendChild(a.dom);return a}function k(a){for(var d=0;de+1E3&&(r.update(1E3*a/(c-e),100),e=c,a=0,t)){var d=performance.memory;t.update(d.usedJSHeapSize/1048576,d.jsHeapSizeLimit/1048576)}return c},update:function(){g=this.end()},domElement:c,setMode:k}}; +Stats.Panel=function(h,k,l){var c=Infinity,g=0,e=Math.round,a=e(window.devicePixelRatio||1),r=80*a,f=48*a,t=3*a,u=2*a,d=3*a,m=15*a,n=74*a,p=30*a,q=document.createElement("canvas");q.width=r;q.height=f;q.style.cssText="width:80px;height:48px";var b=q.getContext("2d");b.font="bold "+9*a+"px Helvetica,Arial,sans-serif";b.textBaseline="top";b.fillStyle=l;b.fillRect(0,0,r,f);b.fillStyle=k;b.fillText(h,t,u);b.fillRect(d,m,n,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d,m,n,p);return{dom:q,update:function(f, +v){c=Math.min(c,f);g=Math.max(g,f);b.fillStyle=l;b.globalAlpha=1;b.fillRect(0,0,r,m);b.fillStyle=k;b.fillText(e(f)+" "+h+" ("+e(c)+"-"+e(g)+")",t,u);b.drawImage(q,d+a,m,n-a,p,d,m,n-a,p);b.fillRect(d+n-a,m,a,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d+n-a,m,a,e((1-f/v)*p))}}};"object"===typeof module&&(module.exports=Stats); diff --git a/js/lib/tweenjs-0.6.2.min.js b/js/lib/tweenjs-0.6.2.min.js new file mode 100644 index 0000000..d7c6ee5 --- /dev/null +++ b/js/lib/tweenjs-0.6.2.min.js @@ -0,0 +1,12 @@ +/*! +* @license TweenJS +* Visit http://createjs.com/ for documentation, updates and examples. +* +* Copyright (c) 2011-2015 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||{},createjs.extend=function(a,b){"use strict";function c(){this.constructor=a}return c.prototype=b.prototype,a.prototype=new c},this.createjs=this.createjs||{},createjs.promote=function(a,b){"use strict";var c=a.prototype,d=Object.getPrototypeOf&&Object.getPrototypeOf(c)||c.__proto__;if(d){c[(b+="_")+"constructor"]=d.constructor;for(var e in d)c.hasOwnProperty(e)&&"function"==typeof d[e]&&(c[b+e]=d[e])}return a},this.createjs=this.createjs||{},function(){"use strict";function Event(a,b,c){this.type=a,this.target=null,this.currentTarget=null,this.eventPhase=0,this.bubbles=!!b,this.cancelable=!!c,this.timeStamp=(new Date).getTime(),this.defaultPrevented=!1,this.propagationStopped=!1,this.immediatePropagationStopped=!1,this.removed=!1}var a=Event.prototype;a.preventDefault=function(){this.defaultPrevented=this.cancelable&&!0},a.stopPropagation=function(){this.propagationStopped=!0},a.stopImmediatePropagation=function(){this.immediatePropagationStopped=this.propagationStopped=!0},a.remove=function(){this.removed=!0},a.clone=function(){return new Event(this.type,this.bubbles,this.cancelable)},a.set=function(a){for(var b in a)this[b]=a[b];return this},a.toString=function(){return"[Event (type="+this.type+")]"},createjs.Event=Event}(),this.createjs=this.createjs||{},function(){"use strict";function EventDispatcher(){this._listeners=null,this._captureListeners=null}var a=EventDispatcher.prototype;EventDispatcher.initialize=function(b){b.addEventListener=a.addEventListener,b.on=a.on,b.removeEventListener=b.off=a.removeEventListener,b.removeAllEventListeners=a.removeAllEventListeners,b.hasEventListener=a.hasEventListener,b.dispatchEvent=a.dispatchEvent,b._dispatchEvent=a._dispatchEvent,b.willTrigger=a.willTrigger},a.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},a.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)},a.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}}},a.off=a.removeEventListener,a.removeAllEventListeners=function(a){a?(this._listeners&&delete this._listeners[a],this._captureListeners&&delete this._captureListeners[a]):this._listeners=this._captureListeners=null},a.dispatchEvent=function(a,b,c){if("string"==typeof a){var d=this._listeners;if(!(b||d&&d[a]))return!0;a=new createjs.Event(a,b,c)}else a.target&&a.clone&&(a=a.clone());try{a.target=this}catch(e){}if(a.bubbles&&this.parent){for(var f=this,g=[f];f.parent;)g.push(f=f.parent);var h,i=g.length;for(h=i-1;h>=0&&!a.propagationStopped;h--)g[h]._dispatchEvent(a,1+(0==h));for(h=1;i>h&&!a.propagationStopped;h++)g[h]._dispatchEvent(a,3)}else this._dispatchEvent(a,2);return!a.defaultPrevented},a.hasEventListener=function(a){var b=this._listeners,c=this._captureListeners;return!!(b&&b[a]||c&&c[a])},a.willTrigger=function(a){for(var b=this;b;){if(b.hasEventListener(a))return!0;b=b.parent}return!1},a.toString=function(){return"[EventDispatcher]"},a._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;try{a.currentTarget=this}catch(f){}try{a.eventPhase=b}catch(f){}a.removed=!1,e=e.slice();for(var g=0;c>g&&!a.immediatePropagationStopped;g++){var h=e[g];h.handleEvent?h.handleEvent(a):h(a),a.removed&&(this.off(a.type,h,1==b),a.removed=!1)}}},createjs.EventDispatcher=EventDispatcher}(),this.createjs=this.createjs||{},function(){"use strict";function Ticker(){throw"Ticker cannot be instantiated."}Ticker.RAF_SYNCHED="synched",Ticker.RAF="raf",Ticker.TIMEOUT="timeout",Ticker.useRAF=!1,Ticker.timingMode=null,Ticker.maxDelta=0,Ticker.paused=!1,Ticker.removeEventListener=null,Ticker.removeAllEventListeners=null,Ticker.dispatchEvent=null,Ticker.hasEventListener=null,Ticker._listeners=null,createjs.EventDispatcher.initialize(Ticker),Ticker._addEventListener=Ticker.addEventListener,Ticker.addEventListener=function(){return!Ticker._inited&&Ticker.init(),Ticker._addEventListener.apply(Ticker,arguments)},Ticker._inited=!1,Ticker._startTime=0,Ticker._pausedTime=0,Ticker._ticks=0,Ticker._pausedTicks=0,Ticker._interval=50,Ticker._lastTime=0,Ticker._times=null,Ticker._tickTimes=null,Ticker._timerId=null,Ticker._raf=!0,Ticker.setInterval=function(a){Ticker._interval=a,Ticker._inited&&Ticker._setupTick()},Ticker.getInterval=function(){return Ticker._interval},Ticker.setFPS=function(a){Ticker.setInterval(1e3/a)},Ticker.getFPS=function(){return 1e3/Ticker._interval};try{Object.defineProperties(Ticker,{interval:{get:Ticker.getInterval,set:Ticker.setInterval},framerate:{get:Ticker.getFPS,set:Ticker.setFPS}})}catch(a){console.log(a)}Ticker.init=function(){Ticker._inited||(Ticker._inited=!0,Ticker._times=[],Ticker._tickTimes=[],Ticker._startTime=Ticker._getTime(),Ticker._times.push(Ticker._lastTime=0),Ticker.interval=Ticker._interval)},Ticker.reset=function(){if(Ticker._raf){var a=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame;a&&a(Ticker._timerId)}else clearTimeout(Ticker._timerId);Ticker.removeAllEventListeners("tick"),Ticker._timerId=Ticker._times=Ticker._tickTimes=null,Ticker._startTime=Ticker._lastTime=Ticker._ticks=0,Ticker._inited=!1},Ticker.getMeasuredTickTime=function(a){var b=0,c=Ticker._tickTimes;if(!c||c.length<1)return-1;a=Math.min(c.length,a||0|Ticker.getFPS());for(var d=0;a>d;d++)b+=c[d];return b/a},Ticker.getMeasuredFPS=function(a){var b=Ticker._times;return!b||b.length<2?-1:(a=Math.min(b.length-1,a||0|Ticker.getFPS()),1e3/((b[0]-b[a])/a))},Ticker.setPaused=function(a){Ticker.paused=a},Ticker.getPaused=function(){return Ticker.paused},Ticker.getTime=function(a){return Ticker._startTime?Ticker._getTime()-(a?Ticker._pausedTime:0):-1},Ticker.getEventTime=function(a){return Ticker._startTime?(Ticker._lastTime||Ticker._startTime)-(a?Ticker._pausedTime:0):-1},Ticker.getTicks=function(a){return Ticker._ticks-(a?Ticker._pausedTicks:0)},Ticker._handleSynch=function(){Ticker._timerId=null,Ticker._setupTick(),Ticker._getTime()-Ticker._lastTime>=.97*(Ticker._interval-1)&&Ticker._tick()},Ticker._handleRAF=function(){Ticker._timerId=null,Ticker._setupTick(),Ticker._tick()},Ticker._handleTimeout=function(){Ticker._timerId=null,Ticker._setupTick(),Ticker._tick()},Ticker._setupTick=function(){if(null==Ticker._timerId){var a=Ticker.timingMode||Ticker.useRAF&&Ticker.RAF_SYNCHED;if(a==Ticker.RAF_SYNCHED||a==Ticker.RAF){var b=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(b)return Ticker._timerId=b(a==Ticker.RAF?Ticker._handleRAF:Ticker._handleSynch),void(Ticker._raf=!0)}Ticker._raf=!1,Ticker._timerId=setTimeout(Ticker._handleTimeout,Ticker._interval)}},Ticker._tick=function(){var a=Ticker.paused,b=Ticker._getTime(),c=b-Ticker._lastTime;if(Ticker._lastTime=b,Ticker._ticks++,a&&(Ticker._pausedTicks++,Ticker._pausedTime+=c),Ticker.hasEventListener("tick")){var d=new createjs.Event("tick"),e=Ticker.maxDelta;d.delta=e&&c>e?e:c,d.paused=a,d.time=b,d.runTime=b-Ticker._pausedTime,Ticker.dispatchEvent(d)}for(Ticker._tickTimes.unshift(Ticker._getTime()-b);Ticker._tickTimes.length>100;)Ticker._tickTimes.pop();for(Ticker._times.unshift(b);Ticker._times.length>100;)Ticker._times.pop()};var b=window.performance&&(performance.now||performance.mozNow||performance.msNow||performance.oNow||performance.webkitNow);Ticker._getTime=function(){return(b&&b.call(performance)||(new Date).getTime())-Ticker._startTime},createjs.Ticker=Ticker}(),this.createjs=this.createjs||{},function(){"use strict";function Tween(a,b,c){this.ignoreGlobalPause=!1,this.loop=!1,this.duration=0,this.pluginData=c||{},this.target=a,this.position=null,this.passive=!1,this._paused=!1,this._curQueueProps={},this._initQueueProps={},this._steps=[],this._actions=[],this._prevPosition=0,this._stepPosition=0,this._prevPos=-1,this._target=a,this._useTicks=!1,this._inited=!1,this._registered=!1,b&&(this._useTicks=b.useTicks,this.ignoreGlobalPause=b.ignoreGlobalPause,this.loop=b.loop,b.onChange&&this.addEventListener("change",b.onChange),b.override&&Tween.removeTweens(a)),b&&b.paused?this._paused=!0:createjs.Tween._register(this,!0),b&&null!=b.position&&this.setPosition(b.position,Tween.NONE)}var a=createjs.extend(Tween,createjs.EventDispatcher);Tween.NONE=0,Tween.LOOP=1,Tween.REVERSE=2,Tween.IGNORE={},Tween._tweens=[],Tween._plugins={},Tween.get=function(a,b,c,d){return d&&Tween.removeTweens(a),new Tween(a,b,c)},Tween.tick=function(a,b){for(var c=Tween._tweens.slice(),d=c.length-1;d>=0;d--){var e=c[d];b&&!e.ignoreGlobalPause||e._paused||e.tick(e._useTicks?1:a)}},Tween.handleEvent=function(a){"tick"==a.type&&this.tick(a.delta,a.paused)},Tween.removeTweens=function(a){if(a.tweenjs_count){for(var b=Tween._tweens,c=b.length-1;c>=0;c--){var d=b[c];d._target==a&&(d._paused=!0,b.splice(c,1))}a.tweenjs_count=0}},Tween.removeAllTweens=function(){for(var a=Tween._tweens,b=0,c=a.length;c>b;b++){var d=a[b];d._paused=!0,d.target&&(d.target.tweenjs_count=0)}a.length=0},Tween.hasActiveTweens=function(a){return a?null!=a.tweenjs_count&&!!a.tweenjs_count:Tween._tweens&&!!Tween._tweens.length},Tween.installPlugin=function(a,b){var c=a.priority;null==c&&(a.priority=c=0);for(var d=0,e=b.length,f=Tween._plugins;e>d;d++){var g=b[d];if(f[g]){for(var h=f[g],i=0,j=h.length;j>i&&!(c=a)return this;var c=this._cloneProps(this._curQueueProps);return this._addStep({d:a,p0:c,e:this._linearEase,p1:c,v:b})},a.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))})},a.call=function(a,b,c){return this._addAction({f:a,p:b?b:[this],o:c?c:this._target})},a.set=function(a,b){return this._addAction({f:this._set,o:this,p:[a,b?b:this._target]})},a.play=function(a){return a||(a=this),this.call(a.setPaused,[!1],a)},a.pause=function(a){return a||(a=this),this.call(a.setPaused,[!0],a)},a.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},a.tick=function(a){this._paused||this.setPosition(this._prevPosition+a)},a.setPaused=function(a){return this._paused===!!a?this:(this._paused=!!a,Tween._register(this,!a),this)},a.w=a.wait,a.t=a.to,a.c=a.call,a.s=a.set,a.toString=function(){return"[Tween]"},a.clone=function(){throw"Tween can not be cloned."},a._updateTargetProps=function(a,b){var c,d,e,f,g,h;if(a||1!=b){if(this.passive=!!a.v,this.passive)return;a.e&&(b=a.e(b,0,1,1)),c=a.p0,d=a.p1}else this.passive=!1,c=d=this._curQueueProps;for(var i in this._initQueueProps){null==(f=c[i])&&(c[i]=f=this._initQueueProps[i]),null==(g=d[i])&&(d[i]=g=f),e=f==g||0==b||1==b||"number"!=typeof f?1==b?g:f:f+(g-f)*b;var j=!1;if(h=Tween._plugins[i])for(var k=0,l=h.length;l>k;k++){var m=h[k].tween(this,i,e,c,d,b,!!a&&c==d,!a);m==Tween.IGNORE?j=!0:e=m}j||(this._target[i]=e)}},a._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)}},a._appendQueueProps=function(a){var b,c,d,e,f;for(var g in a)if(void 0===this._initQueueProps[g]){if(c=this._target[g],b=Tween._plugins[g])for(d=0,e=b.length;e>d;d++)c=b[d].init(this,g,c);this._initQueueProps[g]=this._curQueueProps[g]=void 0===c?null:c}else c=this._curQueueProps[g];for(var g in a){if(c=this._curQueueProps[g],b=Tween._plugins[g])for(f=f||{},d=0,e=b.length;e>d;d++)b[d].step&&b[d].step(this,g,c,a[g],f);this._curQueueProps[g]=a[g]}return f&&this._appendQueueProps(f),this._curQueueProps},a._cloneProps=function(a){var b={};for(var c in a)b[c]=a[c];return b},a._addStep=function(a){return a.d>0&&(this._steps.push(a),a.t=this.duration,this.duration+=a.d),this},a._addAction=function(a){return a.t=this.duration,this._actions.push(a),this},a._set=function(a,b){for(var c in a)b[c]=a[c]},createjs.Tween=createjs.promote(Tween,"EventDispatcher")}(),this.createjs=this.createjs||{},function(){"use strict";function Timeline(a,b,c){this.EventDispatcher_constructor(),this.ignoreGlobalPause=!1,this.duration=0,this.loop=!1,this.position=null,this._paused=!1,this._tweens=[],this._labels=null,this._labelList=null,this._prevPosition=0,this._prevPos=-1,this._useTicks=!1,this._registered=!1,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)}var a=createjs.extend(Timeline,createjs.EventDispatcher);a.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)},a.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},a.addLabel=function(a,b){this._labels[a]=b;var c=this._labelList;if(c){for(var d=0,e=c.length;e>d&&!(bd&&!(b=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},a.setPaused=function(a){this._paused=!!a,createjs.Tween._register(this,!a)},a.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)}},a.tick=function(a){this.setPosition(this._prevPosition+a)},a.resolve=function(a){var b=Number(a);return isNaN(b)&&(b=this._labels[a]),b},a.toString=function(){return"[Timeline]"},a.clone=function(){throw"Timeline can not be cloned."},a._goto=function(a){var b=this.resolve(a);null!=b&&this.setPosition(b)},a._calcPosition=function(a){return 0>a?0:aa&&(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))}},Ease.getPowIn=function(a){return function(b){return Math.pow(b,a)}},Ease.getPowOut=function(a){return function(b){return 1-Math.pow(1-b,a)}},Ease.getPowInOut=function(a){return function(b){return(b*=2)<1?.5*Math.pow(b,a):1-.5*Math.abs(Math.pow(2-b,a))}},Ease.quadIn=Ease.getPowIn(2),Ease.quadOut=Ease.getPowOut(2),Ease.quadInOut=Ease.getPowInOut(2),Ease.cubicIn=Ease.getPowIn(3),Ease.cubicOut=Ease.getPowOut(3),Ease.cubicInOut=Ease.getPowInOut(3),Ease.quartIn=Ease.getPowIn(4),Ease.quartOut=Ease.getPowOut(4),Ease.quartInOut=Ease.getPowInOut(4),Ease.quintIn=Ease.getPowIn(5),Ease.quintOut=Ease.getPowOut(5),Ease.quintInOut=Ease.getPowInOut(5),Ease.sineIn=function(a){return 1-Math.cos(a*Math.PI/2)},Ease.sineOut=function(a){return Math.sin(a*Math.PI/2)},Ease.sineInOut=function(a){return-.5*(Math.cos(Math.PI*a)-1)},Ease.getBackIn=function(a){return function(b){return b*b*((a+1)*b-a)}},Ease.backIn=Ease.getBackIn(1.7),Ease.getBackOut=function(a){return function(b){return--b*b*((a+1)*b+a)+1}},Ease.backOut=Ease.getBackOut(1.7),Ease.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)}},Ease.backInOut=Ease.getBackInOut(1.7),Ease.circIn=function(a){return-(Math.sqrt(1-a*a)-1)},Ease.circOut=function(a){return Math.sqrt(1- --a*a)},Ease.circInOut=function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)},Ease.bounceIn=function(a){return 1-Ease.bounceOut(1-a)},Ease.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},Ease.bounceInOut=function(a){return.5>a?.5*Ease.bounceIn(2*a):.5*Ease.bounceOut(2*a-1)+.5},Ease.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))}},Ease.elasticIn=Ease.getElasticIn(1,.3),Ease.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}},Ease.elasticOut=Ease.getElasticOut(1,.3),Ease.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):a*Math.pow(2,-10*(d-=1))*Math.sin((d-e)*c/b)*.5+1}},Ease.elasticInOut=Ease.getElasticInOut(1,.3*1.5),createjs.Ease=Ease}(),this.createjs=this.createjs||{},function(){"use strict";function MotionGuidePlugin(){throw"MotionGuidePlugin cannot be instantiated."}MotionGuidePlugin.priority=0,MotionGuidePlugin._rotOffS,MotionGuidePlugin._rotOffE,MotionGuidePlugin._rotNormS,MotionGuidePlugin._rotNormE,MotionGuidePlugin.install=function(){return createjs.Tween.installPlugin(MotionGuidePlugin,["guide","x","y","rotation"]),createjs.Tween.IGNORE},MotionGuidePlugin.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},MotionGuidePlugin.step=function(a,b,c,d,e){if("rotation"==b&&(a.__rotGlobalS=c,a.__rotGlobalE=d,MotionGuidePlugin.testRotData(a,e)),"guide"!=b)return d;var f,g=d;g.hasOwnProperty("path")||(g.path=[]);var h=g.path;if(g.hasOwnProperty("end")||(g.end=1),g.hasOwnProperty("start")||(g.start=c&&c.hasOwnProperty("end")&&c.path===h?c.end:0),g.hasOwnProperty("_segments")&&g._length)return d;var i=h.length,j=10;if(!(i>=6&&(i-2)%4==0))throw"invalid 'path' data, please see documentation for valid paths";g._segments=[],g._length=0;for(var k=2;i>k;k+=4){for(var l,m,n=h[k-2],o=h[k-1],p=h[k+0],q=h[k+1],r=h[k+2],s=h[k+3],t=n,u=o,v=0,w=[],x=1;j>=x;x++){var y=x/j,z=1-y;l=z*z*n+2*z*y*p+y*y*r,m=z*z*o+2*z*y*q+y*y*s,v+=w[w.push(Math.sqrt((f=l-t)*f+(f=m-u)*f))-1],t=l,u=m}g._segments.push(v),g._segments.push(w),g._length+=v}f=g.orient,g.orient=!0;var A={};return MotionGuidePlugin.calc(g,g.start,A),a.__rotPathS=Number(A.rotation.toFixed(5)),MotionGuidePlugin.calc(g,g.end,A),a.__rotPathE=Number(A.rotation.toFixed(5)),g.orient=!1,MotionGuidePlugin.calc(g,g.end,e),g.orient=f,g.orient?(a.__guideData=g,MotionGuidePlugin.testRotData(a,e),d):d},MotionGuidePlugin.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}},MotionGuidePlugin.tween=function(a,b,c,d,e,f,g){var h=e.guide;if(void 0==h||h===d.guide)return c;if(h.lastRatio!=f){var i=(h.end-h.start)*(g?h.end:f)+h.start;switch(MotionGuidePlugin.calc(h,i,a.target),h.orient){case"cw":case"ccw":case"auto":a.target.rotation+=h.rotOffS+h.rotDelta*f;break;case"fixed":default:a.target.rotation+=h.rotOffS}h.lastRatio=f}return"rotation"!=b||h.orient&&"false"!=h.orient?a.target[b]:c},MotionGuidePlugin.calc=function(a,b,c){if(void 0==a._segments)throw"Missing critical pre-calculated information, please file a bug";void 0==c&&(c={x:0,y:0,rotation:0});for(var d=a._segments,e=a.path,f=a._length*b,g=d.length-2,h=0;f>d[h]&&g>h;)f-=d[h],h+=2;var i=d[h+1],j=0;for(g=i.length-1;f>i[j]&&g>j;)f-=i[j],j++;var k=j/++g+f/(g*i[j]);h=2*h+2;var l=1-k;return c.x=l*l*e[h-2]+2*l*k*e[h+0]+k*k*e[h+2],c.y=l*l*e[h-1]+2*l*k*e[h+1]+k*k*e[h+3],a.orient&&(c.rotation=57.2957795*Math.atan2((e[h+1]-e[h-1])*l+(e[h+3]-e[h+1])*k,(e[h+0]-e[h-2])*l+(e[h+2]-e[h+0])*k)),c},createjs.MotionGuidePlugin=MotionGuidePlugin}(),this.createjs=this.createjs||{},function(){"use strict";var a=createjs.TweenJS=createjs.TweenJS||{};a.version="0.6.2",a.buildDate="Thu, 26 Nov 2015 20:44:31 GMT"}(); \ No newline at end of file diff --git a/js/misc/Candlelight.js b/js/misc/Candlelight.js new file mode 100644 index 0000000..5972547 --- /dev/null +++ b/js/misc/Candlelight.js @@ -0,0 +1,25 @@ +Game.addToManifest({ + + candlelight: "sprites/misc/candlelight.json" + +}); + +function Candlelight(position){ + + var self = this; + var mc = MakeMovieClip("candlelight"); + self.graphics = mc; + + mc.anchor.x = 0.5; + mc.anchor.y = 0.5; + mc.x = position[0]-100; // HACK, LOL W/E + mc.y = position[1]-100; // HACK, LOL W/E + + self.update = function(){ + if(Math.random()<0.2){ + var frame = Math.floor(Math.random()*mc.totalFrames); + mc.gotoAndStop(frame); + } + }; + +} \ No newline at end of file diff --git a/js/misc/Cricket.js b/js/misc/Cricket.js new file mode 100644 index 0000000..4290318 --- /dev/null +++ b/js/misc/Cricket.js @@ -0,0 +1,100 @@ +Game.addToManifest({ + cricket: "sprites/misc/cricket.json" +}); +function Cricket(scene){ + + var self = this; + self.scene = scene; + + self._CLASS_ = "Cricket"; + + var mc = MakeMovieClip("cricket"); + self.graphics = mc; + self.mc = mc; + var DRAWING_SCALE = 0.25; + mc.scale.x = mc.scale.y = DRAWING_SCALE; + + self.width = 137*DRAWING_SCALE; + self.height = 137*DRAWING_SCALE; + + var MODE = 0; + var MODE_CHIRP = 0; + var MODE_HOP = 1; + + self.flip = 1; + self.period = 10; + self.breathe = Math.floor(Math.random()*self.period); + self.hop = 0; + + self.x = self.y = self.z = 0; + + self.update = function(){ + + if(MODE==MODE_CHIRP){ + self.breathe++; + if(self.breathe>self.period+10) self.breathe=0; + if(self.breathe>self.period){ + var scale; + if(self.breathe%4==0) scale=1.1; + if(self.breathe%4==1) scale=1.0; + if(self.breathe%4==2) scale=0.9; + if(self.breathe%4==3) scale=1.0; + mc.scale.x = DRAWING_SCALE*(scale); + mc.scale.y = DRAWING_SCALE*(1/scale); + }else{ + mc.scale.x = mc.scale.y = DRAWING_SCALE; + } + } + if(self.hopAwayTimeout>0){ + self.hopAwayTimeout--; + if(self.hopAwayTimeout==0) MODE=MODE_HOP; + } + if(MODE==MODE_HOP){ + var tv = scene.tv; + self.flip = 1; + self.x += 3.5; + self.hop += 0.1570795; + self.z = -Math.abs(Math.sin(self.hop))*100; + self.y = tv.y; + } + if(self.x>Game.width+50){ + self.kill(); + } + + mc.scale.x = self.flip*Math.abs(mc.scale.x); + mc.x = self.x; + mc.y = self.y+self.z; + + }; + + ////////////// + // WATCH TV // + ////////////// + + self.hopAwayTimeout = -1; + self.watchTV = function(){ + + // 1) Stop & look + var tv = scene.tv; + self.x = tv.x + 100; + self.y = tv.y; + self.flip = -1; + var WAIT = Director.ZOOM_OUT_1_TIME + Director.SEE_VIEWERS_TIME + 2.3; + + // 2) And go on. + self.hopAwayTimeout = _s(WAIT); + + }; + + ///////////// + // THE END // + ///////////// + + // KILL ME + self.kill = function(){ + var world = self.scene.world; + world.props.splice(world.props.indexOf(self),1); + world.layers.props.removeChild(self.graphics); + }; + +} \ No newline at end of file diff --git a/js/misc/Cursor.js b/js/misc/Cursor.js new file mode 100644 index 0000000..85ea2ad --- /dev/null +++ b/js/misc/Cursor.js @@ -0,0 +1,45 @@ +Game.addToManifest({ + cursor: "sprites/misc/cursor.json" +}, true); + +function Cursor(scene){ + + var self = this; + var mc = MakeMovieClip("cursor"); + mc.anchor.x = mc.anchor.y = 0; + self.graphics = mc; + mc.x = -100; + mc.y = -100; + + self.click = false; + Game.stage.mousemove = function(mouseData){ + var pos = mouseData.data.global; + mc.x = pos.x+1; + mc.y = pos.y+1; + }; + Game.stage.mousedown = function(mouseData){ + self.click = true; + }; + Game.stage.mouseup = function(mouseData){ + self.click = false; + }; + + var doubles = 0; + self.update = function(isHover){ + + doubles = (doubles+1)%2; // animate on doubles! + if(doubles!=0) return; + + if(self.click){ + mc.gotoAndStop(4); + }else{ + if(isHover){ + if(mc.currentFrame<3) mc.gotoAndStop(mc.currentFrame+1); + }else{ + if(mc.currentFrame>0) mc.gotoAndStop(mc.currentFrame-1); + } + } + + }; + +} \ No newline at end of file diff --git a/js/misc/LoversWatching.js b/js/misc/LoversWatching.js new file mode 100644 index 0000000..d7590e7 --- /dev/null +++ b/js/misc/LoversWatching.js @@ -0,0 +1,31 @@ +Game.addToManifest({ + lovers_watching: "sprites/misc/lovers_watching.json" +}); +function LoversWatching(type){ + + var self = this; + var mc = MakeMovieClip("lovers_watching"); + self.graphics = mc; + + self.breathe = 0; + self.breatheSpeed = 0; + if(type=="circle"){ + mc.x = 520; + mc.y = 380; + self.breatheSpeed = 0.025; + mc.gotoAndStop(0); + }else{ + mc.x = 550; + mc.y = 375; + self.breatheSpeed = 0.020; + mc.gotoAndStop(1); + } + + self.update = function(){ + var scale = 1 + Math.sin(self.breathe)*0.02; + mc.scale.x = scale; + mc.scale.y = 1/scale; + self.breathe += self.breatheSpeed; + }; + +} \ No newline at end of file diff --git a/js/peeps/AngryPeep.js b/js/peeps/AngryPeep.js new file mode 100644 index 0000000..8777d22 --- /dev/null +++ b/js/peeps/AngryPeep.js @@ -0,0 +1,234 @@ +Game.addToManifest({ + face_angry: "sprites/peeps/face_angry.json", + body_red: "sprites/peeps/body_red.json", + + shout: "sounds/shout.mp3" +}); + +/**** + +FRAMES: +00-05: frown at screen +06-10: anger awayyyyyy! +11-25: SHOUT! // loop back to 10. (>=20, no, not screaming) + +****/ + +function AngryPeep(scene, type){ + + var self = this; + Peep.apply(self, [scene]); + self._CLASS_ = "AngryPeep"; + + // Add the body & face sprites + var g = self.graphics; + self.bodyMC = self.addMovieClip("body"); + self.bodyRedMC = self.addMovieClip("body_red"); + self.bodyRedMC.alpha = 0; + self.faceMC = self.addMovieClip("face_angry"); + self.faceMC.anchor.x = 0.333333333; + self.faceMC.gotoAndStop(0); + + // Set Type: Am I a circle or square? + self.type = "???"; + self.setType = function(type){ + self.type = type; + self.bodyMC.gotoAndStop((type=="circle") ? 0 : 1); + self.bodyRedMC.gotoAndStop(self.bodyMC.currentFrame); + }; + self.setType(type); + + // IS SHOUTING? + self.isShouting = false; + + // Animate on triples + var doubles = 0; + var MODE = -1; + var MODE_STARE = 0; + var MODE_BLINK = 1; + var MODE_SHOUT = 2; + self.gracePeriod = -1; + + // HACK + self.HACK_JUMPSTART = function(){ + MODE = MODE_BLINK; + }; + + // WANDERING + self.wander = 0; + self.changeWander = function(){ + self.wander = Math.random()*0.1-0.05; + }; + + self.callbacks.update = function(){ + + // Animate on doubles! ...or... TRIPLES? + doubles = (doubles+1)%3; + + // Wander around + self.direction += self.wander; + if(Math.random()<0.05) self.changeWander(); + self.stayWithinRect({ + l:100, r:860, t:100, b:480 + },0.15); + + // FRAMES: MANUALLY + var face = self.faceMC; + var frame = face.currentFrame; + if(doubles==0){ + switch(MODE){ + case MODE_STARE: + if(frame<5) face.gotoAndStop(frame+1); + break; + case MODE_BLINK: + if(frame<10){ + face.gotoAndStop(frame+1); + } + break; + case MODE_SHOUT: + if(frame<25){ + face.gotoAndStop(frame+1); + }else{ + face.gotoAndStop(10); + MODE = MODE_BLINK; + self.isShouting = false; + self.startWalking(); + } + break; + } + } + + if(frame>=10){ + self.bodyRedMC.alpha = self.bodyRedMC.alpha*0.9 + 1*0.1; + } + + /////////////////////////// + /////////////////////////// + /////////////////////////// + + // Less red bod... + // self.bodyRedMC.alpha *= 0.985; + + // Scream at THE OPPOSITE TYPE + // Grace period... AND IF SCENE ALLOWS IT. + if(self.gracePeriod<=0 && !scene.noYellingYet){ + var opposite = (self.type=="circle") ? "square" : "circle"; + var closeTo = self.touchingPeeps(90, function(peep){ + return(!peep.offended && peep.isWalking && peep.type==opposite); + }); + if(self.isWalking && closeTo.length>0){ + + var other = closeTo[0]; + + // Bounce TOWARDS + self.flip = (other.x>self.x) ? 1 : -1; + self.bounce = 1.7; + self.vel.y = 0; + self.vel.x = 3*self.flip; + + // BE SHOCKED + MODE = MODE_SHOUT; + + self.isWalking = false; + self.isShouting = true; + + // AHHHHH + var peeps = scene.world.peeps; + var angry = peeps.filter(function(peep){ + return(peep._CLASS_=="AngryPeep"); + }); + var angryNum = angry.length; + var volume; + if(angryNum<5) volume=1; + else if(angryNum<10) volume=0.70; + else if(angryNum<15) volume=0.42; + else volume=0.27; + var shout = Game.sounds.shout; + shout.volume(volume); + shout.play(); + + // MAKE BOD REDDER + // self.bodyRedMC.alpha = 1; + + // GRACE... + self.gracePeriod = _s(2.5); + + // If the closeTo is ANOTHER ANGRY ONE. + // They get confused! + if(other._CLASS_=="NormalPeep"){ + if(other.shocked) return; + other.vel.x = self.flip*5; + other.flip = -1*self.flip; + other.beShocked(self); + }else{ + // nothing...? + } + + } + }else{ + self.gracePeriod--; + } + + }; + + // WEIRD WALK + self.walkAnim = function(){ + + // Hop & flip + self.hop += self.speed/40; + if(self.hop>1) self.hop--; + self.flip = (self.vel.x<0) ? -1 : 1; + + // Hop up & down + var t = self.hop*Math.TAU; + g.pivot.y = Math.abs(Math.sin(t))*15; + g.rotation = 0; + + // Squash at the bottom of your cycle + if(self._lastHop<0.5 && self.hop>=0.5) self.bounce = 1.2; + if(self._lastHop>0.9 && self.hop<=0.1) self.bounce = 1.2; + + }; + self.callbacks.startWalking = function(){ + self.speed = 1.7; + }; + self.callbacks.startWalking(); + + // AT FIRST... + self.watchTV = function(){ + + self.clearAnims(); // just in case... + + // 0) Stop & look + var tv = scene.tv; + self.stopWalking(true); + self.flip = (tv.x>self.x) ? 1 : -1; + var OFFSET = (Math.abs(self.x-tv.x)-60)/100; + var WAIT = Director.ZOOM_OUT_1_TIME + Director.SEE_VIEWERS_TIME; + + // 1) Become frowny + self.setTimeout(function(){ + + self.bounce = 1.6; + MODE = MODE_STARE; + + // SQUEAK + Game.sounds.squeak.play(); + + },_s(BEAT*2+OFFSET)); + + // 2) Blink... + self.setTimeout(function(){ + self.bounce = 1.3; + MODE = MODE_BLINK; + },_s(WAIT+OFFSET)); + + // 3) And go on. + self.setTimeout(function(){ + // self.bounce = 1.2; + self.startWalking(); + },_s(WAIT+1+OFFSET)); + + }; + +} \ No newline at end of file diff --git a/js/peeps/CrazyPeep.js b/js/peeps/CrazyPeep.js new file mode 100644 index 0000000..fc8f28f --- /dev/null +++ b/js/peeps/CrazyPeep.js @@ -0,0 +1,171 @@ +Game.addToManifest({ + + hangry: "sprites/peeps/hangry.json", + + scream: "sounds/scream.mp3" + +}); + +/**** + +FRAMES: +00-09: walk loop +10-20: shout (14-19 as 2ndary loop) + +****/ + +function CrazyPeep(scene){ + + var self = this; + Peep.apply(self, [scene]); + self._CLASS_ = "CrazyPeep"; + + // MAD SPRITE + var g = self.graphics; + self.bodyMC = self.addMovieClip("hangry"); + self.bodyMC.anchor.x = 0.33; // not quite + + // STARTING POS & DIRECTION + self.x = 1200; + self.y = 330; + self.direction = Math.PI; + self.loop = false; + + // GRACE PERIODS FOR YELLIN' + self.metaGracePeriod = _s(BEAT*3.5); + self.wanderGracePeriod = _s(2); + self.gracePeriod = _s(4.5); + + // WANDERING + self.wander = 0; + self.changeWander = function(){ + self.wander = Math.random()*0.1-0.05; + }; + self.callbacks.update = function(){ + + // NOPE + if(self.metaGracePeriod>0){ + self.metaGracePeriod--; + if(self.metaGracePeriod==0){ + self.callbacks.startWalking(); + } + return; // NO MORE. + } + + // Grace Period + if(self.gracePeriod>0){ + self.gracePeriod--; + } + if(self.wanderGracePeriod>0){ + self.wanderGracePeriod--; + } + + // Animate on doubles + doubles = (doubles+1)%2; + + // Wander around + if(self.wanderGracePeriod<=0){ + self.direction += self.wander; + if(Math.random()<0.05) self.changeWander(); + } + + // STAY WITHIN GAME FRAME + if(self.wanderGracePeriod<=0){ + self.stayWithinRect({ + l:100, r:860, t:100, b:480 + },0.15); + } + + // BUMP the walking peeps I'm close to. + if(self.gracePeriod<=0){ + var closeTo = self.touchingPeeps(50, function(peep){ + return peep.isWalking; + }); + if(closeTo.length>0 && self.isWalking){ + + // STOP & SHOUT + self.isWalking = false; + self.bodyMC.gotoAndStop(10); + loopScreaming = 2; + self.direction += Math.PI; + + // AHHHHH + Game.sounds.scream.play(); + + // Grace Period + self.gracePeriod = _s(1); + + // SHOCK 'EM + closeTo.forEach(function(other){ + if(!other.isWalking) return; + other.vel.x = self.flip*10; + other.flip = -1*self.flip; + other.beShocked(); + }); + + } + } + + }; + self.callbacks.startWalking = function(){ + self.speed = 2; + }; + self.speed = 0; + + // Animate on doubles + var doubles = 0; + var loopScreaming = -1; + + // WEIRD WALK + self.walkAnim = function(){ + + // Hop & flip + self.hop += self.speed/50; + if(self.hop>1) self.hop--; + self.flip = (self.vel.x<0) ? -1 : 1; + + // Hop up & down + var t = self.hop*Math.PI; + g.pivot.y = Math.abs(Math.sin(t))*20; + + // FRAMES: MANUALLY + if(doubles==0){ + var nextFrame = self.bodyMC.currentFrame+1; + if(nextFrame>9) nextFrame=0; + self.bodyMC.gotoAndStop(nextFrame); + } + + }; + + // SHOUT STANDING + self.standAnim = function(){ + + g.rotation = 0; + g.pivot.y = 0; + + // FRAMES: MANUALLY + if(doubles==0){ + var nextFrame = self.bodyMC.currentFrame+1; + if(loopScreaming>0){ + if(nextFrame>19){ + nextFrame=16; + loopScreaming--; + } + }else{ + if(nextFrame>20){ + nextFrame=0; + self.isWalking = true; + loopScreaming--; + } + } + self.bodyMC.gotoAndStop(nextFrame); + } + + }; + + // IS SCREAMING? + self.isScreaming = function(){ + return(loopScreaming>=0); + }; + +} \ No newline at end of file diff --git a/js/peeps/EvilHatPeep.js b/js/peeps/EvilHatPeep.js new file mode 100644 index 0000000..444ac0b --- /dev/null +++ b/js/peeps/EvilHatPeep.js @@ -0,0 +1,142 @@ +Game.addToManifest({ + gun: "sprites/peeps/gun.json", + + gun_cock: "sounds/gun_cock.mp3" +}); + +/**** + +Same. Except.... +A GUN. + +Gun MC: +00-17: pulling it out. + +****/ + +function EvilHatPeep(scene){ + + var self = this; + Peep.apply(self, [scene]); + self._CLASS_ = "EvilHatPeep"; + + // Add the body & GUN sprites + self.gunMC = self.addMovieClip("gun"); + self.gunMC.gotoAndStop(0); + self.bodyMC = self.addMovieClip("hatguy"); + self.bodyMC.gotoAndStop(0); + + // Position. + self.loop = false; + self.x = -300; + //self.x = 300; // HAAAACK + self.y = 470; + self.direction = 0; + + // WHO TO KILL + self.victim = null; // plz tell this peep. + self.freezeEveryone = null; // plz tell this peep. + self.bang = null; // plz tell this peep. + + // Goes through the spot... + var doubles = 0; + var MODE = 0; + MODE_WALK = 0; + MODE_GUN = 1; + self.goThroughSpots = true; + self.callbacks.update = function(){ + + if(self.x>420 && !self.isMurdering){ + self.itsMurderTime(); + } + + // Animate on triples. + doubles = (doubles+1)%3; + var gun = self.gunMC; + var frame = gun.currentFrame; + if(doubles==0){ + switch(MODE){ + case MODE_GUN: + if(frame<17) gun.gotoAndStop(frame+1); + break; + } + } + + // SPEED ONLY WHEN SEEN + if(MODE==MODE_WALK){ + self.speed = scene.director.isWatchingTV ? 0 : 1.25; + } + + }; + + // WEIRD WALK + self.walkAnim = function(){ + + // Hop & flip + self.hop += self.speed/40; + if(self.hop>1) self.hop--; + self.flip = (self.vel.x<0) ? -1 : 1; + + // Hop up & down + var t = self.hop*Math.TAU; + var g = self.graphics; + g.rotation = Math.sin(t)*0.2; + g.pivot.y = Math.abs(Math.sin(t))*7; + + }; + // WOBBLE IN PLACE + /*self.standAnim = function(){ + + // Hop & flip + self.hop += self.speed/200; + if(self.hop>1) self.hop--; + + // Hop up & down + var t = self.hop*Math.TAU; + var g = self.graphics; + g.rotation = Math.sin(t)*0.035; + g.pivot.y = 0; + + };*/ + + // IT'S MURDER TIME + self.isMurdering = false; + self.hasGunOut = false; + self.pauseAnimsWhenNotWatching = true; + self.itsMurderTime = function(){ + + // STOP. + self.isMurdering = true; + self.stopWalking(); + self.bounce = 1.2; + + // Half Beat. + // Happy Smiles at you. + self.setTimeout(function(){ + self.victim.smile(); + },_s(0.5)); + + // +1.5 beats. + // Pull out gun. Happy frowns. + // AND EVERYONE FREEZES. + self.setTimeout(function(){ + self.hasGunOut = true; + Game.sounds.bg_park.stop(); // STAHP. + Game.sounds.gun_cock.play(); // SOUND + MODE = MODE_GUN; + },_s(0.5+1.5)); + self.setTimeout(function(){ + self.freezeEveryone(); + self.victim.frown(); + },_s(0.5+1.5+0.5)); + + // +4 beats. + // BANG. + self.setTimeout(function(){ + Game.sounds.gunshot.play(); + self.bang(); + },_s(0.5+1.5+4.0)); + + } + +} \ No newline at end of file diff --git a/js/peeps/HappyWeirdoPeep.js b/js/peeps/HappyWeirdoPeep.js new file mode 100644 index 0000000..e6b2884 --- /dev/null +++ b/js/peeps/HappyWeirdoPeep.js @@ -0,0 +1,139 @@ +Game.addToManifest({ + happy_weirdo: "sprites/peeps/happy_weirdo.json" +}); + +/**** + +FRAMES: +00-00: happy still +01-02: blink to greet murderer +03-05: shock. + +****/ + +function HappyWeirdoPeep(scene){ + + var self = this; + Peep.apply(self, [scene]); + self._CLASS_ = "HappyWeirdoPeep"; + + // position + self.x = 115; + self.y = 170; + + // MAD SPRITE + var g = self.graphics; + self.bodyMC = self.addMovieClip("happy_weirdo"); + self.bodyMC.anchor.x = 0.35; // not quite + + // MODE o' ANIMATION + var MODE = -1; + MODE_SMILE = 1; + MODE_FROWN = 2; + self.smile = function(){ + MODE = MODE_SMILE; + }; + self.frown = function(){ + MODE = MODE_FROWN; + }; + var doubles = 0; + + // WANDERING + self.wander = 0; + self.changeWander = function(){ + self.wander = Math.random()*0.1-0.05; + }; + self.callbacks.update = function(){ + + // Wander around + self.direction += self.wander; + if(Math.random()<0.05) self.changeWander(); + + // STAY WITHIN GAME FRAME + self.stayWithinRect({ + l:100, r:860, t:100, b:480 + },0.15); + + // Animation! on quadtriples. + doubles = (doubles+1)%4; + var body = self.bodyMC; + var frame = body.currentFrame; + if(doubles==0){ + switch(MODE){ + case MODE_SMILE: + if(frame<2) body.gotoAndStop(frame+1); + break; + case MODE_FROWN: + if(frame<5) body.gotoAndStop(frame+1); + break; + } + } + + }; + self.callbacks.startWalking = function(){ + self.speed = 2; + }; + self.callbacks.startWalking(); + + // WEIRD WALK + self.hop = 0; + self._lastHop = 0.99; + self.direction = 1; + self.walkAnim = function(){ + + // Hop & flip + self.hop += self.speed/50; + if(self.hop>1) self.hop--; + self.flip = (self.vel.x<0) ? -1 : 1; + + // Hop up & down + var t = self.hop*Math.PI; + g.pivot.y = Math.abs(Math.sin(t))*20; + g.rotation = 0; + + // Squash at the bottom of your cycle + if(self._lastHop>0.9 && self.hop<=0.1) self.bounce=1.2; + + }; + + // WOBBLE IN PLACE + self.standAnim = function(){ + + // Hop & flip + self.hop += self.speed/150; + if(self.hop>1) self.hop--; + self.flip = (self.vel.x<0) ? -1 : 1; + + // Wobble! + if(MODE!=MODE_FROWN){ + var t = self.hop*Math.TAU; + g.rotation = Math.sin(t)*0.1; + g.pivot.y = 0; + } + + }; + + // Prepare to get murdered + self.prepareForMurder = function(){ + + // Wobble in place + self.stopWalking(); + self.x = 540; + self.y = 470; + self.vel.x = -1; + self.vel.y = 0; + self.flip = -1; + + // AVOID SPOT. BAD STUFF GON' HAPPEN. + var spot = { + x: 480, + y: 430, + radius: 150 + }; + scene.avoidSpots.push(spot); + + }; + + // GET MURDERED + +} \ No newline at end of file diff --git a/js/peeps/HatPeep.js b/js/peeps/HatPeep.js new file mode 100644 index 0000000..d1c4349 --- /dev/null +++ b/js/peeps/HatPeep.js @@ -0,0 +1,46 @@ +Game.addToManifest({ + hatguy: "sprites/peeps/hatguy.json" +}); + +/**** + +JUST WADDLE BACK & FORTH + +****/ + +function HatPeep(scene){ + + var self = this; + Peep.apply(self, [scene]); + self._CLASS_ = "HatPeep"; + + // Add the body & face sprites + self.bodyMC = self.addMovieClip("hatguy"); + self.bodyMC.gotoAndStop(0); + + self.callbacks.update = function(){ + + // stay within game frame + self.stayWithinRect({ + l:100, r:860, t:100, b:480 + },0.05); + + }; + + // WEIRD WALK + self.walkAnim = function(){ + + // Hop & flip + self.hop += self.speed/40; + if(self.hop>1) self.hop--; + self.flip = (self.vel.x<0) ? -1 : 1; + + // Hop up & down + var t = self.hop*Math.TAU; + var g = self.graphics; + g.rotation = Math.sin(t)*0.2; + g.pivot.y = Math.abs(Math.sin(t))*7; + + }; + +} \ No newline at end of file diff --git a/js/peeps/HelpingAnim.js b/js/peeps/HelpingAnim.js new file mode 100644 index 0000000..88c06ee --- /dev/null +++ b/js/peeps/HelpingAnim.js @@ -0,0 +1,138 @@ +Game.addToManifest({ + helping: "sprites/peeps/helping.json" +}); + +/**** + +HELPING!! +000-110: helping +(12: SCREAM!) +(70: helped!) +(and then 1 second pause...) +111: no-lover frame + +****/ + +function HelpingAnim(scene){ + + var self = this; + AnimationProp.apply(self, [scene]); + self._CLASS_ = "HelpingAnim"; + + // INIT + self.init(180, 170, "helping"); + + // AVOID SPOT + var spot = { + x: self.x, + y: self.y-40, + radius: 170 + }; + scene.avoidSpots.push(spot); + scene.noYellingYet = true; + + // Helped? + self.hasHelped = false; + + // ANIMATION CODE + var MODE = 0; + MODE_HELPING = 0; + self.triples = 0; + var gracePeriod = _s(Director.ZOOM_OUT_2_TIME*0.8); + var frame2 = 0; + self.updateAnimation = function(){ + + // ONLY PAST GRACE... + if(scene.director.isWatchingTV){ + gracePeriod = _s(Director.ZOOM_OUT_2_TIME*0.9); + } + if(gracePeriod>0){ + gracePeriod--; + return; + } + + // ANIMATE on TRIPLES + // AND ONLY WHEN NOT WATCHING TV. + self.triples = (self.triples+1)%3; + if(self.triples==0 && !scene.director.isWatchingTV){ + + var mc = self.mc; + var totalFrames = mc.totalFrames; + var frame = mc.currentFrame; + + switch(MODE){ + case MODE_HELPING: + if(frame<110){ + frame = frame+1; + mc.gotoAndStop(frame); + if(frame==12) Game.sounds.scream.play(); + if(frame==70){ + self.hasHelped=true; + Game.sounds.squeak.play();// SQUEAK + } + }else{ + frame2++; + if(frame2>20){ + mc.gotoAndStop(111); + self.byeLovers(); + } + if(frame2>170){ + self.byeSelf(); + } + } + break; + } + + } + + }; + + // REPLACE WITH WEIRDO & LOVERS + self.loversGone = false; + self.byeLovers = function(){ + + // ONCE + if(self.loversGone) return; + self.loversGone = true; + + // Put in lovers #2, they just run off screen. + var lover1 = new LoverPeep(self.scene); + lover1.x = 188; + lover1.y = 165; + lover1.setType("circle"); + lover1.startWalking(); + lover1.hatMC.visible = false; + lover1.faceMC.gotoAndStop(6); + lover1.bounceVel = 0.22; + lover1.loop = false; + + var lover2 = new LoverPeep(self.scene); + lover2.follow(lover1); + lover2.x = 235; + lover2.y = 165; + lover2.setType("square"); + lover2.startWalking(); + lover2.faceMC.gotoAndStop(6); + lover2.bounceVel = 0.22; + lover2.loop = false; + + self.scene.world.addPeep(lover1); + self.scene.world.addPeep(lover2); + + // Remove spot + scene.avoidSpots.splice(scene.avoidSpots.indexOf(spot),1); + scene.noYellingYet = false; + + }; + self.byeSelf = function(){ + + // Put in the Happy Weirdo! + var happyWeirdo = new HappyWeirdoPeep(self.scene); + self.scene.world.addPeep(happyWeirdo); + + // KILL! + self.kill(); + + }; + +} \ No newline at end of file diff --git a/js/peeps/LoverPeep.js b/js/peeps/LoverPeep.js new file mode 100644 index 0000000..1ceee60 --- /dev/null +++ b/js/peeps/LoverPeep.js @@ -0,0 +1,158 @@ +Game.addToManifest({ + lovehat: "sprites/peeps/lovehat.json", + lover_shirt: "sprites/peeps/lover_shirt.json" +}); + +/**** + +FRAMES for "face": +08: LUV +09: Embarrassed looking up +10: Embarrassed blink +11: Embarrassed look fwd + +****/ + +function LoverPeep(scene){ + + var self = this; + NormalPeep.apply(self, [scene]); + self._CLASS_ = "LoverPeep"; + + // Add the body & face sprites + self.hatMC = self.addMovieClip("lovehat"); + self.shirtMC = self.addMovieClip("lover_shirt"); + self.faceMC.gotoAndStop(8); + + // Set Type: ALSO CHANGE SHIRT + var _oldSetType = self.setType; + self.setType = function(type){ + _oldSetType(type); + self.shirtMC.gotoAndStop((type=="circle") ? 0 : 1); + }; + + // STARTING POS + self.x = 1000; + self.y = 580; + + // Follow? + self.follows = null; + self.follow = function(follow){ + self.follows = follow; + self.x = self.follows.x; + self.y = self.follows.y; + }; + self.callbacks.update = function(){ + if(self.follows){ + + var f = self.follows; + var tx = f.x - Math.cos(f.direction)*20; + var ty = f.y - Math.sin(f.direction)*20; + + // LOOP THEM BOUNDS + var margin = 50; + var dx = tx-self.x; + while(dx>300){ + tx -= Game.width+margin*2; + dx = tx-self.x; + } + while(dx<-300){ + tx += Game.width+margin*2; + dx = tx-self.x; + } + var dy = ty-self.y; + while(dy>300){ + ty -= Game.height+margin*2; + dy = ty-self.y; + } + while(dy<-300){ + ty += Game.height+margin*2; + dy = ty-self.y; + } + + var direction = Math.atan2(dy,dx); + self.direction = direction; + }else{ + + // stay within game frame + /*self.stayWithinRect({ + l:100, r:860, t:100, b:480 + },0.05);*/ + + } + + if(self.follows && self.isEmbarrassed && self.x>1100){ + self.follows.kill(); + self.kill(); + } + + if(self.follows && self.x<-500){ + self.follows.kill(); + self.kill(); + } + + }; + self.callbacks.startWalking = function(){ + self.direction = 3.3; // a bit upwards from a full-left + self.speed = 1.3; + }; + var _pastWalkAnim = self.walkAnim; + self.walkAnim = function(){ + if(self.follows) self.hop+=self.speed/120; + _pastWalkAnim(); + }; + self.callbacks.startWalking(); + + // STAHP. *THEN walk.* + self.stopWalking(); + self.setTimeout(function(){ + self.startWalking(); + },_s(BEAT*4)); + + // MAKE EMBARRASSED + self.isEmbarrassed = false; + self.makeEmbarrassed = function(){ + + self.clearAnims(); // just in case... + + // 1) Stop & look + var tv = scene.tv; + self.x = tv.x; + self.y = tv.y-5-Math.random(); // tiny offset to avoid glitchy depth-sort + if(self.type=="square"){ + self.x += 80; + }else{ + self.x += 120; + } + self.stopWalking(true); + self.faceMC.gotoAndStop(9); + self.flip = (tv.x>self.x) ? 1 : -1; + var WAIT = 3.7*BEAT; + self.isWatching = true; + + // 2) Blink... + self.setTimeout(function(){ + + self.isWatching = false; + self.faceMC.gotoAndStop(10); + self.bounce = 1.2; + + },_s(WAIT)); + + // 3) And go on. + self.setTimeout(function(){ + + self.isEmbarrassed = true; + self.faceMC.gotoAndStop(11); + + // GET ON OUT + self.startWalking(); + self.loop = false; + self.direction = 0; + self.speed = 3; + + },_s(WAIT+0.06)); + + }; + +} \ No newline at end of file diff --git a/js/peeps/MurderPeep.js b/js/peeps/MurderPeep.js new file mode 100644 index 0000000..f4c7cb1 --- /dev/null +++ b/js/peeps/MurderPeep.js @@ -0,0 +1,244 @@ +Game.addToManifest({ + + face_murder: "sprites/peeps/face_murder.json", + + weapon_gun: "sprites/peeps/weapon_gun.json", + weapon_axe: "sprites/peeps/weapon_axe.json", + weapon_bat: "sprites/peeps/weapon_bat.json", + weapon_shotgun: "sprites/peeps/weapon_shotgun.json", + + gunshot: "sounds/gunshot.mp3", + shotgun: "sounds/shotgun.mp3", + impact: "sounds/impact.mp3" + +}); + +/**** + +FACE FRAMES: +00-04: crazy at screen (loop) +05-13: blink, and crazy forever (loop: 09-13) + +WEAPON FRAMES: +00-05: pull out (04 is rest) +06: BAM +07-15: return to rest (04 is rest) + +****/ + +function MurderPeep(scene){ + + var self = this; + Peep.apply(self, [scene]); + self._CLASS_ = "MurderPeep"; + + // Add the body & face sprites + self.type = "???"; + self.bodyMC = self.addMovieClip("body"); + self.faceMC = self.addMovieClip("face_murder"); + self.weaponType = null; + self.weaponMC = null; + + // Init with what kinda weapon? + self.init = function(shapeType, weaponType){ + + // Type + self.type = shapeType; + self.bodyMC.gotoAndStop((shapeType=="circle") ? 0 : 1); + + // Weapon + self.weaponType = weaponType; + self.weaponMC = self.addMovieClip("weapon_"+weaponType); + self.weaponMC.gotoAndStop(0); + + // Transform + self.x = scene.tv.x; + self.y = scene.tv.y+Math.random(); // tiny offset to avoid glitchy depth-sort + if(shapeType=="circle"){ + self.x -= 60; + self.flip = 1; + self.gracePeriod = 30; + }else{ + self.x += 60; + self.flip = -1; + self.gracePeriod = 50; + } + + // Let's Watch TV! + self.watchTV(); + + }; + + // Animate on doubles + var MODE = 0; + var MODE_STARE = 0; + var MODE_CRAZY = 1; + var MODE_KILL = 2; + + // Animate! + var doubles = 0; + self.gracePeriod = -1; + self.standingTime = -1; + self.callbacks.update = function(){ + + // Animate on doubles! ...or... TRIPLES? + doubles = (doubles+1)%4; + + // stay within game frame + self.stayWithinRect({ + l:100, r:860, t:100, b:480 + },0.15); + + // FRAMES: MANUALLY + if(doubles==0){ + + var frame; + + // Face + var face = self.faceMC; + frame = face.currentFrame; + switch(MODE){ + case MODE_STARE: + if(frame<4) face.gotoAndStop(frame+1); + else face.gotoAndStop(0); + break; + case MODE_CRAZY: + if(frame<13) face.gotoAndStop(frame+1); + else face.gotoAndStop(9); + break; + } + + // Weapon + var weapon = self.weaponMC; + frame = weapon.currentFrame; + if(MODE==MODE_CRAZY || MODE==MODE_KILL){ + if(frame<5){ + weapon.gotoAndStop(frame+1); + } + if(frame>=6){ + if(frame<15){ + weapon.gotoAndStop(frame+1); + }else{ + if(self.standingTime<=0){ + self.startWalking(); + weapon.gotoAndStop(5); + }else{ + self.standingTime--; + } + } + } + } + + } + + /////////////////////////// + /////////////////////////// + /////////////////////////// + + // KILL THE OTHER KIND + if(self.gracePeriod<=0){ + if(!self.isShocked){ + var otherType = (self.type=="circle") ? "square" : "circle"; + var closeTo = self.touchingPeeps(120, function(peep){ + return(peep._CLASS_=="PanicPeep" && peep.type==otherType); + }); + if(closeTo.length>0 && self.isWalking){ + + // FACE 'EM + self.flip = (closeTo[0].x>self.x) ? 1 : -1; + + // USE WEAPON + MODE = MODE_KILL; + self.weaponMC.gotoAndStop(6); + self.gracePeriod = _s(BEAT*2); + self.bounce = 1.6; + self.standingTime = 5; // hack + self.stopWalking(); + + // What sound? + var sound = null; + var volume = 0.2; + switch(self.weaponType){ + case "gun": + sound = Game.sounds.gunshot; + break; + case "axe": case "bat": + sound = Game.sounds.impact; + break; + case "shotgun": + sound = Game.sounds.shotgun; + break; + } + sound.volume(volume); + sound.play(); + + // TODO: Actually hurt 'em + closeTo[0].getKilledBy(self); + + } + } + }else if(self.isWalking){ + self.gracePeriod--; + } + + }; + + // Speed... + self.callbacks.startWalking = function(){ + self.speed = 3; + }; + + // SAME WALK ANIM, EXCEPT: RANDOM ROTATION + self.walkAnim = function(){ + var g = self.graphics; + + // Hop & Flip + self.hop += self.speed/40; + if(self.hop>1) self.hop--; + self.flip = (self.vel.x<0) ? -1 : 1; + + // Sway back & forth + var t = self.hop*Math.PI*2; + g.pivot.y = Math.abs(Math.sin(t))*15; + g.rotation = (Math.random()*2-1)*0.05; + + }; + + // SAME STAND ANIM, EXCEPT: RANDOM ROTATION + self.standAnim = function(){ + var g = self.graphics; + g.rotation = (Math.random()*2-1)*0.05; + g.pivot.y = 0; + }; + + // AT FIRST... + self.watchTV = function(){ + + self.clearAnims(); // just in case... + + // 0) Stop & look + var tv = scene.tv; + self.stopWalking(true); + self.flip = (tv.x>self.x) ? 1 : -1; + var OFFSET = 0; // (Math.abs(self.x-tv.x)-60)/100; + var WAIT = Director.ZOOM_OUT_1_TIME + Director.SEE_VIEWERS_TIME; + + // 1) Become nervous + self.setTimeout(function(){ + self.bounce = 1.6; + MODE = MODE_CRAZY; + },_s(OFFSET+BEAT*2)); + + // 3) And go on. + self.setTimeout(function(){ + self.startWalking(); + if(self.type=="circle"){ + self.direction = Math.PI + (Math.random()*2-1); + }else{ + self.direction = (Math.random()*2-1); + } + },_s(OFFSET+WAIT+1)); + + }; + +} \ No newline at end of file diff --git a/js/peeps/NervousPeep.js b/js/peeps/NervousPeep.js new file mode 100644 index 0000000..245a3e2 --- /dev/null +++ b/js/peeps/NervousPeep.js @@ -0,0 +1,212 @@ +Game.addToManifest({ + + face_nervous: "sprites/peeps/face_nervous.json", + + peep_gasp: "sounds/peep_gasp.mp3", + peep_hngh: "sounds/peep_hngh.mp3" + +}); + +/**** + +FRAMES: +00-03: nervous at screen +00-06: look away from screen (frame 06 is resting) +08-10: look backwards +12-16: look forward (then loop to 06) +17-22: shocked +23-25: run away +26-29: return to normal (frame 06 is resting) + +****/ + +function NervousPeep(scene){ + + var self = this; + Peep.apply(self, [scene]); + self._CLASS_ = "NervousPeep"; + + // Add the body & face sprites + self.bodyMC = self.addMovieClip("body"); + self.faceMC = self.addMovieClip("face_nervous"); + self.faceMC.gotoAndStop(0); + + // Animate on doubles + var MODE = -1; + var MODE_STARE = 0; + var MODE_BLINK = 1; + var MODE_SHOCKED = 2; + var MODE_RUNAWAY = 3; + var MODE_CALMDOWN = 4; + + // HACK + self.HACK_JUMPSTART = function(){ + MODE = MODE_BLINK; + }; + + var doubles = 0; + self.isShocked = false; + self.callbacks.update = function(){ + + // Animate on doubles! ...or... TRIPLES? + doubles = (doubles+1)%3; + + // stay within game frame + self.stayWithinRect({ + l:150, r:810, t:150, b:450 + },0.05); + + // FRAMES: MANUALLY + var face = self.faceMC; + var frame = face.currentFrame; + if(doubles==0){ + switch(MODE){ + case MODE_STARE: + if(frame<3) face.gotoAndStop(frame+1); + break; + case MODE_BLINK: + if(frame<6) face.gotoAndStop(frame+1); + + // Look shifty... + if(frame==6){ + if(Math.random()<0.05) face.gotoAndStop(frame+1); + }else if(frame<10){ + face.gotoAndStop(frame+1); + }else if(frame==10){ + if(Math.random()<0.05) face.gotoAndStop(frame+1); + }else if(frame<16){ + face.gotoAndStop(frame+1); + }else if(frame==16){ + face.gotoAndStop(6); + } + + break; + case MODE_SHOCKED: + if(frame<22) face.gotoAndStop(frame+1); + break; + case MODE_RUNAWAY: + if(frame<25) face.gotoAndStop(frame+1); + break; + case MODE_CALMDOWN: + if(frame<29){ + face.gotoAndStop(frame+1); + }else{ + face.gotoAndStop(6); + MODE = MODE_BLINK; + self.isShocked = false; + } + break; + } + } + + /////////////////////////// + /////////////////////////// + /////////////////////////// + + // Shocked by a square! + if(!self.isShocked){ + var closeTo = self.touchingPeeps(90, function(peep){ + return(peep.isWalking && peep.type=="square"); + }); + if(closeTo.length>0 && self.isWalking){ + + // BE SHOCKED + MODE = MODE_SHOCKED; + self.isWalking = false; + face.gotoAndStop(17); + self.isShocked = true; + + // Sound! + Game.sounds.peep_gasp.play(); + + // Bounce back + self.flip = (closeTo[0].x>self.x) ? 1 : -1; + self.bounce = 1.5; + self.vel.x = -self.flip*5; + + // They get confused! + closeTo.forEach(function(other){ + if(!other.isWalking) return; + other.beConfused(self); + }); + + // Run away! + self.setTimeout(function(){ + + // Sound! + Game.sounds.peep_hngh.volume(0.6); + Game.sounds.peep_hngh.play(); + + // RUN! + MODE = MODE_RUNAWAY; + self.flip *= -1; + self.bounce = 1.5; + self.startWalking(); + self.speed = 3.5; + if(self.flip>0){ + self.direction = Math.TAU*0/4; + }else{ + self.direction = Math.TAU*2/4; + } + + // Calm down... + self.setTimeout(function(){ + MODE = MODE_CALMDOWN; + self.callbacks.startWalking(); + },_s(3)); + + + },_s(1)); + + } + } + + }; + + // Speed... + self.callbacks.startWalking = function(){ + self.speed = 0.8; + }; + + // AT FIRST... + self.watchTV = function(){ + + self.clearAnims(); // just in case... + + // 0) Stop & look + var tv = scene.tv; + self.stopWalking(true); + self.flip = (tv.x>self.x) ? 1 : -1; + var OFFSET = 0; // (Math.abs(self.x-tv.x)-60)/100; + var WAIT = Director.ZOOM_OUT_1_TIME + Director.SEE_VIEWERS_TIME; + + // 1) Become nervous + self.setTimeout(function(){ + self.bounce = 1.6; + MODE = MODE_STARE; + + // SQUEAK + Game.sounds.squeak.play(); + + },_s(OFFSET+BEAT*2)); + + // 2) Blink... + self.setTimeout(function(){ + self.bounce = 1.3; + MODE = MODE_BLINK; + },_s(OFFSET+WAIT)); + + // 3) And go on. + self.setTimeout(function(){ + // self.bounce = 1.2; + self.startWalking(); + },_s(OFFSET+WAIT+1)); + + }; + + // IS SCARED? + self.isScared = function(){ + return self.isShocked; + }; + +} \ No newline at end of file diff --git a/js/peeps/NormalPeep.js b/js/peeps/NormalPeep.js new file mode 100644 index 0000000..f3601f3 --- /dev/null +++ b/js/peeps/NormalPeep.js @@ -0,0 +1,328 @@ +Game.addToManifest({ + body: "sprites/peeps/body.json", + face: "sprites/peeps/face.json", + hat: "sprites/peeps/hat.json", + + squeak: "sounds/squeak.mp3" +}); + +/**** + +FRAMES for "body": +0: circle +1: square + +FRAMES for "face": +0: normal +1: looking at TV +2: blink +3: spooked +4: confused +5: offended +6: ^_^ +7: ashamed + +****/ + +function NormalPeep(scene){ + + var self = this; + Peep.apply(self, [scene]); + self._CLASS_ = "NormalPeep"; + + // Add the body & face sprites + self.hatMC = self.addMovieClip("hat"); + self.bodyMC = self.addMovieClip("body"); + self.faceMC = self.addMovieClip("face"); + + // Set Type: Am I a circle or square? + self.type = "???"; + self.setType = function(type){ + self.type = type; + self.bodyMC.gotoAndStop((type=="circle") ? 0 : 1); + }; + + // Animation + var doubles = 0; + self.callbacks.update = function(){ + + // Animate on doubles! ...or... TRIPLES? + doubles = (doubles+1)%3; + + // FRAMES: MANUALLY ANIMATE HAT + var hat = self.hatMC; + var frame = hat.currentFrame; + if(doubles==0){ + if(self.wearingHat && frame<15){ + frame++; + hat.gotoAndStop(frame); + if(frame==11){ + self.bounce=1.6; + Game.sounds.squeak.play(); + } + if(frame==15) self.faceMC.gotoAndStop(6); + } + if(!self.wearingHat && frame>=15){ + frame++; + hat.gotoAndStop(frame); + if(frame==26) hat.gotoAndStop(0); + } + } + + } + + + /////////////////////////////////// + // STUNNED //////////////////////// + + self.stunned = false; + self.beStunned = function(){ + self.stunned = true; + self.stopWalking(); + self.faceMC.gotoAndStop(3); + } + + var _oldStartWalking = self.startWalking; + self.startWalking = function(){ + if(self.stunned) return; + _oldStartWalking(); + } + + + /////////////////////////////////// + // SHOCKED //////////////////////// + + self.shocked = false; + self.beShocked = function(){ + + self.shocked = true; + self.stopWalking(); + self.bounce = 2; + self.faceMC.gotoAndStop(3); + + self.setTimeout(function(){ + self.faceMC.gotoAndStop(0); + self.startWalking(); + self.shocked = false; + },_s(2)); + + } + + /////////////////////////////////// + // CONFUSED /////////////////////// + + self.confused = false; + self.beConfused = function(target){ + + self.flip = (target.x>self.x) ? 1 : -1; + + self.confused = true; + self.stopWalking(); + self.bounce = 1.1; + self.faceMC.gotoAndStop(2); + + self.setTimeout(function(){ + self.faceMC.gotoAndStop(4); + },_s(0.2)); + + self.setTimeout(function(){ + + self.faceMC.gotoAndStop(2); + self.setTimeout(function(){ + self.faceMC.gotoAndStop(0); + },_s(0.2)); + + self.startWalking(); + self.confused = false; + + },_s(2.2)); + + }; + + /////////////////////////////////// + // OFFENDED /////////////////////// + + self.offended = false; + self.beOffended = function(target){ + + self.flip = (target.x>self.x) ? 1 : -1; + self.offended = true; + self.stopWalking(); + + self.clearAnims(); // just in case... + + // Blink + self.bounce = 1.2; + self.faceMC.gotoAndStop(2); + self.setTimeout(function(){ + self.faceMC.gotoAndStop(0); + },_s(0.15)); + + // Blink - Pissed. + self.setTimeout(function(){ + + self.bounce = 1.2; + self.faceMC.gotoAndStop(2); + self.setTimeout(function(){ + self.faceMC.gotoAndStop(5); // PISSED. + },_s(0.15)); + + },_s(1.2)); + + // Walk away + self.setTimeout(function(){ + self.startWalking(); + },_s(3)); + + // Stop being pissed + self.setTimeout(function(){ + self.faceMC.gotoAndStop(2); + self.setTimeout(function(){ + self.faceMC.gotoAndStop(0); + self.offended = false; + },_s(0.2)); + },_s(8)); + + }; + + //////////////////////////////////// + // WEAR A HAT *WHILE WATCHING TV* // + + self.wearingHat = false; + self.wearHat = function(){ + + self.clearAnims(); // just in case... + + // 1) Stop & look + var tv = scene.tv; + self.stopWalking(true); + self.faceMC.gotoAndStop(1); + self.flip = (tv.x>self.x) ? 1 : -1; + var WAIT = Director.ZOOM_OUT_1_TIME + Director.SEE_VIEWERS_TIME; + WAIT += Math.random()*0.4; // random offset + self.isWatching = true; + + // 2) Wear HAT! IN SYNCHRONIZED TIME + var HAT_TIME = Director.ZOOM_OUT_1_TIME + (Math.abs(self.x-tv.x)-60)/100; + self.setTimeout(function(){ + self.wearingHat = true; + },_s(HAT_TIME)); + + // 3) And go on. + self.setTimeout(function(){ + self.isWatching = false; + self.bounce = 1.2; + self.startWalking(); + },_s(WAIT+1)); + + }; + self.takeOffHat = function(instant){ + + self.clearAnims(); // just in case... + + if(!instant){ + + // 1) Stop & look + var tv = scene.tv; + self.stopWalking(true); + self.faceMC.gotoAndStop(1); + self.flip = (tv.x>self.x) ? 1 : -1; + var WAIT = 4*BEAT + Math.random()*0.4; + self.isWatching = true; + + // 2) Take off HAT! + self.setTimeout(function(){ + self.wearingHat = false; + self.bounce = 1.1; + + // Blink, then shame. + self.faceMC.gotoAndStop(2); + self.setTimeout(function(){ + self.faceMC.gotoAndStop(7); + },_s(0.2)); + + },_s( BEAT*1.75 + Math.random()*0.75 )); + + // 3) And go on. + self.setTimeout(function(){ + self.isWatching = false; + self.bounce = 1.2; + self.startWalking(); + self.faceMC.gotoAndStop(0); + },_s(WAIT+0.06)); + + }else{ + self.faceMC.gotoAndStop(0); + self.hatMC.gotoAndStop(0); + self.wearingHat = false; + } + + }; + + /////////////////////////////////////////// + // THINGS THE DIRECTOR CAN TELL ME TO DO // + /////////////////////////////////////////// + + self.getOuttaTV = function(){ + + // just in case... + self.shocked = false; + self.confused = false; + + // TV Rect Bounds + var gx = Game.width/2; + var gy = Game.height/2; + var cw = (440)/2; + var ch = (220)/2; + var bounds = { + l:gx-cw, r:gx+cw, + t:gy-ch, b:gy+ch+80 + }; + + // While within those bounds, go literally anywhere else + while(self.x>bounds.l && self.xbounds.t && self.yself.x) ? 1 : -1; + var WAIT = Director.ZOOM_OUT_1_TIME + Director.SEE_VIEWERS_TIME; + WAIT += Math.random()*0.4; // random offset + self.isWatching = true; + + // 2) Blink... + self.setTimeout(function(){ + self.isWatching = false; + self.faceMC.gotoAndStop(2); + self.bounce = 1.2; + },_s(WAIT)); + + // 3) And go on. + self.setTimeout(function(){ + self.faceMC.gotoAndStop(0); + self.startWalking(); + },_s(WAIT+0.06)); + + }; + +} \ No newline at end of file diff --git a/js/peeps/PanicPeep.js b/js/peeps/PanicPeep.js new file mode 100644 index 0000000..ba927ed --- /dev/null +++ b/js/peeps/PanicPeep.js @@ -0,0 +1,142 @@ +Game.addToManifest({ + lover_panic: "sprites/peeps/lover_panic.json" +}); + +/**** + +I guess they're just NormalPeeps with screaming face & running REAL fast + +****/ + +function PanicPeep(scene){ + + var self = this; + NormalPeep.apply(self, [scene]); + self._CLASS_ = "PanicPeep"; + + // Add the body & face sprites + self.faceMC.gotoAndStop(12); + + self.callbacks.startWalking = function(){ + self.speed = 3+Math.random()*2; + }; + self.startWalking(); + + // Is Lover? + self.setLover = function(type){ + + if(type=="circle"){ + self.x = 635; + self.y = 200; + self.direction = Math.TAU*-0.12; + }else{ + self.x = 665; + self.y = 200; + self.direction = Math.TAU*-0.10; + } + + self.loverMC = self.addMovieClip("lover_panic"); + self.loverMC.gotoAndStop( (type=="circle") ? 0 : 1 ); + self.loop = false; + self.isLover = true; + + }; + self.callbacks.update = function(){ + if(self.isLover){ + if(self.y<-500){ + self.kill(); + } + } + }; + + // Can be overridden + self.walkAnim = function(){ + + var g = self.graphics; + + // Hop & Flip + self.hop += self.speed/60; + if(self.hop>1) self.hop--; + self.flip = (self.vel.x<0) ? -1 : 1; + + // Sway back & forth + var t = self.hop*Math.PI*2; + g.rotation = Math.sin(t)*0.3; + g.pivot.y = Math.abs(Math.sin(t))*15; + + // Squash at the bottom of your cycle + if(self._lastHop<0.5 && self.hop>=0.5) self.bounce = 1.2; + if(self._lastHop>0.9 && self.hop<=0.1) self.bounce = 1.2; + + }; + + // GET KILLED BY + self.getKilledBy = function(killer){ + + var CORPSE_FRAME, CORPSE_VELOCITY, GORE_AMOUNT; + switch(killer.weaponType){ + case "gun": + CORPSE_FRAME = 0; + CORPSE_VELOCITY = 2; + GORE_AMOUNT = 5; + break; + case "bat": + CORPSE_FRAME = 1; + CORPSE_VELOCITY = 5; + GORE_AMOUNT = 15; + break; + case "shotgun": + CORPSE_FRAME = 2; + CORPSE_VELOCITY = 10; + GORE_AMOUNT = 30; + break; + case "axe": + CORPSE_FRAME = 3; + CORPSE_VELOCITY = 5; + GORE_AMOUNT = 15; + break; + } + + // SCREEN SHAKE + scene.shaker.shake(30); + + // MY CORPSE + var flip = (killer.x=18){ + if(self.wordMC.currentFrame==0){ + self.wordMC.gotoAndStop(1); + }else{ + var nextFrame = self.wordMC.currentFrame+1; + if(nextFrame>3) nextFrame=1; + self.wordMC.gotoAndStop(nextFrame); + } + } + } + break; + case MODE_POP: + self.wordMC.gotoAndStop(0); + if(frame<25) face.gotoAndStop(frame+1); + break; + case MODE_AWAY: + if(frame<29){ + face.gotoAndStop(frame+1); + }else{ + + // Loop back + face.gotoAndStop(7); + MODE = MODE_BLINK; + self.isSmug = false; + + } + break; + } + } + + /////////////////////////// + /////////////////////////// + /////////////////////////// + + // Shocked by a square! + if(!self.isSmug){ + + if(self.gracePeriod<=0){ + var closeTo = self.touchingPeeps(90, function(peep){ + return(!peep.offended && peep.type=="circle"); + }); + if(closeTo.length>0 && self.isWalking){ + + // Bounce back + self.flip = (closeTo[0].x>self.x) ? 1 : -1; + self.bounce = 1.5; + + // BE SHOCKED + MODE = MODE_SMUG; + self.isWalking = false; + + // Sound! + Game.sounds.peep_huh.play(); + + // They get confused! + closeTo.forEach(function(other){ + if(other.offended) return; + other.beOffended(self); + }); + + // HMPH! + self.setTimeout(function(){ + + MODE = MODE_HMPH; + self.isSmug = true; + + // Sound! + Game.sounds.peep_hmph.play(); + + // POP! + self.setTimeout(function(){ + MODE = MODE_POP; + + // Then stop + self.setTimeout(function(){ + + // Turn around & walk + self.flip *= -1; + self.startWalking(); + self.direction = (self.flip>0) ? 0 : Math.PI; // override! + self.direction += Math.random()*0.2-0.1; + + // Move away... + MODE = MODE_AWAY; + self.gracePeriod = 60; + + },_s(0.8)); + + },_s(1.4)); + + },_s(0.9)); + + } + }else{ + self.gracePeriod--; + } + + } + + }; + + // AT FIRST... + self.watchTV = function(){ + + self.clearAnims(); // just in case... + + // 0) Stop & look + var tv = scene.tv; + self.stopWalking(true); + self.flip = (tv.x>self.x) ? 1 : -1; + var OFFSET = 0; // (Math.abs(self.x-tv.x)-60)/100; + var WAIT = Director.ZOOM_OUT_1_TIME + Director.SEE_VIEWERS_TIME; + + // 1) Become nervous + self.setTimeout(function(){ + + self.bounce = 1.6; + MODE = MODE_STARE; + + // SQUEAK + Game.sounds.squeak.play(); + + },_s(OFFSET+BEAT*2)); + + // 2) Blink... + self.setTimeout(function(){ + self.bounce = 1.3; + MODE = MODE_BLINK; + },_s(OFFSET+WAIT)); + + // 3) And go on. + self.setTimeout(function(){ + // self.bounce = 1.2; + self.startWalking(); + },_s(OFFSET+WAIT+1)); + + }; + +} \ No newline at end of file diff --git a/js/scenes/Act_I.js b/js/scenes/Act_I.js new file mode 100644 index 0000000..a1644c5 --- /dev/null +++ b/js/scenes/Act_I.js @@ -0,0 +1,219 @@ +/***************************** + +ACT I: THE SETUP +1. Hat guy +2. Lovers +// then let's start escalating... + +******************************/ + +function Stage_Start(self){ + + // Create Peeps + self.world.clearPeeps(); + self.world.addBalancedPeeps(20); + +} + +function Stage_Hat(self){ + + // A Hat Guy + var hat = new HatPeep(self); + self.world.addPeep(hat); + + // Director + self.director.callbacks = { + takePhoto: function(d){ + + // DECLARATIVE + d.tryChyron(function(d){ + var p = d.photoData; + var caught = d.caught({ + hat: {_CLASS_:"HatPeep"} + }); + if(caught.hat){ + p.audience = 3; + p.caughtHat = caught.hat; + d.chyron = "OOH NICE HAT"; + return true; + } + return false; + }).otherwise(_chyPeeps); + + }, + movePhoto: function(d){ + d.audience_movePhoto(); + }, + cutToTV: function(d){ + + // If you did indeed catch a hat peep... + var p = d.photoData; + if(p.caughtHat){ + self.world.addBalancedPeeps(1); // Add with moar! + d.audience_cutToTV(function(peep){ + peep.wearHat(); + }); // make all viewers wear HATS! + p.caughtHat.kill(); // Get rid of hat + Stage_Lovers(self); // Next stage + }else{ + d.audience_cutToTV(); + } + + } + }; + +} + +function Stage_Lovers(self){ + + // LOVERS + var lover1 = new LoverPeep(self); + lover1.setType("circle"); + var lover2 = new LoverPeep(self); + lover2.setType("square"); + lover2.follow(lover1); + self.world.addPeep(lover1); + self.world.addPeep(lover2); + + // Director + self.director.callbacks = { + takePhoto: function(d){ + + // MODULAR & DECLARATIVE + d.tryChyron(_chyLovers) + .otherwise(_chyHats) + .otherwise(_chyPeeps); + + }, + movePhoto: function(d){ + d.audience_movePhoto(); + }, + cutToTV: function(d){ + + // MODULAR & DECLARATIVE + d.tryCut2TV(_cutLovers) + .otherwise(_cutHats) + .otherwise(_cutPeeps); + + // And whatever happens, just go to the next stage + // ACT II!!! + Stage_Screamer(self); + + } + }; + +} + +/////////////////////////////////////// +/////////////////////////////////////// +////// DECLARATIVE CHYRON MODULES ///// +/////////////////////////////////////// +/////////////////////////////////////// + +function _chyLovers(d){ + var p = d.photoData; + var caught = d.caught({ + lover: {_CLASS_:"LoverPeep"} + }); + if(caught.lover){ + if(caught.lover.isEmbarrassed){ + d.chyron = "yeah git on outta here"; + }else{ + p.caughtLovers = true; + p.forceChyron = true; + d.chyron = "GROSS, GO GET A ROOM"; + } + return true; + } + return false; +} +function _chyHats(d){ + var p = d.photoData; + var caught = d.caught({ + hat: {_CLASS_:"NormalPeep", wearingHat:true} + }); + if(caught.hat){ + p.audience = 1; + p.caughtHat = true; + d.chyron = "nvm hats aren't cool anymore"; + return true; + } + return false; +} +function _chyPeeps(d){ + var p = d.photoData; + if(d.scene.camera.isOverTV(true)){ + d.chyron = "A TV... ON TV!"; + }else{ + var caught = d.caught({ + peeps: {_CLASS_:"NormalPeep", returnAll:true}, + crickets: {_CLASS_:"Cricket", returnAll:true} + }); + if(caught.crickets.length>0){ + p.CAUGHT_A_CRICKET = true; + if(caught.crickets.length==1){ + d.chyron = "LIL' CRICKY <3"; + }else{ + d.chyron = "okay that's too many crickets"; + } + }else if(caught.peeps.length>0){ + if(caught.peeps.length==1){ + d.chyron = "just a normal peep"; + }else{ + d.chyron = "just some normal peeps"; + } + }else{ + p.ITS_NOTHING = true; + d.chyron = "WOWWEE, IT'S NOTHING"; + } + } + return true; +} + +/////////////////////////////////////// +/////////////////////////////////////// +///// DECLARATIVE CUTTING MODULES ///// +/////////////////////////////////////// +/////////////////////////////////////// + +function _cutLovers(d){ + var p = d.photoData; + if(p.caughtLovers){ + // Crickets + d.audience_cutToTV(); + // MAKE LOVERS EMBARRASSED + d.scene.world.peeps.filter(function(peep){ + return peep._CLASS_=="LoverPeep"; + }).forEach(function(lover){ + lover.makeEmbarrassed(); + }); + return true; + }else{ + return false; + } +} +function _cutHats(d){ + var p = d.photoData; + if(p.caughtHat){ + // Only get the hat-wearers, make 'em take off the hat. + d.audience_cutToTV( + function(peep){ peep.takeOffHat(); }, + function(peep){ return peep.wearingHat; } + ); + return true; + }else{ + // And if not, have them decrease by 1 each time anyway. + var hatPeeps = d.scene.world.peeps.slice(0).filter(function(peep){ + return peep.wearingHat; + }); + if(hatPeeps.length>0){ + var randomIndex = Math.floor(Math.random()*hatPeeps.length); + hatPeeps[randomIndex].takeOffHat(true); + } + return false; + } +} +function _cutPeeps(d){ + d.audience_cutToTV(); + return true; +} diff --git a/js/scenes/Act_II.js b/js/scenes/Act_II.js new file mode 100644 index 0000000..c651974 --- /dev/null +++ b/js/scenes/Act_II.js @@ -0,0 +1,558 @@ +/***************************** + +ACT II: THE ESCALATION +1. Weird square screams at others +2. Circle becomes fearful +3. Square becomes snobby +4. Circle becomes angry... +5. Angry escalates... until... + +******************************/ + +function Stage_Screamer(self){ + + // The crazy one + var crazy = new CrazyPeep(self); + self.world.addPeep(crazy); + + // Director + self.director.callbacks = { + takePhoto: function(d){ + + // IMPORTANCE: + // 1. Screamer Dude + // 2. Lovers + // 3. Hats + // 4. Shocked Peeps + // 5. Everything else. + d.tryChyron(function(d){ + var p = d.photoData; + var caught = d.caught({ + shocked: {_CLASS_:"NormalPeep", shocked:true}, + crazy: {_CLASS_:"CrazyPeep"} + }); + if(caught.crazy){ + if(crazy.isScreaming()){ + p.HIJACK = true; + p.audienceCircles = 1; + p.audienceSquares = 0; + p.caughtCrazy = caught.crazy; + d.chyron = "CRAZED SQUARE ATTACKS"; + }else{ + if(caught.shocked) d.chyron = "oooooh just missed it"; + else d.chyron = "(ya gotta catch 'em doing *something* interesting...)"; + } + return true; + } + return false; + }) + .otherwise(_chyLovers) + .otherwise(_chyHats) + .otherwise(function(d){ + var p = d.photoData; + var caught = d.caught({ + shocked: {_CLASS_:"NormalPeep", shocked:true} + }); + if(caught.shocked) d.chyron = "(ya gotta catch who's screaming at 'em)"; + return caught.shocked; + }) + .otherwise(_chyPeeps); + + }, + movePhoto: function(d){ + d.audience_movePhoto(); + }, + cutToTV: function(d){ + + // Importance: + // 1. Crazy + // 2. Lovers + // 3. Hats + // 4. Everything Else + d.tryCut2TV(function(d){ + var p = d.photoData; + if(p.caughtCrazy){ + self.world.addBalancedPeeps(1); // Add with moar! + d.audience_cutToTV(); // Show audience watching! + p.caughtCrazy.kill(); // Get rid of crazy + self.world.replaceWatcher("circle", new NervousPeep(self)); // Replace with nervous + Stage_Nervous(self); // Next stage + return true; + } + return false; + }) + .otherwise(_cutLovers) + .otherwise(_cutHats) + .otherwise(_cutPeeps); + + } + }; + +} + +function Stage_Nervous(self, HACK){ + + // Also, get rid of the lovers if they're still here. + self.world.peeps.filter(function(peep){ + return peep._CLASS_=="LoverPeep"; + }).forEach(function(lover){ + lover.kill(); + }); + + // HACK - The nervous one + if(HACK){ + var nervous = new NervousPeep(self); + self.world.addPeep(nervous); + nervous.HACK_JUMPSTART(); + } + + // Director + self.director.callbacks = { + takePhoto: function(d){ + + // IMPORTANCE: + // 1. Nervous + // 2. Hats + // 3. Everything else. + d.tryChyron(function(d){ + var p = d.photoData; + var caught = d.caught({ + confused: {_CLASS_:"NormalPeep", confused:true}, + nervous: {_CLASS_:"NervousPeep"} + }); + if(caught.nervous){ + if(caught.nervous.isScared()){ + if(caught.confused){ + p.HIJACK = true; + p.audienceCircles = 0; + p.audienceSquares = 1; + p.caughtNervous = caught.nervous; + d.chyron = "CIRCLE FEARS SQUARES"; + }else{ + d.chyron = "(ya gotta also catch *who* they're scared by)"; + } + }else{ + d.chyron = "(ya gotta catch 'em doing *something* interesting...)"; + // d.chyron = "(ya gotta catch 'em *being* scared by a square)"; + } + return true; + } + return false; + }) + .otherwise(_chyHats) + .otherwise(_chyPeeps); + + }, + movePhoto: function(d){ + d.audience_movePhoto(); + }, + cutToTV: function(d){ + + // IMPORTANCE: + // 1. Nervous + // 2. Hats + // 3. Everything else. + + d.tryCut2TV(function(d){ + var p = d.photoData; + if(p.caughtNervous){ + self.world.addBalancedPeeps(1); // Add with moar! + d.audience_cutToTV(); // Show audience watching! + p.caughtNervous.kill(); // Get rid of nervous + self.world.replaceWatcher("square", new SnobbyPeep(self)); // Replace with snpb + Stage_Snobby(self); // Next stage + return true; + } + return false; + }) + .otherwise(_cutHats) + .otherwise(_cutPeeps); + + } + }; + +} + +function Stage_Snobby(self, HACK){ + + // HACK - The snobby one + if(HACK){ + var snobby = new SnobbyPeep(self); + self.world.addPeep(snobby); + snobby.HACK_JUMPSTART(); + } + + // Director + self.director.callbacks = { + takePhoto: function(d){ + + // Importance: + // 1. Snobby + // 2. Hats + // 3. Everything else + + d.tryChyron(function(d){ + var p = d.photoData; + var caught = d.caught({ + offended: {_CLASS_:"NormalPeep", offended:true}, + snobby: {_CLASS_:"SnobbyPeep"} + }); + if(caught.snobby){ + if(caught.snobby.isSmug){ + p.HIJACK = true; + p.audienceCircles = 1; + p.audienceSquares = 0; + p.caughtSnobby = caught.snobby; + d.chyron = "SQUARES SNUB CIRCLES"; + }else{ + //d.chyron = "(ya gotta catch 'em *while* snubbing a circle)"; + d.chyron = "(ya gotta catch 'em doing *something* interesting...)"; + } + return true; + } + return false; + }) + .otherwise(_chyHats) + .otherwise(_chyPeeps); + + }, + movePhoto: function(d){ + d.audience_movePhoto(); + }, + cutToTV: function(d){ + + // Importance: + // 1. Snobby + // 2. Hats + // 3. Everything else + + d.tryCut2TV(function(d){ + var p = d.photoData; + if(p.caughtSnobby){ + + // self.world.addBalancedPeeps(1); // Add with moar! + + // Get rid of all hats + self.world.peeps.slice(0).filter(function(peep){ + return peep.wearingHat; + }).forEach(function(hatPeep){ + hatPeep.takeOffHat(true); + }); + + d.audience_cutToTV(); // Show audience watching! + p.caughtSnobby.kill(); // Get rid of snob + + // Replace with angry + var angry = new AngryPeep(self, "circle"); + self.world.replaceWatcher("circle",angry); + + Stage_Angry_Escalation(self); // Next stage + + return true; + + } + return false; + }) + .otherwise(_cutHats) + .otherwise(_cutPeeps); + + } + }; + +} + +function Stage_Angry_Escalation(self, HACK){ + + // HACK - ONE angry one + if(HACK){ + var angry = new AngryPeep(self, "circle"); + self.world.addPeep(angry); + angry.HACK_JUMPSTART(); + } + + // HELPING. + var helping = new HelpingAnim(self); + self.world.addProp(helping); + + // PROTESTERS! + var protest = null; + var _addProtesters = function(){ + + // ONCE + if(protest) return; + protest = new ProtestAnim(self); + + self.world.addProp(protest); + + } + + // Director + self.director.callbacks = { + takePhoto: function(d){ + + // IMPORTANCE: + // 1. Helping + // 2. Protest + // 3. Angry + // 4. Weirdo + // 5. Shocked + // 6. Everything Else + + d.tryChyron(_chyHelping) + .otherwise(_chyProtest) + .otherwise(_chyAngry) + .otherwise(_chyWeirdo) + .otherwise(_chyShocked) + .otherwise(_chyPeeps) + + }, + movePhoto: function(d){ + d.audience_movePhoto(); + }, + cutToTV: function(d){ + + // IMPORTANCE: + // 1. Helping + // 2. Protest + // 3. Angry + // 4. Weirdo + // 5. Shocked + // 6. Everything Else + + d.tryChyron(_cutHelping) + .otherwise(_cutProtest) + .otherwise(_cutAngry) + .otherwise(_cutWeirdo) + .otherwise(_cutShocked) + .otherwise(_cutPeeps) + + // WHAT PERCENT OF PEEPS ARE NOW ANGRY??? + var peeps = d.scene.world.peeps; + var angry = peeps.filter(function(peep){ + return(peep._CLASS_=="AngryPeep"); + }); + var angryRatio = angry.length/(peeps.length-1); + // angryRatio = 0.95; // HACK TO SKIP + + // MORE THAN 66%: BRING IN THE PEACE PROTESTERS + if(angryRatio>0.5){ + _addProtesters(); + } + + // ONCE (ALMOST) EVERYONE IS ANGRY, IT'S TIME FOR MURDER + if(angryRatio==1.00){ // EXACTLY 1. + Stage_Evil(self); // Next stage + } + + } + }; + +} + + +//////////////////////////////////////////////// +//////////////////////////////////////////////// +///////////// THE FINAL MANIFESTO ////////////// +//////////////////////////////////////////////// +//////////////////////////////////////////////// + +var _manifestoIndex = -1; +var _manifesto = [ + //"as if you viewers want GOOD news", + "who tunes in to watch *people get along?*", + "peace is boring. violence goes viral.", + //"peace is boring. conflict gets clicks.", + "and every story needs a conflict, so...", + //"...GIVE THE AUDIENCE WHAT THEY WANT.", + "GIVE THE AUDIENCE WHAT THEY WANT." +]; +function _spoutManifesto(){ + if(_manifestoIndex<_manifesto.length-1){ + _manifestoIndex++; + } + return _manifesto[_manifestoIndex]; +} + + + + +//////////////////////////////////////////// +//////////////////////////////////////////// +///////////// THE FINAL THANG ////////////// +//////////////////////////////////////////// +//////////////////////////////////////////// + +function _chyAngry(d){ + var p = d.photoData; + var caught = d.caught({ + shocked: {_CLASS_:"NormalPeep", shocked:true}, + angry: {_CLASS_:"AngryPeep", returnAll:true}, + angryCircleShouting: {_CLASS_:"AngryPeep", type:"circle", isShouting:true, returnAll:true}, + angrySquareShouting: {_CLASS_:"AngryPeep", type:"square", isShouting:true, returnAll:true}, + }); + if(caught.angry.length>0){ + + if(caught.angryCircleShouting.length+caught.angrySquareShouting.length>0){ + + p.audience = 2; + p.caughtAngry = true; + + // How many angrys? (*AFTER* you add 4 more...) + var peeps = d.scene.world.peeps; + var angry = peeps.filter(function(peep){ + return(peep._CLASS_=="AngryPeep"); + }); + var angriesAfterwards = angry.length+4; + var angryRatio = angriesAfterwards/(peeps.length-1); + + if(angryRatio>=1){ + d.chyron = "EVERYONE HATES EVERYONE!!1!"; + }else if(angryRatio>=0.75){ + d.chyron = "ALMOST EVERYONE HATES EVERYONE..."; + }else{ + + // Who was caught angry & shouting? + if(caught.angryCircleShouting.length>0) p.caughtAngryCircle=true; + if(caught.angrySquareShouting.length>0) p.caughtAngrySquare=true; + + if(caught.angryCircleShouting.length==0){ + d.chyron = "SQUARES HATE CIRCLES"; // must be a square + }else{ + d.chyron = "CIRCLES HATE SQUARES"; // must be a circle, or both + } + + } + + }else{ + if(caught.shocked){ + d.chyron = "oooooh just missed it"; + }else{ + // d.chyron = "(ya gotta catch 'em *yelling* at others)"; + d.chyron = "(ya gotta catch 'em doing *something* interesting...)"; + } + } + return true; + } + return false; +} + +function _chyHelping(d){ + var p = d.photoData; + var caught = d.caught({ + helping: {_CLASS_:"HelpingAnim"} + }); + if(caught.helping){ + if(caught.helping.hasHelped){ + d.chyron = _spoutManifesto(); + }else{ + d.chyron = "what are these nerds doing now"; + } + return true; + } + return false; +} + +function _chyProtest(d){ + var p = d.photoData; + var caught = d.caught({ + protest: {_CLASS_:"ProtestAnim"} + }); + if(caught.protest) d.chyron = _spoutManifesto(); + return caught.protest; +} + +function _chyWeirdo(d){ + var p = d.photoData; + var caught = d.caught({ + happyWeirdo: {_CLASS_:"HappyWeirdoPeep"}, + lovers: {_CLASS_:"LoverPeep"} + }); + if(caught.happyWeirdo){ + d.chyron = _spoutManifesto(); + return true; + } + if(caught.lovers){ + d.chyron = _spoutManifesto(); + return true; + } + return false; +} + +function _chyShocked(d){ + var p = d.photoData; + var caught = d.caught({ + shocked: {_CLASS_:"NormalPeep", shocked:true} + }); + if(caught.shocked) d.chyron = "why's this peep shocked?"; + return caught.shocked; +} + +function _cutAngry(d){ + + var p = d.photoData; + if(p.caughtAngry){ + + d.audience_cutToTV(); + + // Make ALL the watching normal peeps angry + var world = d.scene.world; + var peeps = world.peeps; + peeps.filter(function(p){ + return (p._CLASS_=="NormalPeep" && p.isWatching); + }).forEach(function(peep){ + var newPeep = new AngryPeep(d.scene, peep.type); + world.replacePeep(peep, newPeep); + newPeep.watchTV(); + }); + + return true; + } + return false; + +} +function _cutHelping(d){ + return false; +} +function _cutProtest(d){ + return false; +} +function _cutWeirdo(d){ + return false; +} +function _cutShocked(d){ + return false; +} + +//////////////////////////////////////////// +//////////////////////////////////////////// +//////////////////////////////////////////// +//////////////////////////////////////////// +//////////////////////////////////////////// +//////////////////////////////////////////// + + +function Stage_Whatever(self){ + + // HACK - The snobby one + /* + if(HACK){ + var snobby = new SnobbyPeep(self); + self.world.addPeep(snobby); + snobby.HACK_JUMPSTART(); + } + */ + + // Director + self.director.callbacks = { + takePhoto: function(d){ + d.chyron = "whatever"; + }, + movePhoto: function(d){ + d.audience_movePhoto(); + }, + cutToTV: function(d){ + d.audience_cutToTV(); + } + }; + +} \ No newline at end of file diff --git a/js/scenes/Act_III.js b/js/scenes/Act_III.js new file mode 100644 index 0000000..284481c --- /dev/null +++ b/js/scenes/Act_III.js @@ -0,0 +1,262 @@ +Game.addToManifest({ + bg_panic: "sounds/bg_panic.mp3", + bg_creepy: "sounds/bg_creepy.mp3" +}); + +/***************************** + +ACT III: THE MURDERS. +Just lots and lots of murdering. +Also, after 10 seconds, zoom out +for 20 seconds into "the real world". + +******************************/ + +function Stage_Evil(self, HACK){ + + // HACK - The happy one + if(HACK){ + self.world.addPeep(new HappyWeirdoPeep(self)); + self.world.addProp(new ProtestAnim(self)); + } + + // FREEZE EVERYONE + var _freezeEveryone = function(){ + + var peeps = self.world.peeps; + + // Freeze all Angry & Normal peeps. + var freezeEm = peeps.filter(function(peep){ + return(peep._CLASS_=="NormalPeep" || peep._CLASS_=="AngryPeep"); + }); + freezeEm.forEach(function(oldPeep){ + + var stunnedPeep = new NormalPeep(self); + stunnedPeep.setType(oldPeep.type); + stunnedPeep.vel.x = oldPeep.vel.x; + stunnedPeep.vel.y = oldPeep.vel.y; + stunnedPeep.flip = (oldPeep.x0 && !self.zoomer.started){ + self.zoomer.init(); + } + + // CREATE TWO MURDERERS. + var weapon1 = weapons[weaponIndex]; + var murderer1 = new MurderPeep(self); + murderer1.init("circle", weapon1); + self.world.addPeep(murderer1); + var weapon2 = weapons[(weaponIndex+1)%weapons.length]; + var murderer2 = new MurderPeep(self); + murderer2.init("square", weapon2); + self.world.addPeep(murderer2); + + // Cycle through weapons... + weaponIndex = (weaponIndex+1)%weapons.length; + + } + }; + +} \ No newline at end of file diff --git a/js/scenes/Scene_Credits.js b/js/scenes/Scene_Credits.js new file mode 100644 index 0000000..b6f8f3a --- /dev/null +++ b/js/scenes/Scene_Credits.js @@ -0,0 +1,111 @@ +Game.addToManifest({ + + credits0001: "sprites/credits/credits0001.png", // nicky case + credits0002: "sprites/credits/credits0002.png", // playtesters + credits0003: "sprites/credits/credits0003.png", // patreon + credits0004: "sprites/credits/credits0004.png", // patreon + credits0005: "sprites/credits/credits0005.png", // patreon + credits0006: "sprites/credits/credits0006.png", // patreon + credits0007: "sprites/credits/credits0007.png", // and thank... + credits0008: "sprites/credits/credits0008.png", // ...YOU! + +}); + +function Scene_Credits(){ + + var self = this; + Scene.call(self); + + // Layers, yo. + var cont = new PIXI.Container(); + Game.stage.addChild(cont); + var c = {}; + for(var i=1; i<=8; i++){ + c[i] = MakeSprite("credits000"+i); + c[i].alpha = 0; + cont.addChild(c[i]); + } + + // TWEEN ANIM + Tween_get(c[1]).wait(_s(BEAT*4)) // 0. Wait 4 beats before credits... + .to({alpha:1}, _s(BEAT), Ease.quadInOut) // 1. CREATED BY! + .wait(_s(BEAT*3)) + .to({alpha:0}, _s(BEAT), Ease.quadInOut) + .call(function(){ + + // 2. PLAYTESTERS + Tween_get(c[2]) + .to({alpha:1}, _s(BEAT), Ease.quadInOut) + .wait(_s(BEAT*3)) + .to({alpha:0}, _s(BEAT), Ease.quadInOut) + .call(function(){ + + // 3. PATREONS: CUT BETWEEN THEM THEN FADE OUT + Tween_get(c[3]) + .to({alpha:1}, _s(BEAT), Ease.quadInOut) + .wait(_s(BEAT*2)) + .call(function(){ + + // CUT! + c[3].alpha = 0; + c[4].alpha = 1; + + Tween_get(c[4]) + .wait(_s(BEAT*2)) + .call(function(){ + + // CUT! + c[4].alpha = 0; + c[5].alpha = 1; + + Tween_get(c[5]) + .wait(_s(BEAT*2)) + .call(function(){ + + // CUT! + c[5].alpha = 0; + c[6].alpha = 1; + + Tween_get(c[6]) + .wait(_s(BEAT*2)) + .to({alpha:0}, _s(BEAT), Ease.quadInOut) // fade... + .call(function(){ + + // 4. And finally... thank YOU! + Tween_get(c[7]) + .to({alpha:1}, _s(BEAT), Ease.quadInOut) + .wait(_s(BEAT)) + .call(function(){ + Tween_get(c[8]) + .to({alpha:1}, _s(BEAT), Ease.quadInOut) + .wait(_s(BEAT*3)) + .call(function(){ + + // 5. Fade everything out, and NIGHTTIME SOUNDS + Tween_get(cont) + .wait(_s(BEAT)) + .to({alpha:0}, _s(BEAT), Ease.quadInOut) + .call(function(){ + Game.sceneManager.gotoScene("Post_Credits"); + }); + + // Background Ambience + var ambience = Game.sounds.bg_nighttime; + ambience.loop(true); + ambience.volume(0); + ambience.play(); + ambience.fade(0, 1, 2000); + + }); + }); + + }); + }); + }); + }); + + }); + + }); + +} \ No newline at end of file diff --git a/js/scenes/Scene_EndPrototype.js b/js/scenes/Scene_EndPrototype.js new file mode 100644 index 0000000..516da5c --- /dev/null +++ b/js/scenes/Scene_EndPrototype.js @@ -0,0 +1,28 @@ +/*Game.addToManifest({ + end_prototype: "sprites/quote/end_prototype.png", + gunshot: "sounds/gunshot.mp3" +}); + +function Scene_EndPrototype(){ + + var self = this; + Scene.call(self); + + // Layers, yo. + var q1 = MakeSprite("blackout"); + var q2 = MakeSprite("end_prototype"); + + // BANG + Game.sounds.gunshot.play(); + + // Add 'em in. + q2.alpha = 0; + Game.stage.addChild(q1); + Game.stage.addChild(q2); + + // TWEEN ANIM + Tween_get(q2) + .wait(_s(BEAT*3.5)) + .to({alpha:1}, _s(BEAT), Ease.quadInOut); + +}*/ \ No newline at end of file diff --git a/js/scenes/Scene_Game.js b/js/scenes/Scene_Game.js new file mode 100644 index 0000000..232dae4 --- /dev/null +++ b/js/scenes/Scene_Game.js @@ -0,0 +1,99 @@ +/************************************ + +THE GAME SCENE. THE BIG 'UN. + +ACT I - Teaching controls, showing main feedback loop +ACT II - Crazed Square, Nervous Circle, Snobby Square... +ACT III - Angry escalation! And lovers protest! +ACT IV - MURDER AND VIOLENCE AND AHHHHHH. #BeScaredBeAngry + +(different scene...) +ACT V - Post-credits peace + +*************************************/ + +function Scene_Game(){ + + var self = this; + Scene.call(self); + + //////////// + // SET UP // + //////////// + + // Graphics! + var g = new PIXI.Container(); + self.graphics = g; + Game.stage.addChild(g); + + // Set Up Everything + self.world = new World(self); + self.camera = new Camera(self); + self.director = new Director(self); + self.tv = new TV(self); + self.world.addProp(self.tv); + + // Special effects! + self.scale = 1; + self.x = self.y = self.offX = self.offY = 0; + self.shaker = new ScreenShake(self); + self.zoomer = new ScreenZoomOut(self); + + // Avoid these spots. + self.avoidSpots = []; + + // UPDATE + self.update = function(){ + + self.world.update(); + self.camera.update(); + self.director.update(); + + // This order is important + self.zoomer.update(); + self.shaker.update(); + g.scale.x = g.scale.y = self.scale; + g.x = self.x + self.offX; + g.y = self.y + self.offY; + self.zoomer.fixLaptop(); // hack. + + // TOTALLY A HACK + var ratio = self.zoomer.timer/self.zoomer.fullTimer; + ratio = (1-ratio)/1; + self.shaker.baseAlpha = 0.15 + ratio*0.45; + + }; + + // TO IMPLEMENT + self.kill = function(){}; + + // Going to a Stage + self.go = function(sceneFunc){ + sceneFunc(self); + self.update(); + }; + + ///////////// + // FADE IN // + ///////////// + + var blackout = MakeSprite("blackout"); + Game.stage.addChild(blackout); + Tween_get(blackout).to({alpha:0}, _s(BEAT), Ease.quadInOut).call(function(){ + Game.stage.removeChild(blackout); + }); + + //////////// + // STAGES // + //////////// + + Stage_Start(self); + Stage_Hat(self); + //Stage_Lovers(self); + //Stage_Screamer(self, true); + //Stage_Nervous(self, true); + //Stage_Snobby(self, true); + //Stage_Angry_Escalation(self, true); + //Stage_Evil(self, true); + +} \ No newline at end of file diff --git a/js/scenes/Scene_Meta.js b/js/scenes/Scene_Meta.js new file mode 100644 index 0000000..5412048 --- /dev/null +++ b/js/scenes/Scene_Meta.js @@ -0,0 +1,112 @@ +/********************** + +A SCENE PURELY FOR PROMOTIONAL REASONS + +**********************/ + +function Scene_Meta(){ + + var self = this; + Scene.call(self); + + self.UNPAUSEABLE = true; // HACK. + + //////////// + // SET UP // + //////////// + + // Graphics! + var g = new PIXI.Container(); + self.graphics = g; + Game.stage.addChild(g); + + // Set Up Everything + self.world = new World(self); + self.tv = new TV(self); + self.tv.y += 32; + self.world.addProp(self.tv); + + // RECURSIVE SCREEN + var renderTexturePoolIndex = 0; + var renderTexturePool = [ + new PIXI.RenderTexture(Game.renderer, Game.width, Game.height), + new PIXI.RenderTexture(Game.renderer, Game.width, Game.height) + ]; + self.stream = new PIXI.Sprite(); + self.stream.x = Game.width/2; + self.stream.y = Game.height/2; + self.stream.scale.x = self.stream.scale.y = 0.125; + self.stream.anchor.x = self.stream.anchor.y = 0.5; + g.addChild(self.stream); + + // CHYRON + + // Chryon container + /* + var chyron = new PIXI.Container(); + chyron.alpha = 1; + g.addChild(chyron); + + // Chyron BG + var resourceName = "chyron"; + var bg = new MakeSprite(resourceName); + bg.scale.x = bg.scale.y = 1/2; + chyron.addChild(bg); + + // Chyron Text + var text = "WE BECOME WHAT WE BEHOLD"; + var fontsize=100, max=14; + if(text.length>max){ // more than [max] chars... + fontsize = Math.floor(max*fontsize/text.length); + } + var text = new PIXI.Text(text, {font:"bold "+fontsize+"px Poppins", fill:"#FFF"}); + text.scale.x = text.scale.y = 0.2; + text.anchor.x = 0; + text.anchor.y = 0.5; + text.x = 45; + text.y = 115; + chyron.addChild(text);*/ + + self.scale = 1; + + // UPDATE + self.update = function(){ + + self.world.update(); + + // RECURSIVE SCREEN + + var matrix = new PIXI.Matrix(); + matrix.translate(-self.graphics.x, -self.graphics.y); + matrix.scale(1/self.graphics.scale.x, 1/self.graphics.scale.y); + //matrix.translate(-sx,-sy); + + var renderTexture = renderTexturePool[renderTexturePoolIndex]; + renderTexture.render(self.graphics, matrix); + renderTexturePoolIndex = (renderTexturePoolIndex+1)%renderTexturePool.length; + self.stream.texture = renderTexture; + + // ZOOM OUT + self.scale *= 0.993; + if(self.scale<1){ + self.scale=8; + } + g.scale.x = g.scale.y = self.scale; + g.x = (Game.width-(Game.width*self.scale))/2; + g.y = (Game.height-(Game.height*self.scale))/2; + + }; + + // TO IMPLEMENT + self.kill = function(){}; + + self.world.clearPeeps(); + self.world.addBalancedPeeps(30); + var peeps = self.world.peeps; + for(var i=0;i<10;i++){ + var randomPeep = peeps[Math.floor(Math.random()*peeps.length)]; + randomPeep.wearingHat = true; + randomPeep.hatMC.gotoAndStop(15); + } + +} \ No newline at end of file diff --git a/js/scenes/Scene_Post_Credits.js b/js/scenes/Scene_Post_Credits.js new file mode 100644 index 0000000..fb5600f --- /dev/null +++ b/js/scenes/Scene_Post_Credits.js @@ -0,0 +1,136 @@ +Game.addToManifest({ + bg_shade: "sprites/bg_shade.png", + bg_nighttime: "sounds/bg_nighttime.mp3" +}); + +/************************************ + +THE GAME SCENE. THE BIG 'UN. + +ACT I - Teaching controls, showing main feedback loop +ACT II - Crazy, Nervous, Snobby, Angry escalation... +ACT III - Protest! (what gameplay here???) +ACT IV - MURDER AND VIOLENCE AND AHHHHHH. #BeScaredBeAngry + +(different scene...) +ACT V - Post-credits peace + +*************************************/ + +function Scene_Post_Credits(){ + + var self = this; + Scene.call(self); + + // HACK: Background Ambience + /*var ambience = Game.sounds.bg_nighttime; + ambience.loop(true); + ambience.play();*/ + + //////////// + // SET UP // + //////////// + + // Graphics! + var g = new PIXI.Container(); + self.graphics = g; + Game.stage.addChild(g); + + // Set Up Everything + self.world = new World(self,{ + bg: "bg_dark" + }); + self.world.layers.bg.addChild(MakeSprite("bg_shade")); + self.camera = new Camera(self,{ + noIntro: true, + streaming: true, + onTakePhoto: function(){ + //if(self.camera.isOverTV()){ + Game.sounds.bg_nighttime.stop(); + Game.sceneManager.gotoScene("Post_Post_Credits"); + //} + } + }); + self.camera.x = Game.width; + self.camera.y = Game.height; + + // Put a SPRITE RIGHT IN THE BG + self.stream = new PIXI.Sprite(); + self.stream.width = Game.width/8; + self.stream.height = Game.height/8; + self.stream.x = Game.width/2 - self.stream.width/2 - 2; // hack + self.stream.y = Game.height/2 - self.stream.height/2 + 2; // hack + self.world.layers.bg.addChild(self.stream); + + // UPDATE + self.update = function(){ + + self.world.update(); + self.camera.update(); + + // THE STREAM + self.stream.texture = self.camera.getTexture(); + + }; + + ////////////////////// + // EVEN MORE SET UP // + ////////////////////// + + // Candlelights + var candlePositions =[ + [468.6,276.6], + [535.7,281.6], + [679.7,279.1], + [612,281.6], + [490.1,314.1], + [421.8,309], + [363.1,301.1], + [786.9,304.4], + [726.1,310.5], + [656.9,309.5], + [869.8,350.3], + [820,373.5], + [768.2,382.8], + [698.4,389], + [464.6,386.1], + [396.3,382.3], + [339.6,370.1], + [294.3,350.3] + ]; + for(var i=0;i