refactor(tick): В условия добавлены return для отсеивания лишних операций

This commit is contained in:
Ilia Mashkov
2026-07-18 13:32:54 +03:00
parent 274cc93c55
commit 562805b35c
2 changed files with 5 additions and 3 deletions
+3 -1
View File
@@ -41,12 +41,14 @@ export function tick(game, containerWidth, containerHeight, deltaTime) {
if (ball.x <= leftBoundary || ball.x >= rightBoundary) {
ball.x = ball.x <= leftBoundary ? leftBoundary : rightBoundary;
ball.horizontalSpeed *= -1;
return;
}
// Не даем мячу выйти за границу стены сверху и меняем направление
if (ball.y <= topBoundary) {
ball.y = topBoundary;
ball.verticalSpeed *= -1;
return;
}
// Проверяем выход за границу стены снизу
@@ -84,7 +86,7 @@ export function tick(game, containerWidth, containerHeight, deltaTime) {
ball.horizontalSpeed *= directions[0];
ball.verticalSpeed *= directions[1];
brick.kill();
break;
return;
}
}
}