Skip to content

Commit

Permalink
feat: #main added failCounter in flappybird
Browse files Browse the repository at this point in the history
  • Loading branch information
pablitoo1 committed Nov 19, 2024
1 parent 5dd719f commit 8e3d013
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/app/game/games/flappybird/flappybird.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ 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;

this.game.state.isGameStarted = false;
this.resetBirdAndObstacle();
Expand Down
5 changes: 4 additions & 1 deletion src/app/game/games/flappybird/models/flappybird.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class FlappyBirdState implements TGameState {
centerGapY: 0,
}));
public isGameStarted = false;
public failCounter = 0;
}

export class FlappyBird extends Game {
Expand All @@ -31,6 +32,7 @@ export class FlappyBird extends Game {
difficulty: int, <0, inf>;
obstacles: [{distanceX: int, <-50, 1900>, centerGapyY: int <100, 500>}];
isGameStarted: boolean;
failCounter: int, <0, inf>
default values:
birdY: 300;
Expand All @@ -41,6 +43,7 @@ export class FlappyBird extends Game {
score: 0;
difficulty: 1;
isGameStarted: false;
failCounter: 0;
`;

public override players = [
Expand All @@ -56,7 +59,7 @@ export class FlappyBird extends Game {
releasedValue: 0,
},
},
'<jump>: value of {0, 1}, 0: not jump, 1: jump',
'<jump>, <start>: value of {0, 1}, 0: not jump, 1: jump',
{ jump: '[SPACE]', start: '[SPACE]' }
),
];
Expand Down

0 comments on commit 8e3d013

Please sign in to comment.