Feature/appearance #6

Merged
ilia merged 9 commits from feature/appearance into main 2026-07-20 07:09:11 +00:00
10 changed files with 15 additions and 6 deletions
Showing only changes of commit 004720acd6 - Show all commits
Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

+3 -1
View File
@@ -38,8 +38,10 @@ import { createGameView, managePerkViewsLifetime, rebuildBrickViews, syncronizeV
app.stage.addChild(container); app.stage.addChild(container);
const textures = await Assets.load(['/sprites/fire_ball_1.png']);
const game = new Game(LEVELS); const game = new Game(LEVELS);
const views = createGameView(game, container); const views = createGameView(game, container, textures);
let currentLevel = game.currentLevel; let currentLevel = game.currentLevel;
container.on('pointermove', (event) => { container.on('pointermove', (event) => {
+12 -5
View File
@@ -1,4 +1,4 @@
import { Container, Graphics, Text } from 'pixi.js'; import { Container, Graphics, Sprite, Text } from 'pixi.js';
import { Ball } from './entities/ball/ball'; import { Ball } from './entities/ball/ball';
import { Brick } from './entities/brick/brick'; import { Brick } from './entities/brick/brick';
import { Paddle } from './entities/paddle/paddle'; import { Paddle } from './entities/paddle/paddle';
@@ -8,9 +8,15 @@ import { Game } from './game';
/** /**
* Создает визуальное отображение мяча с помощью Pixi.js * Создает визуальное отображение мяча с помощью Pixi.js
* @param {Ball} ball экземпляр класса мяч * @param {Ball} ball экземпляр класса мяч
* @param {unknown} texture текстура мяча
*/ */
function createBallView(ball) { function createBallView(ball, texture) {
return new Graphics().circle(0, 0, ball.radius).fill('#ffffff'); const ballSprite = new Sprite(texture);
ballSprite.anchor.set(0.5);
ballSprite.width = ball.radius * 2;
ballSprite.height = ball.radius * 2;
return ballSprite;
} }
/** /**
@@ -64,8 +70,9 @@ function createPerkView(perk) {
* Создает визуальное отображение всех сущностей в игре с помощью Pixi.js и добавляет в контейнер * Создает визуальное отображение всех сущностей в игре с помощью Pixi.js и добавляет в контейнер
* @param {Game} game экземпляр класса игра * @param {Game} game экземпляр класса игра
* @param {Container} container экземпляр класса контейнер Pixi.js * @param {Container} container экземпляр класса контейнер Pixi.js
* @param {object} textures объект с текстурами для визуального отображения
*/ */
export function createGameView(game, container) { export function createGameView(game, container, textures) {
try { try {
const header = new Text({ style: { fill: '#ffffff', fontSize: 16 } }); const header = new Text({ style: { fill: '#ffffff', fontSize: 16 } });
header.x = 8; header.x = 8;
@@ -74,7 +81,7 @@ export function createGameView(game, container) {
const balls = new Map(); const balls = new Map();
for (const ball of game.balls) { for (const ball of game.balls) {
const ballView = createBallView(ball); const ballView = createBallView(ball, textures['/sprites/fire_ball_1.png']);
container.addChild(ballView); container.addChild(ballView);
balls.set(ball, ballView); balls.set(ball, ballView);
} }