Skip to content

Commit 16e9aae

Browse files
save\
1 parent a3e8d13 commit 16e9aae

File tree

1 file changed

+7
-6
lines changed
  • games/running-ball-babylonjs/src

1 file changed

+7
-6
lines changed

games/running-ball-babylonjs/src/Game.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ export class Game {
3939
width: Game.SinglePlatformSize.width / 3
4040
});
4141
private static readonly ZeroVector = new Vector3(0, 0, 0);
42-
private static readonly SpeedOfMovingStraight = 6;
42+
private static readonly StartSpeedOfMovingStraight = 6;
4343
private static readonly SpeedOfMovingAside = 2;
44-
private static readonly MoveVectorStraight = new Vector3(0, 0, Game.SpeedOfMovingStraight);
4544
private static readonly MoveVectorLeft = new Vector3(-Game.SpeedOfMovingAside, 0, 0);
4645
private static readonly MoveVectorRight = new Vector3(Game.SpeedOfMovingAside, 0, 0);
4746
private static readonly BallRadius = 0.75;
47+
private readonly MoveVectorStraight = new Vector3(0, 0, Game.StartSpeedOfMovingStraight);
4848

4949
private readonly platformMaterial: Material;
5050
private readonly wallMaterial: Material;
@@ -186,7 +186,7 @@ export class Game {
186186

187187
private configureLight(): PointLight {
188188
const light = new PointLight('light', new Vector3(10, 10, 10), this.scene);
189-
light.intensity = 0.3;
189+
light.intensity = 0.4;
190190
return light;
191191
}
192192

@@ -336,7 +336,7 @@ export class Game {
336336

337337
private createAllWalls(): Mesh[] {
338338
const notRepeatedFreeSpaceGenerator = notRepeatedRandomFreeSpacePositionGenerator(3);
339-
const offset = 10;
339+
const offset = 7;
340340
const rowsCount = 20;
341341

342342
const walls = new Array<Mesh>(rowsCount);
@@ -383,7 +383,8 @@ export class Game {
383383
}
384384

385385
private stopBallMovingAside(): void {
386-
this.ball.physicsImpostor?.setLinearVelocity(Game.MoveVectorStraight);
386+
this.MoveVectorStraight.z += this.MoveVectorStraight.z * 0.01;
387+
this.ball.physicsImpostor?.setLinearVelocity(this.MoveVectorStraight);
387388
this.ball.physicsImpostor?.setAngularVelocity(Game.ZeroVector);
388389
}
389390

@@ -434,6 +435,6 @@ export class Game {
434435
this.storage.saveScore(StoredDataType.CurrentScore, 0);
435436

436437
this.elementsRefs.gameOver.currentScore.innerText = `CURRENT SCORE: ${this.coinScore}`;
437-
this.elementsRefs.gameOver.bestScore.innerText = `BEST SCORE:dad ${this.bestScore}`;
438+
this.elementsRefs.gameOver.bestScore.innerText = `BEST SCORE: ${this.bestScore}`;
438439
}
439440
}

0 commit comments

Comments
 (0)