Skip to content

Commit

Permalink
Merge pull request #47 from cashlionjp/patch-1
Browse files Browse the repository at this point in the history
Update pipe.js
  • Loading branch information
shiffman authored Apr 28, 2018
2 parents bc3f2d7 + a6720d1 commit 420c09c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ class Pipe {
}

hits(bird) {
if (bird.y - bird.height / 2 < this.top || bird.y + bird.height / 2 > this.bottom) {
let halfBirdHeight = bird.height / 2;
let halfBirdwidth = bird.width / 2;
if (bird.y - halfBirdHeight < this.top || bird.y + halfBirdHeight > this.bottom) {
//if this.w is huge, then we need different collision model
if (bird.x + bird.width / 2 > this.x && bird.x - bird.width / 2 < this.x + this.w) {
if (bird.x + halfBirdwidth > this.x && bird.x - halfBirdwidth < this.x + this.w) {
this.highlight = true;
this.passed = true;
return true;
Expand Down

0 comments on commit 420c09c

Please sign in to comment.