Skip to content

Commit

Permalink
refactor(game): make one call of context translate instead of two
Browse files Browse the repository at this point in the history
  • Loading branch information
divanov committed Nov 15, 2016
1 parent dd57f6b commit 56f133f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions game.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ Game.prototype.display = function(){
for(var i in this.birds){
if(this.birds[i].alive){
this.ctx.save();
this.ctx.translate(this.birds[i].x, this.birds[i].y);
this.ctx.translate(this.birds[i].width/2, this.birds[i].height/2);
this.ctx.translate(this.birds[i].x + this.birds[i].width/2, this.birds[i].y + this.birds[i].height/2);
this.ctx.rotate(Math.PI/2 * this.birds[i].gravity/20);
this.ctx.drawImage(images.bird, -this.birds[i].width/2, -this.birds[i].height/2, this.birds[i].width, this.birds[i].height);
this.ctx.restore();
Expand Down

0 comments on commit 56f133f

Please sign in to comment.