Skip to content

Commit

Permalink
Having the game end when you hit
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-tiger authored Mar 9, 2018
1 parent 753ebbc commit f86964e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var birdIcon;
var pipeBodySprite;
var bgImg;
var bgX = 0;
var gameisover = false;

function preload() {
pipeBodySprite = loadImage("./graphics/pipe_body.png");
Expand Down Expand Up @@ -68,6 +69,10 @@ function draw() {
}

showScores();

if (gameisover) {
noLoop();
}
}

function showScores() {
Expand All @@ -82,6 +87,7 @@ function gameover() {
text("HIT", width / 2, height / 2);
maxScore = max(score, maxScore);
score = 0;
gameisover = true;
}
function keyPressed() {
if (key == " ") {
Expand Down

0 comments on commit f86964e

Please sign in to comment.