feat: Добавлен хедер с информацией о текущем уровне и количестве оставшихся жизней

This commit is contained in:
Ilia Mashkov
2026-07-19 19:19:24 +03:00
parent 8f593c6a6f
commit 2cbff5b924
5 changed files with 31 additions and 5 deletions
+9 -1
View File
@@ -1,4 +1,4 @@
import { Container, Graphics } from 'pixi.js';
import { Container, Graphics, Text } from 'pixi.js';
import { Ball } from './entities/ball/ball';
import { Brick } from './entities/brick/brick';
import { Paddle } from './entities/paddle/paddle';
@@ -67,6 +67,11 @@ function createPerkView(perk) {
*/
export function createGameView(game, container) {
try {
const header = new Text({ style: { fill: '#ffffff', fontSize: 16 } });
header.x = 8;
header.y = 8;
container.addChild(header);
const balls = new Map();
for (const ball of game.balls) {
const ballView = createBallView(ball);
@@ -86,6 +91,7 @@ export function createGameView(game, container) {
const perks = new Map();
return {
header,
balls,
paddle,
bricks,
@@ -155,6 +161,8 @@ export function syncronizeViewsWithGame(views, game) {
throw new Error('Аргумент game должен быть экземпляром класса Game');
}
views.header.text = `Уровень: ${game.currentLevel + 1} Количество жизней: ${game.livesAmount}`;
for (const ball of game.balls) {
const ballView = views.balls.get(ball);
ballView.x = ball.x;