Trade-Winds/minified/Oversimplified.js

2 lines
No EOL
40 KiB
JavaScript

function IsInternetExplorer(){var e=window.navigator.userAgent,i=e.indexOf("MSIE ");return i>0||navigator.userAgent.match(/Trident.*rv\:11\./)?!0:!1}var Oversimplified={},OS=Oversimplified;Oversimplified.canvas=null,Oversimplified.context=null,Oversimplified.nextID=0,Oversimplified.loadingScripts=[],Oversimplified.loadedScripts=[],Oversimplified.emptyImage=new Image,Oversimplified.emptyImage.src="data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=",Oversimplified.emptyImage.width=1,Oversimplified.emptyImage.height=1,Oversimplified.Settings={defaultStep:1/30,numberOfScriptsToLoad:0,soundVolume:.75,musicVolume:.75,preventRightClick:!0},Oversimplified.S=Oversimplified.Settings,Oversimplified.timestamp=function(){return window.performance&&window.performance.now?window.performance.now():(new Date).getTime()},Oversimplified.now=null,Oversimplified.dateTime=0,Oversimplified.lastFrame=Oversimplified.timestamp(),Oversimplified.step=Oversimplified.Settings.defaultStep,Oversimplified.camera={x:0,y:0,width:640,height:480,hBorder:64,vBorder:64,following:"",Follow:function(e){this.following=e.name}},Oversimplified.SetCamera=function(e){Oversimplified.camera.width="undefined"!=typeof e.width?e.width:Oversimplified.camera.width,Oversimplified.camera.height="undefined"!=typeof e.height?e.height:Oversimplified.camera.height,Oversimplified.SetCanvasToCameraSize(),Oversimplified.camera.x="undefined"!=typeof e.x?e.x:Oversimplified.camera.x,Oversimplified.camera.y="undefined"!=typeof e.y?e.y:Oversimplified.camera.y,"undefined"!=typeof e.objectToFollow&&(e.objectToFollow.name?Oversimplified.camera.Follow(e.objectToFollow):Oversimplified.DEBUG.showMessages&&console.log("Oversimplified.Settings.SetCamera()'s objectToFollow argument must be a Oversimplified.GameObject.")),Oversimplified.camera.hBorder="undefined"!=typeof e.hBorder?e.hBorder:Oversimplified.camera.hBorder,Oversimplified.camera.vBorder="undefined"!=typeof e.vBorder?e.vBorder:Oversimplified.camera.vBorder},Oversimplified.mouse={x:0,y:0,leftCode:IsInternetExplorer()?1:0,middleCode:IsInternetExplorer()?4:1,rightCode:2,leftDown:!1,left:!1,leftUp:!1,middleDown:!1,middle:!1,middleUp:!1,rightDown:!1,right:!1,rightUp:!1,wheel:0},Oversimplified.heldKeys=[],Oversimplified.pressedKeys=[],Oversimplified.releasedKeys=[],Oversimplified.Key={37:"left arrow",38:"up arrow",39:"right arrow",40:"down arrow",45:"insert",46:"delete",8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"caps lock",27:"escape",32:"space",33:"page up",34:"page down",35:"end",91:"left win/special key",92:"right win/special key",93:"select key",96:"numpad 0",97:"numpad 1",98:"numpad 2",99:"numpad 3",100:"numpad 4",101:"numpad 5",102:"numpad 6",103:"numpad 7",104:"numpad 8",105:"numpad 9",106:"numpad asterisk",107:"numpad plus",109:"numpad dash",110:"numpad period",111:"numpad slash",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"num lock",145:"scroll lock",186:"semicolon",187:"equal",188:"comma",189:"dash",190:"period",191:"slash",192:"grave accent",219:"open bracket",220:"backslash",221:"close bracket",222:"quote"},Oversimplified.Keycode={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,pausebreak:19,capslock:20,escape:27,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,del:46,zero:48,one:49,two:50,three:51,four:52,five:53,six:54,seven:55,eight:56,nine:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,leftwinkey:91,rightwinkey:92,selectkey:93,numpad_0:96,numpad_1:97,numpad_2:98,numpad_3:99,numpad_4:100,numpad_5:101,numpad_6:102,numpad_7:103,numpad_8:104,numpad_9:105,numpad_asterisk:106,numpad_plus:107,numpad_dash:109,numpad_period:110,numpad_slash:111,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,numlock:144,scrolllock:145,semicolon:186,equal:187,comma:188,dash:189,period:190,slash:191,grave:192,openbracket:219,backslash:220,closebraket:221,quote:222},Oversimplified.Controls={},Oversimplified.Controls.Add=function(e,i,t){return"undefined"!=typeof t?Oversimplified.Controls[e]=new Oversimplified.Axis(i,t):Oversimplified.Controls[e]=new Oversimplified.Control(i),Oversimplified.Controls[e]},Oversimplified.Controls.New=Oversimplified.Controls.Add,Oversimplified.Controls.CheckAll=function(){for(var e in Oversimplified.Controls)"undefined"!=typeof Oversimplified.Controls[e].Check&&Oversimplified.Controls[e].Check()},Oversimplified.C=Oversimplified.Controls,Oversimplified.Control=function(e){this.keyCode=e,this.keyName=Oversimplified.Key[e],this.down=!1,this.held=!1,this.up=!1},Oversimplified.Control.prototype.type="Control",Oversimplified.Control.prototype.Check=function(){-1!=Oversimplified.heldKeys.indexOf(this.keyCode)?this.held=!0:this.held=!1,-1!=Oversimplified.pressedKeys.indexOf(this.keyCode)?this.down=!0:this.down=!1,-1!=Oversimplified.releasedKeys.indexOf(this.keyCode)?this.up=!0:this.up=!1},Oversimplified.Axis=function(e,i){this.positiveKeycode=e,this.positiveKeyName=Oversimplified.Key[e],this.negativeKeycode=i,this.negativeKeyName=Oversimplified.Key[i],this.direction=0},Oversimplified.Axis.prototype.type="Axis",Oversimplified.Axis.prototype.Check=function(){-1!=Oversimplified.heldKeys.indexOf(this.positiveKeycode)&&-1==Oversimplified.heldKeys.indexOf(this.negativeKeycode)&&(this.direction=1),-1!=Oversimplified.heldKeys.indexOf(this.negativeKeycode)&&-1==Oversimplified.heldKeys.indexOf(this.positiveKeycode)&&(this.direction=-1),(-1==Oversimplified.heldKeys.indexOf(this.negativeKeycode)&&-1==Oversimplified.heldKeys.indexOf(this.positiveKeycode)||-1!=Oversimplified.heldKeys.indexOf(this.negativeKeycode)&&-1!=Oversimplified.heldKeys.indexOf(this.positiveKeycode))&&(this.direction=0)},Oversimplified.Rooms={currentRoom:"Default",AllBeforeDo:function(){},AllDo:function(){},AllAfterDo:function(){}},Oversimplified.Rooms.Add=function(e,i){return"undefined"==typeof Oversimplified.Rooms[e]?(Oversimplified.Rooms[e]=new Oversimplified.Room(e,i),Oversimplified.Rooms[e]):(Oversimplified.DEBUG.showMessages&&console.log('A Room with the name "'+e+'" already exists!'),!1)},Oversimplified.Rooms.New=Oversimplified.Rooms.Add,Oversimplified.R=Oversimplified.Rooms,Oversimplified.O=null,Oversimplified.Room=function(e,i){this.id=Oversimplified.nextID++;var t=this;this.name=e,i="undefined"!=typeof i?i:{},i.width="undefined"!=typeof i.width&&i.width>=Oversimplified.camera.width?i.width:Oversimplified.camera.width,i.height="undefined"!=typeof i.height&&i.height>=Oversimplified.camera.height?i.height:Oversimplified.camera.height,i.stepSpeed="undefined"!=typeof i.stepSpeed&&i.stepSpeed>0?i.stepSpeed:Oversimplified.Settings.defaultStep,this.width=i.width,this.height=i.height,"undefined"!=typeof i.backgroundSrc&&""!=i.backgroundSrc?(this.background=new Image,this.background.src=i.backgroundSrc):this.background=Oversimplified.emptyImage,this.background.loaded=!1,this.background!=Oversimplified.emptyImage&&(this.background.onload=function(){this.loaded=!0,1==i.backgroundSize&&(t.width=this.width,t.height=this.height)}),this.stepSpeed=i.stepSpeed,this.objects={},this.O=this.objects,"undefined"!=typeof i.backgroundColor&&(t.background.color=i.backgroundColor),"undefined"!=typeof i.foreground&&(t.foreground=new Image,t.foreground.loaded=!1,t.foreground.src=i.foreground,t.foreground.onload=function(){this.loaded=!0});for(var s in i)"undefined"==typeof this[s]&&(this[s]=i[s]);this.drawOrder=[],this.DoFirst=function(){},this.BeforeDo=function(){},this.Do=function(){},this.AfterDo=function(){},this.DoLast=function(){},this.DrawBelow=function(){},this.DrawAbove=function(){}},Oversimplified.Room.prototype.type="Room",Oversimplified.Room.prototype.Start=function(){if(this.DoFirst(),this.name===Oversimplified.Rooms.currentRoom)for(var e in this.objects)this.objects[e].Start()},Oversimplified.Room.prototype.Update=function(){Oversimplified.step!=this.stepSpeed&&(Oversimplified.step=this.stepSpeed),this.drawOrder=[];for(var e in this.objects)if("GameObject"==this.objects[e].type){if(this.drawOrder.length<=0){this.drawOrder=[e];continue}for(var i=this.objects[e].depth,t=0;t<this.drawOrder.length;t++)if(i<this.objects[this.drawOrder[t]].depth){this.drawOrder.splice(t,0,e);break}this.drawOrder.indexOf(e)<0&&this.drawOrder.push(e)}if(this.BeforeDo(),this.Do(),this.name===Oversimplified.Rooms.currentRoom)for(var e in this.objects)this.objects[e].Update();this.AfterDo()},Oversimplified.Room.prototype.End=function(){this.DoLast()},Oversimplified.Room.prototype.Draw=function(){var e=this;if("undefined"!=typeof this.background.color){var i=Oversimplified.context.fillStyle;Oversimplified.context.fillStyle=this.background.color,Oversimplified.context.fillRect(0,0,Oversimplified.camera.width,Oversimplified.camera.height),Oversimplified.context.fillStyle=i}this.background.loaded&&Oversimplified.context.drawImage(e.background,Oversimplified.camera.x,Oversimplified.camera.y,Oversimplified.camera.width<=e.background.width?Oversimplified.camera.width:e.background.width,Oversimplified.camera.height<=e.background.height?Oversimplified.camera.height:e.background.height,0,0,e.background.width,e.background.height),this.DrawBelow();for(var t=0;t<this.drawOrder.length;t++)"undefined"!=typeof this.objects[this.drawOrder[t]]&&this.objects[this.drawOrder[t]].Draw();"undefined"!=typeof this.foreground&&this.foreground.loaded&&Oversimplified.context.drawImage(e.foreground,Oversimplified.camera.x,Oversimplified.camera.y,Oversimplified.camera.width,Oversimplified.camera.height,0,0,e.foreground.width,e.foreground.height),this.DrawAbove()},Oversimplified.Room.prototype.AddObject=function(e,i){i="undefined"!=typeof i?i:{};var t=this;if("GameObject"==e.type){var s=Oversimplified.nextID++,o=e.name+s.toString();return t.objects[o]=Oversimplified.CopyObject(e,s,o,i),t.objects[o]}return t.objects[e]?(Oversimplified.DEBUG.showMessages&&console.log('Object with name "'+e+'" already exists in current room!'),!1):(t.objects[e]=new Oversimplified.GameObject(e,i),t.objects[e])},Oversimplified.SetRoom=function(e){"undefined"!=typeof Oversimplified.Rooms[Oversimplified.Rooms.currentRoom]&&Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].End(),Oversimplified.Rooms.currentRoom=e.name,Oversimplified.O=Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].objects,Oversimplified.camera.following="",Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].Start()},Oversimplified.PremadeObjects={},Oversimplified.PremadeObjects.Add=function(e,i){return"undefined"==typeof Oversimplified.PremadeObjects[e]?(Oversimplified.PremadeObjects[e]=new Oversimplified.GameObject(e,i),Oversimplified.PremadeObjects[e]):(Oversimplified.DEBUG.showMessages&&console.log('A Premade Object with the name "'+e+'" already exists!'),!1)},Oversimplified.PremadeObjects.New=Oversimplified.PremadeObjects.Add,Oversimplified.Prefabs=Oversimplified.PremadeObjects,Oversimplified.P=Oversimplified.PremadeObjects,Oversimplified.GameObject=function(e,i){this.id=Oversimplified.nextID++;var t=this;if(this.self=t,this.doFirstHasRun=!1,this.name=e,this.depth="undefined"!=typeof i.depth?i.depth:0,this.solid="undefined"!=typeof i.solid?i.solid:!1,this.persistent="undefined"!=typeof i.persistent?i.persistent:!1,this.x="undefined"!=typeof i.x?i.x:-1,this.y="undefined"!=typeof i.y?i.y:-1,this.xPrevious=this.x,this.yPrevious=this.y,this.screenX=this.x-Oversimplified.camera.x,this.screenY=this.y-Oversimplified.camera.y,"undefined"!=typeof i.imageSrc&&""!=i.imageSrc?(this.image=new Image,this.image.src=i.imageSrc):this.image=Oversimplified.emptyImage,this.image.xScale="undefined"!=typeof i.xScale?i.xScale:1,this.image.yScale="undefined"!=typeof i.yScale?i.yScale:this.image.xScale,this.image.rotation="undefined"!=typeof i.rotation?Math.clampAngle(i.rotation):0,this.image.animations={},this.image.frameColumn=0,this.image.frameRow=0,"undefined"!=typeof i.animations)for(var s=0;s<i.animations.length;s++)0==s&&"Default"!=i.animations[s].name&&(this.image.animations.Default=i.animations[s]),this.image.animations[i.animations[s].name]=i.animations[s];else this.image!=Oversimplified.emptyImage?this.image.onload=function(){this.animations.Default=new Oversimplified.Animation("newAnimation",{width:this.width,height:this.height})}:this.image.animations.Default=new Oversimplified.Animation("newAnimation",{width:this.image.width,height:this.image.height});this.image.currentAnimation="Default",this.mask=i.maskImageSrc?new Image:{},this.mask.src=i.maskImageSrc?i.maskImageSrc:"",""==this.mask.src&&(this.mask.width=this.image.animations.Default.width,this.mask.height=this.image.animations.Default.height),""!=this.mask.src?this.mask.onload=function(){t.xBound=this.width/2*t.image.xScale,t.yBound=this.height/2*t.image.yScale}:(t.xBound=this.mask.width/2*t.image.xScale,t.yBound=this.mask.height/2*t.image.yScale);for(var o in i)"undefined"==typeof this[o]&&(this[o]=i[o]);this.DoFirst=function(){},this.BeforeDo=function(){},this.Do=function(){},this.AfterDo=function(){},this.DoLast=function(){},this.DrawBelow=function(){},this.DrawAbove=function(){}},Oversimplified.GameObject.prototype.type="GameObject",Oversimplified.GameObject.prototype.AddAnimation=function(e,i,t,s){"undefined"!=typeof e.name?this.image.animations[s.name]=e:("undefined"==typeof Oversimplified.Animations[e]&&Oversimplified.Animations.Add(e,i,t,s),this.image.animations[Oversimplified.Animations[e].name]=Oversimplified.Animations[e])},Oversimplified.GameObject.prototype.Draw=function(){this.DrawBelow();var e=this,i=e.image.currentAnimation;if(e.image.animations[i]){var t=e.image.animations[i].width,s=e.image.animations[i].height,o=e.image.animations[i].width*e.image.xScale,r=e.image.animations[i].height*e.image.yScale,d=e.image.animations[i].columns,n=e.image.animations[i].rows,m=e.image.animations[i].xOffset,l=e.image.animations[i].yOffset,a=e.image.animations[i].speed;if(e.image.frameColumn<d&&(e.image.frameColumn+=a),e.image.frameColumn>=d&&(e.image.frameColumn=0,e.image.frameRow++),e.image.frameRow>n-1&&(e.image.frameRow=0),Oversimplified.IsOnCamera(e)){var f=Math.floor(e.image.frameColumn),p=Math.floor(e.image.frameRow);Oversimplified.context.translate(e.x-Oversimplified.camera.x,e.y-Oversimplified.camera.y);var h=e.image.rotation*(Math.PI/180);Oversimplified.context.rotate(h),Oversimplified.context.drawImage(e.image,t*f+m,s*p+l,t,s,-(o/2),-(r/2),o,r),Oversimplified.context.rotate(-h),Oversimplified.context.translate(-(e.x-Oversimplified.camera.x),-(e.y-Oversimplified.camera.y)),Oversimplified.DEBUG.objectsOnScreen++}}else Oversimplified.DEBUG.showMessages&&console.log("No animation at "+i);this.DrawAbove()},Oversimplified.GameObject.prototype.SetScale=function(e,i){this.image.xScale=e,this.image.yScale="undefined"!=typeof i?i:e,this.xBound=this.mask.width/2*this.image.xScale,this.yBound=this.mask.height/2*this.image.yScale},Oversimplified.GameObject.prototype.SetImageRotation=function(e){this.image.rotation=Math.clampAngle(e)},Oversimplified.GameObject.prototype.RotateImage=function(e){this.image.rotation+=Math.clampAngle(e)},Oversimplified.GameObject.prototype.SetAnimation=function(e){e.name&&(e=e.name),this.image.currentAnimation=e,this.image.frameColumn=0,this.image.frameRow=0},Oversimplified.GameObject.prototype.Start=function(){this.DoFirst()},Oversimplified.GameObject.prototype.Update=function(){this.screenX=this.x-Oversimplified.camera.x,this.screenY=this.y-Oversimplified.camera.y,this.xPrevious=this.x,this.yPrevious=this.y,this.doFirstHasRun||(this.DoFirst(),this.doFirstHasRun=!0),this.BeforeDo(),this.Do(),this.AfterDo(),this.image.rotation=Math.clampAngle(this.image.rotation)},Oversimplified.GameObject.prototype.End=function(){this.DoLast()},Oversimplified.GameObject.prototype.MoveTo=function(e,i,t){t="undefined"!=typeof t?t:1,this.x<e&&(this.x+=t),this.x>e&&(this.x-=t),this.y<i&&(this.y+=t),this.y>i&&(this.y-=t)},Oversimplified.GameObject.prototype.PointOverlaps=function(e,i){return e>this.x-this.xBound&&e<this.x+this.xBound&&i>this.y-this.yBound&&i<this.y+this.yBound?!0:!1},Oversimplified.GameObject.prototype.IsOverlapping=function(e){e="undefined"!=typeof e?e:!1;for(var i in Oversimplified.O){var t=Oversimplified.O[i];if(t!=this)if(e){if(t.PointOverlaps(this.x-this.xBound,this.y-this.yBound)||t.PointOverlaps(this.x+this.xBound,this.y-this.yBound)||t.PointOverlaps(this.x-this.xBound,this.y+this.yBound)||t.PointOverlaps(this.x+this.xBound,this.y+this.yBound)||t.PointOverlaps(this.x-this.xBound,this.y)||t.PointOverlaps(this.x+this.xBound,this.y)||t.PointOverlaps(this.x,this.y-this.yBound)||t.PointOverlaps(this.x,this.y+this.yBound))return t}else for(var s=0;s<2*t.xBound;s++)for(var o=0;o<2*t.yBound;o++){var r=t.x-t.xBound+s,d=t.y-t.yBound+o;if(r>this.x-this.xBound&&r<this.x+this.xBound&&d>this.y-this.yBound&&d<this.y+this.yBound)return t}}return!1},Oversimplified.GameObject.prototype.IfOverlappingThenMove=function(e){var i=this.IsOverlapping(e);return 0!=i?(this.x<i.x&&this.x--,this.x>=i.x&&this.x++,this.y<i.y&&this.y--,this.y>=i.y&&this.y++,!0):!1},Oversimplified.GameObject.prototype.KeepInsideRoom=function(){var e=Oversimplified.Rooms[Oversimplified.Rooms.currentRoom];(this.x<this.xBound||this.x>e.width-this.xBound)&&(this.x=this.xPrevious),(this.y<this.yBound||this.y>e.height-this.yBound)&&(this.y=this.yPrevious)},Oversimplified.GameObject.prototype.MouseIsOver=function(){return this.PointOverlaps(Oversimplified.mouse.x,Oversimplified.mouse.y)?!0:!1},Oversimplified.GameObject.prototype.Clicked=function(e){return e="undefined"!=typeof e?e:Oversimplified.mouse.leftDown,this.MouseIsOver()&&e?!0:!1},Oversimplified.GameObject.prototype.SimpleMove=function(e,i,t,s){s="undefined"!=typeof s?s:2;var o=!1,r=!1,d=!1,n=!1;if(t){for(var m=0;m<2*this.yBound;m+=s){var l=this.y-this.yBound+m;o||(o=0>e&&Oversimplified.CollisionAtPoint(this.x-this.xBound+e,l)),r||(r=e>0&&Oversimplified.CollisionAtPoint(this.x+this.xBound+e,l))}for(var a=0;a<2*this.xBound;a+=s){var f=this.x-this.xBound+a;d||(d=0>i&&Oversimplified.CollisionAtPoint(f,this.y-this.yBound+i)),n||(n=i>0&&Oversimplified.CollisionAtPoint(f,this.y+this.yBound+i))}}return t&&(o||r||d||n)?!1:(this.x+=e,this.y+=i,!0)},Oversimplified.GameObject.prototype.Destroy=function(){this.End(),delete Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].objects[this.name]},Oversimplified.GameObjectsAtPoint=function(e,i){var t=[];for(var s in Oversimplified.O){var o=Oversimplified.O[s];e<=o.x+o.xBound&&e>=o.x-o.xBound&&i<=o.y+o.yBound&&i>=o.y-o.yBound&&t.push(o)}return t.length>0?t:!1},Oversimplified.CollisionAtPoint=function(e,i){for(var t=Oversimplified.GameObjectsAtPoint(e,i),s=0;s<t.length;s++)if(1==t[s].solid)return!0;return!1},Oversimplified.Animations={},Oversimplified.Animations.Add=function(e,i,t,s){return"undefined"==typeof Oversimplified.Animations[e]?(Oversimplified.Animations[e]=new Oversimplified.Animation(e,i,t,s),Oversimplified.Animations[e]):(Oversimplified.DEBUG.showMessages&&console.log('An animation with the name "'+e+'" already exists!'),!1)},Oversimplified.Animations.New=Oversimplified.Animations.Add,Oversimplified.A=Oversimplified.Animations,Oversimplified.Animation=function(e,i,t,s){this.id=Oversimplified.nextID++,this.name=e,this.width=i,this.height=t,this.columns="undefined"!=typeof s.columns?s.columns:1,this.rows="undefined"!=typeof s.rows?s.rows:1,this.speed="undefined"!=typeof s.speed?Math.clamp01(s.speed):1,this.xOffset="undefined"!=typeof s.xOffset?s.xOffset:0,this.yOffset="undefined"!=typeof s.yOffset?s.yOffset:0},Oversimplified.Animation.prototype.type="Animation",Oversimplified.GUIs={},Oversimplified.GUIs.Add=function(e,i){return"undefined"==typeof Oversimplified.GUIs[e]?(Oversimplified.GUIs[e]=new Oversimplified.Animation(e,i),Oversimplified.GUIs[e]):(Oversimplified.DEBUG.showMessages&&console.log('An GUI with the name "'+e+'" already exists!'),!1)},Oversimplified.GUI=function(e,i){this.id=OS.nextID++,this.name=e,this.x="undefined"!=typeof i.x?i.x:0,this.y="undefined"!=typeof i.y?i.y:0,this.width="undefined"!=typeof i.width?i.width:0,this.height="undefined"!=typeof i.height?i.height:0,this.xScroll="undefined"!=typeof i.xScroll?i.xScroll:0,this.yScroll="undefined"!=typeof i.yScroll?i.yScroll:0,this.leftBorder="undefined"!=typeof i.leftBorder?i.leftBorder:0,this.rightBorder="undefined"!=typeof i.rightBorder?i.rightBorder:0,this.topBorder="undefined"!=typeof i.topBorder?i.topBorder:0,this.bottomBorder="undefined"!=typeof i.bottomBorder?i.bottomBorder:0,this.elements=[],this.show="undefined"!=typeof i.show?i.show:!1},Oversimplified.GUI.prototype.AddElement=function(e){var i={GUI:this,index:this.elements.length++,x:"undefined"!=typeof e.x?e.x:0,y:"undefined"!=typeof e.y?e.y:0,width:"undefined"!=typeof e.width?e.width:0,height:"undefined"!=typeof e.height?e.height:0};return this.elements.push(i),this.elements[i.index]},Oversimplified.Effects={Sounds:[],Tunes:[]},Oversimplified.Effects.Tunes.CheckLoops=function(){for(var e in Oversimplified.Effects.Tunes)"Tune"==Oversimplified.Effects.Tunes[e].type&&Oversimplified.Effects.Tunes[e].IsPlaying()&&Oversimplified.Effects.Tunes[e].CheckLoop()},Oversimplified.Sound=function(e,i,t){this.id=Oversimplified.nextID++,t="undefined"!=typeof t?t:!1,this.name=e,this.source=i,this.secondarySource=t,this.audioElement=document.createElement("audio"),this.audioElement.id=this.name+this.id.toString();var s=document.createElement("source");s.src=this.source,this.audioElement.appendChild(s),0!=this.secondarySource&&(s.src=this.secondarySource,this.audioElement.appendChild(s)),document.getElementById("audio").appendChild(this.audioElement),this.audioElement.load(),this.element=this.audioElement},Oversimplified.Sound.prototype.type="Sound",Oversimplified.Sound.prototype.Play=function(){this.element.currentTime=0,this.element.volume=Oversimplified.Settings.soundVolume,this.element.play()},Oversimplified.Sound.prototype.Stop=function(){this.element.pause(),this.element.currentTime=0},Oversimplified.Sound.prototype.IsPlaying=function(){return!this.element.paused&&!this.element.ended&&0<this.element.currentTime},Oversimplified.Tune=function(e,i,t,s){this.id=Oversimplified.nextID++,t="undefined"!=typeof t?t:!1,s="undefined"!=typeof s?s:!1,this.name=e,this.source=i,this.secondarySource=t,this.duration=s,this.audioElement=document.createElement("audio"),this.audioElement.id=this.name+this.id.toString();var o=document.createElement("source");o.src=this.source,this.audioElement.appendChild(o),0!=this.secondarySource&&(o.src=this.secondarySource,this.audioElement.appendChild(o)),document.getElementById("audio").appendChild(this.audioElement),this.audioElement.load(),this.element=this.audioElement},Oversimplified.Tune.prototype.type="Tune",Oversimplified.Tune.prototype.Play=function(){this.element.currentTime=0,this.element.volume=Oversimplified.Settings.musicVolume,this.element.loop=!0,this.element.play()},Oversimplified.Tune.prototype.Stop=function(){this.element.pause(),this.element.currentTime=0},Oversimplified.Tune.prototype.CheckLoop=function(){this.duration<this.element.duration&&this.element.currentTime>this.duration&&(this.element.currentTime=0)},Oversimplified.Tune.prototype.IsPlaying=function(){return!this.element.paused&&!this.element.ended&&0<this.element.currentTime},Oversimplified.Effects.S=Oversimplified.Effects.Sounds,Oversimplified.Effects.T=Oversimplified.Effects.Tunes,Oversimplified.Effects.Music=Oversimplified.Effects.Tunes,Oversimplified.Effects.M=Oversimplified.Effects.Tunes,Oversimplified.E=Oversimplified.Effects,Oversimplified.CreateObject=function(e,i,t,s,o,r){if("GameObject"==e.type){var d=Oversimplified.nextID++,n=e.name+d.toString();return Oversimplified.O[n]=Oversimplified.CopyObject(e,d,n),Oversimplified.O[n].x=i,Oversimplified.O[n].y=t,Oversimplified.O[n]}return Oversimplified.O[e]?(Oversimplified.DEBUG.showMessages&&console.log('Object with name "'+e+'" already exists in current room!'),!1):(Oversimplified.O[e]=new Oversimplified.GameObject(e,i,t,s,o,r),Oversimplified.O[e].Start(),Oversimplified.O[e])},Oversimplified.CopyObject=function(e,i,t,s){var o={};"identical"!=i?(o.id="undefined"!=typeof i?i:Oversimplified.nextID++,o.name="undefined"!=typeof t?t:e.name+o.id.toString()):(o.id=e.id,o.name=e.name),"GameObject"==e.type&&(o.self=o,o.image=new Image,o.image.src=e.image.src,o.image.xScale=e.image.xScale,o.image.yScale=e.image.yScale,o.image.rotation=e.image.rotation,o.image.frameColumn=0,o.image.frameRow=0,o.image.animations=e.image.animations,o.image.currentAnimation=e.image.currentAnimation,o.mask=new Image,o.mask.src=e.mask.src,""==o.mask.src&&(o.mask.width=o.image.animations.Default.width,o.mask.height=o.image.animations.Default.height),o.mask.onload=function(){o.xBound=this.width/2,o.yBound=this.height/2});for(var r in e)"undefined"==typeof o[r]&&(e[r].slice?o[r]=e[r].slice():o[r]=e[r]);for(var d in s)e[d].slice?o[d]=e[d].slice():o[d]=s[d];return o},Oversimplified.Copy=function(e,i,t){var s={};if("identical"!=i?(s.id="undefined"!=typeof i?i:Oversimplified.nextID++,s.name="undefined"!=typeof t?t:e.name+s.id.toString()):(s.id=e.id,s.name=e.name),"GameObject"==e.type&&(s=Oversimplified.CopyObject(e,i,t)),"Room"==e.type){s.objects={};for(var o in e.objects)s.objects[o]=Oversimplified.Copy(e.objects[o])}for(var r in e)"undefined"==typeof s[r]&&(s[r]=e[r]);return s},Oversimplified.Save=function(e,i){if("undefined"!=typeof Storage){if(localStorage.setItem(e,i),localStorage.getItem(e)==i)return Oversimplified.DEBUG.showMessages&&console.log("Successfully saved "+i+' to localStorage["'+e+'"].'),!0;Oversimplified.DEBUG.showMessages&&console.log("Could not save "+i+' to localStorage["'+e+'"].')}else Oversimplified.DEBUG.showMessages&&console.log("This browser does not support saving to localStorage.");return!1},Oversimplified.Load=function(e){if("undefined"!=typeof Storage){if(localStorage.getItem(e))return Oversimplified.DEBUG.showMessages&&console.log('Successfully loaded from localStorage["'+e+'"].'),localStorage.getItem(e);Oversimplified.DEBUG.showMessages&&console.log('No data saved in localStorage["'+e+'"].')}else Oversimplified.DEBUG.showMessages&&console.log("This browser does not support loading from localStorage.");return!1},Oversimplified.Erase=function(e){if("undefined"!=typeof Storage)if(localStorage.getItem(e)){if(localStorage.removeItem(e),!localStorage.getItem(e))return Oversimplified.DEBUG.showMessages&&console.log('Successfully erased localStorage["'+e+'"].'),!0;Oversimplified.DEBUG.showMessages&&console.log('Could not erase localStorage["'+e+'"].')}else Oversimplified.DEBUG.showMessages&&console.log('There is no data to remove from localStorage["'+e+'"].');else Oversimplified.DEBUG.showMessages&&console.log("This browser does not support manipulating localStorage.");return!1},Oversimplified.DEBUG={showMessages:!0,DrawBoundingBox:function(e){var i=Oversimplified.context.fillStyle;Oversimplified.context.fillStyle="rgba(255, 0, 255, 0.5)",Oversimplified.context.fillRect(e.x-e.xBound-Oversimplified.camera.x,e.y-e.yBound-Oversimplified.camera.y,2*e.xBound,2*e.yBound),Oversimplified.context.fillStyle=i},CountObjectsInRoom:function(e){var i,t=0;i="undefined"!=typeof e?e.name?e:Oversimplified.Rooms[e]:Oversimplified.Rooms[Oversimplified.Rooms.currentRoom];for(var s in i.objects)t++;return t},objectsOnScreen:0,CountObjectsOnScreen:function(){return Oversimplified.DEBUG.objectsOnScreen},ListControls:function(){var e=0,i=0,t=0;for(var s in Oversimplified.Controls)if("undefined"!=typeof Oversimplified.Controls[s].Check){t++;var o='Oversimplified.C["'+s+'"] ';"Control"==Oversimplified.Controls[s].type&&(o+="(Control): "+Oversimplified.C[s].keyName,e++),"Axis"==Oversimplified.Controls[s].type&&(o+="(Axis) Positive: "+Oversimplified.C[s].positiveKeyName+", Negative: "+Oversimplified.C[s].negativeKeyName,i++),console.log(o)}console.log(e+" Controls and "+i+" Axes.\n"+t+" in all")}},window.onload=function(){Oversimplified.Initialize()},Oversimplified.Initialize=function(){Oversimplified.SetupCanvas(),Oversimplified.SetupControls(),Oversimplified.AddScript("start.js",function(){start(),Oversimplified.SetCanvasToCameraSize(),Oversimplified.Frame()})},Oversimplified.SetupCanvas=function(){Oversimplified.canvas=document.getElementById("game"),Oversimplified.canvas.getContext?Oversimplified.context=Oversimplified.canvas.getContext("2d"):alert("No 2D Canvas Context for game."),Oversimplified.Settings.preventRightClick&&(Oversimplified.canvas.oncontextmenu=function(){return!1})},Oversimplified.SetupControls=function(){Oversimplified.SetupMouseListeners(),Oversimplified.SetupKeyboardListeners()},Oversimplified.SetupMouseListeners=function(){Oversimplified.canvas.addEventListener("mousemove",function(e){var i=Oversimplified.canvas.getBoundingClientRect();Oversimplified.mouse.x=e.clientX-i.left+Oversimplified.camera.x,Oversimplified.mouse.y=e.clientY-i.top+Oversimplified.camera.y},!1),Oversimplified.canvas.addEventListener("mousedown",function(e){e.button===Oversimplified.mouse.leftCode?(Oversimplified.mouse.left||(Oversimplified.mouse.leftDown=!0),Oversimplified.mouse.left=!0):e.button===Oversimplified.mouse.middleCode?(e.preventDefault(),Oversimplified.mouse.middle||(Oversimplified.mouse.middleDown=!0),Oversimplified.mouse.middle=!0):e.button===Oversimplified.mouse.rightCode&&(Oversimplified.mouse.right||(Oversimplified.mouse.rightDown=!0),Oversimplified.mouse.right=!0)},!1),Oversimplified.canvas.addEventListener("mouseup",function(e){e.button===Oversimplified.mouse.leftCode?(Oversimplified.mouse.left=!1,Oversimplified.mouse.leftUp=!0):e.button===Oversimplified.mouse.middleCode?(Oversimplified.mouse.middle=!1,Oversimplified.mouse.middleUp=!0):e.button===Oversimplified.mouse.rightCode&&(Oversimplified.mouse.right=!1,Oversimplified.mouse.rightUp=!0)},!1),Oversimplified.canvas.addEventListener("mouseout",function(){Oversimplified.mouse.left=Oversimplified.mouse.middle=Oversimplified.mouse.right=!1},!1),Oversimplified.canvas.addEventListener("mousewheel",Oversimplified.MouseWheelHandler,!1),Oversimplified.canvas.addEventListener("DOMMouseScroll",Oversimplified.MouseWheelHandler,!1),Oversimplified.canvas.addEventListener("touchstart",function(e){switch(e.preventDefault(),e.targetTouches.length){case 1:Oversimplified.mouse.right=!1,Oversimplified.mouse.middle=!1,Oversimplified.mouse.left||(Oversimplified.mouse.leftDown=!0),Oversimplified.mouse.left=!0;break;case 2:Oversimplified.mouse.left=!1,Oversimplified.mouse.middle=!1,Oversimplified.mouse.right||(Oversimplified.mouse.rightDown=!0),Oversimplified.mouse.right=!0;break;case 3:Oversimplified.mouse.left=!1,Oversimplified.mouse.right=!1,Oversimplified.mouse.middle||(Oversimplified.mouse.middleDown=!0),Oversimplified.mouse.middle=!0}var i=Oversimplified.canvas.getBoundingClientRect();Oversimplified.mouse.x=e.targetTouches[0].clientX-i.left+Oversimplified.camera.x,Oversimplified.mouse.y=e.targetTouches[0].clientY-i.top+Oversimplified.camera.y},!1),Oversimplified.canvas.addEventListener("touchmove",function(e){e.preventDefault();var i=Oversimplified.canvas.getBoundingClientRect();Oversimplified.mouse.x=e.targetTouches[0].clientX-i.left+Oversimplified.camera.x,Oversimplified.mouse.y=e.targetTouches[0].clientY-i.top+Oversimplified.camera.y},!1),window.addEventListener("touchend",function(e){e.targetTouches.length<1?(Oversimplified.mouse.left&&(Oversimplified.mouse.leftUp=!0),Oversimplified.mouse.left=!1,Oversimplified.mouse.right=!1,Oversimplified.mouse.middle=!1):e.targetTouches.length<2?(Oversimplified.mouse.right&&(Oversimplified.mouse.rightUp=!0),Oversimplified.mouse.right=!1,Oversimplified.mouse.middle=!1):e.targetTouches.length<3&&(Oversimplified.mouse.middle&&(Oversimplified.mouse.middleUp=!0),Oversimplified.mouse.middle=!1)},!1)},Oversimplified.SetupKeyboardListeners=function(){window.addEventListener("keydown",function(e){[Oversimplified.Keycode.left,Oversimplified.Keycode.right,Oversimplified.Keycode.up,Oversimplified.Keycode.down,Oversimplified.Keycode.space,Oversimplified.Keycode.tab].indexOf(e.keyCode)>-1&&e.preventDefault();
},!1),document.addEventListener("keydown",function(e){var i=e.which;-1==Oversimplified.pressedKeys.indexOf(i)&&-1==Oversimplified.heldKeys.indexOf(i)&&Oversimplified.pressedKeys.push(i),-1==Oversimplified.heldKeys.indexOf(i)&&Oversimplified.heldKeys.push(i)},!1),document.addEventListener("keyup",function(e){var i=e.which;Oversimplified.heldKeys.splice(Oversimplified.heldKeys.indexOf(i),1),-1==Oversimplified.releasedKeys.indexOf(i)&&Oversimplified.releasedKeys.push(i)},!1)},Oversimplified.SetCanvasToCameraSize=function(){Oversimplified.canvas.width!=Oversimplified.camera.width&&(Oversimplified.DEBUG.showMessages&&console.log("Adjusting Camera Width from "+Oversimplified.canvas.width+" to "+Oversimplified.camera.width),Oversimplified.canvas.width=Oversimplified.camera.width),Oversimplified.canvas.height!=Oversimplified.camera.height&&(Oversimplified.DEBUG.showMessages&&console.log("Adjusting Camera Height from "+Oversimplified.canvas.height+" to "+Oversimplified.camera.height),Oversimplified.canvas.height=Oversimplified.camera.height)},Oversimplified.Frame=function(){if(Oversimplified.Settings.numberOfScriptsToLoad>0&&Oversimplified.loadedScripts.length==Oversimplified.Settings.numberOfScriptsToLoad||Oversimplified.Settings.numberOfScriptsToLoad<=0&&0==Oversimplified.loadingScripts.length){for(Oversimplified.now=Oversimplified.timestamp(),Oversimplified.dateTime=Oversimplified.dateTime+Math.min(1,(Oversimplified.now-Oversimplified.lastFrame)/1e3);Oversimplified.dateTime>Oversimplified.step;)Oversimplified.dateTime=Oversimplified.dateTime-Oversimplified.step,Oversimplified.Update(),Oversimplified.Draw(),Oversimplified.EndFrame();Oversimplified.lastFrame=Oversimplified.now}else{if(Oversimplified.DEBUG.showMessages){var e="Loaded "+Oversimplified.loadedScripts.length.toString();e+=Oversimplified.Settings.numberOfScriptsToLoad>0?" of "+Oversimplified.Settings.numberOfScriptsToLoad.toString():"",e+=" scripts:\n"+Oversimplified.loadedScripts.toString()+".\nWaiting for:\n"+Oversimplified.loadingScripts.toString(),console.log(e)}if(Oversimplified.Settings.numberOfScriptsToLoad>0){var i=Oversimplified.loadedScripts.length/Oversimplified.Settings.numberOfScriptsToLoad,t=32,s=Math.round(.6*Oversimplified.camera.width),o=Math.round(s*i),r=Math.round(.2*Oversimplified.camera.width),d=Math.round(.5*Oversimplified.camera.height)-Math.round(t/2),n=OS.context.fillStyle,m=OS.context.strokeStyle;OS.context.fillStyle="#DD5511",OS.context.fillRect(r,d,o,t),OS.context.strokeStyle="#882200",OS.context.lineWidth=5,OS.context.strokeRect(r,d,s,t),OS.context.fillStyle=n,OS.context.strokeStyle=m}}requestAnimationFrame(Oversimplified.Frame)},Oversimplified.Update=function(){Oversimplified.Controls.CheckAll(),Oversimplified.Rooms.AllBeforeDo(),Oversimplified.Rooms.AllDo(),"undefined"!=typeof Oversimplified.Rooms[Oversimplified.Rooms.currentRoom]?Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].Update():Oversimplified.DEBUG.showMessages&&console.log("There is no current room. Please add one or make sure you are referencing the correct room with Oversimplified.Rooms.SetRoom()."),Oversimplified.Rooms.AllAfterDo(),""!=Oversimplified.camera.following&&(Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].objects[Oversimplified.camera.following].x-Oversimplified.camera.x>Oversimplified.camera.width-Oversimplified.camera.hBorder&&(Oversimplified.camera.x=Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].objects[Oversimplified.camera.following].x-(Oversimplified.camera.width-Oversimplified.camera.hBorder)),Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].objects[Oversimplified.camera.following].x-Oversimplified.camera.x<Oversimplified.camera.hBorder&&(Oversimplified.camera.x=Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].objects[Oversimplified.camera.following].x-Oversimplified.camera.hBorder),Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].objects[Oversimplified.camera.following].y-Oversimplified.camera.y>Oversimplified.camera.height-Oversimplified.camera.vBorder&&(Oversimplified.camera.y=Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].objects[Oversimplified.camera.following].y-(Oversimplified.camera.height-Oversimplified.camera.vBorder)),Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].objects[Oversimplified.camera.following].y-Oversimplified.camera.y<Oversimplified.camera.vBorder&&(Oversimplified.camera.y=Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].objects[Oversimplified.camera.following].y-Oversimplified.camera.vBorder)),Oversimplified.camera.x<0&&(Oversimplified.camera.x=0),Oversimplified.camera.x+Oversimplified.camera.width>Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].width&&(Oversimplified.camera.x=Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].width-Oversimplified.camera.width),Oversimplified.camera.y<0&&(Oversimplified.camera.y=0),Oversimplified.camera.y+Oversimplified.camera.height>Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].height&&(Oversimplified.camera.y=Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].height-Oversimplified.camera.height)},Oversimplified.Draw=function(){Oversimplified.context.clearRect(0,0,Oversimplified.canvas.width,Oversimplified.canvas.height),Oversimplified.DEBUG.objectsOnScreen=0,"undefined"!=typeof Oversimplified.Rooms[Oversimplified.Rooms.currentRoom]?Oversimplified.Rooms[Oversimplified.Rooms.currentRoom].Draw():Oversimplified.DEBUG.showMessages&&console.log("There is no current room. Please add one or make sure you are referencing the correct room with Oversimplified.Rooms.SetRoom().")},Oversimplified.EndFrame=function(){Oversimplified.mouse.wheel=0,Oversimplified.mouse.leftDown=!1,Oversimplified.mouse.middleDown=!1,Oversimplified.mouse.rightDown=!1,Oversimplified.mouse.leftUp=!1,Oversimplified.mouse.middleUp=!1,Oversimplified.mouse.rightUp=!1,Oversimplified.pressedKeys=[],Oversimplified.releasedKeys=[]},Oversimplified.MouseWheelHandler=function(e){e.preventDefault(),Oversimplified.mouse.wheel=Math.max(-1,Math.min(1,e.wheelDelta||-e.detail))},Oversimplified.IsOnCamera=function(e,i){if("undefined"!=typeof i)return e>Oversimplified.camera.x&&e<Oversimplified.camera.x+Oversimplified.camera.width&&i>Oversimplified.camera.y&&i<Oversimplified.camera.y+Oversimplified.camera.height?!0:!1;var t=e;return t.x+t.xBound>Oversimplified.camera.x&&t.x-t.xBound<Oversimplified.camera.x+Oversimplified.camera.width&&t.y+t.yBound>Oversimplified.camera.y&&t.y-t.yBound<Oversimplified.camera.y+Oversimplified.camera.height?!0:!1},Oversimplified.AddScript=function(e,i){i="undefined"!=typeof i?i:e.slice(e.lastIndexOf("/")>-1?e.lastIndexOf("/")+1:0,e.indexOf(".")),Oversimplified.loadingScripts.push(e);var t=document.createElement("script");t.src=e,t.onload=function(){"string"!=typeof i?Oversimplified.WaitForScriptsToLoad(function(){i()}):"function"==typeof window[i]?Oversimplified.WaitForScriptsToLoad(function(){window[i]()}):Oversimplified.DEBUG.showMessages&&console.log(i+" is not a function!"),Oversimplified.loadedScripts.push(e),Oversimplified.loadingScripts.splice(Oversimplified.loadingScripts.indexOf(e),1)},document.body.appendChild(t)},Oversimplified.WaitForScriptsToLoad=function(e){Oversimplified.DEBUG.showMessages&&Oversimplified.Settings.numberOfScriptsToLoad>0&&console.log("Waiting for "+(Oversimplified.Settings.numberOfScriptsToLoad-Oversimplified.loadedScripts.length).toString()+" scripts to load"),Oversimplified.loadingScripts.length>0?setTimeout(function(){Oversimplified.WaitForScriptsToLoad(e)},.1):e()},Math.clamp=function(e,i,t){return i==t?(Oversimplified.DEBUG.showMessages&&console.log("Min and Max cannot be the same number!"),!1):i>t?(Oversimplified.DEBUG.showMessages&&console.log("Min must be less than Max!"),!1):(i>e&&(e=i),e>t&&(e=t),e)},Math.clamp01=function(e){return 0>e&&(e=0),e>1&&(e=1),e},Math.clampAngle=function(e,i,t){for(;e>=360;)e-=360;for(;0>e;)e+=360;if("undefined"!=typeof i&&"undefined"!=typeof t){for(;i>=360;)i-=360;for(;0>i;)i+=360;for(;t>=360;)t-=360;for(;0>t;)t+=360;if(i==t)return Oversimplified.DEBUG.showMessages&&console.log("Min and Max cannot be the same number!"),!1;if(i>t)return Oversimplified.DEBUG.showMessages&&console.log("Min must be less than Max!"),!1;i>e&&(e=i),e>t&&(e=t)}return e},Math.radToDeg=function(e){return e/(Math.PI/180)},Math.degToRad=function(e){return e*(Math.PI/180)},Math.getCos=function(e){return Math.cos(Math.degToRad(e))},Math.getSin=function(e){return Math.sin(Math.degToRad(e))},Math.coinFlip=function(){return Math.random()>=.5?!0:!1},Math.randomRange=function(e,i){return Math.random()*(i-e)+e};