text: function getCookie(e){var t=e+"=";var n=document.cookie.split(";");for(var r=0;r<n.length;r++){var i=n[r].trim();if(i.indexOf(t)==0)return i.substring(t.length,i.length)}return""}function setCookie(e,t,n){var r=new Date;r.setTime(r.getTime()+n*24*60*60*1e3);var i="expires="+r.toGMTString();document.cookie=e+"="+t+"; "+i}function showSplash(){currentstate=states.SplashScreen;velocity=0;position=180;rotation=0;score=0;$("#player").css({y:0,x:0});updatePlayer($("#player"));soundSwoosh.stop();soundSwoosh.play();$(".pipe").remove();pipes=new Array;$(".animated").css("animation-play-state","running");$(".animated").css("-webkit-animation-play-state","running");$("#splash").transition({opacity:1},2e3,"ease")}function startGame(){currentstate=states.GameScreen;$("#splash").stop();$("#splash").transition({opacity:0},500,"ease");setBigScore();if(debugmode){$(".boundingbox").show()}var e=1e3/60;loopGameloop=setInterval(gameloop,e);loopPipeloop=setInterval(updatePipes,2700);playerJump();updatePipes()}function updatePlayer(e){rotation=Math.min(velocity/10*90,90);$(e).css({rotate:rotation,top:position})}function gameloop(){var e=$("#player");velocity+=gravity;position+=velocity;updatePlayer(e);var t=document.getElementById("player").getBoundingClientRect();var n=34;var r=24;var i=n-Math.sin(Math.abs(rotation)/90)*8;var s=(r+t.height)/2;var o=(t.width-i)/2+t.left;var u=(t.height-s)/2+t.top;var a=o+i;var f=u+s;if(t.bottom>=$("#land").offset().top){playerDead();return}var l=$("#ceiling");if(u<=l.offset().top+l.height())position=0;if(pipes[0]==null)return;var c=pipes[0];var h=c.children(".pipe_upper");var p=c.children(".pipe_middle");var d=p.offset().top;var v=d+ +p.height();var m=h.offset().top+h.height();var g=h.offset().left-2;var y=g+pipewidth;var b=m+pipeheight;if(a>g){if(u>m&&f<d){if(c.correct===1){}else{playerDead();return}}else if(f<b&&u>v){if(c.correct===0){}else{playerDead();return}}else{playerDead();return}}if(o>y){pipes.splice(0,1);playerScore()}}function screenClick(){if(currentstate==states.GameScreen){playerJump()}else if(currentstate==states.SplashScreen){startGame()}}function playerJump(){velocity=jump;soundJump.stop();soundJump.play()}function setBigScore(e){var t=$("#bigscore");t.empty();if(e)return;var n=score.toString().split("");for(var r=0;r<n.length;r++)t.append("<img src='assets/font_big_"+n[r]+".png' alt='"+n[r]+"'>")}function setSmallScore(){var e=$("#currentscore");e.empty();var t=score.toString().split("");for(var n=0;n<t.length;n++)e.append("<img src='assets/font_small_"+t[n]+".png' alt='"+t[n]+"'>")}function setHighScore(){var e=$("#highscore");e.empty();var t=highscore.toString().split("");for(var n=0;n<t.length;n++)e.append("<img src='assets/font_small_"+t[n]+".png' alt='"+t[n]+"'>")}function setMedal(){var e=$("#medal");e.empty();if(score<10)return false;if(score>=10)medal="bronze";if(score>=20)medal="silver";if(score>=30)medal="gold";if(score>=40)medal="platinum";e.append('<img src="assets/medal_'+medal+'.png" alt="'+medal+'">');return true}function playerDead(){$(".animated").css("animation-play-state","paused");$(".animated").css("-webkit-animation-play-state","paused");var e=$("#player").position().top+$("#player").width();var t=$("#flyarea").height();var n=Math.max(0,t-e);$("#player").transition({y:n+"px",rotate:90},1e3,"easeInOutCubic");currentstate=states.ScoreScreen;clearInterval(loopGameloop);clearInterval(loopPipeloop);loopGameloop=null;loopPipeloop=null;if(isIncompatible.any()){showScore()}else{soundHit.play().bindOnce("ended",function(){soundDie.play().bindOnce("ended",function(){showScore()})})}}function showScore(){$("#scoreboard").css("display","block");setBigScore(true);if(score>highscore){highscore=score;setCookie("highscore",highscore,999)}setSmallScore();setHighScore();var e=setMedal();soundSwoosh.stop();soundSwoosh.play();$("#scoreboard").css({y:"40px",opacity:0});$("#replay").css({y:"40px",opacity:0});$("#scoreboard").transition({y:"0px",opacity:1},600,"ease",function(){soundSwoosh.stop();soundSwoosh.play();$("#replay").transition({y:"0px",opacity:1},600,"ease");if(e){$("#medal").css({scale:2,opacity:0});$("#medal").transition({opacity:1,scale:1},1200,"ease")}});replayclickable=true}function playerScore(){score+=1;soundScore.stop();soundScore.play();setBigScore()}function randomIntFromInterval(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function updatePipes(){$(".pipe").filter(function(){return $(this).position().left<=-100}).remove();var e=20;var t=420-pipeheight-e*2;var n=Math.floor(Math.random()*t+e);var r=420-pipeheight-n;var i=pipeheight/3;var s=n+pipeheight/3;var o=$('<div class="pipe animated"><div class="pipe_upper" style="height: '+n+'px;"></div><div class="guess top" style="top: '+(n+35)+'px;"></div><div class="pipe_middle" style="height: '+i+"px; top: "+s+'px;"></div><div class="guess bottom" style="bottom: '+(r+35)+'px;"></div><div class="pipe_lower" style="height: '+r+'px;"></div><div class="question"></div></div>');var u=randomIntFromInterval(2,13);var a=randomIntFromInterval(2,13);var f=u.toString().split("");var l=a.toString().split("");for(var c=0;c<f.length;c++){var h=$('<div class = "question_digit first" style = "background-image: url(\'assets/font_big_'+f[c]+".png');\"></div>");o.children(".question").append(h)}o.children(".question").append('<div class="question_digit symbol" style="background-image: url(\'assets/font_shitty_x.png\');"></div>');for(var c=0;c<l.length;c++){var h=$('<div class = "question_digit second" style = "background-image: url(\'assets/font_big_'+l[c]+".png');\"></div>");o.children(".question").append(h)}var p=u*a;var d=randomIntFromInterval(-10,10)+1;var v=Math.abs(p+d);if(p===v){v+=randomIntFromInterval(1,10)}var m=randomIntFromInterval(0,1);correctguess_digits=p.toString().split("");incorrectguess_digits=v.toString().split("");for(var c=0;c<correctguess_digits.length;c++){var h=$('<div class = "guess_digit" style = "background-image: url(\'assets/font_big_'+correctguess_digits[c]+".png');\"></div>");if(m===1){o.children(".guess.top").append(h)}else{o.children(".guess.bottom").append(h)}}for(var c=0;c<incorrectguess_digits.length;c++){var h=$('<div class = "guess_digit" style = "background-image: url(\'assets/font_big_'+incorrectguess_digits[c]+".png');\"></div>");if(m===1){o.children(".guess.bottom").append(h)}else{o.children(".guess.top").append(h)}}$("#flyarea").append(o);o.correct=m;pipes.push(o)}var debugmode=false;var states=Object.freeze({SplashScreen:0,GameScreen:1,ScoreScreen:2});var currentstate;var gravity=.25;var velocity=0;var position=180;var rotation=0;var jump=-4.6;var score=0;var highscore=0;var pipeheight=300;var pipewidth=52;var pipes=new Array;var replayclickable=false;var volume=30;var soundJump=new buzz.sound("assets/sounds/sfx_wing.ogg");var soundScore=new buzz.sound("assets/sounds/sfx_point.ogg");var soundHit=new buzz.sound("assets/sounds/sfx_hit.ogg");var soundDie=new buzz.sound("assets/sounds/sfx_die.ogg");var soundSwoosh=new buzz.sound("assets/sounds/sfx_swooshing.ogg");buzz.all().setVolume(volume);var loopGameloop;var loopPipeloop;$(document).ready(function(){if(window.location.search=="?debug")debugmode=true;if(window.location.search=="?easy")pipeheight=200;var e=getCookie("highscore");if(e!="")highscore=parseInt(e);showSplash()});$(document).keydown(function(e){if(e.keyCode==32){if(currentstate==states.ScoreScreen)$("#replay").click();else screenClick()}});if("ontouchstart"in window)$(document).on("touchstart",screenClick);else $(document).on("mousedown",screenClick);$("#replay").click(function(){if(!replayclickable)return;else replayclickable=false;soundSwoosh.stop();soundSwoosh.play();$("#scoreboard").transition({y:"-40px",opacity:0},1e3,"ease",function(){$("#scoreboard").css("display","none");showSplash()})});var isIncompatible={Android:function(){return navigator.userAgent.match(/Android/i)},BlackBerry:function(){return navigator.userAgent.match(/BlackBerry/i)},iOS:function(){return navigator.userAgent.match(/iPhone|iPad|iPod/i)},Opera:function(){return navigator.userAgent.match(/Opera Mini/i)},Safari:function(){return navigator.userAgent.match(/OS X.*Safari/)&&!navigator.userAgent.match(/Chrome/)},Windows:function(){return navigator.userAgent.match(/IEMobile/i)},any:function(){return isIncompatible.Android()||isIncompatible.BlackBerry()||isIncompatible.iOS()||isIncompatible.Opera()||isIncompatible.Safari()||isIncompatible.Windows()}}
  