From 8e3d0136999a3bb06e55e843afb84754db7733a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Buczek?= Date: Tue, 19 Nov 2024 15:56:04 +0100 Subject: [PATCH] feat: #main added failCounter in flappybird --- src/app/game/games/flappybird/flappybird.component.ts | 3 +++ src/app/game/games/flappybird/models/flappybird.class.ts | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/game/games/flappybird/flappybird.component.ts b/src/app/game/games/flappybird/flappybird.component.ts index 3356d62..de4473a 100644 --- a/src/app/game/games/flappybird/flappybird.component.ts +++ b/src/app/game/games/flappybird/flappybird.component.ts @@ -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(); diff --git a/src/app/game/games/flappybird/models/flappybird.class.ts b/src/app/game/games/flappybird/models/flappybird.class.ts index a4aa22d..2ef8736 100644 --- a/src/app/game/games/flappybird/models/flappybird.class.ts +++ b/src/app/game/games/flappybird/models/flappybird.class.ts @@ -15,6 +15,7 @@ export class FlappyBirdState implements TGameState { centerGapY: 0, })); public isGameStarted = false; + public failCounter = 0; } export class FlappyBird extends Game { @@ -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; @@ -41,6 +43,7 @@ export class FlappyBird extends Game { score: 0; difficulty: 1; isGameStarted: false; + failCounter: 0; `; public override players = [ @@ -56,7 +59,7 @@ export class FlappyBird extends Game { releasedValue: 0, }, }, - ': value of {0, 1}, 0: not jump, 1: jump', + ', : value of {0, 1}, 0: not jump, 1: jump', { jump: '[SPACE]', start: '[SPACE]' } ), ];