mirror of
https://github.com/sigmasternchen/88x31breakout
synced 2025-03-15 07:59:00 +00:00
feat: Ball gets removed when reaching bottom
This commit is contained in:
parent
a43a70f523
commit
d8d6ba0118
2 changed files with 6 additions and 1 deletions
|
@ -34,6 +34,10 @@ export class Ball {
|
||||||
gameElement.appendChild(this.element);
|
gameElement.appendChild(this.element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public readonly remove = (gameElement: HTMLElement): void => {
|
||||||
|
gameElement.removeChild(this.element);
|
||||||
|
}
|
||||||
|
|
||||||
public readonly launch = (): void => {
|
public readonly launch = (): void => {
|
||||||
this.phi = choice(startAngles);
|
this.phi = choice(startAngles);
|
||||||
this.speed = defaultBallSpeed;
|
this.speed = defaultBallSpeed;
|
||||||
|
|
|
@ -74,7 +74,8 @@ export class Game {
|
||||||
} else if (ball.position.y - ballSize / 2 < 0) {
|
} else if (ball.position.y - ballSize / 2 < 0) {
|
||||||
ball.collision(0);
|
ball.collision(0);
|
||||||
} else if (ball.position.y + ballSize / 2 >= fieldHeight) {
|
} else if (ball.position.y + ballSize / 2 >= fieldHeight) {
|
||||||
ball.collision(0);
|
ball.remove(this.root);
|
||||||
|
this.balls = this.balls.filter(_ball => _ball != ball);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue