theGame.prototype.refreshWindow=function refreshWindow(){window.scrollTo(0,0);if(this.windowWidth!=document.body.clientWidth||this.windowHeight!=document.body.clientHeight){this.windowWidth=document.body.clientWidth;this.windowHeight=document.body.clientHeight;document.getElementById("p01").style.width=Math.floor(document.getElementById("p01").clientHeight*4/3)+"px";this.canvas.width=this.canvas.clientWidth;this.canvas.height=this.canvas.clientHeight;this.backBuffer.width=this.canvas.width;this.backBuffer.height=
this.canvas.height}var sheet=document.styleSheets[0];if(sheet){var rules="cssRules"in sheet?sheet.cssRules:sheet.rules;if(rules){if(rules[0])if(rules[0].style)rules[0].style.fontSize=Math.round(document.getElementById("p01").clientHeight*0.022)+"px";if(rules[1])if(rules[1].style)rules[1].style.fontSize=Math.round(document.getElementById("p01").clientHeight*0.03)+"px";if(rules[2])if(rules[2].style)rules[2].style.fontSize=Math.round(document.getElementById("p01").clientHeight*0.017)+"px";if(rules[3])if(rules[3].style)rules[3].style.fontSize=
Math.round(document.getElementById("p01").clientHeight*0.019)+"px"}}this.redrawFrame(1)};
theGame.prototype.drawImage=function drawImage(img_idx,desc){var canvas=document.getElementById("photo");var canvas2D=canvas.getContext("2d");if(!this.dataLoader.res[img_idx])img_idx="logo";var img=this.dataLoader.res[img_idx].img;if(!img||!img.width)var img=this.dataLoader.res["logo"].img;canvas2D.drawImage(img,0,0,img.width,img.height,0,0,canvas.width,canvas.height);this.descDiv=document.getElementById("desc");this.descDiv.innerHTML="<span>"+desc+"</span>"};
theGame.prototype.redrawFrame=function redrawFrame(req){var spos=getPageScroll();var img=this.mainList[this.gatunek].photos[0].img;var desc=this.mainList[this.gatunek].photos[0].desc;this.drawImage(img,desc);if(this.windowWidth!=document.body.clientWidth||(this.windowHeight!=document.body.clientHeight||(spos.x!=0||spos.y!=0)))this.refreshWindow();this.photos=[];var avgDieA=0;var avgDieB=0;var avgDieC=0;var resA={osobniki:this.areaA.osobniki,emigracja:0};var resB={osobniki:this.areaB.osobniki,emigracja:0};
if(resA.osobniki<1)avgDieA++;if(resB.osobniki<1)avgDieB++;if(resA.osobniki<1&&resB.osobniki<1)avgDieC++;this.areaA.timeLine[0]=resA.osobniki/2;this.areaB.timeLine[0]=resB.osobniki/2;this.sumAB[0]=this.areaA.timeLine[0]+this.areaB.timeLine[0];for(var i=1;i<100;i++){resA=this.areaA.calcYear(resA.osobniki,resB.emigracja);this.areaA.timeLine[i]=resA.osobniki/2;resB=this.areaB.calcYear(resB.osobniki,resA.emigracja);this.areaB.timeLine[i]=resB.osobniki/2;this.sumAB[i]=this.areaA.timeLine[i]+this.areaB.timeLine[i];
if(resA.wymarcie)avgDieA++;if(resB.wymarcie)avgDieB++;if(resA.wymarcie&&resB.wymarcie)avgDieC++}avgDieA=avgDieA/100;avgDieB=avgDieB/100;avgDieC=avgDieC/100;this.dieAVGA.push(avgDieA);this.dieAVGB.push(avgDieB);this.dieAVGC.push(avgDieC);this.chartA.addInfo=Math.round(ArrAVG(this.dieAVGA)*100)+"% lat z zerow\u0105 liczebno\u015bci\u0105";this.chartB.addInfo=Math.round(ArrAVG(this.dieAVGB)*100)+"% lat z zerow\u0105 liczebno\u015bci\u0105";this.chartC.addInfo=Math.round(ArrAVG(this.dieAVGC)*100)+"% lat z zerow\u0105 liczebno\u015bci\u0105";
this.chartA.refreshWindow();this.chartA.drawData(this.areaA.timeLine);this.chartB.refreshWindow();this.chartB.drawData(this.areaB.timeLine);this.chartC.refreshWindow();this.chartC.drawData(this.sumAB);for(var i in this.sliders)this.sliders[i].drawSlider();var context=this.context2D;context.clearRect(0,0,this.canvas.width,this.canvas.height);var img=this.dataLoader.res["las_"+this.lasA+"_"+this.lasB].img;context.beginPath();context.fillStyle="rgba(0,0,0,1)";context.rect(Math.round(this.canvas.width/
2-this.canvas.width*0.06),Math.round(this.canvas.height/4),this.canvas.width*0.12,this.canvas.height/4*2);var w=Math.round(this.canvas.width*0.18);w=w+this.canvas.width*0.2*this.areaA.powierzchnia/200;var h1=w;context.rect(Math.round(this.canvas.width/2-h1/2),Math.round(this.canvas.height/4-h1/2),h1,h1);var w=Math.round(this.canvas.width*0.18);w=w+this.canvas.width*0.2*this.areaB.powierzchnia/200;var h2=w;context.rect(Math.round(this.canvas.width/2-h2/2),Math.round(this.canvas.height-this.canvas.height/
4-h2/2),h2,h2);context.fill();context.stroke();context.globalCompositeOperation="source-atop";context.drawImage(img,0,0,img.width,img.height,this.canvas.width/4,this.canvas.height/10,this.canvas.width/2,this.canvas.height-this.canvas.height/10*2);context.globalCompositeOperation="source-over";context.beginPath();context.fillStyle="rgba(240,0,0,.9)";w=this.canvas.width*this.areaA.osobniki/750;var h=w;context.rect(Math.round(this.canvas.width/2-w/2),Math.round(this.canvas.height/4-h/2),w,h);w=this.canvas.width*
this.areaB.osobniki/750;var h=w;context.rect(Math.round(this.canvas.width/2-w/2),Math.round(this.canvas.height-this.canvas.height/4-h/2),w,h);context.fill();var img=this.dataLoader.res["k"+this.korytarz].img;var tw=this.canvas.width/1.5;var s=tw/img.width;context.drawImage(img,0,0,img.width,img.height,this.canvas.width/2-img.width*s/2,this.canvas.height/2-img.height*s/2,img.width*s,img.height*s);if(!req)window.requestAnimationFrame(function redrawFrameSetTimeout(){theGameObj.redrawFrame()})};
