Skip to content

Commit

Permalink
added pipes crossed
Browse files Browse the repository at this point in the history
  • Loading branch information
Jagat Brahma committed Nov 10, 2016
1 parent 05b29b9 commit 0ed7eac
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions game.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ Pipe.prototype.isOut = function(){
}
}


var Game = function(){
this.pipes = [];
this.birds = [];
Expand All @@ -113,11 +112,14 @@ var Game = function(){
this.generation = 0;
this.backgroundSpeed = 0.5;
this.backgroundx = 0;
this.pipeCount = 0;
this.maxScore = 0;
}

Game.prototype.start = function(){
this.interval = 0;
this.score = 0;
this.pipeCount = 0;
this.pipes = [];
this.birds = [];

Expand Down Expand Up @@ -155,7 +157,6 @@ Game.prototype.update = function(){
this.birds[i].flap();
}


this.birds[i].update();
if(this.birds[i].isDead(this.height, this.pipes)){
this.birds[i].alive = false;
Expand All @@ -173,6 +174,7 @@ Game.prototype.update = function(){
for(var i in this.pipes){
this.pipes[i].update();
if(this.pipes[i].isOut()){
this.pipeCount++;
deletedPipes.push(i);
}
}
Expand Down Expand Up @@ -242,15 +244,14 @@ Game.prototype.display = function(){
}
}

this.maxScore = (this.score > this.maxScore) ? this.score : this.maxScore;
this.ctx.fillStyle = "white";
this.ctx.font="20px Oswald, sans-serif";
this.ctx.fillText("Score : "+this.score, 10, 25);
if (this.score > maxScore) {
maxScore = this.score;
}
this.ctx.fillText("Max Score : "+maxScore, 10, 50);
this.ctx.fillText("Max Score : "+ this.maxScore, 10, 25);
this.ctx.fillText("Score : "+this.score, 10, 50);
this.ctx.fillText("Generation : "+this.generation, 10, 75);
this.ctx.fillText("Alive : "+this.alives+" / "+Neuvol.options.population, 10, 100);
this.ctx.fillText("Pipes Crossed : " + this.pipeCount/2, 10, 125);
}

window.onload = function(){
Expand Down

0 comments on commit 0ed7eac

Please sign in to comment.