feat: Добавлена базовая логика проигрыша

This commit is contained in:
Ilia Mashkov
2026-07-18 13:01:43 +03:00
parent c7721f2b1a
commit fea05e6b97
3 changed files with 27 additions and 3 deletions
+9 -3
View File
@@ -43,12 +43,18 @@ export function tick(game, containerWidth, containerHeight, deltaTime) {
ball.horizontalSpeed *= -1;
}
// Не даем мячу выйти за границы стен сверху / снизу и меняем направление
if (ball.y <= topBoundary || ball.y >= bottomBoundary) {
ball.y = ball.y <= topBoundary ? topBoundary : bottomBoundary;
// Не даем мячу выйти за границу стены сверху и меняем направление
if (ball.y <= topBoundary) {
ball.y = topBoundary;
ball.verticalSpeed *= -1;
}
// Проверяем выход за границу стены снизу
if (ball.y >= bottomBoundary) {
game.ball.isOut = true;
return;
}
// Базоввое взаимодействие мяча и кирпича
for (const row of bricks) {
for (const brick of row) {