feat: Добавлен счет игры. Очки отличаются для разных типов блоков. Счет в хедере и в окне при завершении игры
Build and push / build (push) Skipped
Build and push / build (pull_request) Successful in 41s
Build and push / build (push) Skipped
Build and push / build (pull_request) Successful in 41s
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { PERK_DROP_CHANCE, PERK_HEIGHT, PERK_WIDTH } from '../../config';
|
||||
import { BRICK_POINTS_AMOUNT, PERK_DROP_CHANCE, PERK_HEIGHT, PERK_WIDTH } from '../../config';
|
||||
import { Ball } from '../../entities/ball/ball';
|
||||
import { Game } from '../../game';
|
||||
import { calculateAABBCollision } from '../calculateAABBCollision/calculateAABBCollision';
|
||||
@@ -55,6 +55,10 @@ export function processBrickCollision(game, ball) {
|
||||
ball.verticalSpeed *= directions[1];
|
||||
brick.kill();
|
||||
|
||||
if (!brick.alive) {
|
||||
game.score += BRICK_POINTS_AMOUNT[brick.type] ?? 0;
|
||||
}
|
||||
|
||||
if (!brick.alive && Math.random() < PERK_DROP_CHANCE) {
|
||||
const perk = spawnRandomPerk(
|
||||
brick.x + brick.width / 2 - PERK_WIDTH / 2,
|
||||
|
||||
Reference in New Issue
Block a user