Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ntend into dev
  • Loading branch information
pablitoo1 committed Nov 19, 2024
2 parents 859d48a + 70883c4 commit 47f02c0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/app/game/games/flappybird/flappybird.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export class FlappyBirdComponent
}

public override restart(): void {
this.game.state.failCounter++;
const tempFailCounter = this.game.state.failCounter;
this.game.state = new FlappyBirdState();
this.game.state.failCounter = tempFailCounter;
Expand Down Expand Up @@ -121,13 +120,15 @@ export class FlappyBirdComponent
birdTop < obstacle.centerGapY - this._obstacleGapHeight / 2 ||
birdBottom > obstacle.centerGapY + this._obstacleGapHeight / 2
) {
this.game.state.failCounter++;
this.restart();
}
break;
}
}

if (birdTop < 0 || birdBottom > this._canvas.height) {
this.game.state.failCounter++;
this.restart();
}
}
Expand All @@ -145,10 +146,12 @@ export class FlappyBirdComponent
this.game.state.birdY += this.game.state.birdSpeedY;

if (this.game.state.birdY > this._canvas.height - this._birdHeight) {
this.game.state.failCounter++;
this.restart();
}

if (this.game.state.birdY < 0) {
this.game.state.failCounter++;
this.restart();
}
}
Expand Down

0 comments on commit 47f02c0

Please sign in to comment.