60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
let app = new PIXI.Application({ width: 400, height: 400, backgroundColor: 0x2a2a3a });
|
|
document.body.appendChild(app.view);
|
|
|
|
// Переменная отвечает, запущена ли игра
|
|
let running = false;
|
|
const REEL_WIDTH = 60;
|
|
const SYMBOL_SIZE = 50;
|
|
|
|
// Создаём колёса
|
|
const reels = [];
|
|
const reelContainer = new PIXI.Container();
|
|
|
|
for (let i = 0; i < 4; i++) {
|
|
const rc = new PIXI.Container();
|
|
rc.x = i * REEL_WIDTH;
|
|
reelContainer.addChild(rc);
|
|
|
|
const reel = {
|
|
container: rc,
|
|
symbols: [],
|
|
position: 0,
|
|
previousPosition: 0,
|
|
blur: new PIXI.filters.BlurFilter(),
|
|
};
|
|
|
|
reel.blur.blurX = 0;
|
|
reel.blur.blurY = 0;
|
|
rc.filters = [reel.blur];
|
|
|
|
// Build the symbols
|
|
for (let j = 0; j < 4; j++) {
|
|
const symbol = new PIXI.Sprite.from('/assets/chest.png');
|
|
// Scale the symbol to fit symbol area.
|
|
symbol.y = j * SYMBOL_SIZE;
|
|
symbol.scale.x = symbol.scale.y = Math.min(SYMBOL_SIZE / symbol.width, SYMBOL_SIZE / symbol.height);
|
|
symbol.x = Math.round((SYMBOL_SIZE - symbol.width) / 2);
|
|
reel.symbols.push(symbol);
|
|
rc.addChild(symbol);
|
|
}
|
|
|
|
reels.push(reel);
|
|
}
|
|
|
|
const basicText = new PIXI.Text('SPIN!');
|
|
basicText.anchor.set(0.5);
|
|
basicText.style.weight = 'bold';
|
|
basicText.style.fill = 0xfff8c0;
|
|
basicText.x = app.screen.width / 2;
|
|
basicText.y = app.screen.height - 50;
|
|
|
|
basicText.interactive = true;
|
|
basicText.buttonMode = true;
|
|
basicText.addListener('click', () => {
|
|
//
|
|
});
|
|
|
|
reelContainer.x = app.screen.width / 2 - (reelContainer.width / 2);
|
|
reelContainer.y = app.screen.height / 2 - (reelContainer.height / 2);
|
|
app.stage.addChild(reelContainer, basicText);
|