Skip to content

Commit 12e1509

Browse files
committed
Revert "Revert "Merge branch 'master' of https://github.com/goomazon/FlappyBird-JavaScript""
This reverts commit a52c855.
1 parent a52c855 commit 12e1509

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎flappyBird.js‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,22 @@ var endcollision = new Audio();
3838
// fly.src = "sounds/fly.mp3";
3939
scor.src = "sounds/score.mp3";
4040
sheesh.src = "sounds/sheesh.mp3";
41-
endcollision.src = "sounds/endcollision.mp3"
41+
endcollision.src = "sounds/endcollision.mp3";
4242

4343
// on key down
4444

4545
document.addEventListener("keydown",moveUp);
46+
endcollision.addEventListener('ended', reloadGame);
4647

4748
function moveUp(){
4849
bY -= 35;
4950
sheesh.play();
5051
}
5152

53+
function reloadGame() {
54+
location.reload();
55+
}
56+
5257
// pipe coordinates
5358

5459
var pipe = [];
@@ -83,8 +88,8 @@ function draw(){
8388
// detect collision
8489

8590
if( bX + bird.width >= pipe[i].x && bX <= pipe[i].x + pipeNorth.width && (bY <= pipe[i].y + pipeNorth.height || bY+bird.height >= pipe[i].y+constant) || bY + bird.height >= cvs.height - fg.height){
86-
endcollision.play();
87-
location.reload(); // reload the page
91+
// location.reload(); // reload the page
92+
endcollision.play()
8893
}
8994

9095
if(pipe[i].x == 5){

0 commit comments

Comments
 (0)