diff --git a/sketch.js b/sketch.js index e1747d4..a128b6c 100644 --- a/sketch.js +++ b/sketch.js @@ -19,7 +19,7 @@ var pipeBodySprite; var pipePeakSprite; var bgImg; var bgX; -var gameisover = false; +var gameoverFrame=0; var touched = false; var prevTouched = touched; @@ -75,7 +75,7 @@ function draw() { bird.update(); bird.show(); - if (frameCount % 150 === 0) { + if ((frameCount-gameoverFrame) % 150 == 0) { pipes.push(new Pipe()); } @@ -97,9 +97,6 @@ function draw() { prevTouched = touched; - if (gameisover) { - noLoop(); - } } function showScores() { @@ -113,7 +110,7 @@ function gameover() { text('HIT', width / 2, height / 2); maxScore = max(score, maxScore); score = 0; - gameisover = true; + reset(); } function reset() { @@ -121,6 +118,7 @@ function reset() { pipes = []; bird = new Bird(); pipes.push(new Pipe()); + gameoverFrame=frameCount-1; } function keyPressed() {