-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
41 lines (38 loc) · 875 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var intervalId;
var bird = new Bird(gameOver);
var border;
var highScore = 0;
$(document).ready(function() {
border = new Border(gameOver,drawScore);
$('.restart').bind('click',restart);
border.draw();
bird.start();
intervalId = setInterval(function() {
border.move();
},10);
});
function restart() {
drawScore(0);
border.score = 0;
$('.borders').remove();
$('.gameover-box').hide(200);
bird.start();
border.setRandomHeight();
border.draw();
drawScore(0);
intervalId = setInterval(function() {
border.move();
},10);
}
function gameOver() {
clearInterval(intervalId);
bird.stop();
$('.gameover-box').show(300);
}
function drawScore(score) {
$('.score-count').html(score);
if (score > highScore) {
highScore = score;
$('.score-high').html(highScore);
}
}