var theGameObj=null;theGame.prototype.setImage=function setImage(img){this.imagesCursor=img;if(this.imagesCursor<0)this.imagesCursor=0;if(this.imagesCursor>this.imagesList.length-1)this.imagesCursor=this.imagesList.length-1};theGame.prototype.resetLoopCounter=function resetLoopCounter(){this.dieAVGA=[];this.dieAVGB=[];this.dieAVGC=[];this.loopCounter=1}; theGame.prototype.start=function start(){this.islands=2;this.rand=30;this.dataLoader=g_dataLoader;this.dataLoader.load("img/logo/INTRO_ptak.png","logo");this.load();this.resetLoopCounter();this.currentPhoto=0;this.mainList=SSS;this.infoClicked=false;that=this;attachEvent(document.getElementById("info"),"tap",function(){that.currentPhoto++;that.infoClicked=true});attachEvent(document.getElementById("prev"),"tap",function(e){document.location="gatunkowy.html"});attachEvent(document.getElementById("next"), "tap",function(e){document.location="koniec.html"});this.areaA=new area("A");this.areaB=new area("B");this.sumAB=[];var that=this;this.sliders=[];this.sliderOsobnikiA=new makeSlider("pb05-a",function(v){that.areaA.setOsobniki(v*2);that.resetLoopCounter()});this.sliderOsobnikiB=new makeSlider("pb05-b",function(v){that.areaB.setOsobniki(v*2);that.resetLoopCounter()});this.sliderPojemnoscA=new makeSlider("pb01-a",function(v){that.chartA.setMaxY(Math.floor(v/2));that.chartC.setMaxY(Math.floor((that.areaB.pojemnosc* 1+v*1)/2));that.areaA.setPojemnosc(v);that.sliderOsobnikiA.p_max=Math.floor(v/2);if(that.sliderOsobnikiA.value>that.sliderOsobnikiA.p_max)that.sliderOsobnikiA.value=that.sliderOsobnikiA.p_max;that.sliderOsobnikiA.refreshSlider();that.sliderOsobnikiA.drawSlider();that.sliderOsobnikiA.onChangeFN(that.sliderOsobnikiA.value);that.resetLoopCounter()});this.sliders.push(this.sliderPojemnoscA);this.sliderPojemnoscB=new makeSlider("pb01-b",function(v){that.chartB.setMaxY(Math.floor(v/2));that.chartC.setMaxY(Math.floor((that.areaA.pojemnosc* 1+v*1)/2));that.areaB.setPojemnosc(v);that.sliderOsobnikiB.p_max=Math.floor(v/2);if(that.sliderOsobnikiB.value>that.sliderOsobnikiB.p_max)that.sliderOsobnikiB.value=that.sliderOsobnikiB.p_max;that.sliderOsobnikiB.refreshSlider();that.sliderOsobnikiB.drawSlider();that.sliderOsobnikiB.onChangeFN(that.sliderOsobnikiB.value);that.resetLoopCounter()});this.sliders.push(this.sliderPojemnoscB);this.sliders.push(new makeSlider("pb02-a",function(v){that.areaA.setCzestotliwoscKatastrof(v);that.resetLoopCounter()})); this.sliders.push(new makeSlider("pb02-b",function(v){that.areaB.setCzestotliwoscKatastrof(v);that.resetLoopCounter()}));this.sliders.push(new makeSlider("pb03-a",function(v){that.areaA.setSilaKatastrof(v);that.resetLoopCounter()}));this.sliders.push(new makeSlider("pb03-b",function(v){that.areaB.setSilaKatastrof(v);that.resetLoopCounter()}));this.sliders.push(new makeSlider("pb04-a",function(v){that.areaA.setPrzepustowoscKorytarza(v);that.resetLoopCounter()}));this.sliders.push(new makeSlider("pb04-b", function(v){that.areaB.setPrzepustowoscKorytarza(v);that.resetLoopCounter()}));this.sliders.push(new makeSlider("pb06-a",function(v){that.areaA.setRozrodczosc(v);that.resetLoopCounter()}));this.sliders.push(new makeSlider("pb06-b",function(v){that.areaB.setRozrodczosc(v);that.resetLoopCounter()}));this.sliders.push(new makeSlider("pb07-a",function(v){that.areaA.setSmiertelnosc(v);that.resetLoopCounter()}));this.sliders.push(new makeSlider("pb07-b",function(v){that.areaB.setSmiertelnosc(v);that.resetLoopCounter()})); this.sliders.push(new makeSlider("pb08-a",function(v){that.areaA.setEmigracja(v);that.resetLoopCounter()}));this.sliders.push(new makeSlider("pb08-b",function(v){that.areaB.setEmigracja(v);that.resetLoopCounter()}));this.sliders.push(this.sliderOsobnikiA);this.sliders.push(this.sliderOsobnikiB);this.chartA=document.getElementById("chart-A");this.chartAContext2D=this.chartA.getContext("2d");this.chartB=document.getElementById("chart-B");this.chartBContext2D=this.chartB.getContext("2d");this.chartC= document.getElementById("chart-C");this.chartCContext2D=this.chartC.getContext("2d");this.canvas=document.getElementById("display");this.context2D=this.canvas.getContext("2d");this.context2D.font="15pt Calibri";this.context2D.fillStyle="black";this.backBuffer=document.createElement("canvas");this.backBuffer.width=this.canvas.width;this.backBuffer.height=this.canvas.height;this.backBufferContext2D=this.backBuffer.getContext("2d");this.attachEvents();this.areas=[];this.subjects=[];this.chartA=new chart(document.getElementById("chart-A"), "Populacja A","liczba par l\u0119gowych","lata");this.chartB=new chart(document.getElementById("chart-B"),"Populacja B","liczba par l\u0119gowych","lata");this.chartC=new chart(document.getElementById("chart-C"),"Metapopulacja A+B","liczba par l\u0119gowych","lata");for(var i in this.sliders)this.sliders[i].onChangeFN(this.sliders[i].value);this.redrawFrame();return this};
