Refactor/entities splitting #4
+13
-4
@@ -1,4 +1,4 @@
|
||||
import { Graphics } from 'pixi.js';
|
||||
import { Container, Graphics } from 'pixi.js';
|
||||
import { Ball } from './entities/ball/ball';
|
||||
import { Brick } from './entities/brick/brick';
|
||||
import { Paddle } from './entities/paddle/paddle';
|
||||
@@ -29,16 +29,25 @@ function createBrickView(brick) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Создает визуальное отображение всех сущностей в игре с помощью Pixi.js
|
||||
* Создает визуальное отображение всех сущностей в игре с помощью Pixi.js и добавляет в контейнер
|
||||
* @param {Game} game экземпляр класса игра
|
||||
* @param {Container} container контейнер Pixi.js
|
||||
*/
|
||||
export function createGameView(game) {
|
||||
export function createGameView(game, container) {
|
||||
try {
|
||||
const ball = createBallView(game.ball);
|
||||
container.addChild(ball);
|
||||
|
||||
const paddle = createPaddleView(game.paddle);
|
||||
container.addChild(paddle);
|
||||
|
||||
const bricks = game.bricks.map((row) => row.map((brick) => createBrickView(brick)));
|
||||
const bricks = game.bricks.map((row) =>
|
||||
row.map((brick) => {
|
||||
const brickView = createBrickView(brick);
|
||||
container.addChild(brickView);
|
||||
return brickView;
|
||||
}),
|
||||
);
|
||||
|
||||
return {
|
||||
ball,
|
||||
|
||||
Reference in New Issue
Block a user