feat: Добавлена базовая логика проигрыша
This commit is contained in:
+16
@@ -23,6 +23,9 @@ export class Game {
|
||||
* @param {number} rowAmount количество кирпичей по оси Y, неотрицателное, целое число
|
||||
*/
|
||||
constructor(columnAmount, rowAmount) {
|
||||
this.livesAmount = 3;
|
||||
this.status = 'in_process';
|
||||
|
||||
this.ball = new Ball(
|
||||
CONTAINER_WIDTH / 2 - BALL_RADIUS,
|
||||
CONTAINER_HEIGHT / 2 - BALL_RADIUS,
|
||||
@@ -40,6 +43,19 @@ export class Game {
|
||||
* @param {*} deltaTime изменение времени из Ticker
|
||||
*/
|
||||
update(deltaTime) {
|
||||
if (this.status !== 'in_process') {
|
||||
return;
|
||||
}
|
||||
tick(this, CONTAINER_WIDTH, CONTAINER_HEIGHT, deltaTime);
|
||||
|
||||
if (this.ball.isOut) {
|
||||
this.livesAmount -= 1;
|
||||
|
||||
if (this.livesAmount === 0) {
|
||||
this.status = 'over';
|
||||
} else {
|
||||
this.ball.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user