function getCookie(e) {
for (
var o = e + "=", t = document.cookie.split(";"), s = 0;
s < t.length;
s++
) {
var a = t[s].trim();
if (0 == a.indexOf(o)) return a.substring(o.length, a.length);
}
return "";
}
function setCookie(e, o, t) {
var s = new Date();
s.setTime(s.getTime() + 24 * t * 60 * 60 * 1e3);
var a = "expires=" + s.toGMTString();
document.cookie = e + "=" + o + "; " + a;
}
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),
soundHit.play(),
soundHit.stop(),
$("#splash").stop(),
$("#splash").transition({ opacity: 0 }, 500, "ease"),
setBigScore(),
debugmode && $(".boundingbox").show();
var e = 1e3 / 60;
(loopGameloop = setInterval(gameloop, e)),
(loopPipeloop = setInterval(updatePipes, 1400)),
playerJump(),
soundNasheed.stop(),
soundNasheed.play();
}
function updatePlayer(e) {
(rotation = Math.min((velocity / 10) * 40, 40)),
$(e).css({ rotate: rotation, top: position });
}
function gameloop() {
var e = $("#player");
(velocity += gravity), (position += velocity), updatePlayer(e);
var o = document.getElementById("player").getBoundingClientRect(),
t = 34,
s = 24,
a = t - 8 * Math.sin(Math.abs(rotation) / 90),
i = (s + o.height) / 2,
n = (o.width - a) / 2 + o.left,
r = (o.height - i) / 2 + o.top,
p = n + a,
c = r + i;
if (debugmode) {
var l = $("#playerbox");
l.css("left", n), l.css("top", r), l.css("height", i), l.css("width", a);
}
if (o.bottom >= $("#land").offset().top) return void playerDead();
var u = $("#ceiling");
if ((r <= u.offset().top + u.height() && (position = 0), null != pipes[0])) {
var d = pipes[0],
h = d.children(".pipe_upper"),
m = h.offset().top + h.height(),
y = h.offset().left - 2,
g = y + pipewidth,
f = m + pipeheight;
if (debugmode) {
var l = $("#pipebox");
l.css("left", y),
l.css("top", m),
l.css("height", pipeheight),
l.css("width", pipewidth);
}
return p > y && !(r > m && f > c)
? void playerDead()
: void (n > g && (pipes.splice(0, 1), playerScore()));
}
}
function screenClick() {
currentstate == states.GameScreen
? playerJump()
: currentstate == states.SplashScreen && startGame();
}
function playerJump() {
(velocity = jump), soundJump.stop(), soundJump.play();
}
function setBigScore(e) {
var o = $("#bigscore");
if ((o.empty(), !e))
for (var t = score.toString().split(""), s = 0; s < t.length; s++)
o.append(
""
);
}
function setSmallScore() {
var e = $("#currentscore");
e.empty();
for (var o = score.toString().split(""), t = 0; t < o.length; t++)
e.append(
"
"
);
}
function setHighScore() {
var e = $("#highscore");
e.empty();
for (var o = highscore.toString().split(""), t = 0; t < o.length; t++)
e.append(
"
"
);
}
function setMedal() {
var e = $("#medal");
return (
e.empty(),
10 > score
? !1
: (score >= 10 && (medal = "bronze"),
score >= 20 && (medal = "silver"),
score >= 30 && (medal = "gold"),
score >= 40 && (medal = "platinum"),
e.append(
'
'
),
!0)
);
}
function playerDead() {
$(".animated").css("animation-play-state", "paused"),
$(".animated").css("-webkit-animation-play-state", "paused");
var e = $(
'