feat: Добавлена базовая логика проигрыша
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user